index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  1. <template>
  2. <view v-if="pageShow" class="page"
  3. :class="bgTabVal==2?'fullsize noRepeat':bgTabVal==1?'repeat ysize':'noRepeat ysize'" :style="[pageStyle]">
  4. <view :style="colorStyle">
  5. <!-- 轮播搜索 -->
  6. <homeComb v-if="showHomeComb" :dataConfig="homeCombData" :belongIndex='belongIndex' :special='1' @bindSortId="bindSortId" :isScrolled="isScrolled" @storeTap="storeTap"></homeComb>
  7. <!-- 顶部搜索框 -->
  8. <headerSerch v-if="isHeaderSerch" :dataConfig="headerSerchCombData" :belongIndex='belongIndex' :special='1' @storeTap="storeTap"></headerSerch>
  9. <tabNav v-if="showCateNav" :dataConfig="cateNavData" @bindHeight="bindHeighta"
  10. @bindSortId="bindSortId" :special='1' :isFixed="isFixed && !cateNavData.stickyConfig.tabVal"></tabNav>
  11. <view class="index">
  12. <!-- 自定义样式 -->
  13. <block v-for="(item, index) in styleConfig" :key="index">
  14. <!-- <homeComb v-if="item.name == 'homeComb'" :dataConfig="item" @bindSortId="bindSortId"
  15. :isScrolled="isScrolled" :special='1'></homeComb> -->
  16. <!-- <headerSerch v-if="item.name == 'headerSerch'" :dataConfig="item" :special='1'></headerSerch> -->
  17. <!-- 顶部选项卡 -->
  18. <!-- <tabNav v-if="item.name == 'tabNav'" :dataConfig="item" @bindHeight="bindHeighta"
  19. @bindSortId="bindSortId" :special='1' :isFixed="isFixed && !item.stickyConfig.tabVal"></tabNav> -->
  20. <userInfor v-if="item.name == 'userInfor'" :dataConfig="item" @changeLogin="changeLogin">
  21. </userInfor>
  22. <newVip v-if="item.name == 'newVip'" :dataConfig="item"></newVip>
  23. <!-- 文章列表 -->
  24. <articleList v-if="item.name == 'articleList'" :dataConfig="item"></articleList>
  25. <bargain v-if="item.name == 'bargain'" :dataConfig="item" @changeBarg="changeBarg"></bargain>
  26. <blankPage v-if="item.name == 'blankPage'" :dataConfig="item"></blankPage>
  27. <combination v-if="item.name == 'combination'" :dataConfig="item">
  28. </combination>
  29. <!-- 优惠券 -->
  30. <coupon v-if="item.name == 'coupon'" :dataConfig="item" @changeLogin="changeLogin"></coupon>
  31. <!-- 客户服务 -->
  32. <customerService v-if="item.name == 'customerService'" :dataConfig="item">
  33. </customerService>
  34. <!-- 商品列表 -->
  35. <goodList ref="goodLists" v-if="item.name == 'goodList'" :dataConfig="item"></goodList>
  36. <guide v-if="item.name == 'guide'" :dataConfig="item"></guide>
  37. <!-- 直播模块 -->
  38. <!-- #ifdef MP-WEIXIN -->
  39. <liveBroadcast v-if="item.name == 'liveBroadcast'" :dataConfig="item"></liveBroadcast>
  40. <!-- #endif -->
  41. <menus v-if="item.name == 'menus'" :dataConfig="item"></menus>
  42. <!-- 实时消息 -->
  43. <news v-if="item.name == 'news'" :dataConfig="item"></news>
  44. <!-- 图片库 -->
  45. <pictureCube v-if="item.name == 'pictureCube'" :dataConfig="item">
  46. </pictureCube>
  47. <!-- 促销列表 -->
  48. <promotionList ref="promotionLists" v-if="item.name == 'promotionList'" :dataConfig="item"
  49. :productVideoStatus='product_video_status' :positionTop="positionTop">
  50. </promotionList>
  51. <richText v-if="item.name == 'richText'" :dataConfig="item"></richText>
  52. <videos v-if="item.name == 'videos'" :dataConfig="item"></videos>
  53. <seckill v-if="item.name == 'seckill'" :dataConfig="item"></seckill>
  54. <!-- 轮播图-->
  55. <swiperBg v-if="item.name == 'swiperBg'" :dataConfig="item"></swiperBg>
  56. <swipers v-if="item.name == 'swipers'" :dataConfig="item"></swipers>
  57. <!-- 标题 -->
  58. <titles v-if="item.name == 'titles'" :dataConfig="item"></titles>
  59. <ranking v-if="item.name == 'ranking'" :dataConfig="item"></ranking>
  60. <presale v-if="item.name == 'presale'" :dataConfig="item"></presale>
  61. <pointsMall v-if="item.name == 'pointsMall'" :dataConfig="item"></pointsMall>
  62. <signIn v-if="item.name == 'signIn'" :dataConfig="item"></signIn>
  63. <hotspot v-if="item.name == 'hotspot'" :dataConfig="item"></hotspot>
  64. <follow v-if="item.name == 'follow'" :dataConfig="item"></follow>
  65. </block>
  66. <!-- 分类商品模块 -->
  67. <!-- #ifndef APP-PLUS -->
  68. <view class="sort-product px-20" v-if="sortList.children && sortList.children.length">
  69. <!-- #endif -->
  70. <!-- #ifdef APP-PLUS -->
  71. <!-- 商品排序 -->
  72. <view class="sort-product px-20" :style="{ marginTop: sortMpTop + 'px' }"
  73. v-if="sortList.children && sortList.children.length">
  74. <!-- #endif -->
  75. <waterfallsFlow ref="waterfallsFlow" :wfList="goodList" :goDetail="'goDetail'" @itemTap="goDetail"></waterfallsFlow>
  76. <Loading :loaded="loaded" :loading="loading"></Loading>
  77. <view v-if="goodList.length == 0 && loaded" class="sort-scroll rd-16rpx">
  78. <view class="empty-box pb-24">
  79. <image :src="imgHost + '/statics/images/no-thing.png'"></image>
  80. <view class="tips">暂无商品,去看点别的吧</view>
  81. </view>
  82. </view>
  83. </view>
  84. <view :style="[pdHeights]" v-if="isFooter"></view>
  85. <pageFooter :isTabBar="false" :configData="tabBarData"></pageFooter>
  86. </view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. const app = getApp();
  92. import colors from "@/mixins/color";
  93. import couponWindow from '@/components/couponWindow/index'
  94. import {
  95. getCouponV2,
  96. getCouponNewUser
  97. } from '@/api/api.js'
  98. import {
  99. getShare
  100. } from '@/api/public.js';
  101. // #ifdef H5
  102. import {
  103. silenceAuth
  104. } from '@/api/public.js';
  105. // #endif
  106. import userInfor from '@/pages/index/components/userInfor';
  107. import homeComb from '@/pages/index/components/homeComb';
  108. import newVip from '@/pages/index/components/newVip';
  109. import headerSerch from '@/pages/index/components/headerSerch';
  110. import swipers from '@/pages/index/components/swipers';
  111. import coupon from '@/pages/index/components/coupon';
  112. import articleList from '@/pages/index/components/articleList';
  113. import bargain from '@/pages/index/components/bargain';
  114. import blankPage from '@/pages/index/components/blankPage';
  115. import combination from '@/pages/index/components/combination';
  116. import customerService from '@/pages/index/components/customerService';
  117. import goodList from '@/pages/index/components/goodList';
  118. import guide from '@/pages/index/components/guide';
  119. import liveBroadcast from '@/pages/index/components/liveBroadcast';
  120. import menus from '@/pages/index/components/menus';
  121. import news from '@/pages/index/components/news';
  122. import pictureCube from '@/pages/index/components/pictureCube';
  123. import promotionList from '@/pages/index/components/promotionList';
  124. import richText from '@/pages/index/components/richText';
  125. import seckill from '@/pages/index/components/seckill';
  126. import swiperBg from '@/pages/index/components/swiperBg';
  127. import tabNav from '@/pages/index/components/tabNav';
  128. import titles from '@/pages/index/components/titles';
  129. import ranking from '@/pages/index/components/ranking';
  130. import presale from '@/pages/index/components/presale'
  131. import pointsMall from '@/pages/index/components/pointsMall';
  132. import videos from '@/pages/index/components/videos';
  133. import signIn from '@/pages/index/components/signIn';
  134. import hotspot from '@/pages/index/components/hotspot';
  135. import follow from '@/pages/index/components/follow';
  136. import waterfallsFlow from "@/components/WaterfallsFlow/WaterfallsFlow.vue";
  137. // #ifdef MP
  138. import {
  139. getTempIds
  140. } from '@/api/api.js';
  141. import {
  142. SUBSCRIBE_MESSAGE,
  143. TIPS_KEY
  144. } from '@/config/cache';
  145. // #endif
  146. import {
  147. mapGetters,
  148. mapMutations
  149. } from 'vuex';
  150. import {
  151. getDiy,
  152. getDiyVersion,
  153. getEntryStore
  154. } from '@/api/api.js';
  155. import {
  156. getCategoryList,
  157. getProductslist,
  158. getProductHot,
  159. } from '@/api/store.js';
  160. import {
  161. goShopDetail
  162. } from '@/libs/order.js';
  163. import {
  164. toLogin
  165. } from '@/libs/login.js';
  166. import {
  167. HTTP_REQUEST_URL
  168. } from '@/config/app';
  169. import pageFooter from '@/components/pageFooter/index.vue'
  170. import Loading from '@/components/Loading/index.vue';
  171. import Cache from '@/utils/cache';
  172. export default {
  173. computed: {
  174. pageStyle() {
  175. return {
  176. backgroundColor: this.bgColor,
  177. backgroundImage: this.bgPic ? `url(${this.bgPic})` : '',
  178. minHeight: this.windowHeight + 'px'
  179. }
  180. },
  181. pdHeights(){
  182. let H = `${this.pdHeight*2 + 100}rpx`
  183. return{
  184. height: this.isFooter?H:'100rpx'
  185. }
  186. },
  187. ...mapGetters(['isLogin', 'uid']),
  188. },
  189. mixins: [colors],
  190. components: {
  191. Loading,
  192. pageFooter,
  193. couponWindow,
  194. homeComb,
  195. newVip,
  196. userInfor,
  197. headerSerch,
  198. swipers,
  199. coupon,
  200. articleList,
  201. bargain,
  202. blankPage,
  203. combination,
  204. customerService,
  205. goodList,
  206. guide,
  207. liveBroadcast,
  208. menus,
  209. pictureCube,
  210. news,
  211. promotionList,
  212. richText,
  213. seckill,
  214. swiperBg,
  215. tabNav,
  216. titles,
  217. ranking,
  218. presale,
  219. pointsMall,
  220. videos,
  221. signIn,
  222. hotspot,
  223. follow,
  224. waterfallsFlow
  225. },
  226. data() {
  227. return {
  228. isFixed: false,
  229. isHeaderSerch: false,
  230. showHomeComb: false,
  231. showCateNav: false,
  232. homeCombData:{},
  233. headerSerchCombData:{},
  234. cateNavData:{},
  235. domOffsetTop: 50,
  236. styleConfig: [],
  237. loading: false,
  238. loadend: false,
  239. loadTitle: '加载更多', //提示语
  240. page: 1,
  241. limit: this.$config.LIMIT,
  242. numConfig: 0,
  243. code: '',
  244. isCouponShow: false,
  245. couponObj: {},
  246. couponObjs: {},
  247. shareInfo: {},
  248. footConfig: {},
  249. pageId: '',
  250. sortMpTop: 0,
  251. bgColor: '',
  252. bgPic: '',
  253. bgTabVal: '',
  254. pageShow: true,
  255. windowHeight: 0,
  256. isShowAuth: false,
  257. isScrolled: false,
  258. sortList: '',
  259. sortAll: [],
  260. isSortType: 0,
  261. hostProduct: [],
  262. hotScroll: false,
  263. hotPage: 1,
  264. hotLimit: 10,
  265. curSort: 0,
  266. loaded: false,
  267. goodPage: 1,
  268. goodList: [],
  269. sid: 0,
  270. positionTop: 0,
  271. imgHost: HTTP_REQUEST_URL,
  272. product_video_status: false,
  273. isFooter: false,
  274. pdHeight:0, //自定义底部导航上下边距和
  275. entryData:{
  276. store_id:'',
  277. latitude:'',
  278. longitude:'',
  279. select_store_id:''
  280. },
  281. goodsIndex: [],
  282. promotionIndex: [],
  283. belongIndex:0, // 进店规则归属门店排序位置;
  284. isBelongStore: false, //判断是否为归属门店;
  285. tabBarData:{},
  286. };
  287. },
  288. onLoad(options) {
  289. let that = this
  290. this.$nextTick(function() {
  291. uni.getSystemInfo({
  292. success: function(res) {
  293. that.windowHeight = res.windowHeight;
  294. }
  295. });
  296. })
  297. const {
  298. state,
  299. scope
  300. } = options;
  301. this.pageId = options.id
  302. // #ifdef MP
  303. if (options.scene) {
  304. let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
  305. this.pageId = value.id
  306. }
  307. // #endif
  308. uni.setNavigationBarTitle({
  309. title: '专题栏'
  310. });
  311. // #ifdef APP-PLUS
  312. this.sortMpTop = -50
  313. // #endif
  314. this.diyData();
  315. // #ifdef H5
  316. this.setOpenShare();
  317. // #endif
  318. // #ifdef MP || APP-PLUS
  319. this.getTempIds();
  320. // #endif
  321. getShare().then(res => {
  322. this.shareInfo = res.data;
  323. })
  324. },
  325. onUnload() {
  326. // 清除监听
  327. uni.$off('activeFn');
  328. },
  329. watch: {
  330. isLogin: {
  331. deep: true, //深度监听设置为 true
  332. handler: function(newV, oldV) {
  333. // 优惠券弹窗
  334. var newDates = new Date().toLocaleDateString();
  335. if (newV) {
  336. try {
  337. var oldDate = uni.getStorageSync('oldDate') || ''
  338. } catch {}
  339. if (oldDate != newDates) {
  340. this.getCoupon();
  341. }
  342. }
  343. }
  344. }
  345. },
  346. onShow() {
  347. uni.removeStorageSync('form_type_cart');
  348. // 优惠券弹窗
  349. var newDates = new Date().toLocaleDateString();
  350. if (this.isLogin) {
  351. try {
  352. var oldDate = uni.getStorageSync('oldDate') || ''
  353. } catch {}
  354. if (oldDate != newDates) {
  355. this.getCoupon();
  356. }
  357. let oldUser = uni.getStorageSync('oldUser') || 0;
  358. if (!oldUser) {
  359. this.getCouponOnce();
  360. }
  361. }
  362. },
  363. mounted() {},
  364. methods: {
  365. ...mapMutations(['SET_NEARBY']),
  366. locationTap(val){
  367. this.entryData.latitude = val.latitude;
  368. this.entryData.longitude = val.longitude;
  369. this.entryStore(1);
  370. },
  371. storeTap(id){
  372. this.entryData.select_store_id = id;
  373. this.entryData.store_id = '';
  374. uni.removeStorageSync('rulesStoreId');
  375. this.entryStore(1);
  376. },
  377. // 分类点击
  378. changeSort(item, index) {
  379. if (this.curSort == index) return;
  380. this.curSort = index;
  381. this.sid = item.id;
  382. this.goodList = [];
  383. this.goodPage = 1;
  384. this.loaded = false;
  385. this.getGoodsList();
  386. },
  387. /**
  388. * @param data {
  389. classPage: 0 分类id
  390. microPage: 0 微页面id
  391. type: 1 0 商品分类 1 微页面
  392. }*/
  393. bindSortId(data) {
  394. this.styleConfig = [];
  395. if (data.type == 1) {
  396. this.getProductList(data.classPage);
  397. } else {
  398. this.sortList = [];
  399. this.getMicroPage(data.microPage, true);
  400. }
  401. },
  402. /**
  403. * 获取DIY
  404. * @param {number} id
  405. * @param {boolean} type 区分是否是微页面
  406. */
  407. getMicroPage(id, type) {
  408. let that = this;
  409. that.styleConfig = []
  410. uni.showLoading({
  411. title: '加载中...'
  412. });
  413. getDiy(id).then(res => {
  414. uni.hideLoading();
  415. let data = res.data;
  416. let diyArr = that.objToArr(res.data.value);
  417. diyArr = diyArr.filter(item => !item.isHide);
  418. diyArr.forEach((item,index) => {
  419. if(['headerSerch','homeComb'].includes(item.name)){
  420. diyArr.splice(index, 1);
  421. }
  422. });
  423. this.styleConfig = diyArr;
  424. }).catch(err => {
  425. return that.$util.Tips({
  426. title: err
  427. });
  428. uni.hideLoading();
  429. });
  430. },
  431. getProductList(data) {
  432. this.curSort = 0;
  433. this.loaded = false;
  434. if (this.sortAll.length > 0) {
  435. this.sortAll.forEach((el, index) => {
  436. if (el.id == data) {
  437. this.$set(this, 'sortList', el);
  438. this.sid = el.children.length ? el.children[0].id : '';
  439. }
  440. });
  441. this.goodList = [];
  442. this.goodPage = 1;
  443. this.$nextTick(() => {
  444. if (this.sortList != '') this.getGoodsList();
  445. });
  446. } else {
  447. getCategoryList().then(res => {
  448. this.sortAll = res.data;
  449. res.data.forEach((el, index) => {
  450. if (el.id == data) {
  451. this.sortList = el;
  452. this.sid = el.children.length ? el.children[0].id : '';
  453. }
  454. });
  455. this.goodList = [];
  456. this.goodPage = 1;
  457. this.$nextTick(() => {
  458. if (this.sortList != '') this.getGoodsList();
  459. });
  460. });
  461. }
  462. },
  463. // 商品列表
  464. getGoodsList() {
  465. if (this.loading || this.loaded) return;
  466. this.loading = true;
  467. getProductslist({
  468. sid: this.sid,
  469. keyword: '',
  470. priceOrder: '',
  471. salesOrder: '',
  472. news: 0,
  473. page: this.goodPage,
  474. limit: 10,
  475. cid: this.sortList.id
  476. }).then(res => {
  477. this.loading = false;
  478. this.loaded = res.data.length < 10;
  479. this.goodPage++;
  480. this.goodList = this.goodList.concat(res.data);
  481. });
  482. },
  483. /**
  484. * 获取我的推荐
  485. */
  486. get_host_product: function() {
  487. let that = this;
  488. if (that.hotScroll) return;
  489. getProductHot(that.hotPage, that.hotLimit).then(res => {
  490. that.hotPage++;
  491. that.hotScroll = res.data.length < that.hotLimit;
  492. that.hostProduct = that.hostProduct.concat(res.data);
  493. });
  494. },
  495. // 新用户优惠券
  496. getCouponOnce() {
  497. getCouponNewUser().then(res => {
  498. this.couponObjs = res.data;
  499. });
  500. },
  501. couponCloses() {
  502. this.couponObjs.show = false;
  503. try {
  504. uni.setStorageSync('oldUser', 1);
  505. } catch (e) {
  506. }
  507. },
  508. // 优惠券弹窗
  509. getCoupon() {
  510. getCouponV2().then(res => {
  511. this.couponObj = res.data
  512. if (res.data.list.length > 0) {
  513. this.isCouponShow = true
  514. }
  515. })
  516. },
  517. // 优惠券弹窗关闭
  518. couponClose() {
  519. this.isCouponShow = false
  520. try {
  521. uni.setStorageSync('oldDate', new Date().toLocaleDateString());
  522. } catch {}
  523. },
  524. // #ifdef H5
  525. // 获取url后面的参数
  526. getQueryString(name) {
  527. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  528. var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
  529. var r = window.location.search.substr(1).match(reg);
  530. var q = window.location.pathname.substr(1).match(reg_rewrite);
  531. if (r != null) {
  532. return unescape(r[2]);
  533. } else if (q != null) {
  534. return unescape(q[2]);
  535. } else {
  536. return null;
  537. }
  538. },
  539. // #endif
  540. // #ifdef MP || APP-PLUS
  541. getTempIds() {
  542. let messageTmplIds = wx.getStorageSync(SUBSCRIBE_MESSAGE);
  543. if (!messageTmplIds) {
  544. // getTempIds().then(res => {
  545. // if (res.data) wx.setStorageSync(SUBSCRIBE_MESSAGE, JSON.stringify(res.data));
  546. // });
  547. }
  548. },
  549. // #endif
  550. // 对象转数组
  551. objToArr(data) {
  552. const keys = Object.keys(data)
  553. keys.sort((a, b) => a - b)
  554. const m = keys.map(key => data[key]);
  555. return m;
  556. },
  557. setDiyData(data) {
  558. if (data.length == 0) {
  559. return this.$util.Tips({
  560. title: '暂无数据'
  561. }, {
  562. tab: 3
  563. })
  564. }
  565. if (data.is_bg_color) {
  566. this.bgColor = data.color_picker
  567. }
  568. if (data.is_bg_pic) {
  569. this.bgPic = data.bg_pic
  570. this.bgTabVal = data.bg_tab_val
  571. }
  572. this.pageShow = data.is_show
  573. uni.setNavigationBarTitle({
  574. title: data.title
  575. })
  576. let temp = []
  577. let goodsIndex = [];
  578. let promotionIndex = [];
  579. let lastArr = this.objToArr(data.value)
  580. lastArr.forEach((item, index, arr) => {
  581. if (item.name === 'homeComb' && !item.isHide) {
  582. this.showHomeComb = true;
  583. this.homeCombData = item;
  584. if (item.searchConfig.tabVal) {
  585. this.positionTop = 43
  586. }
  587. }
  588. if (item.name == 'headerSerch' && !item.isHide) {
  589. this.isHeaderSerch = true;
  590. this.headerSerchCombData = item;
  591. }
  592. if (item.name == 'tabNav' && !item.isHide) {
  593. this.showCateNav = true;
  594. this.cateNavData = item;
  595. }
  596. if(item.name == 'goodList' && !item.isHide){
  597. goodsIndex.push(index)
  598. }
  599. if(item.name == 'promotionList' && !item.isHide){
  600. promotionIndex.push(index)
  601. }
  602. if (item.name == 'pageFoot') {
  603. this.tabBarData = item;
  604. this.isFooter = item.effectConfig.tabVal?true:false
  605. this.pdHeight = item.topConfig.val + item.bottomConfig.val
  606. }
  607. if (!item.isHide) {
  608. temp.push(item);
  609. }
  610. });
  611. function sortNumber(a, b) {
  612. return a.timestamp - b.timestamp;
  613. }
  614. temp.sort(sortNumber);
  615. this.styleConfig = temp;
  616. this.goodsIndex = goodsIndex;
  617. this.promotionIndex = promotionIndex;
  618. this.entryStore();
  619. },
  620. getDiyData() {
  621. getDiy(this.pageId).then(res => {
  622. uni.setStorageSync('specialDiyData', JSON.stringify(res.data));
  623. this.setDiyData(res.data);
  624. });
  625. },
  626. diyData() {
  627. this.getDiyData();
  628. // let that = this;
  629. // let diyData = uni.getStorageSync('specialDiyData');
  630. // if (diyData) {
  631. // getDiyVersion(this.pageId).then(res => {
  632. // let diyVersion = uni.getStorageSync('specialDiyVersion');
  633. // if ((res.data.version + this.pageId) === diyVersion) {
  634. // this.setDiyData(JSON.parse(diyData));
  635. // } else {
  636. // uni.setStorageSync('specialDiyVersion', (res.data.version + this.pageId));
  637. // this.getDiyData();
  638. // }
  639. // });
  640. // } else {
  641. // this.getDiyData();
  642. // }
  643. },
  644. entryStore(num){
  645. // num 更新门店或是位置时需要重新获取门店商品数据(针对得是单店模式)
  646. // this.entryData.store_id = Cache('rulesStoreId');
  647. // getEntryStore(this.entryData).then(res=>{
  648. // if(res.data.user_entry_name == 'user_belong_store'){
  649. // this.isBelongStore = true;
  650. // }
  651. // let storeId= res.data.store_id;
  652. // uni.setStorageSync('user_store_id', storeId);
  653. // uni.setStorageSync('shop_operation_type', res.data.shop_operation_type);
  654. // this.SET_NEARBY(storeId);
  655. // let data = {
  656. // store_id:storeId
  657. // }
  658. // let changeStore = true;
  659. // let entryRules = res.data.user_entry_rules;
  660. // entryRules.forEach((item,index)=>{
  661. // if(item.name == 'user_belong_store'){
  662. // this.belongIndex = index;
  663. // changeStore = item.is_change_store;
  664. // }
  665. // })
  666. // if(res.data.shop_operation_type !=1 && num){
  667. // this.goodsIndex.forEach((item,index)=>{
  668. // this.$refs.goodLists[index].productslist();
  669. // })
  670. // this.promotionIndex.forEach((item,index)=>{
  671. // this.$refs.promotionLists[index].$refs.goodLists.productslist();
  672. // })
  673. // }
  674. // }).catch(err=>{
  675. // this.$util.Tips({
  676. // title: err
  677. // });
  678. // })
  679. },
  680. changeBarg(item) {
  681. if (!this.isLogin) {
  682. toLogin()
  683. } else {
  684. uni.navigateTo({
  685. url: `/pages/activity/goods_bargain_details/index?id=${item.id}&spid=${this.uid}`
  686. });
  687. }
  688. },
  689. goDetail(item) {
  690. goShopDetail(item, this.uid).then(res => {
  691. uni.navigateTo({
  692. url: `/pages/goods_details/index?id=${item.id}`
  693. });
  694. });
  695. },
  696. // #ifdef H5
  697. // 微信分享;
  698. setOpenShare: function() {
  699. let that = this;
  700. if (that.$wechat.isWeixin()) {
  701. getShare().then(res => {
  702. let data = res.data.data;
  703. let configAppMessage = {
  704. desc: data.synopsis,
  705. title: data.title,
  706. link: location.href,
  707. imgUrl: data.img
  708. };
  709. that.$wechat.wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData'],
  710. configAppMessage);
  711. });
  712. }
  713. }
  714. // #endif
  715. },
  716. onReachBottom: function() {},
  717. onPageScroll(e) {
  718. if (this.isHeaderSerch) {
  719. if (e.scrollTop > this.domOffsetTop) {
  720. this.isFixed = true;
  721. }
  722. if (e.scrollTop < this.domOffsetTop) {
  723. this.$nextTick(() => {
  724. this.isFixed = false;
  725. });
  726. }
  727. } else {
  728. this.isFixed = false
  729. }
  730. if (e.scrollTop > 10) {
  731. this.isScrolled = true;
  732. } else {
  733. this.isScrolled = false;
  734. }
  735. uni.$emit('scroll');
  736. uni.$emit('onPageScroll', e.scrollTop);
  737. },
  738. //#ifdef MP || APP-PLUS
  739. onShareAppMessage() {
  740. return {
  741. title: this.shareInfo.title,
  742. path: '/pages/index/index',
  743. imageUrl: this.storeInfo.img,
  744. };
  745. },
  746. //#endif
  747. };
  748. </script>
  749. <style lang="scss">
  750. .sort-scroll {
  751. background-color: #fff;
  752. }
  753. .empty-box {
  754. text-align: center;
  755. padding-top: 50rpx;
  756. .tips {
  757. color: #aaa;
  758. font-size: 26rpx;
  759. }
  760. image {
  761. width: 414rpx;
  762. height: 304rpx;
  763. }
  764. }
  765. .sort-product {
  766. margin-top: 20rpx;
  767. .sort-box {
  768. display: flex;
  769. width: 100%;
  770. border-radius: 16rpx;
  771. padding: 30rpx 0;
  772. .sort-item {
  773. width: 20%;
  774. display: flex;
  775. flex-direction: column;
  776. align-items: center;
  777. justify-content: center;
  778. flex-shrink: 0;
  779. image {
  780. width: 90rpx;
  781. height: 90rpx;
  782. border-radius: 50%;
  783. }
  784. .txt {
  785. color: #272727;
  786. font-size: 24rpx;
  787. margin-top: 10rpx;
  788. overflow: hidden;
  789. white-space: nowrap;
  790. text-overflow: ellipsis;
  791. width: 140rpx;
  792. text-align: center;
  793. }
  794. .pictrues {
  795. width: 90rpx;
  796. height: 90rpx;
  797. background: #f8f8f8;
  798. border-radius: 50%;
  799. margin: 0 auto;
  800. }
  801. .icon-gengduo1 {
  802. color: #333;
  803. }
  804. &.on {
  805. .txt {
  806. color: #fc4141;
  807. }
  808. image {
  809. border: 1px solid #fc4141;
  810. }
  811. }
  812. }
  813. }
  814. .product-list {
  815. display: flex;
  816. flex-wrap: wrap;
  817. justify-content: space-between;
  818. margin-top: 30rpx;
  819. padding: 0 20rpx;
  820. .product-item {
  821. position: relative;
  822. width: 344rpx;
  823. background: #fff;
  824. border-radius: 10rpx;
  825. margin-bottom: 20rpx;
  826. overflow: hidden;
  827. .pictrue {
  828. position: relative;
  829. }
  830. image {
  831. width: 100%;
  832. height: 344rpx;
  833. border-radius: 10rpx 10rpx 0 0;
  834. }
  835. .info {
  836. padding: 14rpx 16rpx;
  837. .title {
  838. font-size: 28rpx;
  839. }
  840. .price-box {
  841. font-size: 34rpx;
  842. font-weight: 700;
  843. margin-top: 8px;
  844. color: #fc4141;
  845. text {
  846. font-size: 26rpx;
  847. }
  848. }
  849. }
  850. }
  851. }
  852. }
  853. .page {
  854. padding-bottom: 50px;
  855. }
  856. .ysize {
  857. background-size: 100%;
  858. }
  859. .fullsize {
  860. background-size: 100% 100%;
  861. }
  862. .repeat {
  863. background-repeat: repeat;
  864. }
  865. .noRepeat {
  866. background-repeat: no-repeat;
  867. }
  868. </style>