index.vue 31 KB

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