index.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. <template>
  2. <!-- 首页 -->
  3. <view v-if="pageShow" class="page"
  4. :class="bgTabVal==2?'fullsize noRepeat':bgTabVal==1?'repeat ysize':'noRepeat ysize'" :style="[pageStyle]">
  5. <view v-if="!errorNetwork" :style="colorStyle">
  6. <!-- 轮播搜索 -->
  7. <homeComb v-if="showHomeComb" :dataConfig="homeCombData" @bindSortId="bindSortId" :isScrolled="isScrolled">
  8. </homeComb>
  9. <!-- 顶部搜索框 -->
  10. <headerSerch v-if="isHeaderSerch" :dataConfig="headerSerchCombData"></headerSerch>
  11. <tabNav v-if="showCateNav" :dataConfig="cateNavData" @bindHeight="bindHeighta" @bindSortId="bindSortId"
  12. :isFixed="isFixed && !cateNavData.stickyConfig.tabVal"></tabNav>
  13. <view class="index">
  14. <!-- 自定义样式 -->
  15. <block v-for="(item, index) in styleConfig" :key="index">
  16. <shortVideo v-if="item.name == 'shortVideo'" :dataConfig="item">
  17. </shortVideo>
  18. <userInfor v-if="item.name == 'userInfor'" :dataConfig="item" @changeLogin="changeLogin">
  19. </userInfor>
  20. <newVip v-if="item.name == 'newVip'" :dataConfig="item"></newVip>
  21. <!-- 文章列表 -->
  22. <articleList v-if="item.name == 'articleList'" :dataConfig="item">
  23. </articleList>
  24. <bargain v-if="item.name == 'bargain'" :dataConfig="item" @changeBarg="changeBarg"></bargain>
  25. <blankPage v-if="item.name == 'blankPage'" :dataConfig="item"></blankPage>
  26. <combination v-if="item.name == 'combination'" :dataConfig="item">
  27. </combination>
  28. <!-- 优惠券 -->
  29. <coupon v-if="item.name == 'coupon'" :dataConfig="item" @changeLogin="changeLogin"></coupon>
  30. <!-- 客户服务 -->
  31. <customerService v-if="item.name == 'customerService'" :dataConfig="item">
  32. </customerService>
  33. <!-- 商品列表 -->
  34. <guide v-if="item.name == 'guide'" :dataConfig="item"></guide>
  35. <!-- 直播模块 -->
  36. <!-- #ifdef MP-WEIXIN -->
  37. <liveBroadcast v-if="item.name == 'liveBroadcast'" :dataConfig="item"></liveBroadcast>
  38. <!-- #endif -->
  39. <menus v-if="item.name == 'menus'" :dataConfig="item"></menus>
  40. <!-- 实时消息 -->
  41. <news v-if="item.name == 'news'" :dataConfig="item"></news>
  42. <!-- 图片库 -->
  43. <pictureCube v-if="item.name == 'pictureCube'" :dataConfig="item"></pictureCube>
  44. <!-- 促销列表 -->
  45. <promotionList v-if="item.name == 'promotionList'" :dataConfig="item"
  46. :productVideoStatus='product_video_status' :positionTop="positionTop">
  47. </promotionList>
  48. <richText v-if="item.name == 'richText'" :dataConfig="item"></richText>
  49. <seckill v-if="item.name == 'seckill'" :dataConfig="item"></seckill>
  50. <!-- 轮播图-->
  51. <swiperBg v-if="item.name == 'swiperBg'" :dataConfig="item"></swiperBg>
  52. <swipers v-if="item.name == 'swipers'" :dataConfig="item"></swipers>
  53. <!-- 顶部选项卡 -->
  54. <!-- 标题 -->
  55. <titles v-if="item.name == 'titles'" :dataConfig="item"></titles>
  56. <ranking v-if="item.name == 'ranking'" :dataConfig="item"></ranking>
  57. <presale v-if="item.name == 'presale'" :dataConfig="item"></presale>
  58. <pointsMall v-if="item.name == 'pointsMall'" :dataConfig="item"></pointsMall>
  59. <videos v-if="item.name == 'videos'" :dataConfig="item"></videos>
  60. <signIn v-if="item.name == 'signIn'" :dataConfig="item"></signIn>
  61. <hotspot v-if="item.name == 'hotspot'" :dataConfig="item"></hotspot>
  62. <follow v-if="item.name == 'follow'" :dataConfig="item"></follow>
  63. </block>
  64. <view class="goodsTitle" v-if="joinList.length>0">
  65. <text class='borderBottom'>
  66. 抢购商品
  67. </text>
  68. </view>
  69. <view class="goodsItem" v-if="joinList.length>0">
  70. <view class="itemList" @click="addCartChange(item)" v-for="(item,index) in joinList">
  71. <view class="itemImage">
  72. <image class="imageBanner" :src="item.image" mode="widthFix"></image>
  73. </view>
  74. <view class="itemContent">
  75. <view class="itemTitle">
  76. {{item.store_name}}
  77. </view>
  78. <view class="itemMoney">
  79. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  80. ></baseMoney>
  81. </view>
  82. <view class="bottomCart">
  83. <view class="flex-center cart-btn">
  84. <text class="iconfont icon-ic_increase fs-26"></text>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="goodsTitle" v-if="giveList.length>0">
  91. <text class='borderBottom'>
  92. 爆单商品
  93. </text>
  94. </view>
  95. <view class="goodsItem" v-if="giveList.length>0">
  96. <view class="itemList" @click="addCartChange(item)" v-for="(item,index) in giveList">
  97. <view class="itemImage">
  98. <image class="imageBanner" :src="item.image" mode="widthFix"></image>
  99. </view>
  100. <view class="itemContent">
  101. <view class="itemTitle">
  102. {{item.store_name}}
  103. </view>
  104. <view class="itemMoney">
  105. <baseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24" weight
  106. ></baseMoney>
  107. </view>
  108. <view class="greenIn" v-if="item.give_award_range">
  109. <text class="greenText">
  110. {{item.give_award_range}}
  111. </text>
  112. 绿积分
  113. </view>
  114. <view class="bottomCart">
  115. <view class="flex-center cart-btn">
  116. <text class="iconfont icon-ic_increase fs-26"></text>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <block v-for="(item, index) in styleConfig" :key="index">
  123. <!-- 商品列表 -->
  124. </block>
  125. <!-- 分类商品模块 -->
  126. <!-- #ifndef APP-PLUS -->
  127. <view class="sort-product px-20" v-if="sortList.children && sortList.children.length">
  128. <!-- #endif -->
  129. <!-- #ifdef APP-PLUS -->
  130. <!-- 商品排序 -->
  131. <view class="sort-product px-20" :style="{ marginTop: sortMpTop + 'px' }"
  132. v-if="sortList.children && sortList.children.length">
  133. <!-- #endif -->
  134. <view class="rd-24rpx bg--w111-fff p-24 mb-24"
  135. v-if="sortList.children && sortList.children.length">
  136. <scroll-view scroll-x="true" class="white-nowrap vertical-middle w-full"
  137. show-scrollbar="false">
  138. <view class="inline-block mr-24" v-for="(item, index) in sortList.children"
  139. :key="index">
  140. <view class="flex-col flex-center" @tap="changeSort(item, index)">
  141. <view class="picture w-90 h-90 rd-50-p111-" :class="{select: curSort == index}">
  142. <image :src="item.pic" class="w-full h-full rd-50-p111-"></image>
  143. </view>
  144. <text class="fs-24 pt-14"
  145. :class="{'font-num': curSort == index}">{{item.cate_name}}</text>
  146. </view>
  147. </view>
  148. </scroll-view>
  149. </view>
  150. <waterfallsFlow ref="waterfallsFlow" :wfList="goodList" @itemTap="goDetail"></waterfallsFlow>
  151. <Loading :loaded="loaded" :loading="loading"></Loading>
  152. <view v-if="goodList.length == 0 && loaded">
  153. <emptyPage title="暂无商品,去看点别的吧~"></emptyPage>
  154. </view>
  155. </view>
  156. <couponWindow :window="isCouponShow" @onColse="couponClose" :couponImage="couponObj.image"
  157. :couponList="couponObj.list"></couponWindow>
  158. <!-- #ifdef H5 -->
  159. <view v-if="site_config" class="site-config" @click="goICP">{{ site_config }}</view>
  160. <!-- #endif -->
  161. <view class="pb-safe" :style="[pdHeights]" v-if="isFooter"></view>
  162. <pageFooter @newDataStatus="newDataStatus"></pageFooter>
  163. </view>
  164. </view>
  165. <view v-else>
  166. <view class="error-network">
  167. <image :src="imgHost + '/statics/images/error-network.gif'"></image>
  168. <view class="title">网络连接断开</view>
  169. <view class="con">
  170. <view class="label">请检查情况:</view>
  171. <view class="item">· 在设置中是否已开启网络权限</view>
  172. <view class="item">· 当前是否处于弱网环境</view>
  173. <view class="item">· 版本是否过低,升级试试吧</view>
  174. </view>
  175. <view class="btn" @click="reconnect">重新连接</view>
  176. </view>
  177. </view>
  178. </view>
  179. </template>
  180. <script>
  181. const app = getApp();
  182. import colors from "@/mixins/color";
  183. import couponWindow from '@/components/couponWindow/index';
  184. import permision from "@/js_sdk/wa-permission/permission.js";
  185. import {
  186. getCouponV2,
  187. getCouponNewUser,
  188. copyRight
  189. } from '@/api/api.js';
  190. import {
  191. getShare
  192. } from '@/api/public.js';
  193. // #ifdef H5
  194. import {
  195. silenceAuth
  196. } from '@/api/public.js';
  197. // #endif
  198. import userInfor from './components/userInfor';
  199. import homeComb from './components/homeComb';
  200. import newVip from './components/newVip';
  201. import shortVideo from './components/shortVideo';
  202. import headerSerch from './components/headerSerch';
  203. import swipers from './components/swipers';
  204. import coupon from './components/coupon';
  205. import articleList from './components/articleList';
  206. import bargain from './components/bargain';
  207. import blankPage from './components/blankPage';
  208. import combination from './components/combination';
  209. import customerService from './components/customerService';
  210. import goodList from './components/goodList';
  211. import guide from './components/guide';
  212. import liveBroadcast from './components/liveBroadcast';
  213. import menus from './components/menus';
  214. import news from './components/news';
  215. import pictureCube from './components/pictureCube';
  216. import promotionList from './components/promotionList';
  217. import richText from './components/richText';
  218. import seckill from './components/seckill';
  219. import swiperBg from './components/swiperBg';
  220. import tabNav from './components/tabNav';
  221. import titles from './components/titles';
  222. import ranking from './components/ranking';
  223. import presale from './components/presale'
  224. import pointsMall from './components/pointsMall';
  225. import videos from './components/videos';
  226. import signIn from './components/signIn';
  227. import hotspot from './components/hotspot';
  228. import follow from './components/follow';
  229. import waterfallsFlow from "@/components/WaterfallsFlow/WaterfallsFlow.vue";
  230. import emptyPage from '@/components/emptyPage.vue';
  231. // #ifdef MP
  232. import {
  233. getTemlIds
  234. } from '@/api/api.js';
  235. import {
  236. SUBSCRIBE_MESSAGE,
  237. TIPS_KEY
  238. } from '@/config/cache';
  239. // #endif
  240. import {
  241. mapGetters,
  242. mapMutations
  243. } from 'vuex';
  244. import {
  245. getDiy,
  246. getDiyVersion
  247. } from '@/api/api.js';
  248. import {
  249. getCategoryList,
  250. getProductslist,
  251. getProductHot,
  252. diyProductApi
  253. } from '@/api/store.js';
  254. import {
  255. goShopDetail
  256. } from '@/libs/order.js';
  257. import {
  258. toLogin
  259. } from '@/libs/login.js';
  260. import {
  261. HTTP_REQUEST_URL
  262. } from '@/config/app';
  263. import pageFooter from '@/components/pageFooter/index.vue';
  264. import Loading from '@/components/Loading/index.vue';
  265. import recommend from '@/components/recommend';
  266. export default {
  267. computed: {
  268. pageStyle() {
  269. return {
  270. backgroundColor: this.bgColor,
  271. backgroundImage: this.bgPic ? `url(${this.bgPic})` : '',
  272. minHeight: this.windowHeight + 'px'
  273. }
  274. },
  275. pdHeights() {
  276. let H = `${this.pdHeight*2 + 100}rpx`
  277. return {
  278. height: this.isFooter ? H : '100rpx'
  279. }
  280. },
  281. ...mapGetters(['isLogin', 'uid', 'cartNum']),
  282. },
  283. mixins: [colors],
  284. components: {
  285. recommend,
  286. Loading,
  287. pageFooter,
  288. couponWindow,
  289. homeComb,
  290. newVip,
  291. userInfor,
  292. shortVideo,
  293. headerSerch,
  294. swipers,
  295. coupon,
  296. articleList,
  297. bargain,
  298. blankPage,
  299. combination,
  300. customerService,
  301. goodList,
  302. guide,
  303. liveBroadcast,
  304. menus,
  305. pictureCube,
  306. news,
  307. promotionList,
  308. richText,
  309. seckill,
  310. swiperBg,
  311. tabNav,
  312. titles,
  313. ranking,
  314. presale,
  315. pointsMall,
  316. videos,
  317. signIn,
  318. hotspot,
  319. follow,
  320. waterfallsFlow,
  321. emptyPage
  322. },
  323. data() {
  324. return {
  325. styleConfig: [],
  326. loading: false,
  327. loadend: false,
  328. loadTitle: '下拉加载更多', //提示语
  329. page: 1,
  330. limit: this.$config.LIMIT,
  331. numConfig: 0,
  332. code: '',
  333. isCouponShow: false,
  334. couponObj: {},
  335. couponObjs: {
  336. show: false
  337. },
  338. shareInfo: {},
  339. sortList: '',
  340. sortAll: [],
  341. goodPage: 1,
  342. goodList: [],
  343. sid: 0,
  344. curSort: 0,
  345. sortMpTop: 0,
  346. loaded: false,
  347. loading: false,
  348. domOffsetTop: 50,
  349. // #ifdef APP-PLUS || MP
  350. isFixed: true,
  351. // #endif
  352. // #ifdef H5
  353. isFixed: false,
  354. // #endif
  355. site_config: '',
  356. errorNetwork: false, // 是否断网
  357. isHeaderSerch: false,
  358. showHomeComb: false,
  359. showCateNav: false,
  360. homeCombData: {},
  361. headerSerchCombData: {},
  362. cateNavData: {},
  363. bgColor: '',
  364. bgPic: '',
  365. bgTabVal: '',
  366. pageShow: true,
  367. windowHeight: 0,
  368. imgHost: HTTP_REQUEST_URL,
  369. isShowAuth: false,
  370. isScrolled: false,
  371. product_video_status: false,
  372. confirm_video_status: false,
  373. positionTop: 0,
  374. isFooter: false,
  375. pdHeight: 0, //自定义底部导航上下边距和
  376. giveList: [], //爆单商品
  377. joinList: [], //抢购商品
  378. };
  379. },
  380. onLoad(options) {
  381. let that = this;
  382. uni.hideTabBar();
  383. that.getOptions(options);
  384. this.$nextTick(function() {
  385. uni.getSystemInfo({
  386. success: function(res) {
  387. that.windowHeight = res.windowHeight;
  388. }
  389. });
  390. })
  391. const {
  392. state,
  393. scope
  394. } = options;
  395. this.diyData();
  396. // #ifdef H5
  397. this.setOpenShare();
  398. // #endif
  399. // #ifdef MP
  400. this.getTemlIds();
  401. // #endif
  402. getShare().then(res => {
  403. this.shareInfo = res.data;
  404. });
  405. this.getCopyRight();
  406. this.$eventHub.$on('confirm_video_status', () => {
  407. if (this.confirm_video_status) {
  408. return;
  409. }
  410. this.confirm_video_status = true;
  411. let flag = true;
  412. // #ifdef H5
  413. flag = window.self == window.top;
  414. // #endif
  415. if (!flag) {
  416. return;
  417. }
  418. uni.showModal({
  419. content: '当前使用移动网络,是否继续播放视频?',
  420. success: (res) => {
  421. if (res.confirm) {
  422. // 监听
  423. this.SET_AUTOPLAY(true);
  424. this.$eventHub.$emit('product_video_observe');
  425. }
  426. }
  427. });
  428. });
  429. this.getInitGoods();
  430. },
  431. onUnload() {
  432. // 清除监听
  433. uni.$off('activeFn');
  434. },
  435. watch: {
  436. isLogin: {
  437. deep: true, //深度监听设置为 true
  438. handler: function(newV, oldV) {
  439. // 优惠券弹窗
  440. var newDates = new Date().toLocaleDateString();
  441. if (newV) {
  442. try {
  443. var oldDate = uni.getStorageSync('oldDate') || '';
  444. } catch {}
  445. if (oldDate != newDates) {
  446. this.getCoupon();
  447. }
  448. }
  449. }
  450. }
  451. },
  452. onShow() {
  453. if (this.cartNum > 0) {
  454. uni.setTabBarBadge({
  455. index: 3,
  456. text: this.cartNum > 99 ? '99+' : this.cartNum + ''
  457. })
  458. } else {
  459. uni.hideTabBarRedDot({
  460. index: 3
  461. })
  462. }
  463. uni.removeStorageSync('form_type_cart');
  464. // 优惠券弹窗
  465. if (this.isLogin) {
  466. this.getCoupon();
  467. }
  468. },
  469. onReady() {},
  470. methods: {
  471. ...mapMutations(['SET_AUTOPLAY']),
  472. addCartChange(item){
  473. uni.navigateTo({
  474. url: `/pages/goods_details/index?id=${item.id}`
  475. });
  476. },
  477. getInitGoods() {
  478. getProductslist({
  479. page: 1,
  480. limit: 1000,
  481. give_award_range: 1,
  482. }).then(res => {
  483. this.giveList = res.data
  484. });
  485. getProductslist({
  486. page: 1,
  487. limit: 1000,
  488. join_games: 1,
  489. }).then(res => {
  490. this.joinList = res.data
  491. });
  492. },
  493. getCopyRight() {
  494. copyRight().then(res => {
  495. let data = res.data;
  496. uni.setStorageSync('wechatStatus', data.wechat_status)
  497. // #ifndef APP-PLUS
  498. this.site_config = data.record_No;
  499. // #endif
  500. if (!data.copyrightContext && !data.copyrightImage) {
  501. data.copyrightImage = '/static/images/support.png'
  502. }
  503. uni.setStorageSync('copyNameInfo', data.copyrightContext);
  504. uni.setStorageSync('copyImageInfo', data.copyrightImage);
  505. // #ifdef MP
  506. uni.setStorageSync('MPSiteData', JSON.stringify({
  507. site_logo: data.site_logo,
  508. site_name: data.site_name
  509. }));
  510. // #endif
  511. }).catch(err => {
  512. return this.$util.Tips({
  513. title: err.msg
  514. });
  515. });
  516. },
  517. getOptions(options) {
  518. let that = this;
  519. // #ifdef MP
  520. if (options.scene) {
  521. let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
  522. //记录推广人uid
  523. if (value.spid) app.globalData.spid = value.spid;
  524. }
  525. // #endif
  526. if (options.spid) app.globalData.spid = options.spid;
  527. },
  528. // 重新链接
  529. reconnect() {
  530. this.diyData();
  531. getShare().then(res => {
  532. this.shareInfo = res.data;
  533. });
  534. },
  535. goICP() {
  536. // #ifdef H5
  537. window.open('http://beian.miit.gov.cn/');
  538. // #endif
  539. // #ifdef MP
  540. uni.navigateTo({
  541. url: `/pages/annex/web_view/index?url=https://beian.miit.gov.cn/`
  542. });
  543. // #endif
  544. },
  545. bindHeighta(data) {
  546. // #ifdef APP-PLUS
  547. this.sortMpTop = data.top + data.height;
  548. // #endif
  549. },
  550. bindHeight(data) {
  551. uni.hideLoading();
  552. this.domOffsetTop = data.top;
  553. },
  554. // 去商品详情
  555. goGoodsDetail(item) {
  556. goShopDetail(item, this.uid).catch(res => {
  557. uni.navigateTo({
  558. url: `/pages/goods_details/index?id=${item.id}`
  559. });
  560. });
  561. },
  562. // 分类点击
  563. changeSort(item, index) {
  564. if (this.curSort == index) return;
  565. this.curSort = index;
  566. this.sid = item.id;
  567. this.goodList = [];
  568. this.goodPage = 1;
  569. this.loaded = false;
  570. this.getGoodsList();
  571. },
  572. /**
  573. * @param data {
  574. classPage: 0 分类id
  575. microPage: 0 微页面id
  576. type: 1 0 微页面 1 商品分类
  577. }*/
  578. bindSortId(data) {
  579. this.styleConfig = [];
  580. if (data.type == 1) {
  581. this.getProductList(data.classPage);
  582. } else {
  583. this.sortList = [];
  584. this.getMicroPage(data.microPage, true);
  585. }
  586. },
  587. /**
  588. * 获取DIY
  589. * @param {number} id
  590. * @param {boolean} type 区分是否是微页面
  591. */
  592. getMicroPage(id, type) {
  593. let that = this;
  594. that.styleConfig = []
  595. uni.showLoading({
  596. title: '加载中...'
  597. });
  598. getDiy(id).then(res => {
  599. uni.hideLoading();
  600. let data = res.data;
  601. let diyArr = that.objToArr(res.data.value);
  602. diyArr = diyArr.filter(item => item.isHide !== '1');
  603. diyArr.forEach((item, index) => {
  604. if (['headerSerch', 'homeComb'].includes(item.name)) {
  605. diyArr.splice(index, 1);
  606. }
  607. });
  608. this.styleConfig = diyArr;
  609. }).catch(err => {
  610. return that.$util.Tips({
  611. title: err
  612. });
  613. uni.hideLoading();
  614. });
  615. },
  616. getProductList(data) {
  617. let tempObj = '';
  618. this.curSort = 0;
  619. this.loaded = false;
  620. if (this.sortAll.length > 0) {
  621. this.sortAll.forEach((el, index) => {
  622. if (el.id == data) {
  623. this.$set(this, 'sortList', el);
  624. this.sid = el.children.length ? el.children[0].id : '';
  625. }
  626. });
  627. this.goodList = [];
  628. this.goodPage = 1;
  629. this.$nextTick(() => {
  630. if (this.sortList != '') this.getGoodsList();
  631. });
  632. } else {
  633. getCategoryList().then(res => {
  634. this.sortAll = res.data;
  635. res.data.forEach((el, index) => {
  636. if (el.id == data) {
  637. this.sortList = el;
  638. this.sid = el.children.length ? el.children[0].id : '';
  639. }
  640. });
  641. this.goodList = [];
  642. this.goodPage = 1;
  643. this.$nextTick(() => {
  644. if (this.sortList != '') this.getGoodsList();
  645. });
  646. });
  647. }
  648. },
  649. // 商品列表
  650. getGoodsList() {
  651. if (this.loading || this.loaded) return;
  652. this.loading = true;
  653. getProductslist({
  654. sid: this.sid,
  655. keyword: '',
  656. priceOrder: '',
  657. salesOrder: '',
  658. news: 0,
  659. page: this.goodPage,
  660. limit: 10,
  661. cid: this.sortList.id
  662. }).then(res => {
  663. this.loading = false;
  664. this.loaded = res.data.length < 10;
  665. this.goodPage++;
  666. this.goodList = this.goodList.concat(res.data);
  667. });
  668. },
  669. // 新用户优惠券
  670. getNewCoupon() {
  671. const oldUser = uni.getStorageSync('oldUser') || 0;
  672. if (!oldUser) {
  673. getCouponNewUser().then(res => {
  674. const {
  675. data
  676. } = res;
  677. if (data.show) {
  678. if (data.list.length) {
  679. this.isCouponShow = true;
  680. this.couponObj = data;
  681. uni.setStorageSync('oldUser', 1);
  682. }
  683. } else {
  684. uni.setStorageSync('oldUser', 1);
  685. }
  686. });
  687. }
  688. },
  689. // 优惠券弹窗
  690. getCoupon() {
  691. const tagDate = uni.getStorageSync('tagDate') || '',
  692. nowDate = new Date().toLocaleDateString();
  693. if (tagDate === nowDate) {
  694. this.getNewCoupon();
  695. } else {
  696. getCouponV2().then(res => {
  697. const {
  698. data
  699. } = res;
  700. if (data.list.length) {
  701. this.isCouponShow = true;
  702. this.couponObj = data;
  703. uni.setStorageSync('tagDate', new Date().toLocaleDateString());
  704. } else {
  705. this.getNewCoupon();
  706. }
  707. });
  708. }
  709. },
  710. // 优惠券弹窗关闭
  711. couponClose() {
  712. this.isCouponShow = false;
  713. if (!uni.getStorageSync('oldUser')) {
  714. this.getNewCoupon();
  715. }
  716. },
  717. onLoadFun() {
  718. this.isShowAuth = false
  719. },
  720. // #ifdef H5
  721. // 获取url后面的参数
  722. getQueryString(name) {
  723. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  724. var reg_rewrite = new RegExp('(^|/)' + name + '/([^/]*)(/|$)', 'i');
  725. var r = window.location.search.substr(1).match(reg);
  726. var q = window.location.pathname.substr(1).match(reg_rewrite);
  727. if (r != null) {
  728. return unescape(r[2]);
  729. } else if (q != null) {
  730. return unescape(q[2]);
  731. } else {
  732. return null;
  733. }
  734. },
  735. // #endif
  736. // #ifdef MP
  737. getTemlIds() {
  738. let messageTmplIds = wx.getStorageSync(SUBSCRIBE_MESSAGE);
  739. if (!messageTmplIds) {
  740. getTemlIds().then(res => {
  741. if (res.data) wx.setStorageSync(SUBSCRIBE_MESSAGE, JSON.stringify(res.data));
  742. });
  743. }
  744. },
  745. // #endif
  746. // 对象转数组
  747. objToArr(data) {
  748. let obj = Object.keys(data).sort();
  749. let m = obj.map(key => data[key]);
  750. return m;
  751. },
  752. setDiyData(data) {
  753. this.errorNetwork = false
  754. if (data.is_bg_color) {
  755. this.bgColor = data.color_picker
  756. }
  757. if (data.is_bg_pic) {
  758. this.bgPic = data.bg_pic
  759. this.bgTabVal = data.bg_tab_val
  760. }
  761. this.pageShow = data.is_show
  762. uni.setNavigationBarTitle({
  763. title: data.title
  764. });
  765. let temp = [];
  766. let lastArr = this.objToArr(data.value);
  767. lastArr.forEach((item, index, arr) => {
  768. if (item.name === 'homeComb') {
  769. this.showHomeComb = true
  770. this.homeCombData = item;
  771. if (item.searchConfig.tabVal) {
  772. this.positionTop = uni.getSystemInfoSync().statusBarHeight + 43
  773. }
  774. }
  775. if (item.name == 'headerSerch') {
  776. this.isHeaderSerch = true;
  777. this.headerSerchCombData = item;
  778. }
  779. if (item.name == 'tabNav') {
  780. this.showCateNav = true;
  781. this.cateNavData = item;
  782. }
  783. if (item.isHide !== '1') {
  784. temp.push(item);
  785. }
  786. });
  787. function sortNumber(a, b) {
  788. return a.timestamp - b.timestamp;
  789. }
  790. temp.sort(sortNumber)
  791. this.styleConfig = temp;
  792. },
  793. getDiyData() {
  794. getDiy(0).then(res => {
  795. uni.setStorageSync('diyData', JSON.stringify(res.data));
  796. this.setDiyData(res.data);
  797. }).catch(error => {
  798. // #ifdef APP-PLUS
  799. if (error.status) {
  800. uni.hideLoading()
  801. if (this.errorNetwork) {
  802. uni.showToast({
  803. title: '请开启网络连接',
  804. icon: 'none',
  805. duration: 2000
  806. })
  807. }
  808. this.errorNetwork = true;
  809. }
  810. // #endif
  811. });
  812. },
  813. diyData() {
  814. let diyData = uni.getStorageSync('diyData');
  815. if (diyData) {
  816. getDiyVersion(0).then(res => {
  817. let diyVersion = uni.getStorageSync('diyVersion');
  818. if ((res.data.version + '0') === diyVersion) {
  819. this.setDiyData(JSON.parse(diyData));
  820. } else {
  821. uni.setStorageSync('diyVersion', (res.data.version + '0'));
  822. this.getDiyData();
  823. }
  824. });
  825. } else {
  826. this.getDiyData();
  827. }
  828. },
  829. changeLogin() {
  830. this.getIsLogin();
  831. },
  832. getIsLogin() {
  833. toLogin()
  834. },
  835. changeBarg(item) {
  836. if (!this.isLogin) {
  837. this.getIsLogin();
  838. } else {
  839. uni.navigateTo({
  840. url: `/pages/activity/goods_bargain_details/index?id=${item.id}&spid=${this.$store.state.app.uid}`
  841. });
  842. }
  843. },
  844. goDetail(item) {
  845. goShopDetail(item, this.$store.state.app.uid).catch(res => {
  846. uni.navigateTo({
  847. url: `/pages/goods_details/index?id=${item.id}`
  848. });
  849. });
  850. },
  851. newDataStatus(val, num) {
  852. this.isFooter = val ? true : false;
  853. this.pdHeight = num;
  854. },
  855. // #ifdef H5
  856. // 微信分享;
  857. setOpenShare: function() {
  858. let that = this;
  859. let uid = this.uid ? this.uid : 0;
  860. if (that.$wechat.isWeixin()) {
  861. getShare().then(res => {
  862. let data = res.data;
  863. let configAppMessage = {
  864. desc: data.synopsis,
  865. title: data.title,
  866. link: location.href + '?spid=' + uid,
  867. imgUrl: data.img
  868. };
  869. that.$wechat.wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData',
  870. 'onMenuShareAppMessage', 'onMenuShareTimeline'
  871. ],
  872. configAppMessage);
  873. });
  874. }
  875. }
  876. // #endif
  877. },
  878. onReachBottom() {
  879. this.getGoodsList();
  880. },
  881. onPageScroll(e) {
  882. // #ifdef H5
  883. if (this.isHeaderSerch) {
  884. if (e.scrollTop > this.domOffsetTop) {
  885. this.isFixed = true;
  886. }
  887. if (e.scrollTop < this.domOffsetTop) {
  888. this.$nextTick(() => {
  889. this.isFixed = false;
  890. });
  891. }
  892. } else {
  893. this.isFixed = false
  894. }
  895. // #endif
  896. if (e.scrollTop > 10) {
  897. this.isScrolled = true;
  898. } else {
  899. this.isScrolled = false;
  900. }
  901. uni.$emit('scroll');
  902. uni.$emit('onPageScroll', e.scrollTop);
  903. },
  904. //#ifdef MP
  905. onShareAppMessage() {
  906. let uid = this.uid ? this.uid : 0;
  907. if (this.shareInfo.img) {
  908. return {
  909. title: this.shareInfo.title,
  910. path: '/pages/index/index?spid=' + uid,
  911. imageUrl: this.shareInfo.img,
  912. desc: this.shareInfo.synopsis
  913. };
  914. } else {
  915. return {
  916. title: this.shareInfo.title,
  917. path: '/pages/index/index?spid=' + uid
  918. // imageUrl: this.shareInfo.img,
  919. // desc: this.shareInfo.synopsis
  920. };
  921. }
  922. },
  923. //分享到朋友圈
  924. onShareTimeline: function() {
  925. return {
  926. title: this.shareInfo.title,
  927. path: '/pages/index/index',
  928. imageUrl: this.shareInfo.img,
  929. desc: this.shareInfo.synopsis
  930. };
  931. }
  932. //#endif
  933. };
  934. </script>
  935. <style lang="scss">
  936. // page {
  937. // padding-bottom: 50px;
  938. // }
  939. .pictrue_log_class {
  940. background-color: var(--view-theme);
  941. }
  942. .ysize {
  943. background-size: 100%;
  944. }
  945. .fullsize {
  946. background-size: 100% 100%;
  947. }
  948. .repeat {
  949. background-repeat: repeat;
  950. }
  951. .noRepeat {
  952. background-repeat: no-repeat;
  953. }
  954. .error-network {
  955. position: fixed;
  956. left: 0;
  957. top: 0;
  958. display: flex;
  959. flex-direction: column;
  960. align-items: center;
  961. width: 100%;
  962. height: 100%;
  963. padding-top: 40rpx;
  964. background: #fff;
  965. image {
  966. width: 414rpx;
  967. height: 336rpx;
  968. }
  969. .title {
  970. position: relative;
  971. top: -40rpx;
  972. font-size: 32rpx;
  973. color: #666;
  974. }
  975. .con {
  976. font-size: 24rpx;
  977. color: #999;
  978. .label {
  979. margin-bottom: 20rpx;
  980. }
  981. .item {
  982. margin-bottom: 20rpx;
  983. }
  984. }
  985. .btn {
  986. display: flex;
  987. align-items: center;
  988. justify-content: center;
  989. width: 508rpx;
  990. height: 86rpx;
  991. margin-top: 100rpx;
  992. border: 1px solid #D74432;
  993. color: #E93323;
  994. font-size: 30rpx;
  995. border-radius: 120rpx;
  996. }
  997. }
  998. .sort-scroll {
  999. background-color: #fff;
  1000. }
  1001. .sort-product {
  1002. margin-top: 20rpx;
  1003. }
  1004. .site-config {
  1005. margin: 40rpx 0;
  1006. font-size: 24rpx;
  1007. text-align: center;
  1008. color: #666;
  1009. &.fixed {
  1010. position: fixed;
  1011. bottom: 69px;
  1012. left: 0;
  1013. width: 100%;
  1014. }
  1015. }
  1016. .select {
  1017. border: 1px solid var(--view-theme);
  1018. }
  1019. .goodsTitle {
  1020. font-size: 30rpx;
  1021. padding: 0rpx 30rpx;
  1022. line-height: 1;
  1023. .borderBottom {
  1024. border-bottom: 4px solid #e93323;
  1025. }
  1026. }
  1027. .goodsItem {
  1028. display: flex;
  1029. justify-content: space-between;
  1030. flex-wrap: wrap;
  1031. padding: 30rpx;
  1032. .itemList {
  1033. width: 48%;
  1034. border-radius: 20rpx;
  1035. overflow: hidden;
  1036. background-color: #FFF;
  1037. }
  1038. .itemContent{
  1039. padding: 20rpx;
  1040. line-height: 1;
  1041. position: relative;
  1042. .itemTitle{
  1043. font-size: 28rpx;
  1044. }
  1045. .itemMoney{
  1046. color: var(--view-theme);
  1047. font-weight: bold;
  1048. padding: 10rpx 0;
  1049. }
  1050. .greenIn{
  1051. font-size: 20rpx;
  1052. .greenText{
  1053. font-size: 32rpx;
  1054. color: $uni-color-success;
  1055. }
  1056. }
  1057. .bottomCart{
  1058. position: absolute;
  1059. right: 20rpx;
  1060. bottom: 20rpx;
  1061. background:linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%); ;
  1062. border-radius: 100%;
  1063. width: 44rpx;
  1064. height: 44rpx;
  1065. color:#FFF;
  1066. line-height: 44rpx;
  1067. }
  1068. }
  1069. .itemImage {
  1070. line-height: 0;
  1071. .imageBanner {
  1072. width: 100%;
  1073. }
  1074. }
  1075. }
  1076. </style>