index.vue 29 KB

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