index.vue 32 KB

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