index.vue 34 KB

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