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