u-booking.vue 6.5 KB

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