index.vue 31 KB

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