index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. <template>
  2. <view class="container">
  3. <!-- 顶部logo and 搜索 start-->
  4. <view class="index-top-wrap">
  5. <image src="../../static/index/index-top.png" mode="widthFix" class="index-top"></image>
  6. <view class="status_bar fud"></view>
  7. <view class="top-search flex fud">
  8. <view class="search-box flex" @click="clickSearch()">
  9. <image class="search" src="../../static/icon/search-h.png" mode=""></image>
  10. <view class="search-font">输入关键词搜索</view>
  11. </view>
  12. </view>
  13. <!-- 顶部logo and 搜索 end-->
  14. <!-- <view class="jg fud" style="background-color: #fff;"></view> -->
  15. <!-- 轮播图 start -->
  16. <swiper class="top-swiper fud" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  17. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  18. @click="bannerNavToUrl(item)">
  19. <image :src="item.pic" />
  20. </swiper-item>
  21. </swiper>
  22. <!-- 轮播图 end -->
  23. </view>
  24. <!-- 顶部logo and 搜索 end-->
  25. <view class="jg" style="background-color: #fff;"></view>
  26. <!-- <view class="swiper-btm flex">
  27. <view class="btm-item flex">
  28. <image src="../../static/icon/index-gou.png" mode=""></image>
  29. <view class="">自用购物返利</view>
  30. </view>
  31. <view class="btm-item flex">
  32. <image src="../../static/icon/index-gou.png" mode=""></image>
  33. <view class="">分享好友赚钱</view>
  34. </view>
  35. <view class="btm-item flex">
  36. <image src="../../static/icon/index-gou.png" mode=""></image>
  37. <view class="">超值正品优惠</view>
  38. </view>
  39. </view> -->
  40. <!-- 分类 start -->
  41. <view class="cate-section flex">
  42. <view class="cate-item flex" @click="navto('/pages/category/category')" >
  43. <view class="img-wrapper flex">
  44. <image src="../../static/icon/in1.png" mode=""></image>
  45. </view>
  46. <view class="item-title">全部商品</view>
  47. </view>
  48. <view class="cate-item flex" @click="navto('/pages/user/team')">
  49. <view class="img-wrapper flex">
  50. <image src="../../static/icon/in2.png" mode=""></image>
  51. </view>
  52. <view class="item-title">我的团队</view>
  53. </view>
  54. <view class="cate-item flex" @click="openKf">
  55. <view class="img-wrapper flex">
  56. <image src="../../static/icon/in3.png" mode=""></image>
  57. </view>
  58. <view class="item-title">联系客服</view>
  59. </view>
  60. <view class="cate-item flex" @click="navto('/pages/user/shareQrCode',1)">
  61. <view class="img-wrapper flex">
  62. <image src="../../static/icon/in4.png" mode=""></image>
  63. </view>
  64. <view class="item-title">邀请好友</view>
  65. </view>
  66. </view>
  67. <!-- 分类 ed -->
  68. <!-- 商品列表 start -->
  69. <view class="product-box" v-if="navList.bd.list.length > 0">
  70. <view class="product-tit flex">
  71. <view class="hx"></view>
  72. <view class="tit">爆单专区</view>
  73. <view class="hx"></view>
  74. </view>
  75. <view class="hotgoods">
  76. <view class="hotgoods-item" v-for="bditem in navList.bd.list" :key="bditem.id"
  77. @click="navto('/pages/product/product?id=' + bditem.id + '&isbd=1')" style="height: 520rpx;">
  78. <view class="image-wrapper">
  79. <image class="image" :src="bditem.image" mode="scaleToFill"></image>
  80. </view>
  81. <view class="flex" style="flex-direction: column;justify-content: space-between;align-items: flex-start;height: 170rpx;">
  82. <view class="title clamp2">{{bditem.store_name}}</view>
  83. <view class="hot-price">
  84. <view class="price">
  85. <text class="font-size-sm"></text>
  86. <text>¥{{ bditem.price * 1 }}</text>
  87. <text class="give-jf">赠{{bditem.give_integral*1}}积分</text>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. <!-- 商品列表 ed-->
  95. <view class="jg" style="background-color: #f5f5f5;height: 20rpx;" v-if="navList.jf.list.length > 0">
  96. </view>
  97. <!-- 商品列表 start -->
  98. <view class="product-box" v-if="navList.jf.list.length > 0">
  99. <view class="product-tit flex">
  100. <view class="hx"></view>
  101. <view class="tit">积分兑换</view>
  102. <view class="hx"></view>
  103. </view>
  104. <view class="hotgoods">
  105. <view class="hotgoods-item" v-for="jfitem in navList.jf.list" :key="jfitem.id"
  106. @click="navto('/pages/product/product?id=' + jfitem.id + '&isjf=1')" style="height: 520rpx;">
  107. <view class="image-wrapper">
  108. <image class="image" :src="jfitem.image" mode="scaleToFill"></image>
  109. </view>
  110. <view class="flex" style="flex-direction: column;justify-content: space-between;align-items: flex-start;height: 170rpx;">
  111. <view class="title clamp2">{{jfitem.store_name}}</view>
  112. <view class="hot-price">
  113. <view class="price">
  114. <text class="font-size-sm"></text>
  115. <text>¥{{ jfitem.price * 1 }}</text>
  116. <!-- <text class="give-jf">赠2000积分</text> -->
  117. <text class="ot-pirce" v-if="jfitem.ot_price*1 > jfitem.price*1">¥{{ jfitem.ot_price*1 }}</text>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <!-- 商品列表 ed-->
  125. <uni-popup ref="popupkf" type="center">
  126. <view class="popup-box">
  127. <view class="img">
  128. <image src="../../static/img/img009.png" mode=""></image>
  129. </view>
  130. <view class="mian">
  131. <view class="delivery">
  132. <view class="title">已经为您定制专属客服</view>
  133. <image src="../../static/img/img010.png" mode=""></image>
  134. </view>
  135. <view class="nocancel">客服VX:{{ text }}</view>
  136. <view class="comfirm-box">
  137. <view class="cancel" @click="cancel">取消</view>
  138. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  139. </view>
  140. </view>
  141. </view>
  142. </uni-popup>
  143. </view>
  144. </template>
  145. <script>
  146. import {
  147. loadIndexs,
  148. groom1
  149. } from '@/api/index.js';
  150. import {
  151. getUserInfo,
  152. spread
  153. } from '@/api/user.js';
  154. import {
  155. getBargainList,
  156. getProducts,
  157. goodsDetail,
  158. poster
  159. } from '@/api/product.js';
  160. import {
  161. saveUrl,
  162. interceptor
  163. } from '@/utils/loginUtils';
  164. import {
  165. mapState,
  166. mapMutations
  167. } from 'vuex';
  168. // #ifdef H5
  169. import {
  170. weixindata,
  171. shareLoad
  172. } from '@/utils/wxAuthorized';
  173. // #endif
  174. export default {
  175. data() {
  176. return {
  177. text: '', //客服微信
  178. page: 1,
  179. limitt: 20,
  180. loadingType: 'more',
  181. current: 0,
  182. shareShow: false, //分享海报
  183. pageProportion: 0, //保存页面基于750宽度的比例
  184. swiperHeight: 0,
  185. checkid: 0,
  186. titleNViewBackground: '',
  187. swiperCurrent: 0,
  188. swiperLength: 0,
  189. carouselList: [], //轮播列表
  190. page: 1,
  191. limit: 5,
  192. firstList: [],
  193. goodList: [], //商品列表
  194. shopList: [],
  195. shareImage: '',
  196. navList:{
  197. bd: {
  198. page: 1,
  199. limit: 10,
  200. loaded: false,
  201. loadingType: 'more',
  202. list: [],
  203. status: 1
  204. },
  205. jf: {
  206. page: 1,
  207. limit: 10,
  208. loaded: false,
  209. loadingType: 'more',
  210. list: [],
  211. status: 3
  212. }
  213. }
  214. };
  215. },
  216. computed: {
  217. ...mapState('user', ['hasLogin', 'userInfo'])
  218. },
  219. onReachBottom() {
  220. },
  221. onLoad: function(option) {
  222. // #ifdef MP
  223. if (option.scene) {
  224. // 存储小程序邀请人
  225. uni.setStorage({
  226. key: 'spread_code',
  227. data: option.scene
  228. });
  229. }
  230. // #endif
  231. },
  232. onShow: function() {
  233. this.getGoodList()
  234. this.getGoodList(2)
  235. this.loadData();
  236. this.groom1()
  237. },
  238. methods: {
  239. //获取复购商品
  240. groom1() {
  241. groom1().then(res => {
  242. console.log(res)
  243. this.fgList = res.data.list
  244. })
  245. },
  246. getGoodList(type=1) {
  247. let that = this;
  248. let item ;
  249. if(type == 1) {
  250. item = that.navList.bd
  251. }else {
  252. item = that.navList.jf
  253. }
  254. if(item.loadingType == 'loading' || item.loadingType == 'nomore') {
  255. return
  256. }
  257. item.loadingType = 'loading'
  258. getProducts({
  259. cid: item.status,
  260. page: item.page,
  261. limit: item.limit
  262. }).then(res => {
  263. item.list = item.list.concat(res.data)
  264. // if(item.limit == res.data) {
  265. // item.loadingType = 'more'
  266. // }else {
  267. // item.loadingType = 'nomore'
  268. // }
  269. })
  270. },
  271. navto(url, type = 0) {
  272. if (type == 1) {
  273. if (!this.hasLogin) {
  274. // 保存地址
  275. saveUrl();
  276. // 登录拦截
  277. interceptor();
  278. } else {
  279. uni.navigateTo({
  280. url,
  281. fail() {
  282. uni.switchTab({
  283. url
  284. })
  285. }
  286. })
  287. }
  288. } else {
  289. uni.navigateTo({
  290. url,
  291. fail() {
  292. uni.switchTab({
  293. url
  294. })
  295. }
  296. })
  297. }
  298. },
  299. navTo(url) {
  300. if (url == '') {
  301. this.$api.msg('暂未开通,敬请期待');
  302. } else {
  303. this.navto(url)
  304. }
  305. },
  306. // 點擊搜索框
  307. clickSearch() {
  308. uni.navigateTo({
  309. url: '/pages/product/search'
  310. });
  311. },
  312. // 监听图片加载完成
  313. onImageError(key, index) {
  314. this[key][index].image = '/static/error/errorImage.jpg';
  315. },
  316. // 请求载入数据
  317. async loadData() {
  318. loadIndexs({})
  319. .then(({
  320. data
  321. }) => {
  322. let goods = data.info;
  323. console.log(goods, '商品信息');
  324. this.carouselList = data.banner;
  325. this.swiperLength = this.carouselList.length;
  326. this.bastList = data.giftInfo; //会员礼包
  327. data.info.firstList.forEach(e => {
  328. e.isVip = e.store_type ? "3" : "0"
  329. })
  330. this.firstList = data.info.firstList //首页商品
  331. uni.stopPullDownRefresh();
  332. })
  333. .catch(e => {
  334. uni.stopPullDownRefresh();
  335. });
  336. },
  337. //轮播图切换修改背景色
  338. swiperChange(e) {
  339. const index = e.detail.current;
  340. this.swiperCurrent = index;
  341. this.titleNViewBackground = this.carouselList[index].background;
  342. },
  343. // 轮播图跳转
  344. bannerNavToUrl(item) {
  345. // #ifdef H5
  346. console.log(item.wap_url.indexOf('http'), 'banner');
  347. if (item.wap_url.indexOf('http') >= 0) {
  348. window.location.href = item.wap_url;
  349. }
  350. // #endif
  351. //测试数据没有写id,用title代替
  352. uni.navigateTo({
  353. url: item.wap_url
  354. });
  355. },
  356. comfirm(text) {
  357. console.log(text);
  358. const result = this.uniCopy(text);
  359. if (result === false) {
  360. uni.showToast({
  361. title: '不支持'
  362. });
  363. } else {
  364. uni.showToast({
  365. title: '复制成功',
  366. icon: 'none'
  367. });
  368. }
  369. this.$refs.popupkf.close();
  370. },
  371. uniCopy(content) {
  372. /**
  373. * 小程序端 和 app端的复制逻辑
  374. */
  375. //#ifndef H5
  376. uni.setClipboardData({
  377. data: content,
  378. success: function() {
  379. console.log('success');
  380. return true;
  381. }
  382. });
  383. //#endif
  384. /**
  385. * H5端的复制逻辑
  386. */
  387. // #ifdef H5
  388. if (!document.queryCommandSupported('copy')) {
  389. //为了兼容有些浏览器 queryCommandSupported 的判断
  390. // 不支持
  391. return false;
  392. }
  393. let textarea = document.createElement('textarea');
  394. textarea.value = content;
  395. textarea.readOnly = 'readOnly';
  396. document.body.appendChild(textarea);
  397. textarea.select(); // 选择对象
  398. textarea.setSelectionRange(0, content.length); //核心
  399. let result = document.execCommand('copy'); // 执行浏览器复制命令
  400. textarea.remove();
  401. return result;
  402. // #endif
  403. },
  404. // 打开客服
  405. openKf() {
  406. this.$refs.popupkf.open();
  407. },
  408. // 关闭客服
  409. cancel() {
  410. this.$refs.popupkf.close();
  411. },
  412. }
  413. };
  414. </script>
  415. <style lang="scss">
  416. page {
  417. background: #ffff;
  418. min-height: 100%;
  419. height: auto;
  420. }
  421. // 顶部搜索
  422. .top-search {
  423. height: 80rpx;
  424. padding: 0 20rpx;
  425. margin-bottom: 20rpx;
  426. // background-color: #fff;
  427. .top-logo {
  428. width: 50rpx;
  429. // height: 50rpx;
  430. margin-right: 10rpx;
  431. image {
  432. width: 48rpx;
  433. }
  434. }
  435. .search-box {
  436. justify-content: center;
  437. width: 698rpx;
  438. height: 60rpx;
  439. background: #EEEEEE;
  440. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  441. border-radius: 30rpx;
  442. .search {
  443. width: 34rpx;
  444. height: 34rpx;
  445. }
  446. .search-font {
  447. margin-left: 14rpx;
  448. font-size: 28rpx;
  449. font-family: PingFang SC;
  450. font-weight: 500;
  451. color: #CBCBCB;
  452. }
  453. }
  454. }
  455. // 顶部轮播图
  456. .top-swiper {
  457. width: 690rpx;
  458. height: 365rpx;
  459. // margin: 20rpx 0 0;
  460. border-radius: 20rpx;
  461. margin: auto;
  462. image {
  463. width: 690rpx;
  464. height: 365rpx;
  465. border-radius: 20rpx;
  466. }
  467. }
  468. .swiper-btm {
  469. height: 60rpx;
  470. width: 750rpx;
  471. background-color: #fff;
  472. margin-bottom: 20rpx;
  473. font-size: 26rpx;
  474. font-weight: 500;
  475. color: #333333;
  476. .btm-item {
  477. flex-grow: 1;
  478. justify-content: center;
  479. image {
  480. width: 25rpx;
  481. height: 25rpx;
  482. margin-right: 14rpx;
  483. }
  484. }
  485. }
  486. .jg {
  487. height: 20rpx;
  488. background: #F8F8F8;
  489. }
  490. // 分类
  491. .cate-section {
  492. justify-content: space-around;
  493. background-color: #fff;
  494. padding: 0rpx 0 30rpx;
  495. .cate-item {
  496. flex-grow: 0;
  497. width: 20%;
  498. flex-direction: column;
  499. text-align: center;
  500. align-items: center;
  501. justify-content: center;
  502. .img-wrapper {
  503. width: 100rpx;
  504. height: 100rpx;
  505. border-radius: 20rpx;
  506. position: relative;
  507. image {
  508. width: 100rpx;
  509. height: 100rpx;
  510. position: absolute;
  511. left: 50%;
  512. top: 50%;
  513. transform: translate(-50%, -50%);
  514. }
  515. }
  516. .item-title {
  517. margin-top: 15rpx;
  518. font-size: 24rpx;
  519. font-weight: 500;
  520. color: #3F3F3F;
  521. }
  522. }
  523. }
  524. .product-box {
  525. margin-top: 20rpx;
  526. background: #ffffff;
  527. padding: 26rpx 0 20rpx;
  528. .product-tit {
  529. justify-content: center;
  530. image {
  531. width: 609rpx;
  532. height: 31rpx;
  533. }
  534. .hx {
  535. width: 120rpx;
  536. height: 1rpx;
  537. background: #363636;
  538. color: #363636;
  539. line-height: 28px;
  540. }
  541. .tit {
  542. margin: 0 70rpx;
  543. font-size: 32rpx;
  544. font-weight: 500;
  545. color: #363636;
  546. }
  547. }
  548. .in-ban {
  549. margin-top: 40rpx;
  550. width: 750rpx;
  551. height: 220rpx;
  552. }
  553. }
  554. .hotgoods {
  555. margin-top: 38rpx;
  556. width: 100%;
  557. display: flex;
  558. flex-wrap: wrap;
  559. padding: 0 20rpx 30rpx;
  560. justify-content: space-between;
  561. .hotgoods-item {
  562. width: 345rpx;
  563. background-color: #ffffff;
  564. border-radius: 12rpx;
  565. box-shadow: 0 0 15rpx rgba(0, 0, 0, 0.2);
  566. margin-bottom: 15rpx;
  567. .image-wrapper {
  568. width: 345rpx;
  569. height: 345rpx;
  570. border-radius: 3px;
  571. overflow: hidden;
  572. position: relative;
  573. .image-bg {
  574. position: absolute;
  575. top: 0;
  576. left: 0;
  577. right: 0;
  578. bottom: 0;
  579. width: 100%;
  580. height: 100%;
  581. opacity: 1;
  582. border-radius: 12rpx 12rpx 0 0;
  583. z-index: 2;
  584. }
  585. .image {
  586. width: 100%;
  587. height: 100%;
  588. opacity: 1;
  589. border-radius: 12rpx 12rpx 0 0;
  590. }
  591. }
  592. .title {
  593. margin-top: 24rpx;
  594. padding: 0 20rpx;
  595. font-size: 32rpx;
  596. font-weight: 500;
  597. color: #333333;
  598. }
  599. .hot-price {
  600. display: flex;
  601. justify-content: flex-start;
  602. align-items: center;
  603. // padding: 14rpx 0 30rpx;
  604. .hotPrice-box {
  605. padding: 2rpx 6rpx;
  606. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  607. border-radius: 5rpx;
  608. text-align: center;
  609. line-height: 28rpx;
  610. font-size: 20rpx;
  611. font-family: Source Han Sans CN;
  612. font-weight: 400;
  613. color: #ffffff;
  614. }
  615. .price {
  616. margin-left: 10rpx;
  617. font-size: 36rpx;
  618. color: #ff0000;
  619. font-weight: 500;
  620. display: flex;
  621. justify-content: flex-start;
  622. align-items: center;
  623. .jf {
  624. font-size: 20rpx;
  625. }
  626. .give-jf {
  627. display: inline-block;
  628. padding: 8rpx;
  629. background: linear-gradient(90deg, #FF834D, #FF2600);
  630. border-radius: 12rpx 0px 12rpx 0px;
  631. font-size: 22rpx;
  632. font-weight: 500;
  633. color: #FFFFFF;
  634. margin-left: 22rpx;
  635. }
  636. .ot-pirce {
  637. margin-left: 7rpx;
  638. font-size: 26rpx;
  639. font-weight: 500;
  640. text-decoration: line-through;
  641. color: #999999;
  642. align-self: flex-end;
  643. }
  644. }
  645. .yuanPrice {
  646. margin-left: 10rpx;
  647. font-size: 20rpx;
  648. font-family: PingFang SC;
  649. font-weight: 500;
  650. text-decoration: line-through;
  651. color: #999999;
  652. }
  653. .cart-icon {
  654. image {
  655. width: 44rpx;
  656. height: 44rpx;
  657. }
  658. }
  659. }
  660. }
  661. }
  662. .popup-box {
  663. width: 522rpx;
  664. height: 605rpx;
  665. background-color: #ffffff;
  666. border-radius: 20rpx;
  667. position: relative;
  668. .img {
  669. position: relative;
  670. top: -56rpx;
  671. left: 0;
  672. width: 522rpx;
  673. height: 132rpx;
  674. display: flex;
  675. justify-content: center;
  676. image {
  677. border-radius: 20rpx 20rpx 0 0;
  678. width: 450rpx;
  679. height: 132rpx;
  680. }
  681. }
  682. .mian {
  683. margin-top: -44rpx;
  684. display: flex;
  685. flex-direction: column;
  686. align-items: center;
  687. // padding: 32rpx 32rpx;
  688. background-color: #ffffff;
  689. border-radius: 0 0 20rpx 20rpx;
  690. text-align: center;
  691. .delivery {
  692. font-size: 40rpx;
  693. color: #333333;
  694. display: flex;
  695. align-items: center;
  696. flex-direction: column;
  697. image {
  698. margin-top: 48rpx;
  699. width: 172rpx;
  700. height: 160rpx;
  701. }
  702. }
  703. .nocancel {
  704. font-size: 32rpx;
  705. color: #333333;
  706. margin-top: 14rpx;
  707. }
  708. .comfirm-box {
  709. margin-top: 52rpx;
  710. display: flex;
  711. // margin-bottom: 32rpx;
  712. // justify-content: space-around;
  713. .cancel {
  714. display: flex;
  715. align-items: center;
  716. justify-content: center;
  717. width: 197rpx;
  718. height: 74rpx;
  719. border: 1px solid #dcc786;
  720. border-radius: 38rpx;
  721. font-size: 32rpx;
  722. color: #605128;
  723. }
  724. .comfirm {
  725. margin-left: 32rpx;
  726. display: flex;
  727. align-items: center;
  728. justify-content: center;
  729. width: 197rpx;
  730. height: 74rpx;
  731. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  732. border-radius: 38px;
  733. font-size: 32rpx;
  734. color: #605128;
  735. }
  736. }
  737. }
  738. }
  739. .index-top-wrap {
  740. position: relative;
  741. .index-top {
  742. width: 750rpx;
  743. position: absolute;
  744. }
  745. .fud {
  746. position: relative;
  747. }
  748. }
  749. </style>