single.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view>
  3. <!--components/recommend/recommend.wxml-->
  4. <template name="single_product">
  5. <view :class="singleTemplate.theme==2?'pdlr20':''" v-if="singleTemplate&&singleTemplate.state==0&&pageList.products.length>0">
  6. <view class="jishida head">
  7. <block v-if="singleTemplate.titleType==1&&singleTemplate.titleCon">
  8. <view class="titleNav pdlr20">{{singleTemplate.titleCon}}</view>
  9. </block>
  10. <block v-if="singleTemplate.titleType==2&&singleTemplate.titleCon">
  11. <navigator :url="'/product/list/list?title=' + singleTemplate.titleSubtitle + web"
  12. hover-class="none">
  13. <image lazy-load="true" :src="singleTemplate.titleCon + '?x-oss-process=style/w750-auto'" mode="widthFix"
  14. class="imgtit"></image>
  15. </navigator>
  16. </block>
  17. <view class="single">
  18. <view class="li" v-for="(item,index) in pageList.products" :key="index" @tap="goUrl" :data-id="item.id" :data-type="type" :data-index="index">
  19. <image :src="item.pic+ '?x-oss-process=style/w750-auto'" mode="aspectFill" class="single-img"></image>
  20. <view class="single-info dflex">
  21. <view class="single-tit flex">{{item.title}}</view>
  22. <!-- <button open-type="share" hover-class="none" class="s-share"><image src="../../static/pages/images/share.png"></image>分享</button> -->
  23. </view>
  24. <view class="pmoney dflex">
  25. <view class="price proprice dflex flex">
  26. <view class="money">¥<text>{{item.salePrice}}</text></view>
  27. <view class="zhuan dflex" v-if="about.show_membership_price==1&&item.actualPrice < item.salePrice">
  28. <text>VIP价</text><view class="members">¥{{item.actualPrice}}</view>
  29. </view>
  30. <view class="zhuan dflex" v-if="about.show_membership_price==1&&item.membersPrice<item.salePrice">
  31. <text>VIP价</text>
  32. <view>¥{{item.membersPrice}}</view>
  33. </view>
  34. <text class="del" v-if="about.show_membership_price!=1">
  35. <block v-if="item.marketPrice!=0&&item.marketPrice>item.salePrice">
  36. ¥{{item.marketPrice}}
  37. </block>
  38. </text>
  39. </view>
  40. <view class="yishou">已售{{item.sellStock}}</view>
  41. </view>
  42. <view class="s-btn dflex">
  43. <view class="s-add dflex">加入购物车</view>
  44. <view class="s-buy mbglinear dflex">立即购买</view>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- <view class="nomore dflex" wx:if="{{hasmore}}">亲,没有更多了</view> -->
  49. </view>
  50. </view>
  51. </template>
  52. </view>
  53. </template>
  54. <script>
  55. const route = require("../../utils/route");
  56. const app = getApp();
  57. const req = require("../../utils/request.js"); // components/recommend/recommend.js
  58. export default {
  59. data() {
  60. return {
  61. };
  62. },
  63. components: {
  64. },
  65. props: {
  66. pageList: Object, //{backgroundColor:背景颜色,displayStyle: 样式模板,lineNumber:每行几个,products:产品列表}
  67. web: String,//地址跳转
  68. url: String,//地址跳转
  69. singleTemplate: Object, //推荐后台配置
  70. about: Object, //参数配置
  71. categoryList:Array, //分类列表
  72. merchant: Object
  73. },
  74. mounted(){
  75. // console.log(this.categoryList)
  76. },
  77. watch: {},
  78. methods: {
  79. goUrl(event) {
  80. console.log("qwewqe")
  81. let id = event.currentTarget.dataset.id
  82. let type = event.currentTarget.dataset.type
  83. let index = event.currentTarget.dataset.index
  84. const activity = this.pageList.products[index];
  85. // console.log(type, !type)
  86. if (!type) {
  87. // console.log("123", id)
  88. app.globalData.openPage('product/detail/detail?id=' + id + '&merchantId=' + this.merchant.id)
  89. } else if (type == 1) {
  90. app.globalData.openPage('product/groupDetail/groupDetail?acid=' + activity.id + "&id=" + activity
  91. .productId +
  92. '&merchantId=' + this.merchant.id)
  93. } else if (type == 4) {
  94. app.globalData.openPage('activity/newbornDetails/newbornDetails?acid=' + activity.id + '&id=' +
  95. activity.productId +
  96. '&merchantId=' + this.merchant.id)
  97. } else if (type == 5) {
  98. app.globalData.openPage('activity/bargain/detail/detail?acid=' + activity.id + '&id=' + activity
  99. .productId +
  100. '&merchantId=' + this.merchant.id)
  101. } else if (type == 3) {
  102. app.globalData.openPage('activity/group/detail/detail?acid=' + activity.id + '&id=' + activity
  103. .productId +
  104. '&merchantId=' + this.merchant.id)
  105. } else if (type == 2) {
  106. app.globalData.openPage('activity/seckillDetails/seckillDetails?acid=' + activity.id + '&id=' +
  107. activity.productId +
  108. '&merchantId=' + this.merchant.id)
  109. }
  110. },
  111. toDetail(e) {
  112. // let id = e.currentTarget.dataset.id;
  113. // app.openPage("product/detail/detail?id=" + id + '&&hideShop=' + false)
  114. let id = e.currentTarget.dataset.id;
  115. let merchantId = e.currentTarget.dataset.merchant;
  116. let shopId = e.currentTarget.dataset.shopid;
  117. if (!shopId) {
  118. app.globalData.openPage("product/detail/detail?id=" + id + "&merchantId=" + merchantId);
  119. } else {
  120. app.globalData.openPage("product/detail/detail?id=" + id + "&merchantId=" + merchantId + "&shopId=" + shopId);
  121. }
  122. },
  123. addShopCart(item) {
  124. let skuId = item.skuId;
  125. let id = item.id;
  126. let _ts = this;
  127. let params = {
  128. skuId: skuId,
  129. quantity: 1,
  130. merchantId: this.merchant.id,
  131. productId: id
  132. };
  133. route.addShopCart(params, res => {
  134. _ts.setData({
  135. isUpdate: !_ts.isUpdate
  136. });
  137. req.msg('加入购物车成功');
  138. });
  139. }
  140. }
  141. };
  142. </script>
  143. <style>
  144. @import "./single.css";
  145. </style>