index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <!-- #ifdef APP-PLUS -->
  5. <view class="status_bar"><!-- 这里是状态栏 --></view>
  6. <!-- #endif -->
  7. <view class="top-bg"><image src="../../static/img/index-bg.png" mode=""></image></view>
  8. </view>
  9. <view class="carousel">
  10. <swiper autoplay="true" duration="400" interval="5000" @change="swiperChange" class="bor">
  11. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"><image :src="item.pic" /></swiper-item>
  12. </swiper>
  13. </view>
  14. <view class="swiper-dot">
  15. <template v-for="item in swiperLength">
  16. <view class="swiper-dots-item" :key="item" :class="{ action: swiperCurrent + 1 === item }"></view>
  17. </template>
  18. </view>
  19. <view class="main">
  20. <view class="main-item" v-for="(item, index) in main" :key="index" @click="nav(item.url)">
  21. <view class="pic"><image :src="item.pic" mode=""></image></view>
  22. <view class="main-name">{{ item.name }}</view>
  23. </view>
  24. </view>
  25. <!-- 商品栏 -->
  26. <view class="commodity" v-if="vipList.length > 0">
  27. <view class="title">
  28. <view class="left">
  29. <image src="../../static/img/index-vip.png" mode=""></image>
  30. <view class="font">
  31. 会员福利
  32. </view>
  33. </view>
  34. <view class="right" @click="nav('/pages/index/recommend?type=4')">
  35. <view class="right-font">
  36. 更多
  37. </view>
  38. <image src="../../static/img/jiantou.png" mode=""></image>
  39. </view>
  40. </view>
  41. <view class="commodity-item" v-for="(item, index) in vipList" @click="navToDetailPages(item)">
  42. <view class="commodity-prc">
  43. <image :src="item.image" mode=""></image>
  44. <!-- <view class="fanli" v-if="item.type == 1">
  45. <view class="fanli-bg"><image src="../../static/img/index-fanl.png" mode=""></image></view>
  46. <view class="fanli-font flex">
  47. <view class="font-left">购物最高可返消费金额的</view>
  48. <view class="font-right">10<text>%</text></view>
  49. </view>
  50. </view> -->
  51. </view>
  52. <view class="commodity-info">
  53. <view class="commodity-name clamp">{{ item.store_name }}</view>
  54. <view class="commodity-systom clamp">{{ item.systom }}</view>
  55. <view class="commodity-price">
  56. ¥{{ item.price }}
  57. <text>¥{{ item.ot_price }}</text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="commodity" v-if="commodityList.length > 0">
  63. <view class="title">
  64. <view class="left">
  65. <image src="../../static/img/index-good.png" mode=""></image>
  66. <view class="font">
  67. 精选好货
  68. </view>
  69. </view>
  70. <view class="right" @click="nav('/pages/index/recommend?type=2')">
  71. <view class="right-font">
  72. 更多
  73. </view>
  74. <image src="../../static/img/jiantou.png" mode=""></image>
  75. </view>
  76. </view>
  77. <view class="commodity-item" v-for="(item, index) in commodityList" @click="navToDetailPages(item)">
  78. <view class="commodity-prc">
  79. <image :src="item.image" mode=""></image>
  80. <view class="fanli" v-if="item.type == 1">
  81. <view class="fanli-bg"><image src="../../static/img/index-fanl.png" mode=""></image></view>
  82. <!-- <view class="fanli-font flex">
  83. <view class="font-left">购物最高可返消费金额的</view>
  84. <view class="font-right">10<text>%</text></view>
  85. </view> -->
  86. </view>
  87. </view>
  88. <view class="commodity-info">
  89. <view class="commodity-name clamp">{{ item.store_name }}</view>
  90. <view class="commodity-systom clamp">{{ item.systom }}</view>
  91. <view class="commodity-price">
  92. ¥{{ item.price }}
  93. <text>¥{{ item.ot_price }}</text>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 兑换专区 -->
  99. <view class="recommend-box" v-for="(item,index) in list" v-if="item.children.length != 0">
  100. <view class="f-header">
  101. <view class="f-left-icon">{{ item.name }}兑换专区</view>
  102. <view class="tit-box"><text class="tit">超级好物 立即抢购</text></view>
  103. <view @click="navto(item)"><text class="iconfont iconenter">更多</text></view>
  104. </view>
  105. <view class="guess-section">
  106. <view v-for="(ls, ind) in item.children" :key="ls.id" class="guess-item" @click="navToDetailPage(ls)">
  107. <view class="image-wrapper"><image :src="item.image" mode="scaleToFill"></image></view>
  108. <view class="info-wrapper">
  109. <text class="title">{{ ls.title }}</text>
  110. <view class="price-box">
  111. <view class="price-left">
  112. <view class="price">
  113. <view class="">{{ ls.money * 1 }}</view>
  114. <view class="ot_price">
  115. <view class="price-tip">{{ ls.money_type }}</view>
  116. <view class="price-tip" v-if="ls.price != 0">+¥{{ ls.price }}</view>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="price-right">
  121. <view class="buyNow">马上购</view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </template>
  130. <script>
  131. import { getTime } from '@/utils/rocessor.js';
  132. import { loadIndexs, dhList } from '@/api/user.js';
  133. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  134. import { mapState, mapMutations } from 'vuex';
  135. import { wallet } from '@/api/finance.js';
  136. // #ifdef H5
  137. import { weixindata, weixinlocation,shareLoad } from '@/utils/wxAuthorized';
  138. import weixinObj from "@/plugin/jweixin-module/index.js";
  139. // #endif
  140. export default {
  141. computed: {
  142. ...mapState('user', ['userInfo' , 'hasLogin', 'urlFile']),
  143. ...mapState(['baseURL']),
  144. },
  145. data() {
  146. return {
  147. carouselList: [],
  148. main: [
  149. // {
  150. // name: '自动拼团',
  151. // pic: '../../static/icon/index1.png',
  152. // url: '/pages/index/appointment'
  153. // },
  154. // {
  155. // name: '11人团专区',
  156. // pic: '../../static/icon/index2.png',
  157. // url: '/pages/product/ping'
  158. // },
  159. {
  160. name: '拼团合伙人',
  161. pic: '../../static/icon/index3.png',
  162. url: '/pages/index/node'
  163. },
  164. {
  165. name: '货款充值',
  166. pic: '../../static/icon/index4.png',
  167. url: '/pages/money/huodai'
  168. },
  169. {
  170. name: '邀请有礼',
  171. pic: '../../static/icon/index5.png',
  172. url: '/pages/user/shareQrCode'
  173. },
  174. // {
  175. // name: '拼购福利',
  176. // pic: '../../static/icon/index6.png',
  177. // url: '/pages/user/fulilist'
  178. // },
  179. {
  180. name: '福利专区',
  181. pic: '../../static/icon/index7.png',
  182. url: '/pages/assets/logroll'
  183. },
  184. {
  185. name: '签到领钱',
  186. pic: '../../static/icon/index8.png',
  187. url: '/pages/index/sign'
  188. },
  189. // {
  190. // name: '服务器兑换',
  191. // pic: '../../static/icon/index9.png',
  192. // url: '/pages/market/market'
  193. // },
  194. {
  195. name: '话费充值',
  196. pic: '../../static/icon/index10.png',
  197. url: '/pages/money/phone'
  198. }
  199. ],
  200. swiperLength: 0,
  201. swiperCurrent: 0,
  202. commodityList: [], //普通商品列表
  203. vipList:[],//会员列表
  204. list: [] //拼团积分列表
  205. };
  206. },
  207. onNavigationBarSearchInputClicked(e) {
  208. //跳转到搜索页面
  209. this.clickSearch();
  210. },
  211. onLoad(option) {
  212. // #ifndef MP
  213. if (option.spread) {
  214. // 存储其他邀请人
  215. uni.setStorageSync('spread', option.spread);
  216. }
  217. // #endif
  218. // #ifdef MP
  219. if (option.scene) {
  220. // 存储小程序邀请人
  221. uni.setStorage({
  222. key: 'spread_code',
  223. data: option.scene
  224. });
  225. }
  226. // #endif
  227. // #ifdef H5
  228. console.log(this.hasLogin)
  229. if (this.hasLogin) {
  230. console.log('显示')
  231. weixinObj.hideAllNonBaseMenuItem();
  232. this.IndexShare();
  233. }else {
  234. console.log('隐藏')
  235. weixinObj.hideAllNonBaseMenuItem();
  236. }
  237. //#endif
  238. },
  239. //页面加载即刻发生
  240. onShow() {
  241. this.loadDate();
  242. },
  243. methods: {
  244. // #ifdef H5
  245. IndexShare() {
  246. let obj = this;
  247. let pages = getCurrentPages();
  248. // 获取当前页面
  249. let page = pages[pages.length - 1];
  250. let path = '/#/' + page.route + '?';
  251. // 保存传值
  252. for (let i in page.options) {
  253. path += i + '=' + page.options[i] + '&';
  254. }
  255. console.log(obj.Path)
  256. // 保存邀请人
  257. path += 'spread=' + this.userInfo.uid;
  258. let data = {
  259. link: this.baseURL + '/index/' + path,
  260. title: this.userInfo.nickname + '邀请您进入星拼乐',
  261. desc:'欢迎加入星拼乐',
  262. imgUrl: 'https://xingpinle.liuniu946.com/index/static/img/log.png'
  263. };
  264. weixindata(data);
  265. },
  266. // #endif
  267. loadDate() {
  268. uni.showLoading({
  269. title: '加载中'
  270. });
  271. const obj = this;
  272. loadIndexs({}).then(({ data }) => {
  273. console.log(data);
  274. obj.carouselList = data.banner;
  275. obj.swiperLength = data.banner.length;
  276. obj.commodityList = data.likeInfo;
  277. obj.vipList = data.benefit;
  278. uni.hideLoading();
  279. }).catch(e =>{
  280. uni.hideLoading();
  281. });
  282. wallet({}).then(({ data }) => {
  283. const obj = this;
  284. const arr = Object.keys(data.back);
  285. obj.list=[];
  286. arr.forEach(e => {
  287. let ar = {};
  288. ar.name = data.back[e].name;
  289. ar.type = e
  290. ar.children = []
  291. obj.list.push(ar);
  292. });
  293. obj.list.forEach(e =>{
  294. console.log(e)
  295. dhList({ page: 1, limit: 6, money_type: e.type }).then(({ data }) => {
  296. e.children = data;
  297. });
  298. })
  299. uni.hideLoading();
  300. }).catch(e =>{
  301. uni.hideLoading();
  302. });
  303. },
  304. //轮播图切换修改背景色
  305. swiperChange(e) {
  306. const index = e.detail.current;
  307. this.swiperCurrent = index;
  308. },
  309. // 點擊搜索框
  310. clickSearch() {
  311. console.log(222)
  312. uni.navigateTo({
  313. url: '/pages/product/search'
  314. });
  315. },
  316. navToDetailPage(item) {
  317. if (!this.hasLogin) {
  318. uni.showModal({
  319. title: '登录',
  320. content: '您未登录,是否马上登陆?',
  321. success: e => {
  322. if (e.confirm) {
  323. interceptor();
  324. }
  325. },
  326. fail: e => {
  327. console.log(e);
  328. }
  329. });
  330. return;
  331. }
  332. uni.navigateTo({
  333. url: '/pages/product/productDuhuan?id=' + item.id
  334. });
  335. },
  336. navToDetailPages(e) {
  337. if (!this.hasLogin) {
  338. uni.showModal({
  339. title: '登录',
  340. content: '您未登录,是否马上登陆?',
  341. success: e => {
  342. if (e.confirm) {
  343. interceptor();
  344. }
  345. },
  346. fail: e => {
  347. console.log(e);
  348. }
  349. });
  350. return;
  351. }
  352. uni.navigateTo({
  353. url: '/pages/product/product?id=' + e.id
  354. });
  355. },
  356. nav(url) {
  357. console.log(url)
  358. if (!this.hasLogin) {
  359. uni.showModal({
  360. title: '登录',
  361. content: '您未登录,是否马上登陆?',
  362. success: e => {
  363. if (e.confirm) {
  364. interceptor();
  365. }
  366. },
  367. fail: e => {
  368. console.log(e);
  369. }
  370. });
  371. return;
  372. }
  373. uni.navigateTo({
  374. url,
  375. fail(error) {
  376. uni.switchTab({
  377. url
  378. });
  379. }
  380. });
  381. },
  382. navto(item) {
  383. if (!this.hasLogin) {
  384. uni.showModal({
  385. title: '登录',
  386. content: '您未登录,是否马上登陆?',
  387. success: e => {
  388. if (e.confirm) {
  389. interceptor();
  390. }
  391. },
  392. fail: e => {
  393. console.log(e);
  394. }
  395. });
  396. return;
  397. }
  398. console.log(item)
  399. uni.navigateTo({
  400. url:'/pages/index/duihuanMore?type=' + item.type
  401. });
  402. }
  403. }
  404. };
  405. </script>
  406. <style lang="scss">
  407. .center {
  408. height: auto;
  409. min-height: 100%;
  410. background-color: #f8f8f8;
  411. }
  412. .status_bar {
  413. height: var(--status-bar-height);
  414. width: 100%;
  415. }
  416. .top {
  417. width: 100%;
  418. height: 368rpx;
  419. position: relative;
  420. .top-bg {
  421. position: absolute;
  422. top: 0;
  423. left: 0;
  424. width: 100%;
  425. height: 368rpx;
  426. image {
  427. width: 100%;
  428. height: 100%;
  429. }
  430. }
  431. }
  432. .carousel {
  433. width: 700rpx;
  434. height: 300rpx;
  435. border-radius: 14rpx;
  436. margin: -180rpx auto 0;
  437. margin-top: calc(-260rpx + var(--status-bar-height));
  438. .bor {
  439. border-radius: 14rpx;
  440. .carousel-item {
  441. image {
  442. width: 100%;
  443. height: 100%;
  444. border-radius: 14rpx;
  445. }
  446. }
  447. }
  448. }
  449. .swiper-dot {
  450. position: relative;
  451. z-index: 10;
  452. margin-top: -40rpx;
  453. display: flex;
  454. justify-content: center;
  455. .swiper-dots-item {
  456. width: 14rpx;
  457. height: 14rpx;
  458. background: #aaaaaa;
  459. border-radius: 50%;
  460. margin: 0 16rpx;
  461. // z-index: 999;
  462. }
  463. .action {
  464. background-color: #ffffff;
  465. }
  466. }
  467. .main {
  468. margin-top: 80rpx;
  469. display: flex;
  470. width: 100%;
  471. align-items: center;
  472. flex-wrap: wrap;
  473. .main-item {
  474. margin: 20rpx 0;
  475. width: 20%;
  476. display: flex;
  477. flex-direction: column;
  478. align-items: center;
  479. .pic {
  480. width: 64rpx;
  481. height: 64rpx;
  482. image {
  483. width: 100%;
  484. height: 100%;
  485. }
  486. }
  487. .main-name {
  488. font-size: 24rpx;
  489. font-family: PingFang SC;
  490. font-weight: 500;
  491. color: #333333;
  492. margin-top: 10rpx;
  493. }
  494. }
  495. }
  496. .commodity {
  497. padding: 36rpx 20rpx;
  498. margin-top: 20rpx;
  499. display: flex;
  500. flex-wrap: wrap;
  501. background-color: #FFFFFF;
  502. .title {
  503. width: 100%;
  504. display: flex;
  505. justify-content: space-between;
  506. margin-bottom: 30rpx;
  507. padding:0 20rpx;
  508. .left {
  509. display: flex;
  510. justify-content: flex-start;
  511. image{
  512. width: 40rpx;
  513. height: 40rpx;
  514. }
  515. .font {
  516. margin-left: 10rpx;
  517. font-size: 30rpx;
  518. font-family: PingFang SC;
  519. font-weight: bold;
  520. color: #333333;
  521. }
  522. }
  523. .right {
  524. display: flex;
  525. justify-content: flex-start;
  526. align-items: center;
  527. .right-font {
  528. color: #a2a2a2;
  529. font-size: 26rpx;
  530. margin-right: 10rpx;
  531. }
  532. image {
  533. width: 16rpx;
  534. height: 26rpx;
  535. }
  536. }
  537. }
  538. .commodity-item {
  539. width: 334rpx;
  540. background: #ffffff;
  541. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  542. border-radius: 10rpx;
  543. margin: 0 10rpx;
  544. .commodity-prc {
  545. width: 330rpx;
  546. height: 330rpx;
  547. border-radius: 10rpx;
  548. position: relative;
  549. image {
  550. border-radius: 10rpx;
  551. width: 100%;
  552. height: 100%;
  553. }
  554. .fanli {
  555. position: absolute;
  556. bottom: 0;
  557. left: 0;
  558. width: 344rpx;
  559. height: 96rpx;
  560. .fanli-bg {
  561. position: absolute;
  562. bottom: 0;
  563. left: 0;
  564. width: 344rpx;
  565. height: 96rpx;
  566. }
  567. .fanli-font {
  568. position: relative;
  569. z-index: 10;
  570. color: #ffffff;
  571. height: 96rpx;
  572. align-items: flex-end;
  573. padding: 36rpx 10rpx 10rpx;
  574. .font-left {
  575. width: 226px;
  576. font-size: 20rpx;
  577. font-family: PingFang SC;
  578. font-weight: 500;
  579. color: #ffffff;
  580. }
  581. .font-right {
  582. font-size: 62rpx;
  583. font-family: Microsoft YaHei;
  584. font-weight: bold;
  585. color: #ffffff;
  586. text {
  587. font-size: 26rpx;
  588. }
  589. }
  590. }
  591. }
  592. }
  593. .commodity-info {
  594. padding: 28rpx 20rpx 35rpx 24rpx;
  595. .commodity-name {
  596. width: 100%;
  597. font-size: 30rpx;
  598. font-family: PingFang SC;
  599. font-weight: bold;
  600. color: #333333;
  601. }
  602. .commodity-systom {
  603. margin-top: 16rpx;
  604. font-size: 26rpx;
  605. font-family: PingFang SC;
  606. font-weight: 500;
  607. color: #666666;
  608. }
  609. .commodity-price {
  610. margin-top: 34rpx;
  611. font-size: 36rpx;
  612. font-family: PingFang SC;
  613. font-weight: bold;
  614. color: #e83f30;
  615. text {
  616. display: inline-block;
  617. padding-left: 6rpx;
  618. font-size: 26rpx;
  619. font-family: PingFang SC;
  620. font-weight: bold;
  621. text-decoration: line-through;
  622. color: #999999;
  623. }
  624. }
  625. }
  626. }
  627. }
  628. .recommend-box {
  629. width: 100%;
  630. padding: 0 32rpx;
  631. margin-top: 20rpx;
  632. }
  633. .f-header {
  634. display: flex;
  635. align-items: center;
  636. height: 92rpx;
  637. padding: 6rpx 30rpx 8rpx;
  638. border-radius: 12rpx 12rpx 0 0;
  639. color: #ffffff;
  640. background: #2e58ff;
  641. .tit-box {
  642. @extend %font-title-box;
  643. font-size: 20rpx;
  644. color: #ffffff;
  645. margin-left: 20rpx;
  646. }
  647. .iconenter {
  648. font-size: $font-lg + 2rpx;
  649. color: #ffffff;
  650. }
  651. .f-left-icon {
  652. font-size: 34rpx;
  653. border-right: 1rpx solid #ffffff;
  654. padding-right: 18rpx;
  655. }
  656. .iconfont {
  657. font-size: 26rpx;
  658. }
  659. }
  660. .guess-section {
  661. background-color: #FFFFFF;
  662. width: 100%;
  663. display: flex;
  664. flex-direction: column;
  665. background-color: #ffffff;
  666. border-radius: 0 0 12rpx 12rpx;
  667. .guess-item {
  668. display: flex;
  669. width: 100%;
  670. padding: 24rpx;
  671. border-bottom: 1rpx solid #f0f0f0;
  672. &:nth-last-child(1) {
  673. border-bottom: none;
  674. }
  675. }
  676. .image-wrapper {
  677. width: 168rpx;
  678. height: 168rpx;
  679. border-radius: 3px;
  680. image {
  681. width: 168rpx;
  682. height: 168rpx;
  683. opacity: 1;
  684. }
  685. }
  686. .info-wrapper {
  687. width: 100%;
  688. display: flex;
  689. flex-direction: column;
  690. margin-left: 20rpx;
  691. }
  692. .title {
  693. font-size: 32rpx;
  694. color: $font-color-dark;
  695. word-break: break-all;
  696. display: -webkit-box;
  697. -webkit-line-clamp: 1;
  698. -webkit-box-orient: vertical;
  699. overflow: hidden;
  700. }
  701. .price-box {
  702. margin-top: 10rpx;
  703. display: flex;
  704. justify-content: space-between;
  705. .price-left {
  706. display: flex;
  707. flex-direction: column;
  708. .price {
  709. display: flex;
  710. justify-content: flex-start;
  711. align-items: center;
  712. margin-top: 60rpx;
  713. height: 56rpx;
  714. line-height: 30rpx;
  715. color: #ff0000;
  716. font-size: 56rpx;
  717. font-weight: 700;
  718. .price-tip {
  719. font-size: 28rpx;
  720. }
  721. }
  722. .ot_price {
  723. margin-left: 4rpx;
  724. font-size: 28rpx;
  725. color: #ff0000;
  726. .price-tip {
  727. font-size: 22rpx;
  728. }
  729. }
  730. }
  731. .price-right {
  732. display: flex;
  733. flex-direction: column;
  734. .people {
  735. margin-top: 32rpx;
  736. font-weight: 700;
  737. color: #999999;
  738. font-size: 22rpx;
  739. text-align: right;
  740. margin-right: 4rpx;
  741. }
  742. .buyNow {
  743. margin-top: 68rpx;
  744. background: linear-gradient(180deg, #fd4646, #ff3535);
  745. border-radius: 26rpx;
  746. padding: 6rpx 18rpx;
  747. font-size: 26rpx;
  748. font-weight: 400;
  749. color: #ffffff;
  750. }
  751. }
  752. }
  753. }
  754. </style>