index.vue 33 KB

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