index.vue 32 KB

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