app-index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="app-index">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <template v-if="mall.setting.is_official_account == 1">
  5. <official-account></official-account>
  6. </template>
  7. <!-- #endif -->
  8. <block v-for="(item, index) in newPage" :key="index">
  9. <template v-if="item.key === 'search'">
  10. <view class="page-width">
  11. <app-search-for></app-search-for>
  12. </view>
  13. </template>
  14. <template v-else-if="item.key === 'banner'">
  15. <view v-if="item.banners.length > 0">
  16. <app-swiper
  17. :list="item.banners"
  18. name="pic_url"
  19. :height="350"
  20. :autoplay="true"
  21. >
  22. </app-swiper>
  23. </view>
  24. </template>
  25. <view class="mt-20" v-else-if="item.key === 'cat'">
  26. <app-index-cat
  27. :theme="theme"
  28. :page_id="page_id"
  29. :index="index"
  30. :is_required="is_required"
  31. @buyProduct="buyProduct"
  32. ></app-index-cat>
  33. </view>
  34. <template v-else-if="item.key === 'home_nav'">
  35. <app-navigation-icon
  36. :navs="item.home_navs"
  37. :columns="Number(item.row_num)"
  38. :rows="-1"
  39. ></app-navigation-icon>
  40. </template>
  41. <template v-else-if="item.key === 'notice'">
  42. <u-announcement
  43. :name="item.notice_name"
  44. :content="item.notice_content"
  45. :icon="item.notice_url"
  46. :bgColor="item.notice_bg_color"
  47. :text-color="item.notice_text_color"
  48. ></u-announcement>
  49. </template>
  50. <template v-else-if="item.key === 'video'">
  51. <view class="mt-20">
  52. <app-video
  53. :pic-url="item.video_pic_url"
  54. :url="item.video_url"
  55. ></app-video>
  56. </view>
  57. </template>
  58. <template v-else-if="item.key === 'topic'">
  59. <view class="mt-20">
  60. <app-topic
  61. :topic_list="item.topics"
  62. :count="Number(item.topic_num)"
  63. :icon="item.label_url"
  64. :logo_2="item.topic_url_2"
  65. :logo_1="item.topic_url"
  66. ></app-topic>
  67. </view>
  68. </template>
  69. <template v-else-if="item.key === 'coupon'">
  70. <view class="mt-20">
  71. <app-exclusive-coupon
  72. v-bind:coupon_list="item.coupons"
  73. v-bind:receive-bg="item.coupon_url"
  74. v-bind:unclaimed-bg="item.coupon_not_url"
  75. @click="changeCoupon"
  76. v-bind:page_id="page_id" :index="index"
  77. v-bind:is_storage="is_storage"
  78. v-bind:is_required="is_required"
  79. v-bind:coupon_req="coupon_req"
  80. ></app-exclusive-coupon>
  81. </view>
  82. </template>
  83. <template v-else-if="item.key === 'block'">
  84. <app-image-ad :image-style="item.block.status" :list="item.block.value"></app-image-ad>
  85. </template>
  86. <template v-else-if="item.key === 'miaosha'">
  87. <view class="miaosha mt-20">
  88. <u-miaosha :appImg="appImg" :appSetting="appSetting" @router="router" :is_storage="is_storage" :is_required="is_required" :page_id="page_id" :index="index" :page-hide="pageHide" :theme="theme"></u-miaosha>
  89. </view>
  90. </template>
  91. <template v-else-if="item.key === 'flash_sale'">
  92. <view class="u-flash-sale mt-20">
  93. <u-flash-sale :appImg="appImg" :appSetting="appSetting" @router="router" :is_storage="is_storage" :is_required="is_required" :page_id="page_id" :index="index" :theme="theme"></u-flash-sale>
  94. </view>
  95. </template>
  96. <template v-else-if="item.key === 'fxhb'">
  97. <view>
  98. <app-popup-ad :opened="true" :is_storage="is_storage" :is_required="is_required" :list="item.fxhb"></app-popup-ad>
  99. </view>
  100. </template>
  101. <template v-else-if="item.key === 'pintuan'">
  102. <view class="pintuan mt-20">
  103. <u-pintuan :appImg="appImg" :appSetting="appSetting" @router="router" :is_required="is_required" :index="index" :page_id="page_id" :theme="theme" ></u-pintuan>
  104. </view>
  105. </template>
  106. <template v-else-if="item.key === 'booking'">
  107. <view class="booking mt-20">
  108. <u-booking :appImg="appImg" :appSetting="appSetting" @router="router" :is_required="is_required" :index="index" :theme="theme" :page_id="page_id" ></u-booking>
  109. </view>
  110. </template>
  111. <template v-else-if="item.key === 'mch'">
  112. <view class="mch mt-20">
  113. <app-good-shop-recommendation :is_required="is_required" :index="index" :theme="theme" :page_id="page_id" :list="item.mch"></app-good-shop-recommendation>
  114. </view>
  115. </template>
  116. <template v-else-if="item.key === 'advance'">
  117. <view class="advance mt-20">
  118. <u-advance :appImg="appImg" :appSetting="appSetting" @router="router" :is_required="is_required" :index="index" :theme="theme" :page_id="page_id"></u-advance>
  119. </view>
  120. </template>
  121. <template v-else-if="item.key === 'pick'">
  122. <view class="pick mt-20">
  123. <u-pick :appImg="appImg" :appSetting="appSetting" @router="router" :is_required="is_required" :index="index" :theme="theme" :page_id="page_id" :activity="item.pick.activity"></u-pick>
  124. </view>
  125. </template>
  126. <template v-else-if="item.key === 'wholesale'">
  127. <view class="booking mt-20">
  128. <app-index-wholesale :is_required="is_required" :index="index" :theme="theme" :page_id="page_id" ></app-index-wholesale>
  129. </view>
  130. </template>
  131. </block>
  132. <view class="page-width">
  133. <app-quick-navigation></app-quick-navigation>
  134. </view>
  135. </view>
  136. </template>
  137. <script>
  138. import { mapState } from 'vuex';
  139. import appSearchFor from '../../page-component/app-search-for/app-search-for.vue';
  140. import appSwiper from '../../page-component/app-swiper/app-swiper.vue';
  141. import appNavigationIcon from '../../page-component/app-navigation-icon/app-navigation-icon.vue';
  142. import uAnnouncement from '../../page-component/u-announcement/u-announcement.vue';
  143. import appVideo from '../../page-component/app-video/app-video.vue';
  144. import appTopic from '../../page-component/app-special-topic/app-special-topic-normal.vue';
  145. import appExclusiveCoupon from '../../page-component/app-exclusive-coupon/app-exclusive-coupon.vue';
  146. import appImageAd from '../../page-component/app-image-ad/app-image-ad.vue';
  147. import appReservation from '../../page-component/app-reservation/app-reservation.vue';
  148. import appGoodShopRecommendation from "../../page-component/app-good-shop-recommendation/app-good-shop-recommendation.vue";
  149. import appTimer from "../../basic-component/app-timer/app-timer.vue";
  150. import appQuickNavigation from "../../page-component/app-quick-navigation/app-quick-navigation.vue";
  151. import appPopupAd from "../../page-component/app-popup-ad/app-popup-ad.vue";
  152. import appIndexWholesale from "../../page-component/app-index-wholesale/app-index-wholesale.vue";
  153. import uMiaosha from "../../page-component/u-index-plugins/u-miaosha.vue";
  154. import uPintuan from "../../page-component/u-index-plugins/u-pintuan.vue";
  155. import uBooking from "../../page-component/u-index-plugins/u-booking.vue";
  156. import appIndexCat from "../../page-component/app-index-cat/app-index-cat.vue";
  157. import uAdvance from '../../page-component/u-index-plugins/u-advance.vue';
  158. import uPick from '../../page-component/u-index-plugins/u-pick.vue';
  159. import uFlashSale from '../../page-component/u-index-plugins/u-flash-sale.vue';
  160. export default {
  161. name: 'app-index',
  162. data() {
  163. return {
  164. newPage: [],
  165. time: -1,
  166. tempList: [],
  167. timeout: 0,
  168. flash_salse: false
  169. }
  170. },
  171. props: {
  172. homePages: {
  173. type: Array,
  174. default() {
  175. return [];
  176. }
  177. },
  178. is_storage: Boolean,
  179. pageHide: Boolean,
  180. theme: Object,
  181. page_id: Number,
  182. is_required: Boolean,
  183. coupon_req: Boolean
  184. },
  185. computed: {
  186. ...mapState('mallConfig', {
  187. mall: state => state.mall,
  188. appImg: state => state.__wxapp_img.mall,
  189. appSetting: state => state.mall.setting
  190. }),
  191. newData() {
  192. uni.setNavigationBarTitle({
  193. title: this.mall.name
  194. });
  195. },
  196. },
  197. watch: {
  198. homePages: {
  199. handler: function(data) {
  200. this.tempList = [];
  201. clearTimeout(this.timeout);
  202. this.newPage = [];
  203. this.tempList = this.cloneData(data);
  204. this.splitData();
  205. },
  206. immediate: true,
  207. }
  208. },
  209. methods: {
  210. changeCoupon(data, index) {
  211. this.newPage[index].coupons[data].is_receive = '1';
  212. },
  213. buyProduct(data) {
  214. this.$emit('buyProduct', data);
  215. },
  216. splitData() {
  217. if (!this.tempList.length) return;
  218. let item = this.tempList[0];
  219. this.newPage.push(item);
  220. this.tempList.splice(0, 1);
  221. if (this.tempList.length) {
  222. this.timeout = setTimeout(() => {
  223. this.splitData();
  224. }, 100);
  225. }
  226. },
  227. // 复制而不是引用对象和数组
  228. cloneData(data) {
  229. return JSON.parse(JSON.stringify(data));
  230. },
  231. router(goods) {
  232. // #ifndef MP-BAIDU
  233. if (goods.video_url && this.getVideo == 1) {
  234. uni.navigateTo({
  235. url: `/pages/goods/video?goods_id=${goods.id}&sign=${goods.sign}`
  236. });
  237. } else {
  238. uni.navigateTo({
  239. url: goods.page_url
  240. })
  241. }
  242. // #endif
  243. // #ifdef MP-BAIDU
  244. uni.navigateTo({
  245. url: goods.page_url
  246. })
  247. // #endif
  248. }
  249. },
  250. components: {
  251. 'app-search-for': appSearchFor,
  252. 'app-swiper': appSwiper,
  253. 'app-navigation-icon': appNavigationIcon,
  254. uAnnouncement,
  255. 'app-video': appVideo,
  256. 'app-topic': appTopic,
  257. 'app-exclusive-coupon': appExclusiveCoupon,
  258. 'app-image-ad': appImageAd,
  259. 'app-reservation': appReservation,
  260. 'app-good-shop-recommendation': appGoodShopRecommendation,
  261. 'app-timer': appTimer,
  262. 'app-quick-navigation': appQuickNavigation,
  263. 'app-popup-ad': appPopupAd,
  264. 'app-index-cat': appIndexCat,
  265. 'app-index-wholesale': appIndexWholesale,
  266. uAdvance,
  267. uMiaosha,
  268. uPintuan,
  269. uBooking,
  270. uFlashSale,
  271. uPick
  272. },
  273. }
  274. </script>
  275. <style scoped lang="scss">
  276. .mch {
  277. background-color: #ffffff;
  278. }
  279. .mt-20 {
  280. margin-top: #{20rpx};
  281. }
  282. </style>