index.vue 32 KB

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