index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  1. <template>
  2. <view class="container">
  3. <!-- 小程序头部兼容 -->
  4. <!-- #ifdef MP -->
  5. <view class="input-box flex" @click="clickSearch">
  6. <view class=" input-content flex">
  7. <view class="iconfont iconsearch"></view>
  8. <view class="input"><input type="text" disabled placeholder="请输入搜索内容" /></view>
  9. </view>
  10. </view>
  11. <view class="mp-height"></view>
  12. <!-- #endif -->
  13. <!-- 头部轮播 -->
  14. <view class="carousel-section">
  15. <!-- 标题栏和状态栏占位符 -->
  16. <view class="titleNview-placing"></view>
  17. <!-- 背景色区域 -->
  18. <view class="titleNview-background" :style="{ backgroundColor: '#5DBC7C' }"></view>
  19. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  20. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  21. @click="bannerNavToUrl(item)">
  22. <image :src="item.pic" />
  23. </swiper-item>
  24. </swiper>
  25. <!-- 自定义swiper指示器 -->
  26. <view class="swiper-dots">
  27. <text class="num">{{ swiperCurrent + 1 }}</text>
  28. <text class="sign">/</text>
  29. <text class="num">{{ swiperLength }}</text>
  30. </view>
  31. </view>
  32. <!-- 分类 -->
  33. <view class="cate-section">
  34. <view class="cate-item">
  35. <image src="/static/icon/c3.png"></image>
  36. <text>联盟礼包</text>
  37. </view>
  38. <navigator url="/pages/product/groupBooking/index">
  39. <view class="cate-item">
  40. <image src="/static/icon/c5.png"></image>
  41. <text>超值拼团</text>
  42. </view>
  43. </navigator>
  44. <navigator url="/pages/product/seckill">
  45. <view class="cate-item">
  46. <image src="/static/icon/c7.png"></image>
  47. <text>限时秒杀</text>
  48. </view>
  49. </navigator>
  50. <navigator url="/pages/index/sign">
  51. <view class="cate-item">
  52. <image src="/static/icon/c8.png"></image>
  53. <text>每日签到</text>
  54. </view>
  55. </navigator>
  56. </view>
  57. <view class="ad-1">
  58. <image src="/static/temp/ad1.jpg" mode="scaleToFill"></image>
  59. </view>
  60. <!-- 可领取优惠券 -->
  61. <!-- <scroll-view class="coupon-box clamp" :scroll-x="true">
  62. <view v-for="(item, index) in couponArray" :key="item.id" class="coupon-list">
  63. <view class="row flex">
  64. <view class="list-money flex">
  65. <image :src="item.is_use ? '/static/img/img02.png' : '/static/img/img03.png'" mode="scaleToFill"></image>
  66. <view class="list-money-text">
  67. <view class="tit" :class="{ noAction: item.is_use }">
  68. <text>{{ item.coupon_price }}</text>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="list-interval position-relative">
  73. <view class="bottom"></view>
  74. <view class="top"></view>
  75. </view>
  76. <view class="row_list_right">
  77. <view class="right_top"><text class="right_title" :class="{ noAction: item.is_use }">满减券</text></view>
  78. <view class="right_time">
  79. <text>满{{ item.use_min_price }}使用</text>
  80. </view>
  81. </view>
  82. <view class="right_use" :class="{ noAction: item.is_use }" @click="setCoupons(item)">
  83. <text>{{ item.is_use ? '已领取' : '立即领取' }}</text>
  84. </view>
  85. </view>
  86. </view>
  87. </scroll-view> -->
  88. <!-- 秒杀楼层 -->
  89. <seckill></seckill>
  90. <!-- 砍价 -->
  91. <view class="hot-goods">
  92. <view class="hot-headers flex-upDown-center">
  93. <!-- <image class="img" src="../../static/img/img44.png"></image> -->
  94. <view class="hot-title">超值砍价</view>
  95. <view>
  96. <view class="more" @click.stop="navTo('/pages/activity/goods_bargain/index')">更多</view>
  97. </view>
  98. </view>
  99. <view class="hot-lists" v-for="(baritem, barindex) in bargainlist" :key="barindex"
  100. @click.stop="navToDetailPages(baritem)">
  101. <view class="hot-produce">
  102. <view class="produce-image">
  103. <image :src="baritem.image"></image>
  104. </view>
  105. <view class="produce-content">
  106. <view class="produce-price1 ">
  107. <view class="produce-name line2">{{ baritem.title }}</view>
  108. <!-- <view class="produce-info">
  109. 已抢
  110. <text style="color: #FF383E">{{ baritem.sales }}</text>
  111. 箱/仅剩
  112. <text style="color:#FF383E">{{ baritem.stock }}</text>
  113. </view> -->
  114. <view class="produce-center">
  115. <view class="kanjia_word">
  116. <view class="word-1">原价:¥{{ baritem.price }}</view>
  117. <view class="word-2">
  118. 砍后价
  119. <text style="font-size: 24rpx;">¥</text>
  120. <text style="font-size: 36rpx;">{{ baritem.min_price }}</text>
  121. </view>
  122. </view>
  123. <view class="kanjia_button flex-center"
  124. @tap.stop="openSubscribe('/pages/activity/goods_bargain_details/index?id=' + baritem.id + '&bargain=' + userInfo.uid)">
  125. <view>查看详情</view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. <!-- 拼团楼层 -->
  134. <view class="recommend flex">
  135. <view class="recommend_list" @click="change(ls.id)" v-for="ls in recommend">
  136. <view class="re_title" v-bind:class="{ active_color: ls.id == checkid }">{{ ls.re_title }}</view>
  137. <view class="re_name" v-bind:class="{ active_color: ls.id == checkid }">{{ ls.re_name }}</view>
  138. <image class="selected_icon" v-bind:class="{ active: ls.id == checkid }" src="/static/img/img04.png">
  139. </image>
  140. </view>
  141. </view>
  142. <swiper id="list-box" @change="listChange" :style="{ height: swiperHeight + 'px' }" :current="checkid">
  143. <swiper-item>
  144. <!-- <scroll-view scroll-y="true" class="list-box-h"> -->
  145. <view class="guess-section">
  146. <view v-for="(item, index) in bastList" :key="index" class="guess-item"
  147. @click="navToDetailPage(item)">
  148. <view class="image-wrapper">
  149. <image :src="item.image" mode="scaleToFill"></image>
  150. </view>
  151. <text class="title clamp margin-c-20">{{ item.store_name }}</text>
  152. <view class="cmy-hr"></view>
  153. <view class="price margin-c-20 flex">
  154. <view>
  155. <text class="font-size-sm ">¥</text>
  156. {{ item.price }}
  157. </view>
  158. <view class="font-size-sm">
  159. <text class="font-color-gray">{{ item.sales }}人购买</text>
  160. </view>
  161. </view>
  162. </view>
  163. </view>
  164. <!-- </scroll-view> -->
  165. </swiper-item>
  166. <swiper-item>
  167. <scroll-view scroll-y="true" class="list-box-h">
  168. <view class="guess-section">
  169. <view v-for="(item, index) in goodsList" :key="index" class="guess-item"
  170. @click="navToDetailPage(item)">
  171. <view class="image-wrapper">
  172. <image :src="item.image" mode="scaleToFill"></image>
  173. </view>
  174. <text class="title clamp margin-c-20">{{ item.store_name }}</text>
  175. <view class="cmy-hr"></view>
  176. <view class="price margin-c-20 flex">
  177. <view>
  178. <text class="font-size-sm ">¥</text>
  179. {{ item.price }}
  180. </view>
  181. <view class="font-size-sm">
  182. <text class="font-color-gray">{{ item.sales }}人购买</text>
  183. </view>
  184. </view>
  185. </view>
  186. </view>
  187. </scroll-view>
  188. </swiper-item>
  189. <swiper-item>
  190. <scroll-view scroll-y="true">
  191. <view class="guess-section">
  192. <view v-for="(item, index) in bastBanner" :key="index" class="guess-item"
  193. @click="navToDetailPage(item)">
  194. <navigator :url="item.link">
  195. <view class="image-wrappe r">
  196. <image :src="item.image" mode="scaleToFill"></image>
  197. </view>
  198. <text class="title clamp margin-c-20">{{ item.store_name }}</text>
  199. <view class="cmy-hr"></view>
  200. <view class="price margin-c-20 flex">
  201. <view>
  202. <text class="font-size-sm ">¥</text>
  203. {{ item.price }}
  204. </view>
  205. <view class="font-size-sm">
  206. <text class="font-color-gray">库存{{ item.stock + item.unit_name }}</text>
  207. </view>
  208. </view>
  209. </navigator>
  210. </view>
  211. </view>
  212. </scroll-view>
  213. </swiper-item>
  214. </swiper>
  215. <!-- 精品 商品 -->
  216. <view class="f-header m-t">
  217. <view class="f-left-icon"></view>
  218. <view class="tit-box"><text class="tit">精品推荐</text></view>
  219. <navigator url="/pages/product/classify?type=1"><text class="iconfont iconenter">更多</text></navigator>
  220. </view>
  221. <view class="guess-section">
  222. <view v-for="(item, index) in bastList" :key="index" class="guess-item" @click="navToDetailPage(item)">
  223. <view class="image-wrapper">
  224. <image :src="item.image" mode="scaleToFill"></image>
  225. </view>
  226. <text class="title clamp margin-c-20">{{ item.store_name }}</text>
  227. <view class="cmy-hr"></view>
  228. <view class="price margin-c-20 flex">
  229. <view>
  230. <text class="font-size-sm ">¥</text>
  231. {{ item.price }}
  232. </view>
  233. <view class="font-size-sm">
  234. <text class="font-color-gray">{{ item.sales }}人购买</text>
  235. </view>
  236. </view>
  237. </view>
  238. </view>
  239. <!-- 最新 商品 -->
  240. <view class="f-header m-t">
  241. <view class="f-left-icon"></view>
  242. <view class="tit-box"><text class="tit">最新商品</text></view>
  243. <navigator url="/pages/product/classify?type=3"><text class="iconfont iconenter">更多</text></navigator>
  244. </view>
  245. <view class="guess-section">
  246. <view v-for="(item, index) in goodsList" :key="index" class="guess-item" @click="navToDetailPage(item)">
  247. <view class="image-wrapper">
  248. <image :src="item.image" mode="scaleToFill"></image>
  249. </view>
  250. <text class="title clamp margin-c-20">{{ item.store_name }}</text>
  251. <view class="cmy-hr"></view>
  252. <view class="price margin-c-20 flex">
  253. <view>
  254. <text class="font-size-sm ">¥</text>
  255. {{ item.price }}
  256. </view>
  257. <view class="font-size-sm">
  258. <text class="font-color-gray">{{ item.sales }}人购买</text>
  259. </view>
  260. </view>
  261. </view>
  262. </view>
  263. <!-- 促销 商品 -->
  264. <view class="f-header m-t">
  265. <view class="f-left-icon"></view>
  266. <view class="tit-box"><text class="tit">促销商品</text></view>
  267. <navigator url="/pages/product/classify?type=4"><text class="iconfont iconenter">更多</text></navigator>
  268. </view>
  269. <view class="guess-section">
  270. <view v-for="(item, index) in bastBanner" :key="index" class="guess-item" @click="navToDetailPage(item)">
  271. <view class="image-wrapper">
  272. <image :src="item.image" mode="scaleToFill"></image>
  273. </view>
  274. <text class="title clamp margin-c-20">{{ item.store_name }}</text>
  275. <view class="cmy-hr"></view>
  276. <view class="price margin-c-20 flex">
  277. <view>
  278. <text class="font-size-sm ">¥</text>
  279. {{ item.price }}
  280. </view>
  281. <view class="font-size-sm">
  282. <text class="font-color-gray">{{ item.sales }}人购买</text>
  283. </view>
  284. </view>
  285. </view>
  286. </view>
  287. <!-- 会员升级专区 -->
  288. <!-- <view class="f-header m-t">
  289. <view class="f-left-icon"></view>
  290. <view class="tit-box"><text class="tit">会员升级专区</text></view>
  291. <text class="iconfont iconenter">更多</text>
  292. </view> -->
  293. <!-- <view class="uservip flex">
  294. <image @error="onImageError('userServant', 0)" lazy-load :src="userServant[0].image" mode="aspectFill"></image>
  295. <view class="detail">
  296. <view class="title">满园春1999元会员升级礼包</view>
  297. <view class="icon">自营</view>
  298. <view class="flex price-box">
  299. <view class="price">
  300. <text class="font-size-sm">¥</text>
  301. 18888
  302. </view>
  303. <view class="text">115人购买</view>
  304. </view>
  305. </view>
  306. </view> -->
  307. <!-- 精品推荐 -->
  308. <!-- <view class="f-header m-t">
  309. <view class="f-left-icon"></view>
  310. <view class="tit-box"><text class="tit">精品推荐</text></view>
  311. <text class="iconfont iconenter">更多</text>
  312. </view> -->
  313. <!-- <view class="guess-section">
  314. <view v-for="(item, index) in goodsList" :key="index" class="guess-item" @click="navToDetailPage(item)">
  315. <view class="image-wrapper"><image @error="onImageError('goodsList', index)" lazy-load :src="item.image" mode="aspectFill"></image></view>
  316. <text class="title clamp margin-c-20">
  317. <text class="icon">自营</text>
  318. {{ item.title }}
  319. </text>
  320. <view class="hr"></view>
  321. <view class="price margin-c-20 flex">
  322. <view>
  323. <text class="font-size-sm ">¥</text>
  324. {{ item.price }}
  325. </view>
  326. <view class="font-size-sm">
  327. <view class='detail'>
  328. <text class="icon">代理价</text>
  329. <text></text>
  330. </view>
  331. <view class="detail">
  332. <text class="font-color-yellow">会员价</text>
  333. <text class="font-color-yellow">7.5折</text>
  334. </view>
  335. </view>
  336. </view>
  337. <view class="tip">兑换价¥44+44积分</view>
  338. </view>
  339. </view> -->
  340. <view class="Mask" v-show="shareShow">
  341. <image @click="share" src="http://shicai.liuniu946.com/static/img/shareimg4.png"></image>
  342. <view class="Toshare" @click="Toshare"></view>
  343. <view class="Tocancel" @click="Tocancel"></view>
  344. </view>
  345. </view>
  346. </template>
  347. <script>
  348. import {lookSubpoints,lookOneself} from '../../api/user.js'
  349. import seckill from '../../components/seckill/seckill.vue';
  350. import {
  351. loadIndexs
  352. } from '@/api/index.js';
  353. import {
  354. getUserInfo
  355. } from '@/api/user.js';
  356. import {
  357. setCoupons
  358. } from '@/api/functionalUnit.js';
  359. import {
  360. getBargainList
  361. } from '@/api/product.js';
  362. import {
  363. interceptor
  364. } from '@/utils/loginUtils';
  365. import {
  366. mapState
  367. } from 'vuex';
  368. export default {
  369. components: {
  370. seckill
  371. },
  372. watch: {
  373. //自适应swiper高度
  374. checkid(newValue, oldValue) {
  375. let obj = this;
  376. if (newValue == 0) {
  377. let bHeight = Math.ceil(obj.bastList.length / 2);
  378. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  379. }
  380. if (newValue == 1) {
  381. let bHeight = Math.ceil(obj.goodsList.length / 2);
  382. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  383. }
  384. if (newValue == 2) {
  385. let bHeight = Math.ceil(obj.bastBanner.length / 2);
  386. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  387. }
  388. },
  389. // 初次加载页面高度时修改页面高度
  390. bastList(newValue, oldValue) {
  391. let obj = this;
  392. let bHeight = Math.ceil(newValue.length / 2);
  393. obj.$nextTick(function() {
  394. uni.createSelectorQuery()
  395. .select('#list-box')
  396. .fields({
  397. size: true
  398. },
  399. function(data) {
  400. obj.pageProportion = data.width / 750;
  401. obj.swiperHeight = Math.ceil(obj.pageProportion * 520 * bHeight);
  402. }
  403. )
  404. .exec();
  405. });
  406. }
  407. },
  408. data() {
  409. return {
  410. shareShow: false, //分享海报
  411. pageProportion: 0, //保存页面基于750宽度的比例
  412. swiperHeight: 0,
  413. checkid: 0,
  414. titleNViewBackground: '',
  415. swiperCurrent: 0,
  416. swiperLength: 0,
  417. bargainlist: [], //砍价商品
  418. carouselList: [], //轮播列表
  419. goodsList: [], //最新商品列表
  420. bastList: [], //精品推荐列表
  421. bastBanner: [], //促销商品列表
  422. menusList: [], //头部菜单
  423. page: 1,
  424. limit: 5,
  425. userServant: [{
  426. image: ''
  427. }], //用户推广服务
  428. couponArray: [], //可领取优惠券
  429. recommend: [
  430. {
  431. id: 0,
  432. re_title: '精选',
  433. re_name: '为你推荐'
  434. },
  435. {
  436. id: 1,
  437. re_title: '最新',
  438. re_name: '最新好货优选'
  439. },
  440. {
  441. id: 2,
  442. re_title: '便宜好货',
  443. re_name: '90天便宜好货'
  444. }
  445. ],
  446. actTime: new Date()
  447. };
  448. },
  449. computed: {
  450. ...mapState(['loginInterceptor']),
  451. ...mapState('user', ['hasLogin', 'userInfo'])
  452. },
  453. onLoad: function(option) {
  454. // #ifndef MP
  455. if (option.spread) {
  456. // 存储其他邀请人
  457. uni.setStorageSync('spread', option.spread);
  458. }
  459. // #endif
  460. // #ifdef MP
  461. if (option.scene) {
  462. // 存储小程序邀请人
  463. uni.setStorage({
  464. key: 'spread_code',
  465. data: option.scene
  466. });
  467. }
  468. // #endif
  469. },
  470. onShow: function() {
  471. this.lookJd()
  472. this.$axios.all([this.$axios({
  473. url: '/api/index',
  474. method: 'get'
  475. }), this.$axios({
  476. url: '/api/bargain/list',
  477. method: 'get'
  478. })]).then(this.$axios.spread((alalm, lalal) => {
  479. console.log(alalm, '222')
  480. console.log(lalal, '333')
  481. })
  482. )
  483. // 判断是否强制登录
  484. if (this.loginInterceptor && !this.hasLogin) {
  485. // 登录拦截
  486. interceptor();
  487. }
  488. this.loadData();
  489. this.getBargainList();
  490. },
  491. //下拉刷新
  492. onPullDownRefresh() {
  493. this.loadData();
  494. },
  495. // #ifndef MP
  496. // 监听导航栏输入框点击事件
  497. onNavigationBarSearchInputClicked(e) {
  498. //跳转到搜索页面
  499. this.clickSearch();
  500. },
  501. //点击导航栏 buttons 时触发
  502. onNavigationBarButtonTap(e) {
  503. const index = e.index;
  504. if (index === 0) {
  505. this.$api.msg('点击了扫描');
  506. } else if (index === 1) {
  507. // #ifdef APP-PLUS
  508. const pages = getCurrentPages();
  509. const page = pages[pages.length - 1];
  510. const currentWebview = page.$getAppWebview();
  511. currentWebview.hideTitleNViewButtonRedDot({
  512. index
  513. });
  514. // #endif
  515. uni.navigateTo({
  516. url: '/pages/user/notice'
  517. });
  518. }
  519. },
  520. // #endif
  521. methods: {
  522. //砍价商品推荐详情页
  523. navToDetailPages(item) {
  524. let id = item.product_id;
  525. //let type = 2;
  526. uni.navigateTo({
  527. url: '/pages/product/product?id=' + id
  528. });
  529. },
  530. openSubscribe: function(e) {
  531. let page = e;
  532. // #ifndef MP
  533. uni.navigateTo({
  534. url: page
  535. });
  536. // #endif
  537. // #ifdef MP
  538. uni.showLoading({
  539. title: '正在加载'
  540. });
  541. openBargainSubscribe()
  542. .then(res => {
  543. uni.hideLoading();
  544. uni.navigateTo({
  545. url: page
  546. });
  547. })
  548. .catch(err => {
  549. uni.hideLoading();
  550. });
  551. // #endif
  552. },
  553. getBargainList() {
  554. let that = this;
  555. getBargainList({
  556. page: that.page,
  557. limit: that.limit
  558. })
  559. .then(function(res) {
  560. that.$set(that, 'bargainlist', res.data.slice(0, 2));
  561. })
  562. .catch(res => {
  563. console.log(res, 'getBargainList');
  564. });
  565. },
  566. Mask() {
  567. this.MaskShow = false;
  568. this.shareShow = true;
  569. uni.setStorage({
  570. key: 'FirstEntry',
  571. data: true,
  572. success: function() {
  573. console.log(uni.getStorageSync('FirstEntry'), 'Mask');
  574. }
  575. });
  576. },
  577. Toshare() {
  578. if (this.userInfo == '') {
  579. getUserInfo({})
  580. .then(({
  581. data
  582. }) => {
  583. this.setUserInfo(data);
  584. this.userInfo = data;
  585. })
  586. .catch(e => {});
  587. } else {
  588. this.shareShow = false;
  589. uni.navigateTo({
  590. url: '/pages/user/shareQrCode?spread=' + this.userInfo.uid
  591. });
  592. }
  593. },
  594. Tocancel() {
  595. this.shareShow = false;
  596. },
  597. // 监听切换事件
  598. listChange(e) {
  599. this.checkid = e.detail.current;
  600. },
  601. // 點擊搜索框
  602. clickSearch() {
  603. uni.navigateTo({
  604. url: '/pages/product/search'
  605. });
  606. },
  607. // 点击触发领取优惠券
  608. setCoupons(item) {
  609. // 判断是否已经领取了优惠券
  610. let obj = this;
  611. uni.showModal({
  612. title: '领取提示',
  613. content: '是否领取优惠券',
  614. success(e) {
  615. if (e.confirm) {
  616. setCoupons({
  617. couponId: item.id
  618. }).then(e => {
  619. item.is_use = true;
  620. uni.showToast({
  621. title: '领取成功',
  622. type: 'top',
  623. duration: 2000
  624. });
  625. });
  626. }
  627. }
  628. });
  629. },
  630. //商品种类切换
  631. change(item) {
  632. let id = item;
  633. this.checkid = id;
  634. if (this.checkid == 1) {
  635. // console.log(1);
  636. this.detail = this.selected_detail;
  637. } else if (this.checkid == 2) {
  638. // console.log(2);
  639. this.detail = this.new_product;
  640. } else {
  641. this.detail = this.cheap_good;
  642. }
  643. },
  644. // 监听图片加载完成
  645. onImageError(key, index) {
  646. this[key][index].image = '/static/error/errorImage.jpg';
  647. },
  648. // 请求载入数据
  649. async loadData() {
  650. loadIndexs({})
  651. .then(({
  652. data
  653. }) => {
  654. let goods = data.info;
  655. this.carouselList = data.banner;
  656. this.swiperLength = this.carouselList.length;
  657. this.menusList = data.menus;
  658. this.goodsList = goods.firstList; //最新商品
  659. this.bastList = goods.bastList; //精品推荐
  660. this.bastBanner = data.benefit; //促销单品
  661. this.$set(this, 'couponArray', data.couponList); //保存卡包券
  662. uni.stopPullDownRefresh();
  663. })
  664. .catch(e => {
  665. uni.stopPullDownRefresh();
  666. });
  667. },
  668. //轮播图切换修改背景色
  669. swiperChange(e) {
  670. const index = e.detail.current;
  671. this.swiperCurrent = index;
  672. this.titleNViewBackground = this.carouselList[index].background;
  673. },
  674. //详情页
  675. navToDetailPage(item) {
  676. let id = item.id;
  677. uni.navigateTo({
  678. url: '/pages/product/product?id=' + id
  679. });
  680. },
  681. // 轮播图跳转
  682. bannerNavToUrl(item) {
  683. // #ifdef H5
  684. if (item.wap_url.indexOf('http') > 0) {
  685. window.location.href = item.wap_url;
  686. }
  687. // #endif
  688. //测试数据没有写id,用title代替
  689. uni.navigateTo({
  690. url: item.wap_url
  691. });
  692. }
  693. }
  694. };
  695. </script>
  696. <style lang="scss">
  697. .Mask {
  698. width: 100%;
  699. height: 100vh;
  700. position: fixed;
  701. z-index: 99999;
  702. background-color: rgba(0, 0, 0, 0.7);
  703. top: 0;
  704. image {
  705. width: 100%;
  706. height: 100vh;
  707. }
  708. }
  709. // 热销商品
  710. .hot-goods {
  711. margin: 0 25rpx;
  712. padding: 5rpx 25rpx 30rpx 25rpx;
  713. background-color: #fff;
  714. border-radius: 10rpx;
  715. .hot-headers {
  716. margin: 25rpx 0;
  717. width: 100%;
  718. display: flex;
  719. .img {
  720. width: 32rpx;
  721. height: 32rpx;
  722. margin-right: 10rpx;
  723. }
  724. .hot-title {
  725. font-size: 30rpx;
  726. margin-right: 15rpx;
  727. }
  728. .more {
  729. line-height: 1;
  730. padding: 5rpx 10rpx 5rpx 15rpx;
  731. text-align: center;
  732. font-size: 20rpx;
  733. border-radius: 15rpx;
  734. color: #ffffff;
  735. background: linear-gradient(90deg, rgba(250, 52, 38, 1) 0%, rgba(249, 30, 83, 1) 100%);
  736. image {
  737. width: 20rpx;
  738. height: 20rpx;
  739. }
  740. }
  741. }
  742. .hot-lists {
  743. line-height: 1;
  744. display: flex;
  745. .hot-produce {
  746. width: 100%;
  747. height: 260rpx;
  748. border-top: 1px solid #f0f0f0;
  749. display: flex;
  750. padding-top: 28rpx;
  751. .produce-image {
  752. width: 200rpx;
  753. height: 200rpx;
  754. image {
  755. width: 200rpx;
  756. height: 200rpx;
  757. border: 1px solid #f0f0f0;
  758. }
  759. }
  760. .produce-content {
  761. // flex-direction: column;
  762. margin-left: 30rpx;
  763. height: 200rpx;
  764. position: relative;
  765. width: calc(100% - 200rpx - 30rpx);
  766. .produce-name {
  767. font-size: 28rpx;
  768. font-weight: bold;
  769. line-height: 35rpx;
  770. color: #343434;
  771. }
  772. .produce-info {
  773. font-size: 20rpx;
  774. margin-top: 25rpx;
  775. }
  776. .produce-price {
  777. display: flex;
  778. align-items: flex-end;
  779. color: #ff383e;
  780. font-size: 24rpx;
  781. margin-top: 70rpx;
  782. font-weight: bold;
  783. text {
  784. font-size: 36rpx;
  785. }
  786. .produce-price-1 {
  787. font-size: 22rpx;
  788. font-weight: 500;
  789. text-decoration: line-through;
  790. color: rgba(170, 170, 170, 1);
  791. margin-left: 20rpx;
  792. }
  793. }
  794. .produce-price1 {
  795. height: 100%;
  796. letter-spacing: 3rpx;
  797. color: #ff383e;
  798. font-size: 24rpx;
  799. font-weight: bold;
  800. .produce-center {
  801. width: 100%;
  802. position: absolute;
  803. bottom: 0;
  804. display: flex;
  805. justify-content: space-between;
  806. align-items: center;
  807. .kanjia_word {
  808. .word-1 {
  809. font-size: 22rpx;
  810. color: #666666;
  811. }
  812. .word-2 {
  813. font-size: 28rpx;
  814. color: #ff383e;
  815. margin-top: 10rpx;
  816. }
  817. }
  818. .kanjia_button {
  819. height: 50rpx;
  820. width: 150rpx;
  821. border-radius: 25rpx;
  822. font-size: 26rpx;
  823. font-weight: 500;
  824. color: #ff383e;
  825. border: 1px solid rgba(255, 56, 62, 1);
  826. }
  827. }
  828. }
  829. }
  830. }
  831. }
  832. }
  833. /* #ifdef MP */
  834. .mp-height {
  835. height: 44px;
  836. }
  837. .input-box {
  838. position: fixed;
  839. top: 0;
  840. left: 0;
  841. width: 100%;
  842. padding: 25rpx;
  843. background-color: #ffffff;
  844. z-index: 999;
  845. height: 44px;
  846. .iconsearch {
  847. font-size: 50rpx;
  848. }
  849. .input-content {
  850. border-radius: 99rpx;
  851. flex-grow: 1;
  852. padding: 10rpx 30rpx;
  853. background-color: rgba(231, 231, 231, 0.7);
  854. .input {
  855. flex-grow: 1;
  856. input {
  857. font-size: $font-lg;
  858. }
  859. }
  860. }
  861. .input-button {
  862. padding-left: 20rpx;
  863. font-size: $font-lg;
  864. height: 100%;
  865. }
  866. }
  867. page {
  868. .cate-section {
  869. position: relative;
  870. z-index: 5;
  871. border-radius: 16rpx 16rpx 0 0;
  872. margin-top: -20rpx;
  873. }
  874. .carousel-section {
  875. padding: 0;
  876. .titleNview-placing {
  877. padding-top: 0;
  878. height: 0;
  879. }
  880. .carousel {
  881. .carousel-item {
  882. padding: 0;
  883. }
  884. }
  885. .swiper-dots {
  886. left: 45rpx;
  887. bottom: 40rpx;
  888. }
  889. }
  890. }
  891. /* #endif */
  892. page {
  893. background: #f7f8f7;
  894. }
  895. .m-t {
  896. margin-top: 16rpx;
  897. }
  898. /* 头部 轮播图 */
  899. .carousel-section {
  900. position: relative;
  901. padding-top: 10px;
  902. overflow: hidden;
  903. .titleNview-placing {
  904. height: var(--status-bar-height);
  905. padding-top: 44px;
  906. box-sizing: content-box;
  907. }
  908. .titleNview-background {
  909. position: absolute;
  910. top: 0;
  911. left: 0;
  912. width: 100%;
  913. height: 426rpx;
  914. transition: 0.4s;
  915. }
  916. .carousel {
  917. width: 100%;
  918. height: 240rpx;
  919. .carousel-item {
  920. width: 100%;
  921. height: 100%;
  922. padding: 0 28rpx;
  923. overflow: hidden;
  924. }
  925. image {
  926. width: 100%;
  927. height: 100%;
  928. border-radius: $border-radius-sm;
  929. }
  930. }
  931. }
  932. .swiper-dots {
  933. display: flex;
  934. position: absolute;
  935. left: 60rpx;
  936. bottom: 15rpx;
  937. width: 72rpx;
  938. height: 36rpx;
  939. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAYAAADDhn8LAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTMyIDc5LjE1OTI4NCwgMjAxNi8wNC8xOS0xMzoxMzo0MCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6OTk4MzlBNjE0NjU1MTFFOUExNjRFQ0I3RTQ0NEExQjMiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OTk4MzlBNjA0NjU1MTFFOUExNjRFQ0I3RTQ0NEExQjMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6Q0E3RUNERkE0NjExMTFFOTg5NzI4MTM2Rjg0OUQwOEUiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6Q0E3RUNERkI0NjExMTFFOTg5NzI4MTM2Rjg0OUQwOEUiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4Gh5BPAAACTUlEQVR42uzcQW7jQAwFUdN306l1uWwNww5kqdsmm6/2MwtVCp8CosQtP9vg/2+/gY+DRAMBgqnjIp2PaCxCLLldpPARRIiFj1yBbMV+cHZh9PURRLQNhY8kgWyL/WDtwujjI8hoE8rKLqb5CDJaRMJHokC6yKgSCR9JAukmokIknCQJpLOIrJFwMsBJELFcKHwM9BFkLBMKFxNcBCHlQ+FhoocgpVwwnv0Xn30QBJGMC0QcaBVJiAMiec/dcwKuL4j1QMsVCXFAJE4s4NQA3K/8Y6DzO4g40P7UcmIBJxbEesCKWBDg8wWxHrAiFgT4fEGsB/CwIhYE+AeBAAdPLOcV8HRmWRDAiQVcO7GcV8CLM8uCAE4sQCDAlHcQ7x+ABQEEAggEEAggEEAggEAAgQACASAQQCCAQACBAAIBBAIIBBAIIBBAIABe4e9iAe/xd7EAJxYgEGDeO4j3EODp/cOCAE4sYMyJ5cwCHs4rCwI4sYBxJ5YzC84rCwKcXxArAuthQYDzC2JF0H49LAhwYUGsCFqvx5EF2T07dMaJBetx4cRyaqFtHJ8EIhK0i8OJBQxcECuCVutxJhCRoE0cZwMRyRcFefa/ffZBVPogePihhyCnbBhcfMFFEFM+DD4m+ghSlgmDkwlOgpAl4+BkkJMgZdk4+EgaSCcpVX7bmY9kgXQQU+1TgE0c+QJZUUz1b2T4SBbIKmJW+3iMj2SBVBWz+leVfCQLpIqYbp8b85EskIxyfIOfK5Sf+wiCRJEsllQ+oqEkQfBxmD8BBgA5hVjXyrBNUQAAAABJRU5ErkJggg==);
  940. background-size: 100% 100%;
  941. .num {
  942. width: 36rpx;
  943. height: 36rpx;
  944. border-radius: 50px;
  945. font-size: 24rpx;
  946. color: #fff;
  947. text-align: center;
  948. line-height: 36rpx;
  949. }
  950. .sign {
  951. position: absolute;
  952. top: 0;
  953. left: 50%;
  954. line-height: 36rpx;
  955. font-size: 12rpx;
  956. color: #fff;
  957. transform: translateX(-50%);
  958. }
  959. }
  960. /* 分类 */
  961. .cate-section {
  962. display: flex;
  963. justify-content: space-around;
  964. align-items: center;
  965. flex-wrap: wrap;
  966. padding: 30rpx 22rpx;
  967. .cate-item {
  968. display: flex;
  969. flex-direction: column;
  970. align-items: center;
  971. font-size: $font-sm + 2rpx;
  972. color: $font-color-dark;
  973. }
  974. /* 原图标颜色太深,不想改图了,所以加了透明度 */
  975. image {
  976. width: 88rpx;
  977. height: 88rpx;
  978. margin-bottom: 14rpx;
  979. border-radius: 50%;
  980. opacity: 0.7;
  981. }
  982. }
  983. // 中间广告图片
  984. .ad-1 {
  985. width: 100%;
  986. height: 210rpx;
  987. padding: 10rpx 0;
  988. background: #fff;
  989. image {
  990. width: 100%;
  991. height: 100%;
  992. }
  993. }
  994. /*公用边框样式*/
  995. %icon {
  996. margin-right: 10rpx;
  997. display: inline-block;
  998. padding: 2rpx 10rpx;
  999. border: 1rpx solid $color-yellow;
  1000. color: $color-yellow;
  1001. line-height: 1;
  1002. font-size: $font-base;
  1003. border-radius: 10rpx;
  1004. }
  1005. .f-header {
  1006. display: flex;
  1007. align-items: center;
  1008. height: 92rpx;
  1009. padding: 6rpx 30rpx 8rpx;
  1010. image {
  1011. flex-shrink: 0;
  1012. width: 80rpx;
  1013. height: 80rpx;
  1014. margin-right: 20rpx;
  1015. }
  1016. .tit-box {
  1017. @extend %font-title-box;
  1018. }
  1019. .tit {
  1020. @extend %font-title;
  1021. }
  1022. .iconenter {
  1023. font-size: $font-lg + 2rpx;
  1024. color: $font-color-light;
  1025. }
  1026. .f-left-icon {
  1027. @extend %f-left-icon;
  1028. }
  1029. .iconfont {
  1030. font-size: $font-sm - 2rpx;
  1031. }
  1032. }
  1033. // 会员升级礼包
  1034. .uservip {
  1035. border-radius: $border-radius-sm;
  1036. background-color: white;
  1037. box-shadow: $box-shadow;
  1038. height: 300rpx;
  1039. margin: 0 30rpx;
  1040. image {
  1041. height: 100%;
  1042. width: 300rpx;
  1043. }
  1044. .detail {
  1045. position: relative;
  1046. padding: 20rpx;
  1047. height: 100%;
  1048. .icon {
  1049. @extend %icon;
  1050. }
  1051. .price-box {
  1052. position: absolute;
  1053. bottom: 20rpx;
  1054. width: calc(100% - 40rpx);
  1055. .price {
  1056. font-size: $font-lg + 2rpx;
  1057. font-weight: bold;
  1058. color: $font-color-base;
  1059. }
  1060. .text {
  1061. color: $color-gray;
  1062. font-size: $font-sm;
  1063. }
  1064. }
  1065. .title {
  1066. font-size: $font-lg;
  1067. font-weight: bold;
  1068. }
  1069. }
  1070. }
  1071. /* 猜你喜欢 */
  1072. .guess-section {
  1073. display: flex;
  1074. flex-wrap: wrap;
  1075. padding: 0 30rpx;
  1076. .guess-item {
  1077. overflow: hidden;
  1078. display: flex;
  1079. flex-direction: column;
  1080. width: 48%;
  1081. margin-bottom: 4%;
  1082. border-radius: $border-radius-sm;
  1083. background-color: white;
  1084. box-shadow: $box-shadow;
  1085. &:nth-child(2n + 1) {
  1086. margin-right: 4%;
  1087. }
  1088. }
  1089. .image-wrapper {
  1090. width: 100%;
  1091. height: 330rpx;
  1092. border-radius: 3px;
  1093. overflow: hidden;
  1094. image {
  1095. width: 100%;
  1096. height: 100%;
  1097. opacity: 1;
  1098. }
  1099. }
  1100. .title {
  1101. font-size: $font-base;
  1102. color: $font-color-dark;
  1103. font-weight: bold;
  1104. line-height: 80rpx;
  1105. }
  1106. .price {
  1107. font-size: $font-lg;
  1108. color: $font-color-base;
  1109. font-weight: bold;
  1110. line-height: 1;
  1111. line-height: 80rpx;
  1112. }
  1113. .icon {
  1114. @extend %icon;
  1115. }
  1116. .detail {
  1117. line-height: 1;
  1118. }
  1119. .tip {
  1120. color: white;
  1121. background-color: $color-yellow;
  1122. line-height: 1.5;
  1123. font-size: $font-sm;
  1124. padding-left: 20rpx;
  1125. }
  1126. }
  1127. // 推荐
  1128. .recommend {
  1129. width: 95%;
  1130. height: 155rpx;
  1131. margin: 0rpx auto;
  1132. padding-top: 30rpx;
  1133. font-size: 26rpx;
  1134. text-align: center;
  1135. color: #333333;
  1136. align-items: flex-start;
  1137. .recommend_list {
  1138. width: 33%;
  1139. }
  1140. .re_title {
  1141. font-size: 32rpx;
  1142. font-weight: bold;
  1143. }
  1144. .re_name {
  1145. color: #999999;
  1146. padding-top: 10rpx;
  1147. }
  1148. .selected_icon {
  1149. width: 25rpx;
  1150. height: 10rpx;
  1151. margin: 0px auto;
  1152. display: none;
  1153. image {
  1154. width: 100%;
  1155. height: 100%;
  1156. }
  1157. }
  1158. .active {
  1159. display: block;
  1160. }
  1161. .active_color {
  1162. color: #dc4d46 !important;
  1163. }
  1164. }
  1165. // 列表
  1166. .list-box-h {
  1167. height: 1550rpx;
  1168. }
  1169. // 优惠券
  1170. .coupon-list {
  1171. display: inline-block;
  1172. }
  1173. .row {
  1174. border-radius: 15rpx;
  1175. margin: 25rpx;
  1176. height: 155rpx;
  1177. // width: 552rpx;
  1178. overflow: hidden;
  1179. background-color: #ffffff;
  1180. padding-right: 25rpx;
  1181. .list-interval {
  1182. border: 1px dashed $border-color-light;
  1183. height: 100%;
  1184. .top,
  1185. .bottom {
  1186. border-radius: 100rpx;
  1187. width: 30rpx;
  1188. height: 30rpx;
  1189. position: absolute;
  1190. background-color: $page-color-base;
  1191. right: -15rpx;
  1192. }
  1193. .top {
  1194. top: -18rpx;
  1195. }
  1196. .bottom {
  1197. bottom: -18rpx;
  1198. }
  1199. }
  1200. .list-money {
  1201. height: 100%;
  1202. min-width: 155rpx;
  1203. text-align: center;
  1204. image {
  1205. height: 100%;
  1206. width: 20rpx;
  1207. }
  1208. .list-money-text {
  1209. flex-grow: 1;
  1210. padding: 0 25rpx;
  1211. .tit {
  1212. text-align: center;
  1213. padding: 15rpx 0rpx;
  1214. font-size: 55rpx;
  1215. color: $color-red;
  1216. font-weight: bold;
  1217. &.noAction {
  1218. color: $font-color-light;
  1219. }
  1220. }
  1221. .price {
  1222. padding-bottom: 25rpx;
  1223. color: $font-color-light;
  1224. }
  1225. }
  1226. }
  1227. .row_list_right {
  1228. // flex-grow: 1;
  1229. min-width: 200rpx;
  1230. padding-left: 25rpx;
  1231. line-height: 1;
  1232. .right_time {
  1233. padding: 10rpx 0rpx;
  1234. color: $font-color-light;
  1235. font-size: $font-sm;
  1236. }
  1237. .right_top {
  1238. margin: 15rpx 0;
  1239. .right_name {
  1240. font-size: $font-base;
  1241. color: #bc253a;
  1242. font-weight: bold;
  1243. }
  1244. .right_title {
  1245. font-size: $font-base;
  1246. color: $font-base;
  1247. font-weight: bold;
  1248. &.noAction {
  1249. color: $font-color-light;
  1250. }
  1251. }
  1252. }
  1253. }
  1254. .right_use {
  1255. margin: 15rpx 0;
  1256. padding: 10rpx;
  1257. width: 160rpx;
  1258. text-align: center;
  1259. color: #fff;
  1260. background-color: #bc253a;
  1261. border-radius: 50rpx;
  1262. font-size: $font-sm;
  1263. &.noAction {
  1264. background-color: $font-color-light;
  1265. }
  1266. }
  1267. .iconlocation {
  1268. font-size: 36rpx;
  1269. color: $font-color-light;
  1270. }
  1271. }
  1272. </style>