u-advance.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <u-index-plugins url="/plugins/advance/index/index">
  3. <template v-slot:u-top-name>
  4. <view class="cross-center u-top">
  5. <image class="u-icon" :src="appImg.advance"></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 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. 定金¥{{goods.deposit}}抵¥{{goods.swell_deposit}}
  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. <u-ordinary-list :theme-object="theme" :showBuyBtn="false" :theme="getTheme" :list-style="2" :list="goodsList"></u-ordinary-list>
  50. </view>
  51. </template>
  52. </u-index-plugins>
  53. </template>
  54. <script>
  55. import {mapGetters, mapState} from 'vuex';
  56. import uIndexPlugins from '../u-index-plugins/u-index-plugins.vue';
  57. import uOrdinaryList from '@/components/page-component/u-goods-list/u-ordinary-list.vue';
  58. export default {
  59. name: "u-advance",
  60. props: {
  61. index: Number,
  62. page_id: Number,
  63. is_required: Boolean,
  64. theme: {
  65. type: Object
  66. },
  67. appImg: {
  68. type: Object,
  69. default: function() {
  70. return {
  71. plugins_out: ''
  72. }
  73. }
  74. },
  75. appSetting: {
  76. type: Object,
  77. default: function() {
  78. return {
  79. is_show_stock: 1,
  80. sell_out_pic: '',
  81. is_use_stock: 1
  82. }
  83. }
  84. }
  85. },
  86. data() {
  87. return {
  88. newData: {},
  89. tempList: [],
  90. goodsList: [],
  91. time: 0,
  92. style: '1',
  93. goods_num: 20
  94. };
  95. },
  96. computed: {
  97. ...mapGetters('mallConfig', {
  98. getTheme: 'getTheme',
  99. })
  100. },
  101. components: {
  102. uIndexPlugins,
  103. uOrdinaryList
  104. },
  105. methods: {
  106. router(goods) {
  107. this.$emit('router', goods);
  108. },
  109. // 是否展示会员价
  110. isShowMemPrice(goods) {
  111. return goods.is_level === 1 && goods.is_negotiable !== 1 ? 1 : 0;
  112. },
  113. // 是否展示超级会员价
  114. isShowVip(goods) {
  115. return goods.vip_card_appoint && goods.vip_card_appoint.discount > 0 && goods.is_negotiable !== 1 ? 1 : 0;
  116. },
  117. // 是否展示售罄
  118. isShowStock(goods) {
  119. return this.appSetting.is_show_stock === 1 && goods.goods_stock === 0 ? 1: 0;
  120. },
  121. loadData() {
  122. let para = {
  123. type: this.page_id === 0 ? 'mall' : 'diy',
  124. key: 'advance',
  125. page_id: this.page_id,
  126. index: this.index
  127. }
  128. if(this.goods_num) {
  129. para.goods_num = this.goods_num
  130. }
  131. this.$request({
  132. url: this.$api.index.extra,
  133. data: para
  134. }).then(info => {
  135. if (info.code === 0 && info.data) {
  136. this.newData = info.data.list;
  137. if (this.page_id === 0) {
  138. let storage = this.$storage.getStorageSync('INDEX_MALL');
  139. storage.home_pages[this.index].list = this.newData;
  140. this.$storage.setStorageSync('INDEX_MALL', storage);
  141. }
  142. }
  143. })
  144. },
  145. // 复制而不是引用对象和数组
  146. cloneData(data) {
  147. return JSON.parse(JSON.stringify(data));
  148. },
  149. // 循环载入
  150. splitData() {
  151. if (!this.tempList.length) return;
  152. let item = this.tempList[0];
  153. this.goodsList.push(item);
  154. this.tempList.splice(0, 1);
  155. if (this.tempList.length) {
  156. this.time = setTimeout(() => {
  157. this.splitData();
  158. }, 200);
  159. }
  160. },
  161. },
  162. mounted() {
  163. let storage = this.$storage.getStorageSync('INDEX_MALL');
  164. this.style = storage.home_pages[this.index].style;
  165. this.goods_num = storage.home_pages[this.index].goods_num;
  166. if (this.is_required) {
  167. this.loadData();
  168. } else {
  169. this.newData = storage.home_pages[this.index].list;
  170. }
  171. },
  172. watch: {
  173. newData: {
  174. handler(newVal) {
  175. if (this.$validation.empty(newVal)) return;
  176. this.tempList = this.cloneData(newVal);
  177. this.splitData();
  178. },
  179. immediate: true
  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. height: 25upx;
  205. line-height: 25rpx;
  206. }
  207. </style>