u-pintuan.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <u-index-plugins url="/plugins/pt/index/index">
  3. <template v-slot:u-top-name>
  4. <view class="cross-center u-top">
  5. <image class="u-icon" :src="appImg.icon_home_pintuan"></image>
  6. <view class="box-grow-1">限量拼团,每日必逛</view>
  7. </view>
  8. </template>
  9. <template v-slot:u-body>
  10. <view v-if="style === '1'" class="dir-left-nowrap">
  11. <view v-for="(goods, index) in newData.list" v-bind:key="index" class="u-goods dir-top-nowrap box-grow-0" v-on:click="router(goods)">
  12. <view class="u-cover-box">
  13. <view class="u-out-dialog" v-if="isShowStock(goods)">
  14. <image class="u-pic" :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  15. </view>
  16. <image class="box-grow-0 u-cover" v-bind:src="goods.cover_pic"></image>
  17. </view>
  18. <view class="box-grow-0 u-goods-name t-omit-two">{{goods.name}}</view>
  19. <view class="box-grow-1 u-content dir-top-nowrap main-right">
  20. <view class="u-margin" v-if="isShowMemPrice(goods)">
  21. <app-member-price :theme="theme" v-bind:price="goods.level_price"></app-member-price>
  22. </view>
  23. <view class="u-margin" v-if="isShowVip(goods)">
  24. <app-sup-vip
  25. v-bind:is_vip_card_user="goods.vip_card_appoint.is_vip_card_user"
  26. v-bind:discount="goods.vip_card_appoint.discount"
  27. ></app-sup-vip>
  28. </view>
  29. <view v-bind:class="[theme.color, 'dir-left-nowrap', 'u-price-box', 't-omit']">
  30. <text class="u-price">{{goods.price_content}}</text>
  31. </view>
  32. <text class="cross-center u-count">{{goods.group_count}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view v-if="style === '2'">
  37. <u-ordinary-list :theme-object="theme" :showBuyBtn="false" :theme="getTheme" :list-style="2" :list="newData.list"></u-ordinary-list>
  38. </view>
  39. </template>
  40. </u-index-plugins>
  41. </template>
  42. <script>
  43. import {mapGetters, mapState} from 'vuex';
  44. import uIndexPlugins from '../u-index-plugins/u-index-plugins.vue';
  45. import uOrdinaryList from '@/components/page-component/u-goods-list/u-ordinary-list.vue';
  46. export default {
  47. name: "u-pintuan",
  48. props: {
  49. theme: {
  50. type: Object
  51. },
  52. index: {
  53. type: Number
  54. },
  55. page_id: {
  56. type: Number
  57. },
  58. is_required: {
  59. type: Boolean
  60. },
  61. appImg: {
  62. type: Object,
  63. default: function() {
  64. return {
  65. plugins_out: ''
  66. }
  67. }
  68. },
  69. appSetting: {
  70. type: Object,
  71. default: function() {
  72. return {
  73. is_show_stock: 1,
  74. sell_out_pic: '',
  75. is_use_stock: 1
  76. }
  77. }
  78. }
  79. },
  80. data() {
  81. return {
  82. newData: {},
  83. tempList: [],
  84. goodsList: [],
  85. time: 0,
  86. style: '1',
  87. goods_num: 10
  88. };
  89. },
  90. components: {
  91. uIndexPlugins,
  92. uOrdinaryList
  93. },
  94. computed: {
  95. ...mapGetters('mallConfig', {
  96. getTheme: 'getTheme',
  97. }),
  98. copyList: function() {
  99. return this.newData;
  100. }
  101. },
  102. mounted() {
  103. let storage = this.$storage.getStorageSync('INDEX_MALL');
  104. this.style = storage.home_pages[this.index].style;
  105. this.goods_num = storage.home_pages[this.index].goods_num;
  106. if (this.is_required) {
  107. this.loadData();
  108. } else {
  109. this.newData = storage.home_pages[this.index].list;
  110. }
  111. },
  112. methods: {
  113. // 是否展示会员价
  114. isShowMemPrice(goods) {
  115. return goods.is_level === 1 && goods.is_negotiable !== 1 ? 1 : 0;
  116. },
  117. // 是否展示超级会员价
  118. isShowVip(goods) {
  119. return goods.vip_card_appoint && goods.vip_card_appoint.discount > 0 && goods.is_negotiable !== 1 ? 1 : 0;
  120. },
  121. // 是否展示售罄
  122. isShowStock(goods) {
  123. return this.appSetting.is_show_stock === 1 && goods.goods_stock === 0 ? 1: 0;
  124. },
  125. router(goods) {
  126. this.$emit('router', goods);
  127. },
  128. async loadData() {
  129. let para = {
  130. type: this.page_id === 0 ? 'mall' : 'diy',
  131. key: 'pintuan',
  132. page_id: this.page_id,
  133. index: this.index
  134. }
  135. if(this.goods_num) {
  136. para.goods_num = this.goods_num
  137. }
  138. const e = await this.$request({
  139. url: this.$api.index.extra,
  140. data: para
  141. });
  142. this.newData = e.data;
  143. if (e.code ===0 && e.data && this.page_id === 0) {
  144. let storage = this.$storage.getStorageSync('INDEX_MALL');
  145. storage.home_pages[this.index].list = this.newData;
  146. this.$storage.setStorageSync('INDEX_MALL', storage);
  147. }
  148. },
  149. // 复制而不是引用对象和数组
  150. cloneData(data) {
  151. return JSON.parse(JSON.stringify(data));
  152. },
  153. // 循环载入
  154. splitData() {
  155. if (!this.tempList.length) return;
  156. let item = this.tempList[0];
  157. this.goodsList.push(item);
  158. this.tempList.splice(0, 1);
  159. if (this.tempList.length) {
  160. this.timeOut = setTimeout(() => {
  161. this.splitData();
  162. }, 200);
  163. }
  164. }
  165. },
  166. watch: {
  167. copyList: {
  168. handler(newVal) {
  169. if (this.$validation.empty(newVal)) return;
  170. this.tempList = this.cloneData(newVal);
  171. this.splitData();
  172. }
  173. }
  174. },
  175. destroyed() {
  176. clearTimeout(this.time);
  177. }
  178. }
  179. </script>
  180. <style scoped lang="scss">
  181. @import url('./index.scss');
  182. .u-icon {
  183. width: 88upx;
  184. height: 40upx;
  185. margin-right: 20upx;
  186. }
  187. .u-top {
  188. font-size: 24upx;
  189. color: #999999;
  190. }
  191. .u-count {
  192. font-size: 22upx;
  193. color: #999999;
  194. }
  195. </style>