index.vue 32 KB

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