index.vue 32 KB

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