index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458
  1. <template>
  2. <view class="center">
  3. <!-- 顶部logo and 搜索 start-->
  4. <view class="status_bar"></view>
  5. <view class="top-search flex">
  6. <view class="search-box flex" @click="navto('/pages/columnGoods/goods_search/index')">
  7. <image class="search" src="../../static/icon/search-h.png" mode=""></image>
  8. <view class="search-font">输入关键词搜索</view>
  9. </view>
  10. </view>
  11. <!-- 顶部logo and 搜索 end-->
  12. <view class="jg"></view>
  13. <!-- 轮播图 start -->
  14. <view class="swiper-wrap">
  15. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  16. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  17. @click="bannerNavToUrl(item)">
  18. <image :src="item.img" />
  19. </swiper-item>
  20. </swiper>
  21. </view>
  22. <!-- 轮播图 end -->
  23. <view class="jg"></view>
  24. <!-- 分类 start-->
  25. <view class="cate-section flex">
  26. <view class="cate-item flex" @click="goCp()">
  27. <view class="img-wrapper flex">
  28. <image src="../../static/icon/c2.png" mode=""></image>
  29. </view>
  30. <view class="item-title">环球国际</view>
  31. </view>
  32. <view class="cate-item flex" @click="gozx">
  33. <view class="img-wrapper flex">
  34. <image src="../../static/icon/c1.png" mode=""></image>
  35. </view>
  36. <view class="item-title">易博甄选</view>
  37. </view>
  38. <view class="cate-item flex" @click="openGg()" v-if="isAndroid">
  39. <view class="img-wrapper flex">
  40. <image src="../../static/icon/c3.png" mode=""></image>
  41. </view>
  42. <view class="item-title">视频领奖</view>
  43. </view>
  44. <view class="cate-item flex" @click="navto('/pages/store/shopStreet/index')">
  45. <view class="img-wrapper flex">
  46. <image src="../../static/icon/c4.png" mode=""></image>
  47. </view>
  48. <view class="item-title">商铺列表</view>
  49. </view>
  50. <view class="cate-item flex" @click="nav('/pages/user/shareQrCode')">
  51. <view class="img-wrapper flex">
  52. <image src="../../static/icon/c5.png" mode=""></image>
  53. </view>
  54. <view class="item-title">邀请有礼</view>
  55. </view>
  56. </view>
  57. <!-- 分类 end-->
  58. <!-- 专区 start -->
  59. <view class="sbkh-wrap">
  60. <image src="../../static/img/sbkh.jpg" mode=""></image>
  61. <view class="sbkh-xfzq" @click.stop="navto('/pages/index/xfqzq')">
  62. </view>
  63. <view class="sbkh-jfzq" @click="navto('/pages/index/bdzq')">
  64. </view>
  65. </view>
  66. <!-- 魔方 -->
  67. <!-- <view class="zq-wrap flex">
  68. <view class="zq-item" @click="nav('/pages/index/xfqzq')">
  69. <view class="zq-tit">
  70. 消费券专区
  71. </view>
  72. <view class="item-info flex">
  73. <image src="../../static/img/xf-bg.png" mode=""></image>
  74. <view class="info-tit">
  75. <image src="../../static/icon/ms.png" mode="widthFix"></image>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="zq-item bd" @click="nav('/pages/index/bdzq')">
  80. <view class="zq-tit">
  81. 积分专区
  82. </view>
  83. <view class="item-info flex">
  84. <image src="../../static/img/bd-bg.png" mode=""></image>
  85. <view class="info-tit">
  86. <image src="../../static/icon/bd.png" mode="widthFix"></image>
  87. </view>
  88. </view>
  89. </view>
  90. </view> -->
  91. <!-- 专区 end -->
  92. <!-- 商品列表 start -->
  93. <view class="product-box">
  94. <view class="product-tit flex">
  95. <view class="hx">
  96. </view>
  97. <view class="tit">
  98. 猜您喜欢
  99. </view>
  100. <view class="hx">
  101. </view>
  102. </view>
  103. <view class="hotgoods">
  104. <view class="hotgoods-item" v-for="item in sortProduct" :key="item.id"
  105. @click="navto('/pages/goods_details/index?id=' + item.product_id)" style="height: 520rpx;">
  106. <view class="image-wrapper">
  107. <image class="image" :src="item.image" mode="scaleToFill"></image>
  108. </view>
  109. <view class="flex"
  110. style="flex-direction: column;justify-content: space-between;align-items: flex-start;height: 160rpx;">
  111. <view class="title clamp2">{{item.store_info}}</view>
  112. <view class="hot-price">
  113. <view class="price">
  114. <text class="font-size-sm"></text>
  115. {{ item.price * 1 }}<text class="jf">积分</text>
  116. </view>
  117. <view class="yuanPrice">市场价:¥{{ item.ot_price*1 }}</view>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- <uni-load-more :status="loadingType"></uni-load-more> -->
  123. </view>
  124. <view class="page-btm" style="padding-top: 20rpx;">
  125. ©2022 浙江易博网络科技有限公司 版权所有
  126. </view>
  127. <view class="page-btm" @click="gocx" style="padding-bottom: 10rpx;">
  128. 浙ICP备2021013190号-9
  129. </view>
  130. </view>
  131. </template>
  132. <script>
  133. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  134. let app = getApp();
  135. import {
  136. getUserInfo
  137. } from '@/api/user.js';
  138. import {
  139. getDiy,
  140. getIndexData,
  141. getAppVersion,
  142. getUserCoupons
  143. } from '@/api/api.js';
  144. // #ifdef MP-WEIXIN
  145. import {
  146. getTemlIds
  147. } from '@/api/api.js';
  148. import {
  149. SUBSCRIBE_MESSAGE,
  150. TIPS_KEY
  151. } from '@/config/cache';
  152. // #endif
  153. import {
  154. getShare,
  155. getconfig,
  156. advertisement
  157. } from '@/api/public.js';
  158. import {
  159. goShopDetail
  160. } from '@/libs/order.js';
  161. import {
  162. mapGetters
  163. } from 'vuex';
  164. import {
  165. getProductslist,
  166. getProductHot,
  167. storeCategory
  168. } from '@/api/store.js';
  169. import {
  170. initiateAssistApi
  171. } from '@/api/activity.js';
  172. import {
  173. openBargainSubscribe
  174. } from '@/utils/SubscribeMessage.js';
  175. import {
  176. setVisit,
  177. spread
  178. } from '@/api/user.js';
  179. import {
  180. isAndroid
  181. } from '@/utils/platform.js';
  182. import recommend from '@/components/recommend';
  183. // #ifndef H5
  184. import passwordPopup from '@/components/passwordPopup';
  185. // #endif
  186. // #ifdef H5
  187. import mConfig from './component/index.js';
  188. // #endif
  189. import authorize from '@/components/Authorize';
  190. // #ifdef MP || APP-PLUS
  191. import activeParty from './component/activeParty';
  192. import headerSerch from './component/headerSerch';
  193. import coupon from './component/coupon';
  194. import bargain from './component/bargain';
  195. import blankPage from './component/blankPage';
  196. import combination from './component/combination';
  197. import customerService from './component/customerService';
  198. import goodList from './component/goodList';
  199. import guide from './component/guide';
  200. import liveBroadcast from './component/liveBroadcast';
  201. import menus from './component/menus';
  202. import news from './component/news';
  203. import topic from './component/topic';
  204. import presellList from './component/presellList';
  205. import plantList from './component/plantList';
  206. import pictureCube from './component/pictureCube'
  207. import shopList from './component/shopList';
  208. import richText from './component/richText';
  209. import seckill from './component/seckill';
  210. import swiperBg from './component/swiperBg';
  211. import tabNav from './component/tabNav';
  212. import titles from './component/titles';
  213. // #endif
  214. import {
  215. silenceBindingSpread,
  216. configMap,
  217. isWeixin
  218. } from '@/utils/index';
  219. import history from '@/mixins/history';
  220. import shareScence from '@/libs/spread';
  221. import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
  222. import {
  223. getNewPeopleCouponLst
  224. } from '@/api/activity.js'
  225. import {
  226. HTTP_REQUEST_URL
  227. } from '@/config/app';
  228. export default {
  229. computed: configMap({
  230. hide_mer_status: 0,
  231. beian_sn: '',
  232. share_title: '',
  233. site_name: ''
  234. },
  235. mapGetters(['isLogin', 'uid', 'keyColor'])),
  236. mixins: [history],
  237. components: {
  238. easyLoadimage,
  239. recommend,
  240. authorize,
  241. // #ifndef H5
  242. passwordPopup,
  243. // #endif
  244. // #ifdef H5
  245. ...mConfig,
  246. // #endif
  247. // #ifdef MP || APP-PLUS
  248. activeParty,
  249. headerSerch,
  250. bargain,
  251. coupon,
  252. blankPage,
  253. combination,
  254. customerService,
  255. goodList,
  256. guide,
  257. liveBroadcast,
  258. menus,
  259. news,
  260. topic,
  261. presellList,
  262. plantList,
  263. pictureCube,
  264. shopList,
  265. richText,
  266. seckill,
  267. swiperBg,
  268. tabNav,
  269. titles
  270. // #endif
  271. },
  272. data() {
  273. return {
  274. list: [],//普通商品列表
  275. isAndroid: false,
  276. carouselList: [], //轮播图
  277. domain: HTTP_REQUEST_URL,
  278. couponTypeMsg: {
  279. 10: '通用券',
  280. 11: '品类券',
  281. 12: '跨店券'
  282. },
  283. styleConfig: [],
  284. showSkeleton: true, //骨架屏显示隐藏
  285. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  286. privacyStatus: false,
  287. errorNetwork: false,
  288. ad: {
  289. home_ad_pic: ''
  290. },
  291. userInfo: {},
  292. loading: false,
  293. isAuto: false, //没有授权的不会自动授权
  294. isShowAuth: false, //是否隐藏授权
  295. statusBarHeight: statusBarHeight,
  296. navIndex: 0,
  297. navTop: [],
  298. subscribe: false,
  299. followUrl: '',
  300. followHid: true,
  301. followCode: false,
  302. imgUrls: [{
  303. url: '',
  304. pic: '',
  305. id: '',
  306. name: ''
  307. }],
  308. hot: [],
  309. sortList: [],
  310. menus: [{
  311. url: '',
  312. pic: '',
  313. id: '',
  314. name: ''
  315. }, {
  316. url: '',
  317. pic: '',
  318. id: '',
  319. name: ''
  320. }, {
  321. url: '',
  322. pic: '',
  323. id: '',
  324. name: ''
  325. }, {
  326. url: '',
  327. pic: '',
  328. id: '',
  329. name: ''
  330. }, {
  331. url: '',
  332. pic: '',
  333. id: '',
  334. name: ''
  335. }, {
  336. url: '',
  337. pic: '',
  338. id: '',
  339. name: ''
  340. }, {
  341. url: '',
  342. pic: '',
  343. id: '',
  344. name: ''
  345. }, {
  346. url: '',
  347. pic: '',
  348. id: '',
  349. name: ''
  350. }, {
  351. url: '',
  352. pic: '',
  353. id: '',
  354. name: ''
  355. }, {
  356. url: '',
  357. pic: '',
  358. id: '',
  359. name: ''
  360. }],
  361. window: false,
  362. navH: '',
  363. couponList: [],
  364. marTop: 0,
  365. loadend: false,
  366. loading: false,
  367. loadTitle: '加载更多',
  368. sortProduct: [],
  369. where: {
  370. // pid: 0,
  371. page: 1,
  372. limit: 30
  373. },
  374. is_switch: true,
  375. hostProduct: [],
  376. hotPage: 1,
  377. hotLimit: 30,
  378. hotScroll: true,
  379. hotLoading: false,
  380. hotTitle: '加载更多',
  381. explosiveMoney: [],
  382. prodeuctTop: 0,
  383. pinkInfo: '',
  384. searchH: 0,
  385. domOffsetTop: 50,
  386. // #ifdef APP-PLUS || MP
  387. isFixed: true,
  388. // #endif
  389. // #ifdef H5
  390. isFixed: false,
  391. // #endif
  392. goodScroll: true, //精品推荐开关
  393. params: {
  394. //精品推荐分页
  395. page: 1,
  396. limit: 10
  397. },
  398. tempArr: [], //精品推荐临时数组
  399. numConfig: 0,
  400. pageInfo: '', // 精品推荐全数据
  401. swiperCur: 0,
  402. d: '',
  403. h: '',
  404. m: '',
  405. s: '',
  406. sum_h: '',
  407. sortMarTop: 0,
  408. globalDatas: {},
  409. // #ifdef MP || APP-PLUS
  410. mpHeight: 108,
  411. // #endif
  412. // #ifndef MP || APP-PLUS
  413. mpHeight: 0,
  414. // #endif
  415. currSpid: '',
  416. _options: {},
  417. isIntegral: false,
  418. appUpdate: {},
  419. sortMpTop: 0,
  420. bgColor: '',
  421. bgPic: '',
  422. bgTabVal: '',
  423. windowHeight: 0,
  424. isHeaderSerch: false,
  425. showCoupon: false,
  426. couponArray: [],
  427. };
  428. },
  429. /**
  430. * 用户点击右上角分享
  431. */
  432. // #ifdef MP
  433. onShareAppMessage: function() {
  434. let that = this;
  435. wx.showShareMenu({
  436. withShareTicket: true,
  437. menus: ['shareAppMessage', 'shareTimeline']
  438. });
  439. return {
  440. title: that.share_title,
  441. path: '/pages/index/index?spid=' + that.uid
  442. };
  443. },
  444. onShareTimeline: function() {
  445. let that = this;
  446. return {
  447. title: that.share_title,
  448. query: {
  449. spid: that.uid
  450. },
  451. imageUrl: ''
  452. };
  453. },
  454. // #endif
  455. onLoad(options) {
  456. let that = this
  457. this._options = options;
  458. // #ifdef APP-PLUS
  459. const pages = getCurrentPages();
  460. const page = pages[pages.length - 1];
  461. const currentWebview = page.$getAppWebview();
  462. currentWebview.setStyle({
  463. pullToRefresh: {
  464. support: !that.isSupport,
  465. style: plus.os.name === 'Android' ? 'circle' : 'default'
  466. }
  467. });
  468. that.isSupport = !that.isSupport;
  469. that.appVersionConfig(); //APP版本检测
  470. // #endif
  471. that.$nextTick(function() {
  472. uni.getSystemInfo({
  473. success: function(res) {
  474. that.windowHeight = res.windowHeight;
  475. }
  476. });
  477. })
  478. that.pageLoad(options);
  479. setTimeout(() => {
  480. that.isNodes++;
  481. }, 100);
  482. },
  483. onShow() {
  484. this.getConfig();
  485. this.isIntegral = uni.getStorageSync('isIntegral')
  486. // #ifdef APP-PLUS
  487. if (this.appUpdate.openUpgrade == '1') {
  488. this.alertAppUpdate();
  489. }
  490. // #endif
  491. this.loadCoupon()
  492. // #ifdef H5
  493. this.isAndroid = isAndroid()
  494. // #endif
  495. // #ifdef APP-PLUS
  496. this.isAndroid = true
  497. // #endif
  498. console.log(this.isAndroid,'this.isAndroid')
  499. this.get_product_list();
  500. },
  501. onHide() {
  502. uni.setStorageSync('isIntegral', false)
  503. },
  504. onReady() {
  505. },
  506. watch: {
  507. globalDatas(nVal, oVal) {
  508. // #ifdef H5
  509. this.ShareInfo(nVal);
  510. // #endif
  511. },
  512. privacyStatus(n) {
  513. if (n) {
  514. uni.hideTabBar();
  515. } else {
  516. uni.showTabBar();
  517. }
  518. },
  519. },
  520. onPullDownRefresh() {
  521. setTimeout(() => {
  522. uni.stopPullDownRefresh();
  523. }, 100);
  524. this.reconnect();
  525. },
  526. methods: {
  527. //观看广告领奖
  528. openGg() {
  529. getUserInfo().then(res => {
  530. that.userInfo = res.data;
  531. this.$dsbridge.call("fnAds.onShowRewardVideoAD", {}, function(result) {
  532. let res = JSON.parse(result)
  533. if (res.event == 'onReward') {
  534. advertisement({
  535. task: '1'
  536. }).then(e => {
  537. }).catch(err => {})
  538. }
  539. });
  540. });
  541. },
  542. navto(url) {
  543. uni.navigateTo({
  544. url,
  545. fail() {
  546. uni.switchTab({
  547. url
  548. })
  549. }
  550. })
  551. },
  552. goCp() {
  553. window.location.href = 'http://web.mall.hqgjsmc.com/'
  554. },
  555. gozx() {
  556. window.location.href =
  557. 'https://chen.ningjuwang.com/shop/wap/27x50ex0ep39-qfKx#/index?preview_template_id=19&preview_page_id=190&preview_template_type=1'
  558. },
  559. swiperChange() {},
  560. bannerNavToUrl(item) {
  561. console.log(item)
  562. },
  563. changeBarg() {},
  564. loadCoupon() {
  565. if (!this.showCoupon && !uni.getStorageSync('show_coupon') && uni.getStorageSync('is_new_user')) {
  566. getNewPeopleCouponLst().then(res => {
  567. this.couponArray = res.data;
  568. setTimeout(() => {
  569. this.showCoupon = this.couponArray.length > 0;
  570. uni.setStorageSync('show_coupon', '1')
  571. }, 1500);
  572. })
  573. }
  574. },
  575. pageLoad(options) {
  576. let that = this;
  577. if (options.spid) {
  578. that.currSpid = options.spid;
  579. app.globalData.spid = options.spid;
  580. }
  581. // #ifdef APP-PLUS
  582. try {
  583. let val = uni.getStorageSync('privacyStatus') || false;
  584. if (!val) {
  585. this.privacyStatus = true;
  586. }
  587. } catch (e) {}
  588. this.snycNetWork();
  589. // #endif
  590. // #ifdef MP
  591. if (options.scene) {
  592. let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
  593. if (value.id) options.id = value.id;
  594. //记录推广人uid
  595. if (value.spid) {
  596. that.currSpid = value.spid;
  597. app.globalData.spid = value.spid;
  598. }
  599. }
  600. // #endif
  601. shareScence(that.currSpid, that.isLogin);
  602. this.isLogin && silenceBindingSpread();
  603. this.getIndexConfig()
  604. Promise.all([
  605. this.diyData(),
  606. this.get_host_product(),
  607. ]);
  608. if (this.isLogin) {
  609. this.getUserInfo();
  610. // #ifdef MP
  611. this.getHistory();
  612. // #endif
  613. }
  614. },
  615. closeShare() {
  616. uni.setStorageSync('isIntegral', false);
  617. this.isIntegral = uni.getStorageSync('isIntegral');
  618. },
  619. bindHeighta(data) {
  620. // #ifdef APP-PLUS
  621. this.sortMpTop = data.top + data.height;
  622. // #endif
  623. },
  624. // 重新链接
  625. reconnect() {
  626. uni.getNetworkType({
  627. success: res => {
  628. this.errorNetwork = res.networkType === 'none';
  629. if (!this.errorNetwork) {
  630. this.pageLoad(this._options);
  631. }
  632. }
  633. });
  634. },
  635. // #ifdef APP-PLUS
  636. snycNetWork() {
  637. uni.getNetworkType({
  638. success: res => {
  639. this.errorNetwork = res.networkType === 'none';
  640. }
  641. });
  642. },
  643. // 同意隐私协议
  644. confirmApp() {
  645. uni.setStorageSync('privacyStatus', true);
  646. this.privacyStatus = false;
  647. },
  648. // 关闭 Model
  649. closeModel() {
  650. this.privacyStatus = false;
  651. },
  652. // #endif
  653. // 对象转数组
  654. objToArr(data) {
  655. let obj = Object.keys(data).sort();
  656. let m = obj.map(key => data[key]);
  657. return m;
  658. },
  659. diyData() {
  660. let that = this;
  661. getDiy().then(res => {
  662. setTimeout(() => {
  663. that.isNodes++;
  664. }, 0);
  665. that.errorNetwork = false
  666. uni.setNavigationBarTitle({
  667. title: res.data.title
  668. });
  669. let data = res.data;
  670. if (data.is_bg_color) {
  671. that.bgColor = data.color_picker
  672. }
  673. if (data.is_bg_pic) {
  674. that.bgPic = data.bg_pic
  675. that.bgTabVal = data.bg_tab_val
  676. }
  677. that.styleConfig = that.objToArr(res.data.value);
  678. that.styleConfig.forEach((item, index, arr) => {
  679. if (item.name == 'headerSerch') {
  680. that.isHeaderSerch = true
  681. }
  682. console.log(item.name)
  683. if (item.name == 'swiperBg') {
  684. that.carouselList = item.swiperConfig.list
  685. console.log(that.carouselList, 'ddddddddddddddddd')
  686. }
  687. });
  688. });
  689. },
  690. // 微信登录回调
  691. onLoadFun: function(e) {
  692. this.isShowAuth = false;
  693. },
  694. // #ifdef APP-PLUS
  695. appVersionConfig() {
  696. var that = this;
  697. //app升级
  698. // 获取本地应用资源版本号
  699. getAppVersion().then(res => {
  700. that.$set(that.appUpdate, 'androidAddress', res.data.androidAddress);
  701. that.$set(that.appUpdate, 'appVersion', res.data.appVersion);
  702. that.$set(that.appUpdate, 'iosAddress', res.data.iosAddress);
  703. that.$set(that.appUpdate, 'openUpgrade', res.data.openUpgrade);
  704. plus.runtime.getProperty(plus.runtime.appid, function(inf) {
  705. let nowVersion = (inf.version).split('.').join('');
  706. let appVersion = (res.data.appVersion).split('.').join('');
  707. that.$set(that.appUpdate, 'alert', appVersion > nowVersion);
  708. that.alertAppUpdate();
  709. });
  710. })
  711. },
  712. alertAppUpdate() {
  713. if (this.appUpdate.alert) {
  714. uni.getSystemInfo({
  715. success: (res) => {
  716. uni.showModal({
  717. title: '更新提示',
  718. content: '发现新版本,是否前去下载?',
  719. showCancel: this.appUpdate.openUpgrade !=
  720. '1',
  721. cancelColor: '#eeeeee',
  722. confirmColor: '#FF0000',
  723. success: (response) => {
  724. if (response.confirm) {
  725. switch (res.platform) {
  726. case "android":
  727. plus.runtime.openURL(this
  728. .appUpdate
  729. .androidAddress);
  730. break;
  731. case "ios":
  732. plus.runtime.openURL(encodeURI(
  733. this.appUpdate
  734. .iosAddress));
  735. break;
  736. }
  737. }
  738. }
  739. });
  740. }
  741. })
  742. }
  743. },
  744. // #endif
  745. getConfig() {
  746. // 获取配置
  747. getconfig()
  748. .then(res => {
  749. let self = this;
  750. this.globalDatas = res.data;
  751. uni.$emit('configData', res.data);
  752. })
  753. .catch(err => {});
  754. },
  755. // 分类页更多
  756. bindMore() {
  757. console.log(this.navTop[this.navIndex]);
  758. try {
  759. uni.setStorageSync('storeIndex', this.navTop[this.navIndex].pid);
  760. uni.switchTab({
  761. url: '/pages/goods_cate/goods_cate'
  762. });
  763. } catch (e) {}
  764. },
  765. goDetails(item) {
  766. goShopDetail(item, this.uid).then(res => {
  767. if (this.isLogin) {
  768. initiateAssistApi(item.activity_id)
  769. .then(res => {
  770. let id = res.data.product_assist_set_id;
  771. uni.hideLoading();
  772. // #ifndef MP
  773. uni.navigateTo({
  774. url: '/pages/activity/assist_detail/index?id=' + id
  775. });
  776. // #endif
  777. // #ifdef MP
  778. openBargainSubscribe()
  779. .then(res => {
  780. uni.hideLoading();
  781. uni.navigateTo({
  782. url: '/pages/activity/assist_detail/index?id=' + id
  783. });
  784. })
  785. .catch(err => {
  786. uni.hideLoading();
  787. });
  788. // #endif
  789. })
  790. .catch(err => {
  791. uni.showToast({
  792. title: err,
  793. icon: 'none'
  794. });
  795. });
  796. } else {
  797. this.isAuto = true;
  798. this.isShowAuth = true
  799. }
  800. });
  801. },
  802. /**
  803. * 获取个人用户信息
  804. */
  805. getUserInfo: function() {
  806. let that = this;
  807. getUserInfo().then(res => {
  808. that.userInfo = res.data;
  809. });
  810. },
  811. // 记录会员访问
  812. setVisit() {
  813. setVisit({
  814. url: '/pages/index/index'
  815. }).then(res => {
  816. console.log(res);
  817. });
  818. },
  819. // 导航分类切换
  820. changeTab(e) {
  821. let self = this;
  822. if (this.navIndex == e.index) return;
  823. this.navIndex = e.index;
  824. if (e.index > 0) {
  825. storeCategory({
  826. pid: e.pid
  827. }).then(res => {
  828. this.sortList = res.data.length > 9 ? res.data.splice(0, 9) : res.data;
  829. if (this.sortList.length > 0) {
  830. this.where.pid = e.pid;
  831. this.where.page = 1;
  832. this.loadend = false;
  833. this.loading = false;
  834. this.sortProduct = [];
  835. this.get_product_list();
  836. }
  837. });
  838. self.sortMarTop = 10;
  839. }
  840. },
  841. //分类产品
  842. get_product_list: function() {
  843. let that = this;
  844. if (that.loading) return;
  845. that.loading = true;
  846. that.loadTitle = '';
  847. getProductslist(that.where)
  848. .then(res => {
  849. let list = res.data.list;
  850. let productList = that.$util.SplitArray(list, that.sortProduct);
  851. let loadend = list.length < that.where.limit;
  852. that.loadend = loadend;
  853. that.loading = false;
  854. that.loadTitle = loadend ? '已全部加载' : '加载更多';
  855. that.$set(that, 'sortProduct', productList);
  856. console.log(that.sortProduct,'sortProduct+++++++++++++++++')
  857. that.$set(that.where, 'page', that.where.page + 1);
  858. })
  859. .catch(err => {
  860. that.loading = false;
  861. that.loadTitle = '加载更多';
  862. });
  863. },
  864. /**
  865. * 获取我的推荐
  866. */
  867. get_host_product: function() {
  868. let that = this;
  869. let num = that.hotLimit;
  870. if (!that.hotScroll) return;
  871. if (that.hotLoading) return;
  872. that.hotLoading = true;
  873. that.hotTitle = '';
  874. getProductHot(that.hotPage, that.hotLimit).then(res => {
  875. let list = res.data.list;
  876. let productList = that.$util.SplitArray(list, that.hostProduct);
  877. let hotScroll = list.length <= num && list.length != 0;
  878. that.hotScroll = hotScroll;
  879. that.hotLoading = false;
  880. that.hotTitle = !hotScroll ? '已全部加载' : '加载更多';
  881. that.$set(that, 'hostProduct', productList);
  882. that.$set(that, 'hotPage', that.hotPage + 1);
  883. });
  884. },
  885. // 首页数据
  886. getIndexConfig: function() {
  887. let that = this;
  888. getIndexData().then(res => {
  889. that.$set(that, 'imgUrls', res.data.banner);
  890. that.$set(that, 'menus', res.data.menu);
  891. that.$set(that, 'hot', res.data.hot);
  892. that.$set(that, 'ad', res.data.ad);
  893. res.data.category.unshift({
  894. cate_name: '首页'
  895. });
  896. that.$set(that, 'navTop', res.data.category);
  897. // #ifdef H5
  898. that.subscribe = res.data.subscribe;
  899. // #endif
  900. // 小程序判断用户是否授权;
  901. // #ifdef MP
  902. uni.getSetting({
  903. success(res) {
  904. if (!res.authSetting['scope.userInfo']) {
  905. that.window = that.couponList.length ? true : false;
  906. } else {
  907. that.window = false;
  908. }
  909. }
  910. });
  911. // #endif
  912. // #ifndef MP
  913. if (that.isLogin) {
  914. that.window = false;
  915. } else {
  916. that.window = that.couponList.length ? true : false;
  917. }
  918. // #endif
  919. that.reloadData();
  920. });
  921. },
  922. reloadData() {
  923. setTimeout(() => {
  924. this.showSkeleton = false
  925. }, 500)
  926. },
  927. // 授权关闭
  928. authColse: function(e) {
  929. this.isShowAuth = e;
  930. },
  931. // 首发新品详情
  932. goDetail(item) {
  933. if (item.activity && item.activity.type === '2' && !this.isLogin) {
  934. // #ifdef H5
  935. uni.showModal({
  936. title: '提示',
  937. content: '您未登录,请登录!',
  938. success: function(res) {
  939. if (res.confirm) {
  940. uni.navigateTo({
  941. url: '/pages/users/login/index'
  942. });
  943. } else if (res.cancel) {}
  944. }
  945. });
  946. // #endif
  947. // #ifdef MP
  948. this.$set(this, 'isAuto', true);
  949. this.$set(this, 'isShowAuth', true);
  950. // #endif
  951. return;
  952. } else {
  953. goShopDetail(item, this.uid).then(res => {
  954. uni.navigateTo({
  955. url: `/pages/goods_details/index?id=${item.id}`
  956. });
  957. });
  958. }
  959. },
  960. // 分类详情
  961. godDetail(item) {
  962. uni.navigateTo({
  963. url: `/pages/goods_details/index?id=${item.id}`
  964. });
  965. },
  966. //拼团详情
  967. goCombinDetail(item) {
  968. uni.navigateTo({
  969. url: `/pages/activity/combination_details/index?id=${item.product_group_id}`
  970. });
  971. },
  972. countTime: function() {
  973. // 获取当前时间
  974. var date = new Date();
  975. var now = date.getTime();
  976. //设置截止时间
  977. var endDate = new Date('2020-10-22 23:23:23');
  978. var end = endDate.getTime();
  979. //时间差
  980. var leftTime = end - now;
  981. //定义变量 d,h,m,s保存倒计时的时间
  982. if (leftTime >= 0) {
  983. this.d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
  984. this.h = Math.floor((leftTime / 1000 / 60 / 60) % 24);
  985. this.m = Math.floor((leftTime / 1000 / 60) % 60);
  986. this.s = Math.floor((leftTime / 1000) % 60);
  987. this.sum_h = this.d * 24 + this.h;
  988. }
  989. //递归每秒调用countTime方法,显示动态时间效果
  990. setTimeout(this.countTime, 1000);
  991. },
  992. //#ifdef H5
  993. ShareInfo(datas) {
  994. let data = this.storeInfo;
  995. let href = location.href;
  996. if (this.$wechat.isWeixin()) {
  997. if (this.isLogin) {
  998. href = href.indexOf('?') === -1 ? href + '?spid=' + this.uid : href + '&spid=' + this.uid;
  999. } else {
  1000. href = href;
  1001. }
  1002. let configAppMessage = {
  1003. desc: datas.share_info,
  1004. title: datas.share_title,
  1005. link: href,
  1006. imgUrl: datas.share_pic
  1007. };
  1008. this.$wechat
  1009. .wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage',
  1010. 'onMenuShareTimeline'
  1011. ], configAppMessage)
  1012. .then(res => {
  1013. console.log(res, '=============================>>WXAPI');
  1014. })
  1015. .catch(err => {
  1016. console.log(err);
  1017. });
  1018. }
  1019. },
  1020. //#endif
  1021. },
  1022. mounted() {
  1023. },
  1024. // 滚动到底部
  1025. onReachBottom() {
  1026. if (this.navIndex == 0) {
  1027. // 首页加载更多
  1028. this.get_host_product();
  1029. } else {
  1030. // 分类栏目加载更多
  1031. if (this.sortProduct.length > 0) {
  1032. this.get_product_list();
  1033. } else {
  1034. this.get_host_product();
  1035. }
  1036. }
  1037. },
  1038. // 滚动监听
  1039. onPageScroll(e) {
  1040. // #ifdef H5
  1041. if (this.isHeaderSerch) {
  1042. if (e.scrollTop > this.domOffsetTop) {
  1043. this.isFixed = true;
  1044. }
  1045. if (e.scrollTop < this.domOffsetTop) {
  1046. this.$nextTick(() => {
  1047. this.isFixed = false;
  1048. });
  1049. }
  1050. } else {
  1051. this.isFixed = false
  1052. }
  1053. // #endif
  1054. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  1055. uni.$emit('scroll');
  1056. }
  1057. };
  1058. </script>
  1059. <style>
  1060. </style>
  1061. <style lang="scss">
  1062. page,
  1063. .center {
  1064. min-height: 100%;
  1065. height: auto;
  1066. background: #fff;
  1067. }
  1068. // 顶部搜索
  1069. .top-search {
  1070. height: 80rpx;
  1071. // padding: 0 20rpx;
  1072. // background-color: #338fc0;
  1073. background-color: #478fbf;
  1074. justify-content: center;
  1075. .search-box {
  1076. justify-content: center;
  1077. width: 700rpx;
  1078. height: 60rpx;
  1079. background: #fff;
  1080. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  1081. border-radius: 30rpx;
  1082. .search {
  1083. width: 34rpx;
  1084. height: 34rpx;
  1085. }
  1086. .search-font {
  1087. margin-left: 14rpx;
  1088. font-size: 28rpx;
  1089. font-family: PingFang SC;
  1090. font-weight: 500;
  1091. color: #CBCBCB;
  1092. }
  1093. }
  1094. }
  1095. // 顶部轮播图
  1096. .swiper-wrap {
  1097. width: 750rpx;
  1098. // background-color: #338fc0;
  1099. background-color: #478fbf;
  1100. .top-swiper {
  1101. width: 700rpx;
  1102. height: 350rpx;
  1103. margin: auto;
  1104. border-radius: 20rpx;
  1105. image {
  1106. width: 700rpx;
  1107. height: 350rpx;
  1108. border-radius: 20rpx;
  1109. }
  1110. }
  1111. }
  1112. .swiper-btm {
  1113. height: 60rpx;
  1114. width: 750rpx;
  1115. background-color: #fff;
  1116. margin-bottom: 20rpx;
  1117. font-size: 21rpx;
  1118. font-weight: 500;
  1119. color: #333333;
  1120. .btm-item {
  1121. flex-grow: 1;
  1122. justify-content: center;
  1123. image {
  1124. width: 25rpx;
  1125. height: 25rpx;
  1126. margin-right: 14rpx;
  1127. }
  1128. }
  1129. }
  1130. .jg {
  1131. height: 20rpx;
  1132. // background-color: #338fc0;
  1133. background-color: #478fbf;
  1134. }
  1135. .status_bar {
  1136. height: var(--status-bar-height);
  1137. width: 100%;
  1138. // background: #338fc0;
  1139. background-color: #478fbf;
  1140. }
  1141. // 分类
  1142. .cate-section {
  1143. justify-content: space-around;
  1144. background-color: #fff;
  1145. padding: 0rpx 0 30rpx;
  1146. // background: #338fc0;
  1147. background-color: #478fbf;
  1148. .cate-item {
  1149. flex-grow: 0;
  1150. width: 20%;
  1151. flex-direction: column;
  1152. text-align: center;
  1153. align-items: center;
  1154. justify-content: center;
  1155. .img-wrapper {
  1156. width: 90rpx;
  1157. height: 90rpx;
  1158. border-radius: 20rpx;
  1159. position: relative;
  1160. image {
  1161. width: 90rpx;
  1162. height: 90rpx;
  1163. position: absolute;
  1164. left: 50%;
  1165. top: 50%;
  1166. transform: translate(-50%, -50%);
  1167. }
  1168. }
  1169. .item-title {
  1170. margin-top: 15rpx;
  1171. font-size: 26rpx;
  1172. font-weight: 500;
  1173. color: #FFFFFF;
  1174. }
  1175. }
  1176. }
  1177. // 专区
  1178. .zq-wrap {
  1179. height: 345rpx;
  1180. width: 750rpx;
  1181. background: linear-gradient(180deg, #338fc0, #fff);
  1182. padding: 0 27rpx;
  1183. .zq-item {
  1184. width: 342rpx;
  1185. height: 300rpx;
  1186. background: linear-gradient(180deg, #fc2f40, #fb829e);
  1187. border-radius: 20rpx;
  1188. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
  1189. position: relative;
  1190. .zq-tit {
  1191. padding: 15rpx 0 0 20rpx;
  1192. font-size: 32rpx;
  1193. font-weight: bold;
  1194. font-style: italic;
  1195. color: #FFFFFF;
  1196. }
  1197. .item-info {
  1198. position: absolute;
  1199. bottom: 8rpx;
  1200. left: 0;
  1201. right: 0;
  1202. margin: auto;
  1203. width: 324rpx;
  1204. height: 232rpx;
  1205. background: #FFFFFF;
  1206. border-radius: 20rpx;
  1207. flex-direction: column;
  1208. justify-content: center;
  1209. align-items: center;
  1210. image {
  1211. width: 294rpx;
  1212. height: 160rpx;
  1213. }
  1214. .info-tit {
  1215. margin-top: 12rpx;
  1216. width: 189rpx;
  1217. height: 36rpx;
  1218. image {
  1219. width: 189rpx;
  1220. }
  1221. }
  1222. }
  1223. }
  1224. .bd {
  1225. background: linear-gradient(180deg, #ff601a, #feba9d);
  1226. }
  1227. }
  1228. .product-box {
  1229. margin-top: 20rpx;
  1230. background: #ffffff;
  1231. padding: 26rpx 20rpx 20rpx;
  1232. .product-tit {
  1233. justify-content: center;
  1234. .hx {
  1235. width: 120rpx;
  1236. height: 1rpx;
  1237. background: #989898;
  1238. }
  1239. .tit {
  1240. margin: 0 70rpx;
  1241. font-size: 30rpx;
  1242. font-weight: 500;
  1243. color: #363636;
  1244. }
  1245. }
  1246. }
  1247. .hotgoods {
  1248. margin-top: 38rpx;
  1249. width: 100%;
  1250. display: flex;
  1251. flex-wrap: wrap;
  1252. padding: 0 0 30rpx;
  1253. justify-content: space-between;
  1254. .hotgoods-item {
  1255. width: 345rpx;
  1256. background-color: #ffffff;
  1257. border-radius: 12rpx;
  1258. box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
  1259. margin-bottom: 15rpx;
  1260. .image-wrapper {
  1261. width: 345rpx;
  1262. height: 345rpx;
  1263. border-radius: 3px;
  1264. overflow: hidden;
  1265. position: relative;
  1266. .image-bg {
  1267. position: absolute;
  1268. top: 0;
  1269. left: 0;
  1270. right: 0;
  1271. bottom: 0;
  1272. width: 100%;
  1273. height: 100%;
  1274. opacity: 1;
  1275. border-radius: 12rpx 12rpx 0 0;
  1276. z-index: 2;
  1277. }
  1278. .image {
  1279. width: 100%;
  1280. height: 100%;
  1281. opacity: 1;
  1282. border-radius: 12rpx 12rpx 0 0;
  1283. }
  1284. }
  1285. .title {
  1286. margin-top: 24rpx;
  1287. padding: 0 20rpx;
  1288. font-size: 28rpx;
  1289. font-family: PingFang SC;
  1290. font-weight: 500;
  1291. color: #333333;
  1292. }
  1293. .hot-price {
  1294. display: flex;
  1295. justify-content: flex-start;
  1296. align-items: center;
  1297. // padding: 14rpx 0 30rpx;
  1298. .hotPrice-box {
  1299. padding: 2rpx 6rpx;
  1300. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  1301. border-radius: 5rpx;
  1302. text-align: center;
  1303. line-height: 28rpx;
  1304. font-size: 20rpx;
  1305. font-family: Source Han Sans CN;
  1306. font-weight: 400;
  1307. color: #ffffff;
  1308. }
  1309. .price {
  1310. margin-left: 10rpx;
  1311. font-size: 40rpx;
  1312. color: #ff0000;
  1313. font-weight: 500;
  1314. .jf {
  1315. font-size: 20rpx;
  1316. }
  1317. }
  1318. .yuanPrice {
  1319. margin-left: 10rpx;
  1320. font-size: 20rpx;
  1321. font-family: PingFang SC;
  1322. font-weight: 500;
  1323. text-decoration: line-through;
  1324. color: #999999;
  1325. }
  1326. .cart-icon {
  1327. image {
  1328. width: 44rpx;
  1329. height: 44rpx;
  1330. }
  1331. }
  1332. }
  1333. }
  1334. }
  1335. .sbkh-wrap {
  1336. width: 750rpx;
  1337. height: 362rpx;
  1338. position: relative;
  1339. image {
  1340. position: absolute;
  1341. top: 0;
  1342. left: 0;
  1343. width: 750rpx;
  1344. height: 362rpx;
  1345. }
  1346. .sbkh-xfzq,
  1347. .sbkh-jfzq {
  1348. width: 340rpx;
  1349. height: 300rpx;
  1350. position: absolute;
  1351. }
  1352. .sbkh-xfzq {
  1353. top: 40rpx;
  1354. left: 27rpx;
  1355. }
  1356. .sbkh-jfzq {
  1357. top: 40rpx;
  1358. right: 27rpx;
  1359. }
  1360. }
  1361. .mf-wrap {
  1362. .mf {
  1363. transform-style: prserve-3d;
  1364. perspective: 500;
  1365. position: relative;
  1366. height: 200rpx;
  1367. width: 200rpx;
  1368. background-color: #bfa;
  1369. }
  1370. image {
  1371. position: absolute;
  1372. width: 100rpx;
  1373. height: 100rpx;
  1374. }
  1375. .top {
  1376. transform: rotateX(90deg);
  1377. transform-origin: 0 0;
  1378. }
  1379. .bottom {
  1380. transform: rotateX(90deg);
  1381. transform-origin: 0 100%;
  1382. }
  1383. }
  1384. .page-btm {
  1385. background-color: #f5f5f5;
  1386. font-size: 20rpx;
  1387. text-align: center;
  1388. color: #d6d6d8;
  1389. }
  1390. </style>