index.vue 27 KB

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