index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <template>
  2. <view class="container">
  3. <view class="carousel-section">
  4. <!-- 背景色区域 -->
  5. <view class="bg"><image src="../../static/index/index1.png" mode=""></image></view>
  6. <!-- 标题栏和状态栏占位符 -->
  7. <view class="titleNview-placing"></view>
  8. </view>
  9. <image class="bg3" src="../../static/index/index3.png" mode=""></image>
  10. <view class="tongz flex">
  11. <view>
  12. <view class="tongz-bg"><image src="../../static/img/tongz-bg.png" mode=""></image></view>
  13. <view class="tongz-left flex">
  14. <image class="image-left" src="../../static/img/ling.png" mode=""></image>
  15. <u-notice-bar
  16. style="width: 100%;"
  17. mode="vertical"
  18. type="none"
  19. :volume-icon="false"
  20. :more-icon="true"
  21. :list="text"
  22. @click="goDetails"
  23. @getMore="navTo('/pages/index/jieshao')"
  24. ></u-notice-bar>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="main-box" v-if="integralList.length != 0">
  29. <view class="main-top">
  30. <image src="../../static/icon/indexI.png" mode="" class="main-icon"></image>
  31. <view class="main-title">阳光兑换</view>
  32. <view class="main-synopsis">超值体验</view>
  33. </view>
  34. <view class="main-content">
  35. <view class="content-top flex" @click="navTo('/pages/index/integral')">
  36. <view class="content-font">
  37. <view class="content-title">阳光兑换热门好物</view>
  38. <view class="content-synopsis">买到就是赚到</view>
  39. </view>
  40. <image src="../../static/icon/fanhui.png" class="go" mode=""></image>
  41. </view>
  42. <view class="commodity flex">
  43. <view class="commodity-item" v-for="(item, index) in integralList" :key="item.id" @click="navToDetailPagejf(item)">
  44. <image class="commodity-image" :src="item.image" mode=""></image>
  45. <view class="commodity-title clamp">{{ item.store_name }}</view>
  46. <view class="price clamp">{{ item.result.value[0].integral * 1 }}阳光+</view>
  47. <view class="vip-price">
  48. <text>¥{{ item.result.value[0].price }}</text>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="product-box" v-if="bastList.length != 0">
  55. <view class="product-title">
  56. <image class="pt-image" src="../../static/index/index15.png" mode=""></image>
  57. <view class="pt-title">热销商品</view>
  58. <view class="pt-tip">好货不用挑</view>
  59. </view>
  60. <view class="hotgoods">
  61. <view class="hotgoods-item" v-for="item in bastList" :key="item.id" @click="navToDetailPage(item)">
  62. <view class="image-wrapper">
  63. <image class="image-bg" src="../../static/img/libao-bg.png" mode=""></image>
  64. <image class="image" :src="item.image" mode="scaleToFill"></image>
  65. </view>
  66. <view class="title clamp2">{{ item.store_name }}</view>
  67. <view class="hot-price">
  68. <!-- <view class="hotPrice-box">会员价</view> -->
  69. <view class="price">
  70. <text class="font-size-sm">¥</text>
  71. {{ item.price * 1 }}
  72. </view>
  73. <view class="yuanPrice">{{ item.ot_price }}</view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 客服 -->
  79. <uni-popup ref="popupkf" type="center">
  80. <view class="popup-box">
  81. <view class="img"><image src="../../static/img/img009.png" mode=""></image></view>
  82. <view class="mian">
  83. <view class="delivery">
  84. <view class="title">已经为您定制专属客服</view>
  85. <image src="../../static/img/img010.png" mode=""></image>
  86. </view>
  87. <view class="nocancel">客服VX:{{ text }}</view>
  88. <view class="comfirm-box">
  89. <view class="cancel" @click="kfClose()">取消</view>
  90. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  91. </view>
  92. </view>
  93. </view>
  94. </uni-popup>
  95. </view>
  96. </template>
  97. <script>
  98. import { lookSubpoints, lookOneself } from '../../api/user.js';
  99. import seckill from '../../components/seckill/seckill.vue';
  100. import { loadIndexs } from '@/api/index.js';
  101. import { article } from '@/api/user.js';
  102. import { getUserInfo, spread } from '@/api/user.js';
  103. import { setCoupons } from '@/api/functionalUnit.js';
  104. import { getProducts } from '@/api/product.js';
  105. import { interceptor } from '@/utils/loginUtils';
  106. import { mapState, mapMutations } from 'vuex';
  107. // #ifdef H5
  108. import { weixindata, shareLoad } from '@/utils/wxAuthorized';
  109. // #endif
  110. import uniCopy from '@/js_sdk/xb-copy/uni-copy.js';
  111. export default {
  112. components: {
  113. seckill
  114. },
  115. data() {
  116. return {
  117. text: '',
  118. pageProportion: 0, //保存页面基于750宽度的比例
  119. swiperHeight: 0,
  120. checkid: 0,
  121. titleNViewBackground: '',
  122. longitude: 0, //经度
  123. latitude: 0, //纬度
  124. swiperCurrent: 0,
  125. swiperLength: 0,
  126. carouselList: [], //轮播列表
  127. bastList: [], //会员礼包
  128. integralList: [], //兑换专区
  129. page: 1,
  130. limit: 10,
  131. loadType: 'more',
  132. text: [],
  133. article: []
  134. };
  135. },
  136. computed: {
  137. ...mapState(['loginInterceptor', 'baseURL']),
  138. ...mapState('user', ['hasLogin', 'userInfo'])
  139. },
  140. onLoad: function(option) {
  141. // #ifdef MP
  142. if (option.scene) {
  143. // 存储小程序邀请人
  144. uni.setStorage({
  145. key: 'spread_code',
  146. data: option.scene
  147. });
  148. }
  149. // #endif
  150. },
  151. onShow: function() {
  152. // 判断是否强制登录
  153. // if (!this.hasLogin) {
  154. // // 登录拦截
  155. // interceptor();
  156. // }
  157. this.loadData();
  158. this.getproducts();
  159. },
  160. onReachBottom() {
  161. this.getproducts();
  162. },
  163. methods: {
  164. ...mapMutations(['setLat', 'setLon']),
  165. kfClose() {
  166. this.$refs.popupkf.close();
  167. },
  168. goDetails(e) {
  169. uni.navigateTo({
  170. url: '/pages/index/detail?id=' + this.article[e].id
  171. });
  172. },
  173. // 复制
  174. comfirm(text) {
  175. console.log(text);
  176. const result = uniCopy(text);
  177. if (result === false) {
  178. uni.showToast({
  179. title: '不支持'
  180. });
  181. } else {
  182. uni.showToast({
  183. title: '复制成功',
  184. icon: 'none'
  185. });
  186. }
  187. this.$refs.popupkp.close();
  188. },
  189. navTo(url) {
  190. if (url == '') {
  191. this.$api.msg('暂未开通,敬请期待');
  192. } else {
  193. uni.navigateTo({
  194. url,
  195. fail() {
  196. uni.switchTab({
  197. url
  198. });
  199. }
  200. });
  201. }
  202. },
  203. // 监听切换事件
  204. listChange(e) {
  205. this.checkid = e.detail.current;
  206. },
  207. //积分详情页
  208. navToDetailPagejf(item) {
  209. uni.navigateTo({
  210. url: '/pages/product/product?id=' + item.id + '&isJF=1'
  211. });
  212. },
  213. // 点击触发领取优惠券
  214. setCoupons(item) {
  215. // 判断是否已经领取了优惠券
  216. let obj = this;
  217. uni.showModal({
  218. title: '领取提示',
  219. content: '是否领取优惠券',
  220. success(e) {
  221. if (e.confirm) {
  222. setCoupons({
  223. couponId: item.id
  224. }).then(e => {
  225. item.is_use = true;
  226. uni.showToast({
  227. title: '领取成功',
  228. type: 'top',
  229. duration: 2000
  230. });
  231. });
  232. }
  233. }
  234. });
  235. },
  236. //商品种类切换
  237. change(item) {
  238. let id = item;
  239. this.checkid = id;
  240. if (this.checkid == 1) {
  241. // console.log(1);
  242. this.detail = this.selected_detail;
  243. } else if (this.checkid == 2) {
  244. // console.log(2);
  245. this.detail = this.new_product;
  246. } else {
  247. this.detail = this.cheap_good;
  248. }
  249. },
  250. // 监听图片加载完成
  251. onImageError(key, index) {
  252. this[key][index].image = '/static/error/errorImage.jpg';
  253. },
  254. // 请求载入数据
  255. async loadData() {
  256. this.text = [];
  257. this.article = [];
  258. loadIndexs({})
  259. .then(({ data }) => {
  260. let goods = data.info;
  261. this.carouselList = data.banner;
  262. console.log(this.carouselList, 'this.carouselList++++++++');
  263. this.swiperLength = this.carouselList.length;
  264. this.integralList = data.likeInfo; //兑换专区
  265. console.log(data.likeInfo, '123456');
  266. })
  267. .catch(e => {});
  268. article({}, 1).then(({ data }) => {
  269. data.forEach(e => {
  270. this.text.push(e.synopsis);
  271. });
  272. this.article = data;
  273. });
  274. },
  275. //轮播图切换修改背景色
  276. swiperChange(e) {
  277. const index = e.detail.current;
  278. this.swiperCurrent = index;
  279. this.titleNViewBackground = this.carouselList[index].background;
  280. },
  281. //详情页
  282. navToDetailPage(item) {
  283. let id = item.id;
  284. uni.navigateTo({
  285. url: '/pages/product/product?id=' + id + '&isVip=1'
  286. });
  287. },
  288. // 轮播图跳转
  289. bannerNavToUrl(item) {
  290. // #ifdef H5
  291. console.log(item.wap_url.indexOf('http'), 'banner');
  292. if (item.wap_url.indexOf('http') >= 0) {
  293. window.location.href = item.wap_url;
  294. }
  295. // #endif
  296. //测试数据没有写id,用title代替
  297. uni.navigateTo({
  298. url: item.wap_url
  299. });
  300. },
  301. getproducts() {
  302. const obj = this;
  303. if (obj.loadType == 'loading' || obj.loadType == 'nomore') {
  304. return;
  305. }
  306. obj.loadType = 'loading';
  307. getProducts({ page: obj.page, limit: obj.limit }).then(({ data }) => {
  308. obj.bastList = obj.bastList.concat(data);
  309. if (data.length == obj.limit) {
  310. obj.page++;
  311. obj.loadType = 'more';
  312. } else {
  313. obj.loadType = 'nomore';
  314. }
  315. });
  316. }
  317. }
  318. };
  319. </script>
  320. <style lang="scss">
  321. .carousel-section {
  322. position: relative;
  323. width: 750rpx;
  324. height: 1450rpx;
  325. .bg {
  326. position: absolute;
  327. top: 0;
  328. left: 0;
  329. width: 750rpx;
  330. height: 1450rpx;
  331. image {
  332. width: 100%;
  333. height: 100%;
  334. }
  335. }
  336. .titleNview-placing {
  337. height: var(--status-bar-height);
  338. box-sizing: content-box;
  339. }
  340. }
  341. .bg2 {
  342. margin-top: -60rpx;
  343. width: 750rpx;
  344. height: 250rpx;
  345. }
  346. .bg3 {
  347. margin-top: -20rpx;
  348. width: 750rpx;
  349. height: 750rpx;
  350. }
  351. .product-box {
  352. margin-top: 20rpx;
  353. background: #ffffff;
  354. padding: 26rpx 30rpx 20rpx;
  355. .product-title {
  356. display: flex;
  357. align-items: center;
  358. .pt-image {
  359. width: 26rpx;
  360. height: 34rpx;
  361. }
  362. .pt-title {
  363. margin-left: 8rpx;
  364. font-size: 36rpx;
  365. font-family: SourceHanSansCN;
  366. font-weight: bold;
  367. color: #666666;
  368. }
  369. .pt-tip {
  370. margin-left: 16rpx;
  371. font-size: 24rpx;
  372. font-family: SourceHanSansCN;
  373. font-weight: bold;
  374. color: #aaaaaa;
  375. }
  376. }
  377. .hotgoods {
  378. margin-top: 38rpx;
  379. width: 100%;
  380. display: flex;
  381. flex-wrap: wrap;
  382. padding: 0 0 30rpx;
  383. .hotgoods-item {
  384. width: 48%;
  385. background-color: #ffffff;
  386. border-radius: 12rpx;
  387. &:nth-child(2n + 1) {
  388. margin-right: 24rpx;
  389. }
  390. .image-wrapper {
  391. width: 100%;
  392. height: 330rpx;
  393. border-radius: 3px;
  394. overflow: hidden;
  395. position: relative;
  396. .image-bg {
  397. position: absolute;
  398. top: 0;
  399. left: 0;
  400. right: 0;
  401. bottom: 0;
  402. width: 100%;
  403. height: 100%;
  404. opacity: 1;
  405. border-radius: 12rpx 12rpx 0 0;
  406. z-index: 2;
  407. }
  408. .image {
  409. width: 100%;
  410. height: 100%;
  411. opacity: 1;
  412. border-radius: 12rpx 12rpx 0 0;
  413. }
  414. }
  415. .title {
  416. margin-top: 24rpx;
  417. font-size: 28rpx;
  418. font-family: PingFang SC;
  419. font-weight: 500;
  420. color: #333333;
  421. }
  422. .hot-price {
  423. display: flex;
  424. justify-content: flex-start;
  425. align-items: center;
  426. padding: 14rpx 0 30rpx;
  427. .hotPrice-box {
  428. padding: 2rpx 6rpx;
  429. background: linear-gradient(90deg, #c79a4c, #f9df7f);
  430. border-radius: 5rpx;
  431. text-align: center;
  432. line-height: 28rpx;
  433. font-size: 20rpx;
  434. font-family: Source Han Sans CN;
  435. font-weight: 400;
  436. color: #ffffff;
  437. }
  438. .price {
  439. margin-left: 10rpx;
  440. font-size: 40rpx;
  441. color: #ff0000;
  442. font-weight: 500;
  443. }
  444. .yuanPrice {
  445. margin-left: 10rpx;
  446. font-size: 20rpx;
  447. font-family: PingFang SC;
  448. font-weight: 500;
  449. text-decoration: line-through;
  450. color: #999999;
  451. }
  452. .cart-icon {
  453. image {
  454. width: 44rpx;
  455. height: 44rpx;
  456. }
  457. }
  458. }
  459. }
  460. }
  461. }
  462. .main-box {
  463. background-color: #ffffff;
  464. margin-top: 20rpx;
  465. padding: 22rpx 30rpx;
  466. .main-top {
  467. display: flex;
  468. justify-content: flex-start;
  469. align-items: center;
  470. .main-icon {
  471. width: 36rpx;
  472. height: 36rpx;
  473. }
  474. .main-title {
  475. margin-left: 8rpx;
  476. font-size: 32rpx;
  477. font-family: Source Han Sans CN;
  478. font-weight: 500;
  479. color: #333333;
  480. }
  481. .main-synopsis {
  482. margin-left: 16rpx;
  483. font-size: 20rpx;
  484. font-family: PingFang SC;
  485. font-weight: bold;
  486. color: #95a0b1;
  487. }
  488. }
  489. .main-content {
  490. width: 690rpx;
  491. background: #f4f4f4;
  492. border-radius: 12rpx;
  493. margin: 20rpx auto 0;
  494. padding-bottom: 10rpx;
  495. .xfq {
  496. background: linear-gradient(43deg, #ffc063, #ffa163) !important;
  497. }
  498. .content-top {
  499. width: 690rpx;
  500. background: linear-gradient(43deg, #73deb2, #52c696);
  501. border-radius: 12rpx 12rpx 0px 0px;
  502. padding: 24rpx 22rpx 68rpx 27rpx;
  503. .content-font {
  504. .content-title {
  505. font-size: 32rpx;
  506. font-family: Source Han Sans CN;
  507. font-weight: 500;
  508. color: #ffffff;
  509. }
  510. .content-synopsis {
  511. margin-top: 10rpx;
  512. font-size: 24rpx;
  513. font-family: Source Han Sans CN;
  514. font-weight: 400;
  515. color: #ffffff;
  516. }
  517. }
  518. .go {
  519. width: 30rpx;
  520. height: 35rpx;
  521. transform: rotate(180deg);
  522. -ms-transform: rotate(180deg); /* Internet Explorer */
  523. -moz-transform: rotate(180deg); /* Firefox */
  524. -webkit-transform: rotate(180deg); /* Safari 和 Chrome */
  525. -o-transform: rotate(180deg); /* Opera */
  526. }
  527. }
  528. }
  529. .commodity {
  530. width: 670rpx;
  531. background: #ffffff;
  532. border-radius: 8rpx;
  533. padding: 2rpx;
  534. margin: -50rpx auto 0;
  535. flex-wrap: wrap;
  536. justify-content: flex-start;
  537. .commodity-item {
  538. width: 33%;
  539. padding: 14rpx 30rpx 22rpx;
  540. .commodity-image {
  541. width: 160rpx;
  542. height: 160rpx;
  543. }
  544. .commodity-title {
  545. margin-top: 14rpx;
  546. width: 162rpx;
  547. font-size: 24rpx;
  548. font-family: PingFang SC;
  549. font-weight: bold;
  550. color: #3f3f3f;
  551. }
  552. .price {
  553. font-size: 24rpx;
  554. font-family: PingFang SC;
  555. font-weight: 500;
  556. color: #999999;
  557. }
  558. .vip-price {
  559. font-size: 30rpx;
  560. font-family: PingFang SC;
  561. font-weight: bold;
  562. color: #ff6f0f;
  563. image {
  564. position: relative;
  565. z-index: 10;
  566. width: 26rpx;
  567. height: 26rpx;
  568. }
  569. text {
  570. display: inline-block;
  571. margin-left: 6rpx;
  572. }
  573. }
  574. }
  575. }
  576. }
  577. .popup-box {
  578. width: 522rpx;
  579. height: 605rpx;
  580. background-color: #ffffff;
  581. border-radius: 20rpx;
  582. position: relative;
  583. .img {
  584. position: relative;
  585. top: -56rpx;
  586. left: 0;
  587. width: 522rpx;
  588. height: 132rpx;
  589. display: flex;
  590. justify-content: center;
  591. image {
  592. border-radius: 20rpx 20rpx 0 0;
  593. width: 450rpx;
  594. height: 132rpx;
  595. }
  596. }
  597. .mian {
  598. margin-top: -44rpx;
  599. display: flex;
  600. flex-direction: column;
  601. align-items: center;
  602. // padding: 32rpx 32rpx;
  603. background-color: #ffffff;
  604. border-radius: 0 0 20rpx 20rpx;
  605. text-align: center;
  606. .delivery {
  607. font-size: 40rpx;
  608. color: #333333;
  609. display: flex;
  610. align-items: center;
  611. flex-direction: column;
  612. .title {
  613. }
  614. image {
  615. margin-top: 48rpx;
  616. width: 172rpx;
  617. height: 160rpx;
  618. }
  619. }
  620. .nocancel {
  621. font-size: 32rpx;
  622. color: #333333;
  623. margin-top: 14rpx;
  624. }
  625. .comfirm-box {
  626. margin-top: 52rpx;
  627. display: flex;
  628. // margin-bottom: 32rpx;
  629. // justify-content: space-around;
  630. .cancel {
  631. display: flex;
  632. align-items: center;
  633. justify-content: center;
  634. width: 197rpx;
  635. height: 74rpx;
  636. border: 1px solid #dcc786;
  637. border-radius: 38rpx;
  638. font-size: 32rpx;
  639. color: #605128;
  640. }
  641. .comfirm {
  642. margin-left: 32rpx;
  643. display: flex;
  644. align-items: center;
  645. justify-content: center;
  646. width: 197rpx;
  647. height: 74rpx;
  648. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  649. border-radius: 38px;
  650. font-size: 32rpx;
  651. color: #605128;
  652. }
  653. }
  654. }
  655. }
  656. .tongz {
  657. width: 690rpx;
  658. height: 70rpx;
  659. margin: 32rpx auto 0;
  660. padding: 18rpx 30rpx 18rpx 24rpx;
  661. align-items: center;
  662. position: relative;
  663. .tongz-bg {
  664. position: absolute;
  665. top: 0;
  666. right: 0;
  667. left: 0;
  668. width: 690rpx;
  669. height: 70rpx;
  670. image {
  671. width: 100%;
  672. height: 100%;
  673. }
  674. }
  675. .tongz-left {
  676. width: 640rpx;
  677. .image-left {
  678. width: 28rpx;
  679. height: 34rpx;
  680. }
  681. .tongz-font {
  682. margin-left: 22rpx;
  683. font-size: 28rpx;
  684. font-family: Source Han Sans CN;
  685. font-weight: 400;
  686. color: #0f253a;
  687. }
  688. }
  689. .tongz-right {
  690. position: relative;
  691. z-index: 11;
  692. width: 12rpx;
  693. height: 26rpx;
  694. image {
  695. width: 100%;
  696. height: 100%;
  697. }
  698. }
  699. }
  700. </style>