index.vue 32 KB

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