u-pick.vue 7.3 KB

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