app-index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. <!-- #ifdef H5 -->
  9. <template v-if="isShowAttention && mall.setting.is_official_account == 1">
  10. <view class="bd-attention">
  11. <view class="bd-content">
  12. <view class="dir-left-nowrap main-between cross-center">
  13. <view class="dir-left-nowrap cross-center">
  14. <image class="bd-logo" :src="userInfo && userInfo.wechat_logo"></image>
  15. <view class="bd-name">{{userInfo && userInfo.wechat_name}}</view>
  16. </view>
  17. <view class="bd-btn" @click="openAttention">去关注</view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <!-- #endif -->
  23. <block v-for="(item, index) in newPage" :key="index">
  24. <template v-if="item.key === 'search'">
  25. <view class="page-width">
  26. <app-search-for></app-search-for>
  27. </view>
  28. </template>
  29. <template v-else-if="item.key === 'banner'">
  30. <view v-if="item.banners.length > 0">
  31. <app-swiper
  32. :list="item.banners"
  33. name="pic_url"
  34. :height="350"
  35. :autoplay="true"
  36. >
  37. </app-swiper>
  38. </view>
  39. </template>
  40. <view class="mt-20" v-else-if="item.key === 'cat'">
  41. <app-index-cat
  42. :theme="theme"
  43. :page_id="page_id"
  44. :index="index"
  45. :is_required="is_required"
  46. @buyProduct="buyProduct"
  47. ></app-index-cat>
  48. </view>
  49. <template v-else-if="item.key === 'home_nav'">
  50. <app-navigation-icon
  51. :navs="item.home_navs"
  52. :columns="Number(item.row_num)"
  53. :rows="-1"
  54. ></app-navigation-icon>
  55. </template>
  56. <template v-else-if="item.key === 'notice'">
  57. <u-announcement
  58. :name="item.notice_name"
  59. :content="item.notice_content"
  60. :icon="item.notice_url"
  61. :bgColor="item.notice_bg_color"
  62. :text-color="item.notice_text_color"
  63. ></u-announcement>
  64. </template>
  65. <template v-else-if="item.key === 'video'">
  66. <view class="mt-20">
  67. <app-video
  68. :pic-url="item.video_pic_url"
  69. :url="item.video_url"
  70. ></app-video>
  71. </view>
  72. </template>
  73. <template v-else-if="item.key === 'topic'">
  74. <view class="mt-20">
  75. <app-topic
  76. :topic_list="item.topics"
  77. :count="Number(item.topic_num)"
  78. :icon="item.label_url"
  79. :logo_2="item.topic_url_2"
  80. :logo_1="item.topic_url"
  81. ></app-topic>
  82. </view>
  83. </template>
  84. <template v-else-if="item.key === 'coupon'">
  85. <view class="mt-20">
  86. <app-exclusive-coupon
  87. v-bind:coupon_list="item.coupons"
  88. v-bind:receive-bg="item.coupon_url"
  89. v-bind:unclaimed-bg="item.coupon_not_url"
  90. @click="changeCoupon"
  91. v-bind:page_id="page_id" :index="index"
  92. v-bind:is_storage="is_storage"
  93. v-bind:is_required="is_required"
  94. v-bind:coupon_req="coupon_req"
  95. ></app-exclusive-coupon>
  96. </view>
  97. </template>
  98. <template v-else-if="item.key === 'block'">
  99. <app-image-ad :image-style="item.block.status" :list="item.block.value"
  100. :height="item.block.height"></app-image-ad>
  101. </template>
  102. <template v-else-if="item.key === 'miaosha'">
  103. <view class="miaosha mt-20">
  104. <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>
  105. </view>
  106. </template>
  107. <template v-else-if="item.key === 'flash_sale'">
  108. <view class="u-flash-sale mt-20">
  109. <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>
  110. </view>
  111. </template>
  112. <template v-else-if="item.key === 'fxhb'">
  113. <view>
  114. <app-popup-ad :opened="true" :is_storage="is_storage" :is_required="is_required" :list="item.fxhb"></app-popup-ad>
  115. </view>
  116. </template>
  117. <template v-else-if="item.key === 'pintuan'">
  118. <view class="pintuan mt-20">
  119. <u-pintuan :appImg="appImg" :appSetting="appSetting" @router="router" :is_required="is_required" :index="index" :page_id="page_id" :theme="theme" ></u-pintuan>
  120. </view>
  121. </template>
  122. <template v-else-if="item.key === 'booking'">
  123. <view class="booking mt-20">
  124. <u-booking :appImg="appImg" :appSetting="appSetting" @router="router" :is_required="is_required" :index="index" :theme="theme" :page_id="page_id" ></u-booking>
  125. </view>
  126. </template>
  127. <template v-else-if="item.key === 'mch'">
  128. <view class="mch mt-20">
  129. <bd-g-s-r :is_required="is_required" :index="index" :theme="theme" :page_id="page_id" :list="item.mch"></bd-g-s-r>
  130. </view>
  131. </template>
  132. <template v-else-if="item.key === 'advance'">
  133. <view class="advance mt-20">
  134. <u-advance :appImg="appImg" :appSetting="appSetting" @router="router" :is_required="is_required" :index="index" :theme="theme" :page_id="page_id"></u-advance>
  135. </view>
  136. </template>
  137. <template v-else-if="item.key === 'pick'">
  138. <view class="pick mt-20">
  139. <u-pick :appImg="appImg" :appSetting="appSetting"
  140. @router="router" :is_required="is_required"
  141. :index="index" :theme="theme"
  142. :page_id="page_id"></u-pick>
  143. </view>
  144. </template>
  145. <template v-else-if="item.key === 'wholesale'">
  146. <view class="booking mt-20">
  147. <app-index-wholesale :is_required="is_required" :index="index" :theme="theme" :page_id="page_id" ></app-index-wholesale>
  148. </view>
  149. </template>
  150. </block>
  151. <view class="page-width">
  152. <app-quick-navigation></app-quick-navigation>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. import {mapGetters, mapState} from 'vuex';
  158. import appSearchFor from '../../page-component/app-search-for/app-search-for.vue';
  159. import appSwiper from '../../page-component/app-swiper/app-swiper.vue';
  160. import appNavigationIcon from '../../page-component/app-navigation-icon/app-navigation-icon.vue';
  161. import uAnnouncement from '../../page-component/u-announcement/u-announcement.vue';
  162. import appVideo from '../../page-component/app-video/app-video.vue';
  163. import appTopic from '../../page-component/app-special-topic/app-special-topic-normal.vue';
  164. import appExclusiveCoupon from '../../page-component/app-exclusive-coupon/app-exclusive-coupon.vue';
  165. import appImageAd from '../../page-component/app-image-ad/app-image-ad.vue';
  166. import appReservation from '../../page-component/app-reservation/app-reservation.vue';
  167. import bdGSR from "../../page-component/app-good-shop-recommendation/app-good-shop-recommendation.vue";
  168. import appTimer from "../../basic-component/app-timer/app-timer.vue";
  169. import appQuickNavigation from "../../page-component/app-quick-navigation/app-quick-navigation.vue";
  170. import appPopupAd from "../../page-component/app-popup-ad/app-popup-ad.vue";
  171. import appIndexWholesale from "../../page-component/app-index-wholesale/app-index-wholesale.vue";
  172. import uMiaosha from "../../page-component/u-index-plugins/u-miaosha.vue";
  173. import uPintuan from "../../page-component/u-index-plugins/u-pintuan.vue";
  174. import uBooking from "../../page-component/u-index-plugins/u-booking.vue";
  175. import appIndexCat from "../../page-component/app-index-cat/app-index-cat.vue";
  176. import uAdvance from '../../page-component/u-index-plugins/u-advance.vue';
  177. import uPick from '../../page-component/u-index-plugins/u-pick.vue';
  178. import uFlashSale from '../../page-component/u-index-plugins/u-flash-sale.vue';
  179. export default {
  180. name: 'app-index',
  181. data() {
  182. return {
  183. newPage: [],
  184. time: -1,
  185. tempList: [],
  186. timeout: 0,
  187. flash_salse: false
  188. }
  189. },
  190. props: {
  191. homePages: {
  192. type: Array,
  193. default() {
  194. return [];
  195. }
  196. },
  197. is_storage: Boolean,
  198. pageHide: Boolean,
  199. theme: Object,
  200. page_id: Number,
  201. is_required: Boolean,
  202. coupon_req: Boolean,
  203. isShowAttention: Boolean
  204. },
  205. computed: {
  206. ...mapState('mallConfig', {
  207. mall: state => state.mall,
  208. appImg: state => state.__wxapp_img.mall,
  209. appSetting: state => state.mall.setting
  210. }),
  211. ...mapGetters({
  212. userInfo: 'user/info'
  213. }),
  214. ...mapState({
  215. platform: function(state) {
  216. return state.gConfig.systemInfo.platform;
  217. }
  218. }),
  219. },
  220. watch: {
  221. homePages: {
  222. handler: function(data) {
  223. uni.setNavigationBarTitle({
  224. title: this.mall.name
  225. });
  226. this.tempList = [];
  227. clearTimeout(this.timeout);
  228. this.newPage = [];
  229. this.tempList = this.cloneData(data);
  230. this.splitData();
  231. },
  232. immediate: true,
  233. },
  234. },
  235. methods: {
  236. changeCoupon(data, index) {
  237. this.newPage[index].coupons[data].is_receive = '1';
  238. },
  239. buyProduct(data) {
  240. this.$emit('buyProduct', data);
  241. },
  242. splitData() {
  243. if (!this.tempList.length) return;
  244. let item = this.tempList[0];
  245. this.newPage.push(item);
  246. this.tempList.splice(0, 1);
  247. if (this.tempList.length) {
  248. this.timeout = setTimeout(() => {
  249. this.splitData();
  250. }, 100);
  251. }
  252. },
  253. // 复制而不是引用对象和数组
  254. cloneData(data) {
  255. return JSON.parse(JSON.stringify(data));
  256. },
  257. router(goods) {
  258. // #ifndef MP-BAIDU
  259. if (goods.video_url && this.getVideo == 1) {
  260. // #ifdef MP
  261. uni.navigateTo({
  262. url: `/pages/goods/video?goods_id=${goods.id}&sign=${goods.sign}`
  263. });
  264. // #endif
  265. // #ifdef H5
  266. uni.navigateTo({
  267. url: goods.page_url
  268. })
  269. // #endif
  270. } else {
  271. uni.navigateTo({
  272. url: goods.page_url
  273. })
  274. }
  275. // #endif
  276. // #ifdef MP-BAIDU
  277. uni.navigateTo({
  278. url: goods.page_url
  279. })
  280. // #endif
  281. },
  282. // #ifdef H5
  283. openAttention() {
  284. this.$store.dispatch('user/showAttentionTwo', true);
  285. this.$store.dispatch('user/showAttention', true);
  286. },
  287. // #endif
  288. },
  289. components: {
  290. 'app-search-for': appSearchFor,
  291. 'app-swiper': appSwiper,
  292. 'app-navigation-icon': appNavigationIcon,
  293. uAnnouncement,
  294. 'app-video': appVideo,
  295. 'app-topic': appTopic,
  296. 'app-exclusive-coupon': appExclusiveCoupon,
  297. 'app-image-ad': appImageAd,
  298. 'app-reservation': appReservation,
  299. 'bd-g-s-r': bdGSR,
  300. 'app-timer': appTimer,
  301. 'app-quick-navigation': appQuickNavigation,
  302. 'app-popup-ad': appPopupAd,
  303. 'app-index-cat': appIndexCat,
  304. 'app-index-wholesale': appIndexWholesale,
  305. uAdvance,
  306. uMiaosha,
  307. uPintuan,
  308. uBooking,
  309. uFlashSale,
  310. uPick
  311. },
  312. }
  313. </script>
  314. <style scoped lang="scss">
  315. .mch {
  316. background-color: #ffffff;
  317. }
  318. .mt-20 {
  319. margin-top: #{20rpx};
  320. }
  321. /* #ifdef H5 */
  322. .bd-attention {
  323. width: 100%;
  324. background-color: #ffffff;
  325. padding: 5upx 10upx 24upx 10upx;
  326. .bd-content {
  327. padding: 0 10upx 0 6upx;
  328. margin-top: 15upx;
  329. }
  330. .bd-logo {
  331. width:70upx;
  332. height: 70upx;
  333. margin-right: 15upx;
  334. }
  335. .bd-name {
  336. font-size: 28upx;
  337. color: #353535;
  338. }
  339. .bd-btn {
  340. width:110upx;
  341. height: 50upx;
  342. line-height: 50upx;
  343. font-size: 22upx;
  344. border: 1upx solid #009400;
  345. color: #009400;
  346. border-radius: 5upx;
  347. text-align: center;
  348. transform: rotateZ(360deg);
  349. }
  350. }
  351. /* #endif */
  352. </style>