index.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482
  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 imgUrls" :key="index" class="carousel-item"
  17. @click="bannerNavToUrl(item)">
  18. <image :src="item.pic" />
  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/c5.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="where.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. loadingType: 'more',
  372. page: 1,
  373. limit: 30
  374. },
  375. is_switch: true,
  376. hostProduct: [],
  377. hotPage: 1,
  378. hotLimit: 30,
  379. hotScroll: true,
  380. hotLoading: false,
  381. hotTitle: '加载更多',
  382. explosiveMoney: [],
  383. prodeuctTop: 0,
  384. pinkInfo: '',
  385. searchH: 0,
  386. domOffsetTop: 50,
  387. // #ifdef APP-PLUS || MP
  388. isFixed: true,
  389. // #endif
  390. // #ifdef H5
  391. isFixed: false,
  392. // #endif
  393. goodScroll: true, //精品推荐开关
  394. params: {
  395. //精品推荐分页
  396. page: 1,
  397. limit: 10
  398. },
  399. tempArr: [], //精品推荐临时数组
  400. numConfig: 0,
  401. pageInfo: '', // 精品推荐全数据
  402. swiperCur: 0,
  403. d: '',
  404. h: '',
  405. m: '',
  406. s: '',
  407. sum_h: '',
  408. sortMarTop: 0,
  409. globalDatas: {},
  410. // #ifdef MP || APP-PLUS
  411. mpHeight: 108,
  412. // #endif
  413. // #ifndef MP || APP-PLUS
  414. mpHeight: 0,
  415. // #endif
  416. currSpid: '',
  417. _options: {},
  418. isIntegral: false,
  419. appUpdate: {},
  420. sortMpTop: 0,
  421. bgColor: '',
  422. bgPic: '',
  423. bgTabVal: '',
  424. windowHeight: 0,
  425. isHeaderSerch: false,
  426. showCoupon: false,
  427. couponArray: [],
  428. };
  429. },
  430. /**
  431. * 用户点击右上角分享
  432. */
  433. // #ifdef MP
  434. onShareAppMessage: function() {
  435. let that = this;
  436. wx.showShareMenu({
  437. withShareTicket: true,
  438. menus: ['shareAppMessage', 'shareTimeline']
  439. });
  440. return {
  441. title: that.share_title,
  442. path: '/pages/index/index?spid=' + that.uid
  443. };
  444. },
  445. onShareTimeline: function() {
  446. let that = this;
  447. return {
  448. title: that.share_title,
  449. query: {
  450. spid: that.uid
  451. },
  452. imageUrl: ''
  453. };
  454. },
  455. // #endif
  456. onLoad(options) {
  457. let that = this
  458. this._options = options;
  459. // #ifdef APP-PLUS
  460. const pages = getCurrentPages();
  461. const page = pages[pages.length - 1];
  462. const currentWebview = page.$getAppWebview();
  463. currentWebview.setStyle({
  464. pullToRefresh: {
  465. support: !that.isSupport,
  466. style: plus.os.name === 'Android' ? 'circle' : 'default'
  467. }
  468. });
  469. that.isSupport = !that.isSupport;
  470. that.appVersionConfig(); //APP版本检测
  471. // #endif
  472. that.$nextTick(function() {
  473. uni.getSystemInfo({
  474. success: function(res) {
  475. that.windowHeight = res.windowHeight;
  476. }
  477. });
  478. })
  479. that.pageLoad(options);
  480. setTimeout(() => {
  481. that.isNodes++;
  482. }, 100);
  483. },
  484. onShow() {
  485. this.getConfig();
  486. this.isIntegral = uni.getStorageSync('isIntegral')
  487. // #ifdef APP-PLUS
  488. if (this.appUpdate.openUpgrade == '1') {
  489. this.alertAppUpdate();
  490. }
  491. // #endif
  492. this.loadCoupon()
  493. // #ifdef H5
  494. this.isAndroid = isAndroid()
  495. // #endif
  496. // #ifdef APP-PLUS
  497. this.isAndroid = true
  498. // #endif
  499. console.log(this.isAndroid,'this.isAndroid')
  500. this.get_product_list();
  501. },
  502. onHide() {
  503. uni.setStorageSync('isIntegral', false)
  504. },
  505. onReady() {
  506. },
  507. watch: {
  508. globalDatas(nVal, oVal) {
  509. // #ifdef H5
  510. this.ShareInfo(nVal);
  511. // #endif
  512. },
  513. privacyStatus(n) {
  514. if (n) {
  515. uni.hideTabBar();
  516. } else {
  517. uni.showTabBar();
  518. }
  519. },
  520. },
  521. onPullDownRefresh() {
  522. setTimeout(() => {
  523. uni.stopPullDownRefresh();
  524. }, 100);
  525. this.reconnect();
  526. },
  527. methods: {
  528. gocx() {
  529. window.location.href = 'https://www.miit.gov.cn/'
  530. },
  531. //观看广告领奖
  532. openGg() {
  533. let that = this
  534. getUserInfo().then(res => {
  535. that.userInfo = res.data;
  536. that.$dsbridge.call("fnAds.onShowRewardVideoAD", {}, function(result) {
  537. let res = JSON.parse(result)
  538. if (res.event == 'onReward') {
  539. advertisement({
  540. task: '1'
  541. }).then(e => {
  542. }).catch(err => {})
  543. }
  544. });
  545. });
  546. },
  547. navto(url) {
  548. uni.navigateTo({
  549. url,
  550. fail() {
  551. uni.switchTab({
  552. url
  553. })
  554. }
  555. })
  556. },
  557. goCp() {
  558. window.location.href = 'http://web.mall.hqgjsmc.com/'
  559. },
  560. gozx() {
  561. window.location.href =
  562. 'https://chen.ningjuwang.com/shop/wap/27x50ex0ep39-qfKx#/index?preview_template_id=19&preview_page_id=190&preview_template_type=1'
  563. },
  564. swiperChange() {},
  565. bannerNavToUrl(item) {
  566. console.log(item)
  567. uni.navigateTo({
  568. url: item.url,
  569. fail() {
  570. uni.switchTab({
  571. url:item.url
  572. })
  573. }
  574. })
  575. },
  576. changeBarg() {},
  577. loadCoupon() {
  578. if (!this.showCoupon && !uni.getStorageSync('show_coupon') && uni.getStorageSync('is_new_user')) {
  579. getNewPeopleCouponLst().then(res => {
  580. this.couponArray = res.data;
  581. setTimeout(() => {
  582. this.showCoupon = this.couponArray.length > 0;
  583. uni.setStorageSync('show_coupon', '1')
  584. }, 1500);
  585. })
  586. }
  587. },
  588. pageLoad(options) {
  589. let that = this;
  590. if (options.spid) {
  591. that.currSpid = options.spid;
  592. app.globalData.spid = options.spid;
  593. }
  594. // #ifdef APP-PLUS
  595. try {
  596. let val = uni.getStorageSync('privacyStatus') || false;
  597. if (!val) {
  598. this.privacyStatus = true;
  599. }
  600. } catch (e) {}
  601. this.snycNetWork();
  602. // #endif
  603. // #ifdef MP
  604. if (options.scene) {
  605. let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
  606. if (value.id) options.id = value.id;
  607. //记录推广人uid
  608. if (value.spid) {
  609. that.currSpid = value.spid;
  610. app.globalData.spid = value.spid;
  611. }
  612. }
  613. // #endif
  614. shareScence(that.currSpid, that.isLogin);
  615. this.isLogin && silenceBindingSpread();
  616. this.getIndexConfig()
  617. Promise.all([
  618. this.diyData(),
  619. this.get_host_product(),
  620. ]);
  621. if (this.isLogin) {
  622. this.getUserInfo();
  623. // #ifdef MP
  624. this.getHistory();
  625. // #endif
  626. }
  627. },
  628. closeShare() {
  629. uni.setStorageSync('isIntegral', false);
  630. this.isIntegral = uni.getStorageSync('isIntegral');
  631. },
  632. bindHeighta(data) {
  633. // #ifdef APP-PLUS
  634. this.sortMpTop = data.top + data.height;
  635. // #endif
  636. },
  637. // 重新链接
  638. reconnect() {
  639. uni.getNetworkType({
  640. success: res => {
  641. this.errorNetwork = res.networkType === 'none';
  642. if (!this.errorNetwork) {
  643. this.pageLoad(this._options);
  644. }
  645. }
  646. });
  647. },
  648. // #ifdef APP-PLUS
  649. snycNetWork() {
  650. uni.getNetworkType({
  651. success: res => {
  652. this.errorNetwork = res.networkType === 'none';
  653. }
  654. });
  655. },
  656. // 同意隐私协议
  657. confirmApp() {
  658. uni.setStorageSync('privacyStatus', true);
  659. this.privacyStatus = false;
  660. },
  661. // 关闭 Model
  662. closeModel() {
  663. this.privacyStatus = false;
  664. },
  665. // #endif
  666. // 对象转数组
  667. objToArr(data) {
  668. let obj = Object.keys(data).sort();
  669. let m = obj.map(key => data[key]);
  670. return m;
  671. },
  672. diyData() {
  673. let that = this;
  674. getDiy().then(res => {
  675. setTimeout(() => {
  676. that.isNodes++;
  677. }, 0);
  678. that.errorNetwork = false
  679. uni.setNavigationBarTitle({
  680. title: res.data.title
  681. });
  682. let data = res.data;
  683. if (data.is_bg_color) {
  684. that.bgColor = data.color_picker
  685. }
  686. if (data.is_bg_pic) {
  687. that.bgPic = data.bg_pic
  688. that.bgTabVal = data.bg_tab_val
  689. }
  690. that.styleConfig = that.objToArr(res.data.value);
  691. that.styleConfig.forEach((item, index, arr) => {
  692. if (item.name == 'headerSerch') {
  693. that.isHeaderSerch = true
  694. }
  695. console.log(item.name)
  696. if (item.name == 'swiperBg') {
  697. that.carouselList = item.swiperConfig.list
  698. console.log(that.carouselList, 'ddddddddddddddddd')
  699. }
  700. });
  701. });
  702. },
  703. // 微信登录回调
  704. onLoadFun: function(e) {
  705. this.isShowAuth = false;
  706. },
  707. // #ifdef APP-PLUS
  708. appVersionConfig() {
  709. var that = this;
  710. //app升级
  711. // 获取本地应用资源版本号
  712. getAppVersion().then(res => {
  713. that.$set(that.appUpdate, 'androidAddress', res.data.androidAddress);
  714. that.$set(that.appUpdate, 'appVersion', res.data.appVersion);
  715. that.$set(that.appUpdate, 'iosAddress', res.data.iosAddress);
  716. that.$set(that.appUpdate, 'openUpgrade', res.data.openUpgrade);
  717. plus.runtime.getProperty(plus.runtime.appid, function(inf) {
  718. let nowVersion = (inf.version).split('.').join('');
  719. let appVersion = (res.data.appVersion).split('.').join('');
  720. that.$set(that.appUpdate, 'alert', appVersion > nowVersion);
  721. that.alertAppUpdate();
  722. });
  723. })
  724. },
  725. alertAppUpdate() {
  726. if (this.appUpdate.alert) {
  727. uni.getSystemInfo({
  728. success: (res) => {
  729. uni.showModal({
  730. title: '更新提示',
  731. content: '发现新版本,是否前去下载?',
  732. showCancel: this.appUpdate.openUpgrade !=
  733. '1',
  734. cancelColor: '#eeeeee',
  735. confirmColor: '#FF0000',
  736. success: (response) => {
  737. if (response.confirm) {
  738. switch (res.platform) {
  739. case "android":
  740. plus.runtime.openURL(this
  741. .appUpdate
  742. .androidAddress);
  743. break;
  744. case "ios":
  745. plus.runtime.openURL(encodeURI(
  746. this.appUpdate
  747. .iosAddress));
  748. break;
  749. }
  750. }
  751. }
  752. });
  753. }
  754. })
  755. }
  756. },
  757. // #endif
  758. getConfig() {
  759. // 获取配置
  760. getconfig()
  761. .then(res => {
  762. let self = this;
  763. this.globalDatas = res.data;
  764. uni.$emit('configData', res.data);
  765. })
  766. .catch(err => {});
  767. },
  768. // 分类页更多
  769. bindMore() {
  770. console.log(this.navTop[this.navIndex]);
  771. try {
  772. uni.setStorageSync('storeIndex', this.navTop[this.navIndex].pid);
  773. uni.switchTab({
  774. url: '/pages/goods_cate/goods_cate'
  775. });
  776. } catch (e) {}
  777. },
  778. goDetails(item) {
  779. goShopDetail(item, this.uid).then(res => {
  780. if (this.isLogin) {
  781. initiateAssistApi(item.activity_id)
  782. .then(res => {
  783. let id = res.data.product_assist_set_id;
  784. uni.hideLoading();
  785. // #ifndef MP
  786. uni.navigateTo({
  787. url: '/pages/activity/assist_detail/index?id=' + id
  788. });
  789. // #endif
  790. // #ifdef MP
  791. openBargainSubscribe()
  792. .then(res => {
  793. uni.hideLoading();
  794. uni.navigateTo({
  795. url: '/pages/activity/assist_detail/index?id=' + id
  796. });
  797. })
  798. .catch(err => {
  799. uni.hideLoading();
  800. });
  801. // #endif
  802. })
  803. .catch(err => {
  804. uni.showToast({
  805. title: err,
  806. icon: 'none'
  807. });
  808. });
  809. } else {
  810. this.isAuto = true;
  811. this.isShowAuth = true
  812. }
  813. });
  814. },
  815. /**
  816. * 获取个人用户信息
  817. */
  818. getUserInfo: function() {
  819. let that = this;
  820. getUserInfo().then(res => {
  821. that.userInfo = res.data;
  822. });
  823. },
  824. // 记录会员访问
  825. setVisit() {
  826. setVisit({
  827. url: '/pages/index/index'
  828. }).then(res => {
  829. console.log(res);
  830. });
  831. },
  832. // 导航分类切换
  833. changeTab(e) {
  834. let self = this;
  835. if (this.navIndex == e.index) return;
  836. this.navIndex = e.index;
  837. if (e.index > 0) {
  838. storeCategory({
  839. pid: e.pid
  840. }).then(res => {
  841. this.sortList = res.data.length > 9 ? res.data.splice(0, 9) : res.data;
  842. if (this.sortList.length > 0) {
  843. this.where.pid = e.pid;
  844. this.where.page = 1;
  845. this.loadend = false;
  846. this.loading = false;
  847. this.sortProduct = [];
  848. this.get_product_list();
  849. }
  850. });
  851. self.sortMarTop = 10;
  852. }
  853. },
  854. //分类产品
  855. get_product_list: function() {
  856. let that = this;
  857. // if (that.loading) return;
  858. if(that.where.loadingType == 'noMore' || that.where.loadingType == 'loading') {
  859. return
  860. }
  861. // that.loading = true;
  862. // that.loadTitle = '';
  863. that.where.loadingType = 'loading'
  864. getProductslist(that.where)
  865. .then(res => {
  866. let list = res.data.list;
  867. let productList = that.$util.SplitArray(list, that.sortProduct);
  868. let loadend = list.length < that.where.limit;
  869. // that.loadend = loadend;
  870. // that.loading = false;
  871. if(loadend) {
  872. that.where.loadingType = 'noMore'
  873. }else {
  874. that.where.loadingType = 'more'
  875. }
  876. // that.loadTitle = loadend ? '已全部加载' : '加载更多';
  877. that.$set(that, 'sortProduct', productList);
  878. console.log(that.sortProduct,'sortProduct+++++++++++++++++')
  879. that.$set(that.where, 'page', that.where.page + 1);
  880. })
  881. .catch(err => {
  882. that.loading = false;
  883. that.loadTitle = '加载更多';
  884. });
  885. },
  886. /**
  887. * 获取我的推荐
  888. */
  889. get_host_product: function() {
  890. let that = this;
  891. let num = that.hotLimit;
  892. if (!that.hotScroll) return;
  893. if (that.hotLoading) return;
  894. that.hotLoading = true;
  895. that.hotTitle = '';
  896. getProductHot(that.hotPage, that.hotLimit).then(res => {
  897. let list = res.data.list;
  898. let productList = that.$util.SplitArray(list, that.hostProduct);
  899. let hotScroll = list.length <= num && list.length != 0;
  900. that.hotScroll = hotScroll;
  901. that.hotLoading = false;
  902. that.hotTitle = !hotScroll ? '已全部加载' : '加载更多';
  903. that.$set(that, 'hostProduct', productList);
  904. that.$set(that, 'hotPage', that.hotPage + 1);
  905. });
  906. },
  907. // 首页数据
  908. getIndexConfig: function() {
  909. let that = this;
  910. getIndexData().then(res => {
  911. that.$set(that, 'imgUrls', res.data.banner);
  912. that.$set(that, 'menus', res.data.menu);
  913. that.$set(that, 'hot', res.data.hot);
  914. that.$set(that, 'ad', res.data.ad);
  915. res.data.category.unshift({
  916. cate_name: '首页'
  917. });
  918. that.$set(that, 'navTop', res.data.category);
  919. // #ifdef H5
  920. that.subscribe = res.data.subscribe;
  921. // #endif
  922. // 小程序判断用户是否授权;
  923. // #ifdef MP
  924. uni.getSetting({
  925. success(res) {
  926. if (!res.authSetting['scope.userInfo']) {
  927. that.window = that.couponList.length ? true : false;
  928. } else {
  929. that.window = false;
  930. }
  931. }
  932. });
  933. // #endif
  934. // #ifndef MP
  935. if (that.isLogin) {
  936. that.window = false;
  937. } else {
  938. that.window = that.couponList.length ? true : false;
  939. }
  940. // #endif
  941. that.reloadData();
  942. });
  943. },
  944. reloadData() {
  945. setTimeout(() => {
  946. this.showSkeleton = false
  947. }, 500)
  948. },
  949. // 授权关闭
  950. authColse: function(e) {
  951. this.isShowAuth = e;
  952. },
  953. // 首发新品详情
  954. goDetail(item) {
  955. if (item.activity && item.activity.type === '2' && !this.isLogin) {
  956. // #ifdef H5
  957. uni.showModal({
  958. title: '提示',
  959. content: '您未登录,请登录!',
  960. success: function(res) {
  961. if (res.confirm) {
  962. uni.navigateTo({
  963. url: '/pages/users/login/index'
  964. });
  965. } else if (res.cancel) {}
  966. }
  967. });
  968. // #endif
  969. // #ifdef MP
  970. this.$set(this, 'isAuto', true);
  971. this.$set(this, 'isShowAuth', true);
  972. // #endif
  973. return;
  974. } else {
  975. goShopDetail(item, this.uid).then(res => {
  976. uni.navigateTo({
  977. url: `/pages/goods_details/index?id=${item.id}`
  978. });
  979. });
  980. }
  981. },
  982. // 分类详情
  983. godDetail(item) {
  984. uni.navigateTo({
  985. url: `/pages/goods_details/index?id=${item.id}`
  986. });
  987. },
  988. //拼团详情
  989. goCombinDetail(item) {
  990. uni.navigateTo({
  991. url: `/pages/activity/combination_details/index?id=${item.product_group_id}`
  992. });
  993. },
  994. countTime: function() {
  995. // 获取当前时间
  996. var date = new Date();
  997. var now = date.getTime();
  998. //设置截止时间
  999. var endDate = new Date('2020-10-22 23:23:23');
  1000. var end = endDate.getTime();
  1001. //时间差
  1002. var leftTime = end - now;
  1003. //定义变量 d,h,m,s保存倒计时的时间
  1004. if (leftTime >= 0) {
  1005. this.d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
  1006. this.h = Math.floor((leftTime / 1000 / 60 / 60) % 24);
  1007. this.m = Math.floor((leftTime / 1000 / 60) % 60);
  1008. this.s = Math.floor((leftTime / 1000) % 60);
  1009. this.sum_h = this.d * 24 + this.h;
  1010. }
  1011. //递归每秒调用countTime方法,显示动态时间效果
  1012. setTimeout(this.countTime, 1000);
  1013. },
  1014. //#ifdef H5
  1015. ShareInfo(datas) {
  1016. let data = this.storeInfo;
  1017. let href = location.href;
  1018. if (this.$wechat.isWeixin()) {
  1019. if (this.isLogin) {
  1020. href = href.indexOf('?') === -1 ? href + '?spid=' + this.uid : href + '&spid=' + this.uid;
  1021. } else {
  1022. href = href;
  1023. }
  1024. let configAppMessage = {
  1025. desc: datas.share_info,
  1026. title: datas.share_title,
  1027. link: href,
  1028. imgUrl: datas.share_pic
  1029. };
  1030. this.$wechat
  1031. .wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareAppMessage',
  1032. 'onMenuShareTimeline'
  1033. ], configAppMessage)
  1034. .then(res => {
  1035. console.log(res, '=============================>>WXAPI');
  1036. })
  1037. .catch(err => {
  1038. console.log(err);
  1039. });
  1040. }
  1041. },
  1042. //#endif
  1043. },
  1044. mounted() {
  1045. },
  1046. // 滚动到底部
  1047. onReachBottom() {
  1048. console.log('daodile')
  1049. this.get_product_list();
  1050. // if (this.navIndex == 0) {
  1051. // // 首页加载更多
  1052. // this.get_host_product();
  1053. // } else {
  1054. // // 分类栏目加载更多
  1055. // if (this.sortProduct.length > 0) {
  1056. // this.get_product_list();
  1057. // } else {
  1058. // this.get_host_product();
  1059. // }
  1060. // }
  1061. },
  1062. // 滚动监听
  1063. onPageScroll(e) {
  1064. // #ifdef H5
  1065. if (this.isHeaderSerch) {
  1066. if (e.scrollTop > this.domOffsetTop) {
  1067. this.isFixed = true;
  1068. }
  1069. if (e.scrollTop < this.domOffsetTop) {
  1070. this.$nextTick(() => {
  1071. this.isFixed = false;
  1072. });
  1073. }
  1074. } else {
  1075. this.isFixed = false
  1076. }
  1077. // #endif
  1078. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  1079. uni.$emit('scroll');
  1080. }
  1081. };
  1082. </script>
  1083. <style>
  1084. </style>
  1085. <style lang="scss">
  1086. page,
  1087. .center {
  1088. min-height: 100%;
  1089. height: auto;
  1090. background: #fff;
  1091. }
  1092. // 顶部搜索
  1093. .top-search {
  1094. height: 80rpx;
  1095. // padding: 0 20rpx;
  1096. // background-color: #338fc0;
  1097. background-color: #478fbf;
  1098. justify-content: center;
  1099. .search-box {
  1100. justify-content: center;
  1101. width: 700rpx;
  1102. height: 60rpx;
  1103. background: #fff;
  1104. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  1105. border-radius: 30rpx;
  1106. .search {
  1107. width: 34rpx;
  1108. height: 34rpx;
  1109. }
  1110. .search-font {
  1111. margin-left: 14rpx;
  1112. font-size: 28rpx;
  1113. font-family: PingFang SC;
  1114. font-weight: 500;
  1115. color: #CBCBCB;
  1116. }
  1117. }
  1118. }
  1119. // 顶部轮播图
  1120. .swiper-wrap {
  1121. width: 750rpx;
  1122. // background-color: #338fc0;
  1123. background-color: #478fbf;
  1124. .top-swiper {
  1125. width: 700rpx;
  1126. height: 350rpx;
  1127. margin: auto;
  1128. border-radius: 20rpx;
  1129. image {
  1130. width: 700rpx;
  1131. height: 350rpx;
  1132. border-radius: 20rpx;
  1133. }
  1134. }
  1135. }
  1136. .swiper-btm {
  1137. height: 60rpx;
  1138. width: 750rpx;
  1139. background-color: #fff;
  1140. margin-bottom: 20rpx;
  1141. font-size: 21rpx;
  1142. font-weight: 500;
  1143. color: #333333;
  1144. .btm-item {
  1145. flex-grow: 1;
  1146. justify-content: center;
  1147. image {
  1148. width: 25rpx;
  1149. height: 25rpx;
  1150. margin-right: 14rpx;
  1151. }
  1152. }
  1153. }
  1154. .jg {
  1155. height: 20rpx;
  1156. // background-color: #338fc0;
  1157. background-color: #478fbf;
  1158. }
  1159. .status_bar {
  1160. height: var(--status-bar-height);
  1161. width: 100%;
  1162. // background: #338fc0;
  1163. background-color: #478fbf;
  1164. }
  1165. // 分类
  1166. .cate-section {
  1167. justify-content: space-around;
  1168. background-color: #fff;
  1169. padding: 0rpx 0 30rpx;
  1170. // background: #338fc0;
  1171. background-color: #478fbf;
  1172. .cate-item {
  1173. flex-grow: 0;
  1174. width: 20%;
  1175. flex-direction: column;
  1176. text-align: center;
  1177. align-items: center;
  1178. justify-content: center;
  1179. .img-wrapper {
  1180. width: 90rpx;
  1181. height: 90rpx;
  1182. border-radius: 20rpx;
  1183. position: relative;
  1184. image {
  1185. width: 90rpx;
  1186. height: 90rpx;
  1187. position: absolute;
  1188. left: 50%;
  1189. top: 50%;
  1190. transform: translate(-50%, -50%);
  1191. }
  1192. }
  1193. .item-title {
  1194. margin-top: 15rpx;
  1195. font-size: 26rpx;
  1196. font-weight: 500;
  1197. color: #FFFFFF;
  1198. }
  1199. }
  1200. }
  1201. // 专区
  1202. .zq-wrap {
  1203. height: 345rpx;
  1204. width: 750rpx;
  1205. background: linear-gradient(180deg, #338fc0, #fff);
  1206. padding: 0 27rpx;
  1207. .zq-item {
  1208. width: 342rpx;
  1209. height: 300rpx;
  1210. background: linear-gradient(180deg, #fc2f40, #fb829e);
  1211. border-radius: 20rpx;
  1212. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
  1213. position: relative;
  1214. .zq-tit {
  1215. padding: 15rpx 0 0 20rpx;
  1216. font-size: 32rpx;
  1217. font-weight: bold;
  1218. font-style: italic;
  1219. color: #FFFFFF;
  1220. }
  1221. .item-info {
  1222. position: absolute;
  1223. bottom: 8rpx;
  1224. left: 0;
  1225. right: 0;
  1226. margin: auto;
  1227. width: 324rpx;
  1228. height: 232rpx;
  1229. background: #FFFFFF;
  1230. border-radius: 20rpx;
  1231. flex-direction: column;
  1232. justify-content: center;
  1233. align-items: center;
  1234. image {
  1235. width: 294rpx;
  1236. height: 160rpx;
  1237. }
  1238. .info-tit {
  1239. margin-top: 12rpx;
  1240. width: 189rpx;
  1241. height: 36rpx;
  1242. image {
  1243. width: 189rpx;
  1244. }
  1245. }
  1246. }
  1247. }
  1248. .bd {
  1249. background: linear-gradient(180deg, #ff601a, #feba9d);
  1250. }
  1251. }
  1252. .product-box {
  1253. margin-top: 20rpx;
  1254. background: #ffffff;
  1255. padding: 26rpx 20rpx 20rpx;
  1256. .product-tit {
  1257. justify-content: center;
  1258. .hx {
  1259. width: 120rpx;
  1260. height: 1rpx;
  1261. background: #989898;
  1262. }
  1263. .tit {
  1264. margin: 0 70rpx;
  1265. font-size: 30rpx;
  1266. font-weight: 500;
  1267. color: #363636;
  1268. }
  1269. }
  1270. }
  1271. .hotgoods {
  1272. margin-top: 38rpx;
  1273. width: 100%;
  1274. display: flex;
  1275. flex-wrap: wrap;
  1276. padding: 0 0 30rpx;
  1277. justify-content: space-between;
  1278. .hotgoods-item {
  1279. width: 345rpx;
  1280. background-color: #ffffff;
  1281. border-radius: 12rpx;
  1282. box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
  1283. margin-bottom: 15rpx;
  1284. .image-wrapper {
  1285. width: 345rpx;
  1286. height: 345rpx;
  1287. border-radius: 3px;
  1288. overflow: hidden;
  1289. position: relative;
  1290. .image-bg {
  1291. position: absolute;
  1292. top: 0;
  1293. left: 0;
  1294. right: 0;
  1295. bottom: 0;
  1296. width: 100%;
  1297. height: 100%;
  1298. opacity: 1;
  1299. border-radius: 12rpx 12rpx 0 0;
  1300. z-index: 2;
  1301. }
  1302. .image {
  1303. width: 100%;
  1304. height: 100%;
  1305. opacity: 1;
  1306. border-radius: 12rpx 12rpx 0 0;
  1307. }
  1308. }
  1309. .title {
  1310. margin-top: 24rpx;
  1311. padding: 0 20rpx;
  1312. font-size: 28rpx;
  1313. font-family: PingFang SC;
  1314. font-weight: 500;
  1315. color: #333333;
  1316. }
  1317. .hot-price {
  1318. display: flex;
  1319. justify-content: flex-start;
  1320. align-items: center;
  1321. // padding: 14rpx 0 30rpx;
  1322. .hotPrice-box {
  1323. padding: 2rpx 6rpx;
  1324. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  1325. border-radius: 5rpx;
  1326. text-align: center;
  1327. line-height: 28rpx;
  1328. font-size: 20rpx;
  1329. font-family: Source Han Sans CN;
  1330. font-weight: 400;
  1331. color: #ffffff;
  1332. }
  1333. .price {
  1334. margin-left: 10rpx;
  1335. font-size: 40rpx;
  1336. color: #ff0000;
  1337. font-weight: 500;
  1338. .jf {
  1339. font-size: 20rpx;
  1340. }
  1341. }
  1342. .yuanPrice {
  1343. margin-left: 10rpx;
  1344. font-size: 20rpx;
  1345. font-family: PingFang SC;
  1346. font-weight: 500;
  1347. text-decoration: line-through;
  1348. color: #999999;
  1349. }
  1350. .cart-icon {
  1351. image {
  1352. width: 44rpx;
  1353. height: 44rpx;
  1354. }
  1355. }
  1356. }
  1357. }
  1358. }
  1359. .sbkh-wrap {
  1360. width: 750rpx;
  1361. height: 362rpx;
  1362. position: relative;
  1363. image {
  1364. position: absolute;
  1365. top: 0;
  1366. left: 0;
  1367. width: 750rpx;
  1368. height: 362rpx;
  1369. }
  1370. .sbkh-xfzq,
  1371. .sbkh-jfzq {
  1372. width: 340rpx;
  1373. height: 300rpx;
  1374. position: absolute;
  1375. }
  1376. .sbkh-xfzq {
  1377. top: 40rpx;
  1378. left: 27rpx;
  1379. }
  1380. .sbkh-jfzq {
  1381. top: 40rpx;
  1382. right: 27rpx;
  1383. }
  1384. }
  1385. .mf-wrap {
  1386. .mf {
  1387. transform-style: prserve-3d;
  1388. perspective: 500;
  1389. position: relative;
  1390. height: 200rpx;
  1391. width: 200rpx;
  1392. background-color: #bfa;
  1393. }
  1394. image {
  1395. position: absolute;
  1396. width: 100rpx;
  1397. height: 100rpx;
  1398. }
  1399. .top {
  1400. transform: rotateX(90deg);
  1401. transform-origin: 0 0;
  1402. }
  1403. .bottom {
  1404. transform: rotateX(90deg);
  1405. transform-origin: 0 100%;
  1406. }
  1407. }
  1408. .page-btm {
  1409. background-color: #f5f5f5;
  1410. font-size: 20rpx;
  1411. text-align: center;
  1412. color: #d6d6d8;
  1413. }
  1414. </style>