u-pick.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 :style="{'background-color': theme.background}" class="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 :style="{'color': theme.color}" class="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" :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. theme: Object,
  63. index: Number,
  64. is_required:Boolean,
  65. page_id: Number,
  66. appImg: {
  67. type: Object,
  68. default: function() {
  69. return {
  70. plugins_out: ''
  71. }
  72. }
  73. },
  74. appSetting: {
  75. type: Object,
  76. default: function() {
  77. return {
  78. is_show_stock: 1,
  79. sell_out_pic: '',
  80. is_use_stock: 1
  81. }
  82. }
  83. }
  84. },
  85. data() {
  86. return {
  87. newData: [],
  88. tempList: [],
  89. goodsList: [],
  90. time: 0,
  91. style: '1',
  92. goods_num: 10
  93. };
  94. },
  95. components: {
  96. uIndexPlugins,
  97. uOrdinaryList
  98. },
  99. computed: {
  100. ...mapGetters('mallConfig', {
  101. getTheme: 'getTheme',
  102. }),
  103. copyList: function() {
  104. if (!this.newData) return;
  105. return this.newData.list;
  106. }
  107. },
  108. methods: {
  109. router(goods) {
  110. this.$emit('router', goods);
  111. },
  112. // 是否展示会员价
  113. isShowMemPrice(goods) {
  114. return goods.is_level === 1 && goods.is_negotiable !== 1 ? 1 : 0;
  115. },
  116. // 是否展示超级会员价
  117. isShowVip(goods) {
  118. return goods.vip_card_appoint && goods.vip_card_appoint.discount > 0 && goods.is_negotiable !== 1 ? 1 : 0;
  119. },
  120. // 是否展示售罄
  121. isShowStock(goods) {
  122. return this.appSetting.is_show_stock === 1 && goods.goods_stock === 0 ? 1: 0;
  123. },
  124. loadData() {
  125. let para = {
  126. type: this.page_id === 0 ? 'mall' : 'diy',
  127. key: 'pick',
  128. page_id: this.page_id,
  129. index: this.index
  130. }
  131. if(this.goods_num) {
  132. para.goods_num = this.goods_num
  133. }
  134. this.$request({
  135. url: this.$api.index.extra,
  136. data: para
  137. }).then(e => {
  138. this.newData = e.data;
  139. if (e.code ===0 && e.data && this.page_id === 0) {
  140. let storage = this.$storage.getStorageSync('INDEX_MALL');
  141. storage.home_pages[this.index].data = this.newData;
  142. this.$storage.setStorageSync('INDEX_MALL', storage);
  143. }
  144. })
  145. },
  146. // 复制而不是引用对象和数组
  147. cloneData(data) {
  148. return JSON.parse(JSON.stringify(data));
  149. },
  150. // 循环载入
  151. splitData() {
  152. if (!this.tempList.length) return;
  153. let item = this.tempList[0];
  154. this.goodsList.push(item);
  155. this.tempList.splice(0, 1);
  156. if (this.tempList.length) {
  157. this.timeOut = setTimeout(() => {
  158. this.splitData();
  159. }, 200);
  160. }
  161. }
  162. },
  163. mounted() {
  164. let storage = this.$storage.getStorageSync('INDEX_MALL');
  165. this.style = storage.home_pages[this.index].style;
  166. this.goods_num = storage.home_pages[this.index].goods_num;
  167. if (this.is_required) {
  168. this.loadData();
  169. } else {
  170. this.newData = storage.home_pages[this.index].data;
  171. }
  172. },
  173. watch: {
  174. copyList: {
  175. handler(newVal) {
  176. if (this.$validation.empty(newVal)) return;
  177. this.tempList = this.cloneData(newVal);
  178. this.splitData();
  179. }
  180. }
  181. },
  182. destroyed() {
  183. clearTimeout(this.time);
  184. }
  185. }
  186. </script>
  187. <style scoped lang="scss">
  188. @import url('./index.scss');
  189. .u-icon {
  190. width: 46upx;
  191. height: 46upx;
  192. margin-right: 16upx;
  193. }
  194. .u-top {
  195. font-size: 28upx;
  196. color: #ff4544;
  197. }
  198. .u-des-price {
  199. display: inline-block;
  200. font-size: 19upx;
  201. color: #ffffff;
  202. border-radius: 7upx;
  203. padding: 0upx 5upx;
  204. }
  205. </style>