index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. <template>
  2. <view class="container">
  3. <!-- 顶部logo and 搜索 start-->
  4. <view class="status_bar"></view>
  5. <!-- <view class="top-bg"></view> -->
  6. <view class="top-search flex">
  7. <view class="search-box flex" @click="clickSearch()">
  8. <image class="search" src="../../static/icon/search-w.png" mode=""></image>
  9. <view class="search-font">输入关键词搜索</view>
  10. </view>
  11. </view>
  12. <!-- 顶部logo and 搜索 end-->
  13. <!-- 轮播图 start -->
  14. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  15. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  16. @click="bannerNavToUrl(item)">
  17. <image :src="item.pic" />
  18. </swiper-item>
  19. </swiper>
  20. <image src="../../static/index/in-banner.png" mode="widthFix" class="in-banner"></image>
  21. <!-- 轮播图 end -->
  22. <!-- 分类 start -->
  23. <view class="cate-section flex">
  24. <view class="cate-item flex" v-for="(citem,cindex) in cateList" @click="gogogo(citem)">
  25. <view class="img-wrapper flex">
  26. <image :src="citem.img + (cindex + 1) + '.png'" mode=""></image>
  27. </view>
  28. <view class="item-title">{{citem.tit}}</view>
  29. </view>
  30. </view>
  31. <!-- 分类 ed -->
  32. <image src="../../static/index/in-tit.png" mode="" class="in-tit"></image>
  33. <image src="../../static/index/in-banner-t.png" mode="" class="in-banner-t"></image>
  34. <view class="in-vip" v-for="item in levelList">
  35. <image :src="item.image" mode=""></image>
  36. <view class="vip-info flex">
  37. <view class="">
  38. <view class="price">
  39. ¥{{item.money}} <text>/{{item.valid_date}}天</text>
  40. </view>
  41. <view class="info">
  42. {{item.name}}
  43. </view>
  44. </view>
  45. <view class="btn" @click="gobuy(item)">
  46. 立即开通
  47. </view>
  48. </view>
  49. </view>
  50. <image src="../../static/index/in-tit-t.png" mode="" class="in-tit"></image>
  51. <view class="art">
  52. <view class="art-tit flex">
  53. <view class="">
  54. M A S S A G E
  55. </view>
  56. <view class="">
  57. +++
  58. </view>
  59. </view>
  60. <view class="art-content" v-html="art">
  61. </view>
  62. <view class="art-line"></view>
  63. </view>
  64. <uni-popup ref="popupkf" type="center">
  65. <view class="popup-box">
  66. <view class="img">
  67. <image src="../../static/img/img009.png" mode=""></image>
  68. </view>
  69. <view class="mian">
  70. <view class="delivery">
  71. <view class="title">已经为您定制专属客服</view>
  72. <image src="../../static/img/img010.png" mode=""></image>
  73. </view>
  74. <view class="nocancel">客服VX:{{ text }}</view>
  75. <view class="comfirm-box">
  76. <view class="cancel" @click="cancel">取消</view>
  77. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  78. </view>
  79. </view>
  80. </view>
  81. </uni-popup>
  82. <uni-popup ref="popup" type="bottom">
  83. <view class="cz-model">
  84. <image :src="choose.image" mode=""></image>
  85. <view class="">
  86. {{choose.name}}
  87. </view>
  88. <view class="price">
  89. ¥{{choose.money}}
  90. </view>
  91. <view class="btn" @click="goNew">
  92. 立即开通
  93. </view>
  94. </view>
  95. </uni-popup>
  96. </view>
  97. </template>
  98. <script>
  99. import {
  100. loadIndexs,
  101. groom1,
  102. getLevelList
  103. } from '@/api/index.js';
  104. import {
  105. getUserInfo,
  106. spread,
  107. levelBuy,
  108. details
  109. } from '@/api/user.js';
  110. import {
  111. getBargainList,
  112. getProducts,
  113. goodsDetail,
  114. poster,
  115. getBd,
  116. getGp
  117. } from '@/api/product.js';
  118. import {
  119. saveUrl,
  120. interceptor
  121. } from '@/utils/loginUtils';
  122. import {
  123. mapState,
  124. mapMutations
  125. } from 'vuex';
  126. // #ifdef H5
  127. import {
  128. weixindata,
  129. shareLoad
  130. } from '@/utils/wxAuthorized';
  131. // #endif
  132. export default {
  133. data() {
  134. return {
  135. buying: false,
  136. choose: {},
  137. levelList: [],
  138. art: ' 希尔伯特作为科学疗人的方法,是指运用高端先进的仪器作用于病患的体表、受伤的部位、不适的所在.特定的脸穴、疼痛的地方,具体运用推、拿、按、摩、揉、捏、点、拍等形式多样的手法,以期达到疏通经络、推行气血、扶伤止痛、祛邪扶正、调和阴阳的 疗 效。', //文章介绍
  139. bastList: [], //爆款推荐
  140. muted: false,
  141. cateList: [{
  142. path: '/pages/index/artDetail?id=4',
  143. img: '../../static/index/in',
  144. tit: '仪器介绍'
  145. },
  146. {
  147. path: 'gift',
  148. img: '../../static/index/in',
  149. tit: '会员商品'
  150. },
  151. // {
  152. // path: 'kf',
  153. // img: '../../static/index/in',
  154. // tit: '联系客服'
  155. // },
  156. {
  157. path: '/pages/user/shareQrCode',
  158. img: '../../static/index/in',
  159. tit: '邀请好友'
  160. }
  161. ],
  162. text: '', //客服微信
  163. // page: 1,
  164. limitt: 20,
  165. loadingType: 'more',
  166. current: 0,
  167. shareShow: false, //分享海报
  168. pageProportion: 0, //保存页面基于750宽度的比例
  169. swiperHeight: 0,
  170. checkid: 0,
  171. titleNViewBackground: '',
  172. swiperCurrent: 0,
  173. swiperLength: 0,
  174. carouselList: [], //轮播列表
  175. page: 1,
  176. limit: 5,
  177. firstList: [],
  178. goodList: [], //商品列表
  179. shopList: [],
  180. period: 1,
  181. shareImage: '',
  182. jfList: [],
  183. };
  184. },
  185. computed: {
  186. ...mapState('user', ['hasLogin', 'userInfo'])
  187. },
  188. onReachBottom() {
  189. console.log('到底')
  190. },
  191. onLoad: function(option) {
  192. // #ifdef MP
  193. if (option.scene) {
  194. // 存储小程序邀请人
  195. uni.setStorage({
  196. key: 'spread_code',
  197. data: option.scene
  198. });
  199. }
  200. // #endif
  201. // #ifdef H5
  202. if (option.spread) {
  203. // 存储小程序邀请人
  204. uni.setStorage({
  205. key: 'spread',
  206. data: option.spread
  207. });
  208. }
  209. // #endif
  210. },
  211. onShow: function() {
  212. this.loadData();
  213. if(this.hasLogin) {
  214. this.getList()
  215. }
  216. this.details()
  217. },
  218. onHide() {},
  219. methods: {
  220. details() {
  221. details({},1).then(res => {
  222. console.log(res)
  223. this.art = res.data.content
  224. })
  225. },
  226. gobuy(e) {
  227. this.choose = e
  228. this.$refs.popup.open()
  229. },
  230. goNew() {
  231. if(this.buying) {
  232. return
  233. }
  234. if(this.userInfo.now_money*1 < this.choose.money*1) {
  235. return this.$api.msg('您当前余额不足')
  236. }
  237. this.buying = true
  238. levelBuy({
  239. level_id: this.choose.id
  240. }).then(res => {
  241. this.$refs.popup.close()
  242. this.buying = false
  243. uni.showToast({
  244. title: '开通成功',
  245. icon: 'success'
  246. });
  247. }).catch(err => {
  248. this.buying = false
  249. })
  250. },
  251. getList() {
  252. getLevelList().then(res => {
  253. console.log(res)
  254. this.levelList = res.data.list
  255. })
  256. },
  257. getBd() {
  258. getBd().then(res => {
  259. console.log(res)
  260. this.navList[0].list = res.data.list
  261. this.navList[0].loaded = true
  262. })
  263. },
  264. getGp(id) {
  265. let nav = this.navList[id]
  266. getGp(nav.qdata).then(res => {
  267. console.log(res)
  268. nav.list = res.data.list
  269. nav.loaded = true
  270. })
  271. },
  272. gogogo(item) {
  273. if (!item.path) {
  274. uni.navigateTo({
  275. url: '/pages/index/dkf'
  276. })
  277. }
  278. if (item.path == 'kf') {
  279. this.$refs.popupkf.open()
  280. } else {
  281. if(item.path == 'gift') {
  282. if(this.hasLogin ) {
  283. if(this.userInfo.vip) {
  284. uni.navigateTo({
  285. url:'/pages/index/gift'
  286. })
  287. }else {
  288. uni.showModal({
  289. title:'提示',
  290. content: '您当前不是会员,请先升级会员'
  291. })
  292. }
  293. }else {
  294. // 保存地址
  295. saveUrl();
  296. // 登录拦截
  297. interceptor();
  298. }
  299. }else {
  300. uni.navigateTo({
  301. url: item.path + '&tit=' + item.tit,
  302. fail() {
  303. uni.navigateTo({
  304. url: item.path,
  305. fail() {
  306. uni.switchTab({
  307. url: item.path,
  308. })
  309. }
  310. })
  311. }
  312. })
  313. }
  314. }
  315. },
  316. getGoodList() {
  317. let obj = this
  318. getProducts({
  319. is_order: 0,
  320. tree_id: 0
  321. }).then(res => {
  322. this.jfList = res.data
  323. })
  324. },
  325. navto(url, type = 0) {
  326. if (type == 1) {
  327. if (!this.hasLogin) {
  328. // 保存地址
  329. saveUrl();
  330. // 登录拦截
  331. interceptor();
  332. } else {
  333. uni.navigateTo({
  334. url,
  335. fail() {
  336. uni.switchTab({
  337. url
  338. })
  339. }
  340. })
  341. }
  342. } else {
  343. uni.navigateTo({
  344. url,
  345. fail() {
  346. uni.switchTab({
  347. url
  348. })
  349. }
  350. })
  351. }
  352. },
  353. navTo(url) {
  354. if (url == '') {
  355. this.$api.msg('暂未开通,敬请期待');
  356. } else {
  357. this.navto(url)
  358. }
  359. },
  360. // 點擊搜索框
  361. clickSearch() {
  362. uni.navigateTo({
  363. url: '/pages/product/search'
  364. });
  365. },
  366. // 监听图片加载完成
  367. onImageError(key, index) {
  368. this[key][index].image = '/static/error/errorImage.jpg';
  369. },
  370. // 请求载入数据
  371. async loadData() {
  372. loadIndexs({})
  373. .then(({
  374. data
  375. }) => {
  376. let goods = data.info;
  377. console.log(goods, '商品信息');
  378. this.carouselList = data.banner;
  379. this.swiperLength = this.carouselList.length;
  380. this.bastList = data.likeInfo; //会员礼包
  381. data.info.firstList.forEach(e => {
  382. e.isVip = e.store_type ? "3" : "0"
  383. })
  384. this.firstList = data.info.firstList //首页商品
  385. this.jfList = data.benefit
  386. uni.stopPullDownRefresh();
  387. })
  388. .catch(e => {
  389. uni.stopPullDownRefresh();
  390. });
  391. },
  392. //轮播图切换修改背景色
  393. swiperChange(e) {
  394. const index = e.detail.current;
  395. this.swiperCurrent = index;
  396. this.titleNViewBackground = this.carouselList[index].background;
  397. },
  398. // 轮播图跳转
  399. bannerNavToUrl(item) {
  400. // #ifdef H5
  401. console.log(item.wap_url.indexOf('http'), 'banner');
  402. if (item.wap_url.indexOf('http') >= 0) {
  403. window.location.href = item.wap_url;
  404. }
  405. // uni.navigateTo({
  406. // url: '/pages/zero/order'
  407. // })
  408. // #endif
  409. //测试数据没有写id,用title代替
  410. uni.navigateTo({
  411. url: item.wap_url
  412. });
  413. },
  414. comfirm(text) {
  415. console.log(text);
  416. const result = this.uniCopy(text);
  417. if (result === false) {
  418. uni.showToast({
  419. title: '不支持'
  420. });
  421. } else {
  422. uni.showToast({
  423. title: '复制成功',
  424. icon: 'none'
  425. });
  426. }
  427. this.$refs.popupkf.close();
  428. },
  429. uniCopy(content) {
  430. /**
  431. * 小程序端 和 app端的复制逻辑
  432. */
  433. //#ifndef H5
  434. uni.setClipboardData({
  435. data: content,
  436. success: function() {
  437. console.log('success');
  438. return true;
  439. }
  440. });
  441. //#endif
  442. /**
  443. * H5端的复制逻辑
  444. */
  445. // #ifdef H5
  446. if (!document.queryCommandSupported('copy')) {
  447. //为了兼容有些浏览器 queryCommandSupported 的判断
  448. // 不支持
  449. return false;
  450. }
  451. let textarea = document.createElement('textarea');
  452. textarea.value = content;
  453. textarea.readOnly = 'readOnly';
  454. document.body.appendChild(textarea);
  455. textarea.select(); // 选择对象
  456. textarea.setSelectionRange(0, content.length); //核心
  457. let result = document.execCommand('copy'); // 执行浏览器复制命令
  458. textarea.remove();
  459. return result;
  460. // #endif
  461. },
  462. // 打开客服
  463. openKf() {
  464. this.$refs.popupkf.open();
  465. },
  466. // 关闭客服
  467. cancel() {
  468. this.$refs.popupkf.close();
  469. },
  470. }
  471. };
  472. </script>
  473. <style lang="scss">
  474. .container {
  475. background-image: url('../../static/index/in-bg.png');
  476. background-size: 100% 100%;
  477. padding-bottom: 68rpx;
  478. }
  479. image {
  480. vertical-align: middle;
  481. }
  482. page {
  483. min-height: 100%;
  484. height: auto;
  485. }
  486. // 顶部搜索
  487. .top-search {
  488. height: 80rpx;
  489. padding: 0 20rpx;
  490. position: relative;
  491. margin-bottom: 20rpx;
  492. .top-logo {
  493. width: 50rpx;
  494. margin-right: 10rpx;
  495. image {
  496. width: 48rpx;
  497. }
  498. }
  499. .search-box {
  500. justify-content: center;
  501. width: 698rpx;
  502. height: 60rpx;
  503. background: rgba(255, 255, 255, 0.5);
  504. color: #CBCBCB;
  505. border-radius: 30rpx;
  506. .search {
  507. width: 34rpx;
  508. height: 34rpx;
  509. }
  510. .search-font {
  511. margin-left: 14rpx;
  512. font-size: 28rpx;
  513. font-weight: 500;
  514. }
  515. }
  516. }
  517. // 顶部轮播图
  518. .top-swiper {
  519. width: 750rpx;
  520. height: 360rpx;
  521. .carousel-item {
  522. image {
  523. width: 100%;
  524. height: 100%;
  525. }
  526. }
  527. }
  528. .in-banner {
  529. width: 750rpx;
  530. height: 57rpx;
  531. }
  532. .in-banner-t {
  533. width: 750rpx;
  534. height: 220rpx;
  535. }
  536. .in-vip {
  537. width: 680rpx;
  538. height: 504rpx;
  539. background-image: url('../../static/index/in-vip.png');
  540. background-size: 100% 100%;
  541. margin: 30rpx auto 70rpx;
  542. position: relative;
  543. image {
  544. width: 100%;
  545. height: 356rpx;
  546. position: absolute;
  547. top: 0;
  548. left: 0;
  549. }
  550. .vip-info {
  551. height: 147rpx;
  552. width: 100%;
  553. position: absolute;
  554. bottom: 0;
  555. left: 0;
  556. padding: 0 27rpx;
  557. .price {
  558. font-weight: bold;
  559. font-size: 35rpx;
  560. color: #FF4C4C;
  561. text {
  562. font-size: 25rpx;
  563. color: #333333;
  564. }
  565. }
  566. .info {
  567. font-weight: 500;
  568. font-size: 22rpx;
  569. color: #443516;
  570. padding-top: 10rpx;
  571. }
  572. .btn {
  573. width: 127rpx;
  574. line-height: 44rpx;
  575. background: linear-gradient(89deg, #BB9159, #E6C79D);
  576. border-radius: 22rpx;
  577. font-weight: 500;
  578. font-size: 22rpx;
  579. color: #443516;
  580. text-align: center;
  581. }
  582. }
  583. }
  584. .swiper-btm {
  585. height: 60rpx;
  586. width: 750rpx;
  587. margin-bottom: 20rpx;
  588. font-size: 26rpx;
  589. font-weight: 500;
  590. color: #333333;
  591. .btm-item {
  592. flex-grow: 1;
  593. justify-content: center;
  594. image {
  595. width: 25rpx;
  596. height: 25rpx;
  597. margin-right: 14rpx;
  598. }
  599. }
  600. }
  601. // 分类
  602. .cate-section {
  603. justify-content: flex-start;
  604. padding: 0 0 30rpx;
  605. flex-wrap: wrap;
  606. .cate-item {
  607. padding-top: 30rpx;
  608. flex-grow: 0;
  609. flex-grow: 1;
  610. min-width: 20%;
  611. flex-direction: column;
  612. text-align: center;
  613. align-items: center;
  614. justify-content: center;
  615. .img-wrapper {
  616. width: 90rpx;
  617. height: 90rpx;
  618. border-radius: 20rpx;
  619. position: relative;
  620. image {
  621. width: 100%;
  622. height: 100%;
  623. position: absolute;
  624. left: 50%;
  625. top: 50%;
  626. transform: translate(-50%, -50%);
  627. }
  628. }
  629. .item-title {
  630. margin-top: 15rpx;
  631. font-size: 26rpx;
  632. font-weight: 500;
  633. color: #443516;
  634. }
  635. }
  636. }
  637. .in-tit {
  638. width: 449rpx;
  639. height: 79rpx;
  640. display: block;
  641. margin: 40rpx auto;
  642. }
  643. .art {
  644. width: 680rpx;
  645. margin: auto;
  646. background: #FFFFFF;
  647. box-shadow: 0rpx 3rpx 3rpx 0rpx rgba(0, 0, 0, 0.1);
  648. border-radius: 30rpx;
  649. padding: 39rpx;
  650. .art-tit {
  651. font-weight: 400;
  652. font-size: 16rpx;
  653. color: #848484;
  654. }
  655. .art-content {
  656. // font-weight: 500;
  657. // font-size: 24rpx;
  658. // color: #000000;
  659. padding: 43rpx 10rpx 31rpx;
  660. // text-indent: 2em;
  661. // text-align: justify;
  662. }
  663. .art-line {
  664. width: 446rpx;
  665. height: 1rpx;
  666. background: #434343;
  667. float: right;
  668. }
  669. }
  670. .popup-box {
  671. width: 522rpx;
  672. height: 605rpx;
  673. background-color: #ffffff;
  674. border-radius: 20rpx;
  675. position: relative;
  676. .img {
  677. position: relative;
  678. top: -56rpx;
  679. left: 0;
  680. width: 522rpx;
  681. height: 132rpx;
  682. display: flex;
  683. justify-content: center;
  684. image {
  685. border-radius: 20rpx 20rpx 0 0;
  686. width: 450rpx;
  687. height: 132rpx;
  688. }
  689. }
  690. .mian {
  691. margin-top: -44rpx;
  692. display: flex;
  693. flex-direction: column;
  694. align-items: center;
  695. // padding: 32rpx 32rpx;
  696. background-color: #ffffff;
  697. border-radius: 0 0 20rpx 20rpx;
  698. text-align: center;
  699. .delivery {
  700. font-size: 40rpx;
  701. color: #333333;
  702. display: flex;
  703. align-items: center;
  704. flex-direction: column;
  705. image {
  706. margin-top: 48rpx;
  707. width: 172rpx;
  708. height: 160rpx;
  709. }
  710. }
  711. .nocancel {
  712. font-size: 32rpx;
  713. color: #333333;
  714. margin-top: 14rpx;
  715. }
  716. .comfirm-box {
  717. margin-top: 52rpx;
  718. display: flex;
  719. .cancel {
  720. display: flex;
  721. align-items: center;
  722. justify-content: center;
  723. width: 197rpx;
  724. height: 74rpx;
  725. border: 1px solid #dcc786;
  726. border-radius: 38rpx;
  727. font-size: 32rpx;
  728. color: #605128;
  729. }
  730. .comfirm {
  731. margin-left: 32rpx;
  732. display: flex;
  733. align-items: center;
  734. justify-content: center;
  735. width: 197rpx;
  736. height: 74rpx;
  737. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  738. border-radius: 38px;
  739. font-size: 32rpx;
  740. color: #605128;
  741. }
  742. }
  743. }
  744. }
  745. .status_bar {
  746. height: var(--status-bar-height);
  747. width: 100%;
  748. }
  749. /deep/ img {
  750. width: 100% !important;
  751. height: auto;
  752. }
  753. .cz-model {
  754. width: 750rpx;
  755. background-color: #fff;
  756. padding: 60rpx 0 30rpx;
  757. text-align: center;
  758. border-radius: 25rpx 25rpx 0 0;
  759. padding-bottom:70px;
  760. /* #ifdef APP-PLUS */
  761. padding-bottom:40px;
  762. /* #endif */
  763. view {
  764. padding: 10rpx 0;
  765. }
  766. image {
  767. width: 680rpx;
  768. // height: ;
  769. height: 356rpx;
  770. }
  771. .price {
  772. color: $base-color;
  773. font-size: 48rpx;
  774. font-weight: bold;
  775. }
  776. .tip {
  777. color: #409eff;
  778. }
  779. .tips {
  780. padding-bottom: 20rpx;
  781. }
  782. .btn {
  783. width: 690rpx;
  784. text-align: center;
  785. line-height: 60rpx;
  786. color: #443516;
  787. background: linear-gradient(89deg, #BB9159, #E6C79D);
  788. border-radius: 40rpx;
  789. margin: auto;
  790. }
  791. }
  792. </style>