index.vue 30 KB

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