index.vue 31 KB

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