index.vue 33 KB

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