index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  1. <template>
  2. <view v-if="pageShow" class="page"
  3. :class="bgTabVal==2?'fullsize noRepeat':bgTabVal==1?'repeat ysize':'noRepeat ysize'"
  4. :style="'background-color:'+bgColor+';background-image: url('+bgPic+');min-height:'+windowHeight+'px;'">
  5. <view v-if="!errorNetwork" :style="colorStyle">
  6. <skeleton :show="showSkeleton" :isNodes="isNodes" ref="skeleton" loading="chiaroscuro" selector="skeleton"
  7. bgcolor="#FFF"></skeleton>
  8. <view class="index skeleton" :style="{visibility: showSkeleton ? 'hidden' : 'visible'}">
  9. <!-- #ifdef H5 -->
  10. <view v-for="(item, index) in styleConfig" :key="index">
  11. <component :is="item.name" :index="index" :dataConfig="item" @changeBarg="changeBarg"
  12. @changeTab="changeTab" :tempArr="tempArr" :iSshowH="iSshowH" @detail="goDetail"
  13. :isSortType="isSortType" @bindSortId="bindSortId" @bindHeight="bindHeight" :isFixed="isFixed">
  14. </component>
  15. </view>
  16. <!-- #endif -->
  17. <!-- #ifdef MP || APP-PLUS -->
  18. <block v-for="(item, index) in styleConfig" :key="index">
  19. <activeParty v-if="item.name == 'activeParty'" :dataConfig="item" :isSortType="isSortType">
  20. </activeParty>
  21. <articleList v-if="item.name == 'articleList'" :dataConfig="item" :isSortType="isSortType">
  22. </articleList>
  23. <bargain v-if="item.name == 'bargain'" :dataConfig="item" @changeBarg="changeBarg"
  24. :isSortType="isSortType"></bargain>
  25. <blankPage v-if="item.name == 'blankPage'" :dataConfig="item" :isSortType="isSortType"></blankPage>
  26. <combination v-if="item.name == 'combination'" :dataConfig="item" :isSortType="isSortType">
  27. </combination>
  28. <coupon v-if="item.name == 'coupon'" :dataConfig="item" :isSortType="isSortType"></coupon>
  29. <customerService v-if="item.name == 'customerService'" :dataConfig="item" :isSortType="isSortType">
  30. </customerService>
  31. <goodList v-if="item.name == 'goodList'" :dataConfig="item" @detail="goDetail"
  32. :isSortType="isSortType"></goodList>
  33. <guide v-if="item.name == 'guide'" :dataConfig="item" :isSortType="isSortType"></guide>
  34. <headerSerch v-if="item.name == 'headerSerch'" :dataConfig="item"></headerSerch>
  35. <liveBroadcast v-if="item.name == 'liveBroadcast'" :dataConfig="item" :isSortType="isSortType">
  36. </liveBroadcast>
  37. <menus v-if="item.name == 'menus'" :dataConfig="item" :isSortType="isSortType"></menus>
  38. <news v-if="item.name == 'news'" :dataConfig="item" :isSortType="isSortType"></news>
  39. <pictureCube v-if="item.name == 'pictureCube'" :dataConfig="item" :isSortType="isSortType">
  40. </pictureCube>
  41. <promotionList v-if="item.name == 'promotionList'" :dataConfig="item" @changeTab="changeTab"
  42. :tempArr="tempArr" :iSshowH="iSshowH" @detail="goDetail" :isSortType="isSortType">
  43. </promotionList>
  44. <richText v-if="item.name == 'richText'" :dataConfig="item" :isSortType="isSortType"></richText>
  45. <seckill v-if="item.name == 'seckill'" :dataConfig="item" :isSortType="isSortType"></seckill>
  46. <swiperBg v-if="item.name == 'swiperBg'" :dataConfig="item" :isSortType="isSortType"></swiperBg>
  47. <swipers v-if="item.name == 'swipers'" :dataConfig="item" :isSortType="isSortType"></swipers>
  48. <tabNav v-if="item.name == 'tabNav'" :dataConfig="item" @bindHeight="bindHeighta"
  49. @bindSortId="bindSortId" :isFixed="isFixed"></tabNav>
  50. <titles v-if="item.name == 'titles'" :dataConfig="item" :isSortType="isSortType"></titles>
  51. </block>
  52. <!-- #endif -->
  53. <!-- 分类商品模块 -->
  54. <!-- #ifdef APP-PLUS -->
  55. <view class="sort-product" v-if="isSortType == 1" style="margin-top: 0;">
  56. <scroll-view scroll-x="true" style="background: #fff;">
  57. <view class="sort-box" v-if="sortList.children && sortList.children.length">
  58. <view class="sort-item" v-for="(item, index) in sortList.children" :key="index"
  59. @click="changeSort(item, index)" :class="{ on: curSort == index }">
  60. <image :src="item.pic" mode="" v-if="item.pic"></image>
  61. <image src="/static/images/sort-img.png" mode="" v-else></image>
  62. <view class="txt">{{ item.cate_name }}</view>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. <view class="product-list" v-if="goodList.length">
  67. <view class="product-item" v-for="(item, index) in goodList" @click="goGoodsDetail(item)">
  68. <image :src="item.image"></image>
  69. <span class="pictrue_log_big pictrue_log_class"
  70. v-if="item.activity && item.activity.type === '1'">秒杀</span>
  71. <span class="pictrue_log_big pictrue_log_class"
  72. v-if="item.activity && item.activity.type === '2'">砍价</span>
  73. <span class="pictrue_log_big pictrue_log_class"
  74. v-if="item.activity && item.activity.type === '3'">拼团</span>
  75. <view class="info">
  76. <view class="title line1">{{ item.store_name }}</view>
  77. <view class="price-box">
  78. <text>¥</text>
  79. {{ item.price }}
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <Loading :loaded="loaded" :loading="loading"></Loading>
  85. <view class="" v-if="goodList.length == 0 && loaded">
  86. <view class="empty-box">
  87. <image src="/static/images/noShopper.png"></image>
  88. </view>
  89. <recommend :hostProduct="hostProduct"></recommend>
  90. </view>
  91. </view>
  92. <!-- #endif -->
  93. <!-- #ifndef APP-PLUS -->
  94. <view class="sort-product" v-if="isSortType == 1" :style="{ marginTop: sortMpTop + 'px' }">
  95. <scroll-view scroll-x="true" style="background: #fff;">
  96. <view class="sort-box" v-if="sortList.children && sortList.children.length">
  97. <view class="sort-item" v-for="(item, index) in sortList.children" :key="index"
  98. @click="changeSort(item, index)" :class="{ on: curSort == index }">
  99. <image :src="item.pic" mode="" v-if="item.pic"></image>
  100. <image src="/static/images/sort-img.png" mode="" v-else></image>
  101. <view class="txt">{{ item.cate_name }}</view>
  102. </view>
  103. </view>
  104. </scroll-view>
  105. <view class="product-list" v-if="goodList.length">
  106. <view class="product-item" v-for="(item, index) in goodList" @click="goGoodsDetail(item)">
  107. <image :src="item.image"></image>
  108. <span class="pictrue_log_big pictrue_log_class"
  109. v-if="item.activity && item.activity.type === '1'">秒杀</span>
  110. <span class="pictrue_log_big pictrue_log_class"
  111. v-if="item.activity && item.activity.type === '2'">砍价</span>
  112. <span class="pictrue_log_big pictrue_log_class"
  113. v-if="item.activity && item.activity.type === '3'">拼团</span>
  114. <span class="pictrue_log_big pictrue_log_class" v-if="item.checkCoupon">券</span>
  115. <view class="info">
  116. <view class="title line2">{{ item.store_name }}</view>
  117. <view class="price-box">
  118. <text>¥</text>
  119. {{ item.price }}
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <Loading :loaded="loaded" :loading="loading"></Loading>
  125. <view class="" v-if="goodList.length == 0 && loaded">
  126. <view class="empty-box">
  127. <image src="/static/images/noShopper.png"></image>
  128. </view>
  129. <recommend :hostProduct="hostProduct"></recommend>
  130. </view>
  131. </view>
  132. <!-- #endif -->
  133. <!-- <view class="loadingicon acea-row row-center-wrapper" v-if="tempArr.length && styleConfig[styleConfig.length - 1].name == 'promotionList'">
  134. <text class="loading iconfont icon-jiazai" :hidden="loading == false"></text>
  135. {{ loadTitle }}
  136. </view> -->
  137. <!-- #ifdef MP -->
  138. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse" :isGoIndex="false"></authorize> -->
  139. <!-- #endif -->
  140. <couponWindow :window="isCouponShow" @onColse="couponClose" :couponImage="couponObj.image"
  141. :couponList="couponObj.list"></couponWindow>
  142. <view class="uni-p-b-98" v-if="footerStatus"></view>
  143. <view v-if="site_config" class="site-config" @click="goICP">{{ site_config }}</view>
  144. <!-- <pageFooter v-if="footerStatus"></pageFooter> -->
  145. <view class="foot" v-if="newData.status && newData.status.status">
  146. <view class="page-footer" id="target" :style="{'background-color':newData.bgColor.color[0].item}">
  147. <view class="foot-item" v-for="(item,index) in newData.menuList" :key="index"
  148. @click="goRouter(item)">
  149. <block v-if="item.link == activeRouter">
  150. <image :src="item.imgList[0]"></image>
  151. <view class="txt" :style="{color:newData.activeTxtColor.color[0].item}">{{item.name}}
  152. </view>
  153. </block>
  154. <block v-else>
  155. <image :src="item.imgList[1]"></image>
  156. <view class="txt" :style="{color:newData.txtColor.color[0].item}">{{item.name}}</view>
  157. </block>
  158. <div class="count-num"
  159. v-if="item.link === '/pages/order_addcart/order_addcart' && countNum > 0">
  160. {{countNum}}
  161. </div>
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. </view>
  167. <view v-else>
  168. <view class="error-network">
  169. <image src="/static/images/error-network.png"></image>
  170. <view class="title">网络连接断开</view>
  171. <view class="con">
  172. <view class="label">请检查情况:</view>
  173. <view class="item">· 在设置中是否已开启网络权限</view>
  174. <view class="item">· 当前是否处于弱网环境</view>
  175. <view class="item">· 版本是否过低,升级试试吧</view>
  176. </view>
  177. <view class="btn" @click="reconnect">重新连接</view>
  178. </view>
  179. </view>
  180. <!-- #ifdef APP-PLUS -->
  181. <app-update v-if="!privacyStatus" ref="appUpdate" :force="true" :tabbar="false"></app-update>
  182. <view class="privacy-wrapper" v-if="privacyStatus">
  183. <view class="privacy-box">
  184. <view class="title">服务协议与隐私政策</view>
  185. <view class="content">
  186. 请务必审慎阅读、充分理解“服务协议与 隐私政策”各条款,包括但不限于:为了 向你提供即时通讯、内容分享等服务,我 们需要收集你的设备信息、操作日志等个 人信息。你可以在“设置”中查看、变更、
  187. 删除个人信息并管理你的授权。<br>
  188. 你可以阅读<navigator url="/pages/users/privacy/index">《服务协议与隐私政策》</navigator>了解
  189. 详细信息。如你同意,请点击“我同意”开始接受我们的服务。
  190. </view>
  191. <view class="btn-box">
  192. <view class="btn-item" @click="confirmApp">我同意</view>
  193. <view class="btn" @click="closeModel">残忍拒绝</view>
  194. </view>
  195. </view>
  196. </view>
  197. <!-- #endif -->
  198. </view>
  199. </template>
  200. <script>
  201. const app = getApp();
  202. import colors from "@/mixins/color";
  203. import couponWindow from '@/components/couponWindow/index';
  204. import {
  205. getCouponV2,
  206. getCouponNewUser,
  207. siteConfig
  208. } from '@/api/api.js';
  209. import {
  210. getNavigation
  211. } from '@/api/public.js';
  212. // #ifdef H5
  213. import mConfig from './components/index.js';
  214. import {
  215. silenceAuth
  216. } from '@/api/public.js';
  217. // #endif
  218. // #ifdef MP || APP-PLUS
  219. import authorize from '@/components/Authorize';
  220. import activeParty from './components/activeParty';
  221. import headerSerch from './components/headerSerch';
  222. import swipers from './components/swipers';
  223. import coupon from './components/coupon';
  224. import articleList from './components/articleList';
  225. import bargain from './components/bargain';
  226. import blankPage from './components/blankPage';
  227. import combination from './components/combination';
  228. import customerService from './components/customerService';
  229. import goodList from './components/goodList';
  230. import guide from './components/guide';
  231. import liveBroadcast from './components/liveBroadcast';
  232. import menus from './components/menus';
  233. import news from './components/news';
  234. import pictureCube from './components/pictureCube';
  235. import promotionList from './components/promotionList';
  236. import richText from './components/richText';
  237. import seckill from './components/seckill';
  238. import swiperBg from './components/swiperBg';
  239. import tabNav from './components/tabNav';
  240. import titles from './components/titles';
  241. import appUpdate from "@/components/update/app-update.vue";
  242. import {
  243. getTemlIds
  244. } from '@/api/api.js';
  245. import {
  246. SUBSCRIBE_MESSAGE,
  247. TIPS_KEY
  248. } from '@/config/cache';
  249. // #endif
  250. import {
  251. mapGetters
  252. } from 'vuex';
  253. import {
  254. getDiy,
  255. getIndexData
  256. } from '@/api/api.js';
  257. import {
  258. getGroomList,
  259. getCategoryList,
  260. getProductslist,
  261. getProductHot
  262. } from '@/api/store.js';
  263. import {
  264. goShopDetail
  265. } from '@/libs/order.js';
  266. import {
  267. getCartCounts,
  268. } from '@/api/order.js';
  269. import {
  270. toLogin
  271. } from '@/libs/login.js';
  272. import pageFooter from '@/components/pageFooter/index.vue';
  273. import Loading from '@/components/Loading/index.vue';
  274. import recommend from '@/components/recommend';
  275. export default {
  276. computed: mapGetters(['isLogin', 'uid']),
  277. mixins: [colors],
  278. components: {
  279. recommend,
  280. Loading,
  281. pageFooter,
  282. couponWindow,
  283. // #ifdef H5
  284. ...mConfig,
  285. // #endif
  286. // #ifdef MP || APP-PLUS
  287. authorize,
  288. activeParty,
  289. headerSerch,
  290. swipers,
  291. coupon,
  292. articleList,
  293. bargain,
  294. blankPage,
  295. combination,
  296. customerService,
  297. goodList,
  298. guide,
  299. liveBroadcast,
  300. menus,
  301. pictureCube,
  302. news,
  303. promotionList,
  304. richText,
  305. seckill,
  306. swiperBg,
  307. tabNav,
  308. titles,
  309. appUpdate, //APP更新
  310. // #endif
  311. },
  312. computed: mapGetters(['isLogin', 'cartNum']),
  313. data() {
  314. return {
  315. showSkeleton: true, //骨架屏显示隐藏
  316. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  317. styleConfig: [],
  318. tempArr: [],
  319. goodType: 3,
  320. loading: false,
  321. loadend: false,
  322. loadTitle: '下拉加载更多', //提示语
  323. page: 1,
  324. limit: this.$config.LIMIT,
  325. iSshowH: false,
  326. numConfig: 0,
  327. code: '',
  328. isCouponShow: false,
  329. couponObj: {},
  330. couponObjs: {
  331. show: false
  332. },
  333. shareInfo: {},
  334. footConfig: {},
  335. isSortType: 0,
  336. sortList: '',
  337. sortAll: [],
  338. goodPage: 1,
  339. goodList: [],
  340. newData: {},
  341. sid: 0,
  342. curSort: 0,
  343. sortMpTop: 0,
  344. loaded: false,
  345. loading: false,
  346. hostProduct: [],
  347. hotScroll: false,
  348. hotPage: 1,
  349. hotLimit: 10,
  350. domOffsetTop: 50,
  351. // #ifdef APP-PLUS || MP
  352. isFixed: true,
  353. // #endif
  354. // #ifdef H5
  355. isFixed: false,
  356. // #endif
  357. site_config: '',
  358. errorNetwork: false, // 是否断网
  359. privacyStatus: false, // 隐私政策是否同意过
  360. footerStatus: false,
  361. isHeaderSerch: false,
  362. bgColor: '',
  363. bgPic: '',
  364. bgTabVal: '',
  365. pageShow: true,
  366. windowHeight: 0,
  367. activeRouter: '',
  368. countNum: 0
  369. };
  370. },
  371. onPullDownRefresh() {
  372. this.diyData();
  373. },
  374. created(options) {
  375. let that = this
  376. this.$nextTick(function() {
  377. uni.getSystemInfo({
  378. success: function(res) {
  379. that.windowHeight = res.windowHeight;
  380. }
  381. });
  382. })
  383. getNavigation().then(res => {
  384. this.newData = res.data
  385. if (this.newData.status && this.newData.status.status) {
  386. uni.hideTabBar()
  387. } else {
  388. uni.showTabBar()
  389. }
  390. })
  391. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  392. let curRoute = routes[routes.length - 1].route //获取当前页面路由
  393. this.activeRouter = '/' + curRoute
  394. // #ifdef APP-PLUS
  395. try {
  396. let val = uni.getStorageSync('privacyStatus') || false
  397. if (!val) {
  398. this.privacyStatus = true
  399. }
  400. } catch (e) {}
  401. // #endif
  402. // const {
  403. // state,
  404. // scope
  405. // } = options;
  406. // #ifndef H5
  407. uni.getLocation({
  408. type: 'wgs84',
  409. success: function(res) {
  410. try {
  411. uni.setStorageSync('user_latitude', res.latitude);
  412. uni.setStorageSync('user_longitude', res.longitude);
  413. } catch {}
  414. }
  415. });
  416. // #endif
  417. // #ifdef H5
  418. if (this.$wechat.isWeixin()) {
  419. this.$wechat.location().then(res => {
  420. uni.setStorageSync('user_latitude', res.latitude);
  421. uni.setStorageSync('user_longitude', res.longitude);
  422. })
  423. } else {
  424. uni.getLocation({
  425. type: 'wgs84',
  426. success: function(res) {
  427. try {
  428. uni.setStorageSync('user_latitude', res.latitude);
  429. uni.setStorageSync('user_longitude', res.longitude);
  430. } catch {}
  431. }
  432. });
  433. }
  434. // #endif
  435. this.diyData();
  436. this.getIndexData();
  437. // #ifdef MP
  438. this.getTemlIds();
  439. // #endif
  440. // #ifndef APP-PLUS
  441. siteConfig().then(res => {
  442. this.site_config = res.data.record_No
  443. }).catch(err => {
  444. console.error(err.msg);
  445. });
  446. // #endif
  447. // 优惠券弹窗
  448. // var newDates = new Date().toLocaleDateString();
  449. if (this.isLogin) {
  450. this.getCoupon();
  451. getCartCounts().then(res => {
  452. this.countNum = res.data.count
  453. this.$store.commit('indexData/setCartNum', res.data.count > 99 ? '..' : res.data.count +
  454. '')
  455. if (res.data.count > 0) {
  456. wx.setTabBarBadge({
  457. index: Number(uni.getStorageSync('FOOTER_ADDCART')) || 2,
  458. text: res.data.count + ''
  459. })
  460. } else {
  461. wx.hideTabBarRedDot({
  462. index: Number(uni.getStorageSync('FOOTER_ADDCART')) || 2
  463. })
  464. }
  465. });
  466. }
  467. },
  468. // onReady() {
  469. // let that = this
  470. // uni.getSystemInfo({
  471. // success: function(res) { // res - 各种参数
  472. // let info = uni.createSelectorQuery().select(".hander"); // 获取某个元素
  473. // info.boundingClientRect(function(data) { //data - 各种参数
  474. // let view = res.windowHeight - data.height
  475. // that.heightHome = view
  476. // }).exec()
  477. // }
  478. // });
  479. // },
  480. watch: {
  481. isLogin: {
  482. deep: true, //深度监听设置为 true
  483. handler: function(newV, oldV) {
  484. // 优惠券弹窗
  485. var newDates = new Date().toLocaleDateString();
  486. if (newV) {
  487. try {
  488. var oldDate = uni.getStorageSync('oldDate') || '';
  489. } catch {}
  490. if (oldDate != newDates) {
  491. this.getCoupon();
  492. }
  493. }
  494. }
  495. }
  496. },
  497. onReady() {},
  498. methods: {
  499. // #ifdef APP-PLUS
  500. // 同意隐私协议
  501. confirmApp() {
  502. uni.setStorageSync('privacyStatus', true)
  503. this.privacyStatus = false
  504. },
  505. // 关闭Model
  506. closeModel() {
  507. //退出app
  508. uni.getSystemInfo({
  509. success: function(res) { // 判断为安卓的手机
  510. if (res.platform == 'android') { // 安卓退出app
  511. plus.runtime.quit();
  512. } else { // 判断为ios的手机,退出App
  513. plus.ios.import("UIApplication").sharedApplication().performSelector("exit");
  514. }
  515. }
  516. })
  517. },
  518. // #endif
  519. // 重新链接
  520. reconnect() {
  521. uni.showLoading({
  522. title: '加载中'
  523. })
  524. this.diyData();
  525. this.getIndexData();
  526. getShare().then(res => {
  527. this.shareInfo = res.data;
  528. });
  529. },
  530. goICP() {
  531. // #ifdef H5
  532. window.open('http://beian.miit.gov.cn/');
  533. // #endif
  534. // #ifdef MP
  535. uni.navigateTo({
  536. url: `/pages/annex/web_view/index?url=https://beian.miit.gov.cn/`
  537. });
  538. // #endif
  539. },
  540. bindHeighta(data) {
  541. // #ifdef APP-PLUS
  542. this.sortMpTop = data.top + data.height;
  543. // #endif
  544. },
  545. bindHeight(data) {
  546. uni.hideLoading();
  547. this.domOffsetTop = data.top;
  548. },
  549. // 去商品详情
  550. goGoodsDetail(item) {
  551. goShopDetail(item, this.uid).then(res => {
  552. uni.navigateTo({
  553. url: `/pages/goods_details/index?id=${item.id}`
  554. });
  555. });
  556. },
  557. /**
  558. * 获取我的推荐
  559. */
  560. get_host_product: function() {
  561. let that = this;
  562. if (that.hotScroll) return;
  563. getProductHot(that.hotPage, that.hotLimit).then(res => {
  564. that.hotPage++;
  565. that.hotScroll = res.data.length < that.hotLimit;
  566. that.hostProduct = that.hostProduct.concat(res.data);
  567. // that.$set(that, 'hostProduct', res.data)
  568. });
  569. },
  570. // 分类点击
  571. changeSort(item, index) {
  572. if (this.curSort == index) return;
  573. this.curSort = index;
  574. this.sid = item.id;
  575. this.goodList = [];
  576. this.goodPage = 1;
  577. this.loaded = false;
  578. this.getGoodsList();
  579. },
  580. // 获取分类id
  581. bindSortId(data) {
  582. this.isSortType = data == -99 ? 0 : 1;
  583. this.getProductList(data);
  584. if (this.hostProduct.length == 0) {
  585. this.get_host_product();
  586. }
  587. },
  588. getProductList(data) {
  589. let tempObj = '';
  590. this.curSort = 0;
  591. this.loaded = false;
  592. if (this.sortAll.length > 0) {
  593. this.sortAll.forEach((el, index) => {
  594. if (el.id == data) {
  595. this.$set(this, 'sortList', el);
  596. this.sid = el.children.length ? el.children[0].id : '';
  597. }
  598. });
  599. this.goodList = [];
  600. this.goodPage = 1;
  601. this.$nextTick(() => {
  602. if (this.sortList != '') this.getGoodsList();
  603. });
  604. } else {
  605. getCategoryList().then(res => {
  606. this.sortAll = res.data;
  607. res.data.forEach((el, index) => {
  608. if (el.id == data) {
  609. this.sortList = el;
  610. this.sid = el.children.length ? el.children[0].id : '';
  611. }
  612. });
  613. this.goodList = [];
  614. this.goodPage = 1;
  615. this.$nextTick(() => {
  616. if (this.sortList != '') this.getGoodsList();
  617. });
  618. });
  619. }
  620. },
  621. getGoodsList() {
  622. if (this.loading || this.loaded) return;
  623. this.loading = true;
  624. getProductslist({
  625. sid: this.sid,
  626. keyword: '',
  627. priceOrder: '',
  628. salesOrder: '',
  629. news: 0,
  630. page: this.goodPage,
  631. limit: 10,
  632. cid: this.sortList.id
  633. }).then(res => {
  634. this.loading = false;
  635. this.loaded = res.data.length < 10;
  636. this.goodPage++;
  637. this.goodList = this.goodList.concat(res.data);
  638. });
  639. },
  640. // 新用户优惠券
  641. getNewCoupon() {
  642. const oldUser = uni.getStorageSync('oldUser') || 0;
  643. if (!oldUser) {
  644. getCouponNewUser().then(res => {
  645. const {
  646. data
  647. } = res;
  648. if (data.show) {
  649. if (data.list.length) {
  650. this.isCouponShow = true;
  651. this.couponObj = data;
  652. uni.setStorageSync('oldUser', 1);
  653. }
  654. } else {
  655. uni.setStorageSync('oldUser', 1);
  656. }
  657. });
  658. }
  659. },
  660. // 优惠券弹窗
  661. getCoupon() {
  662. const tagDate = uni.getStorageSync('tagDate') || '',
  663. nowDate = new Date().toLocaleDateString();
  664. if (tagDate === nowDate) {
  665. this.getNewCoupon();
  666. } else {
  667. getCouponV2().then(res => {
  668. const {
  669. data
  670. } = res;
  671. if (data.list.length) {
  672. this.isCouponShow = true;
  673. this.couponObj = data;
  674. uni.setStorageSync('tagDate', new Date().toLocaleDateString());
  675. } else {
  676. this.getNewCoupon();
  677. }
  678. });
  679. }
  680. },
  681. // 优惠券弹窗关闭
  682. couponClose() {
  683. this.isCouponShow = false;
  684. if (!uni.getStorageSync('oldUser')) {
  685. this.getNewCoupon();
  686. }
  687. },
  688. onLoadFun() {},
  689. // #ifdef H5
  690. // 获取url后面的参数
  691. getQueryString(name) {
  692. var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  693. var reg_rewrite = new RegExp('(^|/)' + name + '/([^/]*)(/|$)', 'i');
  694. var r = window.location.search.substr(1).match(reg);
  695. var q = window.location.pathname.substr(1).match(reg_rewrite);
  696. if (r != null) {
  697. return unescape(r[2]);
  698. } else if (q != null) {
  699. return unescape(q[2]);
  700. } else {
  701. return null;
  702. }
  703. },
  704. // #endif
  705. // #ifdef MP
  706. getTemlIds() {
  707. let messageTmplIds = wx.getStorageSync(SUBSCRIBE_MESSAGE);
  708. if (!messageTmplIds) {
  709. getTemlIds().then(res => {
  710. if (res.data) wx.setStorageSync(SUBSCRIBE_MESSAGE, JSON.stringify(res.data));
  711. });
  712. }
  713. },
  714. // #endif
  715. // 对象转数组
  716. objToArr(data) {
  717. let obj = Object.keys(data);
  718. let m = obj.map(key => data[key]);
  719. return m;
  720. },
  721. diyData() {
  722. let that = this;
  723. getDiy(0).then(res => {
  724. setTimeout(() => {
  725. this.isNodes++;
  726. }, 0);
  727. this.errorNetwork = false
  728. let data = res.data;
  729. if (data.is_bg_color) {
  730. this.bgColor = data.color_picker
  731. }
  732. if (data.is_bg_pic) {
  733. this.bgPic = data.bg_pic
  734. this.bgTabVal = data.bg_tab_val
  735. }
  736. this.pageShow = data.is_show
  737. uni.setNavigationBarTitle({
  738. title: res.data.title
  739. });
  740. let temp = [];
  741. let lastArr = that.objToArr(res.data.value);
  742. lastArr.forEach((item, index, arr) => {
  743. if (item.name == 'headerSerch') {
  744. this.isHeaderSerch = true
  745. }
  746. if (item.name == 'pageFoot') {
  747. console.log(item.status)
  748. if (item.status && item.status.status) {
  749. this.newData = item
  750. setTimeout((e) => {
  751. that.$set(that, 'footerStatus', true);
  752. console.log(this.footerStatus)
  753. }, 50)
  754. }
  755. uni.setStorageSync('FOOTER_BAR', item.status && item.status.status ? true :
  756. false)
  757. item.menuList.map((path, index) => {
  758. if (path.link === '/pages/order_addcart/order_addcart') {
  759. uni.setStorageSync('FOOTER_ADDCART', index)
  760. }
  761. })
  762. arr.splice(index, 1);
  763. }
  764. if (item.name == 'promotionList') {
  765. that.numConfig = item.numConfig.val;
  766. that.goodType = item.tabConfig.list[0].link.activeVal;
  767. that.getGroomList();
  768. }
  769. if (item.name == 'tabNav') {
  770. // #ifndef APP-PLUS
  771. // uni.showLoading({
  772. // title: '加载中',
  773. // mask: true,
  774. // });
  775. // #endif
  776. // setTimeout(function() {
  777. // uni.hideLoading();
  778. // }, 8000);
  779. }
  780. temp = arr;
  781. });
  782. function sortNumber(a, b) {
  783. return a.timestamp - b.timestamp;
  784. }
  785. temp.sort(sortNumber)
  786. that.styleConfig = temp;
  787. setTimeout(() => {
  788. this.showSkeleton = false
  789. }, 1000)
  790. uni.stopPullDownRefresh({
  791. success: (e) => {},
  792. });
  793. }).catch(error => {
  794. // #ifdef APP-PLUS
  795. if (error.status) {
  796. uni.hideLoading()
  797. if (that.errorNetwork) {
  798. uni.showToast({
  799. title: '连接失败',
  800. icon: 'none',
  801. duration: 2000
  802. })
  803. }
  804. this.errorNetwork = true
  805. this.showSkeleton = false;
  806. }
  807. // #endif
  808. });
  809. },
  810. getIndexData() {},
  811. changeBarg(item) {
  812. if (!this.isLogin) {
  813. toLogin();
  814. } else {
  815. uni.navigateTo({
  816. url: `/pages/activity/goods_bargain_details/index?id=${item.id}&bargain=${this.$store.state.app.uid}`
  817. });
  818. }
  819. },
  820. // 促销列表的点击事件;
  821. changeTab(type) {
  822. this.goodType = type;
  823. this.tempArr = [];
  824. this.page = 1;
  825. this.loadend = false;
  826. let onloadH = true;
  827. this.getGroomList(onloadH);
  828. },
  829. // 精品推荐
  830. getGroomList(onloadH) {
  831. let that = this;
  832. let type = that.goodType;
  833. if (that.loadend) return false;
  834. if (that.loading) return false;
  835. if (onloadH) {
  836. that.$set(that, 'iSshowH', true);
  837. }
  838. getGroomList(type, {
  839. page: that.page,
  840. limit: this.numConfig
  841. })
  842. .then(({
  843. data
  844. }) => {
  845. that.$set(that, 'iSshowH', false);
  846. let maxPage = Math.ceil(this.numConfig / this.limit);
  847. let list = data.list,
  848. loadend = list.length < that.limit || that.page >= maxPage;
  849. let tempArr = that.$util.SplitArray(list, that.tempArr);
  850. that.$set(that, 'tempArr', tempArr.slice(0, this.numConfig));
  851. that.loadend = loadend;
  852. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  853. that.page = that.page + 1;
  854. that.loading = false;
  855. })
  856. .catch(res => {
  857. that.loading = false;
  858. that.loadTitle = '加载更多';
  859. });
  860. },
  861. goRouter(item) {
  862. var pages = getCurrentPages();
  863. var page = (pages[pages.length - 1]).$page.fullPath;
  864. if (item.link == page) return
  865. uni.switchTab({
  866. url: item.link,
  867. fail(err) {
  868. uni.redirectTo({
  869. url: item.link
  870. })
  871. }
  872. })
  873. },
  874. goDetail(item) {
  875. goShopDetail(item, this.$store.state.app.uid).then(res => {
  876. uni.navigateTo({
  877. url: `/pages/goods_details/index?id=${item.id}`
  878. });
  879. });
  880. },
  881. },
  882. onReachBottom: function() {
  883. if (this.isSortType == 0) {
  884. // this.getGroomList();
  885. } else {
  886. this.getGoodsList();
  887. }
  888. },
  889. onPageScroll(e) {
  890. // #ifdef H5
  891. if (this.isHeaderSerch) {
  892. if (e.scrollTop > this.domOffsetTop) {
  893. this.isFixed = true;
  894. }
  895. if (e.scrollTop < this.domOffsetTop) {
  896. this.$nextTick(() => {
  897. this.isFixed = false;
  898. });
  899. }
  900. } else {
  901. this.isFixed = false
  902. }
  903. // #endif
  904. },
  905. //#ifdef MP
  906. onShareAppMessage() {
  907. return {
  908. title: this.shareInfo.title,
  909. path: '/pages/index/index'
  910. };
  911. },
  912. //分享到朋友圈
  913. onShareTimeline: function() {
  914. return {
  915. title: this.shareInfo.title,
  916. imageUrl: this.shareInfo.img
  917. };
  918. }
  919. //#endif
  920. };
  921. </script>
  922. <style lang="scss">
  923. // page {
  924. // padding-bottom: 50px;
  925. // }
  926. .pictrue_log_class {
  927. background-color: var(--view-theme);
  928. }
  929. .page {
  930. padding-bottom: 50px;
  931. }
  932. .ysize {
  933. background-size: 100%;
  934. }
  935. .fullsize {
  936. background-size: 100% 100%;
  937. }
  938. .repeat {
  939. background-repeat: repeat;
  940. }
  941. .noRepeat {
  942. background-repeat: no-repeat;
  943. }
  944. .privacy-wrapper {
  945. z-index: 999;
  946. position: fixed;
  947. left: 0;
  948. top: 0;
  949. width: 100%;
  950. height: 100%;
  951. background: #7F7F7F;
  952. .privacy-box {
  953. position: absolute;
  954. left: 50%;
  955. top: 50%;
  956. transform: translate(-50%, -50%);
  957. width: 560rpx;
  958. padding: 50rpx 45rpx 0;
  959. background: #fff;
  960. border-radius: 20rpx;
  961. .title {
  962. text-align: center;
  963. font-size: 32rpx;
  964. text-align: center;
  965. color: #333;
  966. font-weight: 700;
  967. }
  968. .content {
  969. margin-top: 20rpx;
  970. line-height: 1.5;
  971. font-size: 26rpx;
  972. color: #666;
  973. navigator {
  974. display: inline-block;
  975. color: #E93323;
  976. }
  977. }
  978. .btn-box {
  979. margin-top: 40rpx;
  980. text-align: center;
  981. font-size: 30rpx;
  982. .btn-item {
  983. height: 82rpx;
  984. line-height: 82rpx;
  985. background: linear-gradient(90deg, #F67A38 0%, #F11B09 100%);
  986. color: #fff;
  987. border-radius: 41rpx;
  988. }
  989. .btn {
  990. padding: 30rpx 0;
  991. }
  992. }
  993. }
  994. }
  995. .error-network {
  996. position: fixed;
  997. left: 0;
  998. top: 0;
  999. display: flex;
  1000. flex-direction: column;
  1001. align-items: center;
  1002. width: 100%;
  1003. height: 100%;
  1004. padding-top: 40rpx;
  1005. background: #fff;
  1006. image {
  1007. width: 414rpx;
  1008. height: 336rpx;
  1009. }
  1010. .title {
  1011. position: relative;
  1012. top: -40rpx;
  1013. font-size: 32rpx;
  1014. color: #666;
  1015. }
  1016. .con {
  1017. font-size: 24rpx;
  1018. color: #999;
  1019. .label {
  1020. margin-bottom: 20rpx;
  1021. }
  1022. .item {
  1023. margin-bottom: 20rpx;
  1024. }
  1025. }
  1026. .btn {
  1027. display: flex;
  1028. align-items: center;
  1029. justify-content: center;
  1030. width: 508rpx;
  1031. height: 86rpx;
  1032. margin-top: 100rpx;
  1033. border: 1px solid #D74432;
  1034. color: #E93323;
  1035. font-size: 30rpx;
  1036. border-radius: 120rpx;
  1037. }
  1038. }
  1039. .sort-product {
  1040. margin-top: 20rpx;
  1041. .sort-box {
  1042. display: flex;
  1043. width: 100%;
  1044. border-radius: 16rpx;
  1045. padding: 30rpx 0;
  1046. .sort-item {
  1047. width: 20%;
  1048. display: flex;
  1049. flex-direction: column;
  1050. align-items: center;
  1051. justify-content: center;
  1052. flex-shrink: 0;
  1053. image {
  1054. width: 90rpx;
  1055. height: 90rpx;
  1056. border-radius: 50%;
  1057. }
  1058. .txt {
  1059. color: #272727;
  1060. font-size: 24rpx;
  1061. margin-top: 10rpx;
  1062. overflow: hidden;
  1063. white-space: nowrap;
  1064. text-overflow: ellipsis;
  1065. width: 140rpx;
  1066. text-align: center;
  1067. }
  1068. .pictrues {
  1069. width: 90rpx;
  1070. height: 90rpx;
  1071. background: #f8f8f8;
  1072. border-radius: 50%;
  1073. margin: 0 auto;
  1074. }
  1075. .icon-gengduo1 {
  1076. color: #333;
  1077. }
  1078. &.on {
  1079. .txt {
  1080. color: #fc4141;
  1081. }
  1082. image {
  1083. border: 1px solid #fc4141;
  1084. }
  1085. }
  1086. }
  1087. }
  1088. .product-list {
  1089. display: flex;
  1090. flex-wrap: wrap;
  1091. justify-content: space-between;
  1092. margin-top: 30rpx;
  1093. padding: 0 20rpx;
  1094. .product-item {
  1095. position: relative;
  1096. width: 344rpx;
  1097. background: #fff;
  1098. border-radius: 10rpx;
  1099. margin-bottom: 20rpx;
  1100. display: flex;
  1101. flex-direction: column;
  1102. image {
  1103. width: 100%;
  1104. height: 344rpx;
  1105. border-radius: 10rpx 10rpx 0 0;
  1106. }
  1107. .info {
  1108. flex: 1;
  1109. padding: 14rpx 16rpx;
  1110. display: flex;
  1111. flex-direction: column;
  1112. justify-content: space-between;
  1113. .title {
  1114. font-size: 28rpx;
  1115. }
  1116. .price-box {
  1117. font-size: 34rpx;
  1118. font-weight: 700;
  1119. margin-top: 8px;
  1120. color: #fc4141;
  1121. text {
  1122. font-size: 26rpx;
  1123. }
  1124. }
  1125. }
  1126. }
  1127. }
  1128. }
  1129. .empty-box {
  1130. text-align: center;
  1131. image {
  1132. width: 414rpx;
  1133. height: 336rpx;
  1134. }
  1135. }
  1136. .site-config {
  1137. margin-top: 40rpx;
  1138. font-size: 24rpx;
  1139. text-align: center;
  1140. color: #666;
  1141. &.fixed {
  1142. position: fixed;
  1143. bottom: 69px;
  1144. left: 0;
  1145. width: 100%;
  1146. }
  1147. }
  1148. .page-footer {
  1149. position: fixed;
  1150. bottom: 0;
  1151. z-index: 30;
  1152. display: flex;
  1153. align-items: center;
  1154. justify-content: space-around;
  1155. width: 100%;
  1156. height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  1157. height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  1158. box-sizing: border-box;
  1159. border-top: solid 1rpx #F3F3F3;
  1160. background-color: #fff;
  1161. box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  1162. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  1163. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  1164. .foot-item {
  1165. display: flex;
  1166. width: max-content;
  1167. align-items: center;
  1168. justify-content: center;
  1169. flex-direction: column;
  1170. position: relative;
  1171. .count-num {
  1172. position: absolute;
  1173. display: flex;
  1174. justify-content: center;
  1175. align-items: center;
  1176. width: 40rpx;
  1177. height: 40rpx;
  1178. top: 0rpx;
  1179. right: -15rpx;
  1180. color: #fff;
  1181. font-size: 20rpx;
  1182. background-color: #FD502F;
  1183. border-radius: 50%;
  1184. padding: 4rpx;
  1185. }
  1186. }
  1187. .foot-item image {
  1188. height: 50rpx;
  1189. width: 50rpx;
  1190. text-align: center;
  1191. margin: 0 auto;
  1192. }
  1193. .foot-item .txt {
  1194. font-size: 24rpx;
  1195. &.active {}
  1196. }
  1197. }
  1198. </style>