recommend.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="productList">
  3. <view class='list acea-row row-between-wrapper' v-if="isShow && bastList.length">
  4. <view class='item' v-for="(item,index) in bastList" :key="index" @click="goDetail(item)">
  5. <view class='pictrue'>
  6. <image :src='item.image'></image>
  7. <span class="pictrue_log_class pictrue_log_big" v-if="item.activity && item.activity.type === '1'">秒杀</span>
  8. <span class="pictrue_log_class pictrue_log_big" v-if="item.activity && item.activity.type === '2'">砍价</span>
  9. <span class="pictrue_log_class pictrue_log_big" v-if="item.activity && item.activity.type === '3'">拼团</span>
  10. </view>
  11. <view class='text'>
  12. <view class='name line1'>{{item.store_name}}</view>
  13. <view class='money font-color'>¥<text class='num'>{{item.price}}</text></view>
  14. <view class='vip acea-row row-between-wrapper'>
  15. <view class='vip-money' v-if="item.vip_price && item.vip_price > 0 && item.base">¥{{item.vip_price}}
  16. <image src='../../../static/images/jvip.png' class="jvip"></image>
  17. </view>
  18. <view class='vip-money' v-if="item.vip_price && item.vip_price > 0 && item.is_vip">¥{{item.vip_price}}
  19. <image src='../../../static/images/vip.png'></image>
  20. </view>
  21. <view>已售{{item.sales}}{{item.unit_name}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class='list acea-row row-between-wrapper' v-if="!isShow && isIframe && bastList.length">
  27. <view class='item' v-for="(item,index) in bastList" :key="index" @click="goDetail(item)">
  28. <view class='pictrue'>
  29. <image :src='item.image'></image>
  30. <span class="pictrue_log_class pictrue_log_big" v-if="item.activity && item.activity.type === '1'">秒杀</span>
  31. <span class="pictrue_log_class pictrue_log_big" v-if="item.activity && item.activity.type === '2'">砍价</span>
  32. <span class="pictrue_log_class pictrue_log_big" v-if="item.activity && item.activity.type === '3'">拼团</span>
  33. </view>
  34. <view class='text'>
  35. <view class='name line1'>{{item.store_name}}</view>
  36. <view class='money font-color'>¥<text class='num'>{{item.price}}</text></view>
  37. <view class='vip acea-row row-between-wrapper'>
  38. <view class='vip-money' v-if="item.vip_price && item.vip_price > 0 && item.base">¥{{item.vip_price}}
  39. <image src='../../../static/images/jvip.png' class="jvip"></image>
  40. </view>
  41. <view class='vip-money' v-if="item.vip_price && item.vip_price > 0 && item.is_vip">¥{{item.vip_price}}
  42. <image src='../../../static/images/vip.png'></image>
  43. </view>
  44. <view>已售{{item.sales}}{{item.unit_name}}</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <block v-if="isIframe && !bastList.length">
  50. <view class="empty-img">精品推荐,暂无数据</view>
  51. </block>
  52. </view>
  53. </template>
  54. <script>
  55. let app = getApp()
  56. import {
  57. mapState
  58. } from 'vuex'
  59. import { goShopDetail,goPage } from '@/libs/order.js'
  60. import { getHomeProducts } from '@/api/store.js';
  61. import goodLists from '@/components/goodList/index.vue'
  62. export default {
  63. name: 'goodList',
  64. props: {
  65. dataConfig: {
  66. type: Object,
  67. default: () => {}
  68. }
  69. },
  70. components: {
  71. goodLists
  72. },
  73. created() {
  74. },
  75. mounted() {
  76. },
  77. watch: {
  78. dataConfig: {
  79. immediate: true,
  80. handler(nVal, oVal) {
  81. if(nVal){
  82. this.isShow = nVal.isShow.val;
  83. this.selectType = nVal.tabConfig.tabVal;
  84. this.$set(this, 'selectId', nVal.selectConfig.activeValue);
  85. this.$set(this, 'type', nVal.selectSortConfig.activeValue);
  86. this.salesOrder = nVal.goodsSort.type == 1 ? 'desc' : '';
  87. this.newsOrder = nVal.goodsSort.type == 2 ? 'news' : '';
  88. this.ids = nVal.ids?nVal.ids.join(','):'';
  89. this.numConfig = nVal.numConfig.val;
  90. this.productslist();
  91. }
  92. }
  93. }
  94. },
  95. data() {
  96. return {
  97. circular: true,
  98. interval: 3000,
  99. duration: 500,
  100. bastList: [],
  101. name: this.$options.name,
  102. isShow: true,
  103. isIframe: app.globalData.isIframe,
  104. selectType:0,
  105. selectId: '',
  106. salesOrder:'',
  107. newsOrder:'',
  108. ids:'',
  109. page: 1,
  110. limit: this.$config.LIMIT,
  111. type: '',
  112. numConfig:0
  113. }
  114. },
  115. methods: {
  116. // 产品列表
  117. productslist: function() {
  118. let that = this;
  119. let data = {};
  120. if (that.selectType) {
  121. data = {
  122. page: that.page,
  123. limit: that.limit,
  124. type: that.type,
  125. ids: that.ids,
  126. selectType: that.selectType
  127. }
  128. } else {
  129. data = {
  130. page: that.page,
  131. limit: that.numConfig<=that.limit?that.numConfig:that.limit,
  132. type: that.type,
  133. newsOrder: that.newsOrder,
  134. salesOrder: that.salesOrder,
  135. selectId: that.selectId,
  136. selectType: that.selectType
  137. }
  138. }
  139. getHomeProducts(data).then(res => {
  140. that.bastList = res.data.list;
  141. }).catch(err => {
  142. that.$util.Tips({ title: err });
  143. });
  144. },
  145. goDetail(item){
  146. goPage().then(res=>{
  147. goShopDetail(item,this.uid).then(res=>{
  148. uni.navigateTo({
  149. url:`/pages/goods_details/index?id=${item.id}`
  150. })
  151. })
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. .productList .list {
  159. padding: 0 30rpx;
  160. }
  161. .productList .list .item {
  162. width: 335rpx;
  163. margin-top: 20rpx;
  164. background-color: #fff;
  165. border-radius: 20rpx;
  166. border:1rpx solid #eee;
  167. }
  168. .productList .list .item .pictrue {
  169. position: relative;
  170. width: 100%;
  171. height: 335rpx;
  172. }
  173. .productList .list .item .pictrue image {
  174. width: 100%;
  175. height: 100%;
  176. border-radius: 20rpx 20rpx 0 0;
  177. }
  178. .productList .list .item .text {
  179. padding: 20rpx 17rpx 26rpx 17rpx;
  180. font-size: 30rpx;
  181. color: #222;
  182. }
  183. .productList .list .item .text .money {
  184. font-size: 26rpx;
  185. font-weight: bold;
  186. margin-top: 8rpx;
  187. }
  188. .productList .list .item .text .money .num {
  189. font-size: 34rpx;
  190. }
  191. .productList .list .item .text .vip {
  192. font-size: 22rpx;
  193. color: #aaa;
  194. margin-top: 7rpx;
  195. }
  196. .productList .list .item .text .vip .vip-money {
  197. font-size: 24rpx;
  198. color: #282828;
  199. font-weight: bold;
  200. }
  201. .productList .list .item .text .vip .vip-money image {
  202. width: 46rpx;
  203. height: 21rpx;
  204. margin-left: 4rpx;
  205. }
  206. .empty-img {
  207. width: 690rpx;
  208. height: 300rpx;
  209. border-radius: 14rpx;
  210. margin: 26rpx auto 0 auto;
  211. background-color: #ccc;
  212. text-align: center;
  213. line-height: 300rpx;
  214. .iconfont{
  215. font-size: 50rpx;
  216. }
  217. }
  218. </style>