index.vue 31 KB

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