index.vue 32 KB

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