index.vue 33 KB

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