vip.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. <template>
  2. <view class="contet">
  3. <!-- <view class="jg" style="height: 20rpx;background-color: #fff;"></view> -->
  4. <view class="" style="background-color: #fff;padding-top: 40rpx;position: relative;">
  5. <image src="../../static/img/ktbg.png" mode=""
  6. style="position: absolute;top: 0;width: 750rpx;height: 200rpx;"></image>
  7. <view class="card" style="position: relative;">
  8. <view class="card-top flex">
  9. <view class="avtur">
  10. <image :src="userInfo.avatar || '/static/error/missing-face.png'" mode=""></image>
  11. </view>
  12. <view class="main">
  13. <view class="name">{{ userInfo.nickname }}</view>
  14. <view class="tip" v-if="userInfo.level == 0">尚未开通会员</view>
  15. </view>
  16. </view>
  17. <view class="now-wrap">
  18. 立即开通
  19. </view>
  20. <view class="card-info">
  21. <view class="info-tit">
  22. 代言人
  23. </view>
  24. <view class="info-val">
  25. ¥20000起 终身代言人
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="vip">
  31. <view class="system-title">
  32. <view class="img" style="margin-right: 45rpx;">
  33. <image class="img" src="../../static/img/vip-left.png"></image>
  34. </view>
  35. <view class="title">代言人特权</view>
  36. <view class="img" style="margin-left: 45rpx;">
  37. <image class="img" src="../../static/img/vip-right.png"></image>
  38. </view>
  39. </view>
  40. <view class="item-box flex">
  41. <view class="item" v-for="(item, index) in viplist" :key="index">
  42. <image :src="item.pic" mode=""></image>
  43. <view class="item-title">{{ item.title }}</view>
  44. <view class="item-tip">{{ item.tip }}</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="vip">
  49. <view class="system-title">
  50. <view class="img" style="margin-right: 45rpx;">
  51. <image class="img" src="../../static/img/vip-left.png"></image>
  52. </view>
  53. <view class="title">选择代言人</view>
  54. <view class="img" style="margin-left: 45rpx;">
  55. <image class="img" src="../../static/img/vip-right.png"></image>
  56. </view>
  57. </view>
  58. <view class="money-box flex">
  59. <view class="money" v-for="(item, index) in payList" @click="changevip(item, index)"
  60. :class="{ current: index == choose }">
  61. <view class="money-name">{{ item.explain }}</view>
  62. <view class="now-money">
  63. <text>{{ item.money }}</text>
  64. </view>
  65. <view class="bf-money">¥{{ item.yuan }}</view>
  66. <view class="money-tip" :class="{ moneyc: index == choose }">
  67. <!-- <image src="../../static/img/good.png" mode=""></image> -->
  68. 立省{{ item.sq }}元
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="bottom-btn">
  74. <view class="btm-left">
  75. 开通即享代言人特权
  76. </view>
  77. <view class="btm-right" @click="readyPay()">
  78. 马上开通
  79. </view>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import {
  85. becomeVip,
  86. getVip,
  87. setUserRed,
  88. claseauto
  89. } from '@/api/user.js';
  90. import {
  91. mapState,
  92. mapMutations
  93. } from 'vuex';
  94. import {
  95. getUserInfo
  96. } from '@/api/user.js';
  97. export default {
  98. computed: {
  99. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  100. },
  101. data() {
  102. return {
  103. level_id: 3,
  104. money: '',
  105. choose: 0,
  106. payList: [],
  107. viplist: [{
  108. pic: '../../static/icon/zdpt.png',
  109. title: '佣金奖励',
  110. tip: '更多佣金奖励'
  111. },
  112. {
  113. pic: '../../static/icon/ktqy.png',
  114. title: '专属折扣',
  115. tip: '优享会员独享'
  116. },
  117. {
  118. pic: '../../static/icon/yjlhb.png',
  119. title: '团队奖励',
  120. tip: '更多团队奖励'
  121. }
  122. ],
  123. }
  124. },
  125. onLoad() {
  126. this.getVip()
  127. },
  128. methods: {
  129. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  130. getUserInfoA() {
  131. },
  132. // 获取会员等级列表
  133. getVip() {
  134. getVip({}).then(({
  135. data
  136. }) => {
  137. data.forEach((sj, index) => {
  138. console.log(sj, '123456');
  139. if (sj.explain == '村代') {
  140. sj.level = 5;
  141. }
  142. if (sj.explain == '镇代') {
  143. sj.level = 4;
  144. }
  145. if (sj.explain == '区代') {
  146. sj.level = 3;
  147. }
  148. sj.sq = (sj.money * 0.33).toFixed(0);
  149. sj.yuan = (sj.sq * 1 + sj.money * 1).toFixed(2);
  150. });
  151. this.payList = data;
  152. // 设置默认选中的对象
  153. this.level_id = data[0].id;
  154. this.money = data[0].money;
  155. console.log(this.payList);
  156. });
  157. },
  158. changevip(item, index) {
  159. this.level_id = item.id;
  160. this.level = item.level;
  161. this.choose = index;
  162. this.money = item.money;
  163. this.myProvincial = {
  164. id: 0,
  165. name: ''
  166. };
  167. },
  168. getUserInfoB() {
  169. getUserInfo({})
  170. .then(({
  171. data
  172. }) => {
  173. this.setUserInfo(data);
  174. uni.showToast({
  175. title:'购买成功',
  176. duration:2000
  177. });
  178. setTimeout(function() {
  179. uni.navigateBack();
  180. }, 800);
  181. // uni.showModal({
  182. // })
  183. // if (data.wx_qr) {
  184. // uni.navigateTo({
  185. // url: '/pages/vip/success'
  186. // });
  187. // } else {
  188. // this.$api.msg('请完善会员信息')
  189. // setTimeout(() => {
  190. // uni.navigateTo({
  191. // url: '/pages/set/userdata'
  192. // });
  193. // }, 1000);
  194. // }
  195. })
  196. .catch(e => {
  197. console.log(e);
  198. });
  199. },
  200. // 开通会员
  201. readyPay() {
  202. let obj = this;
  203. if (obj.userInfo.level > 0) {
  204. return obj.$api.msg('您已开通会员')
  205. }
  206. getUserInfo()
  207. .then(({
  208. data
  209. }) => {
  210. this.setUserInfo(data);
  211. if (data.now_money * 1 < obj.money * 1) {
  212. return obj.$api.msg('您的余额不足')
  213. } else {
  214. obj.payLoding = true;
  215. obj.froms = uni.getStorageSync('weichatBrowser') || '';
  216. uni.showLoading({
  217. title: '支付中',
  218. mask: true
  219. });
  220. let data = {
  221. pay_type: 'yue',
  222. level_id: obj.level_id,
  223. // #ifdef H5
  224. from: obj.froms ? 'weixin' : 'H5', //来源
  225. // #endif
  226. // #ifdef MP-WEIXIN
  227. from: 'routine', //来源
  228. // #endif
  229. // #ifdef APP-PLUS
  230. from: 'app' //来源
  231. // #endif
  232. };
  233. console.log(data, '传值');
  234. becomeVip(data).then(({
  235. data
  236. }) => {
  237. console.log('fufei', data);
  238. uni.hideLoading();
  239. if (data.status == 'PAY_ERROR') {
  240. console.log(data);
  241. }
  242. if (data.status == 'SUCCESS') {
  243. obj.getUserInfoB();
  244. }
  245. console.log('-----', data);
  246. let da = data.result.jsConfig;
  247. if (obj.payName == 'weixin' || obj.payName == 'routine') {
  248. // let da = data.result.jsConfig;
  249. console.log('--da--', da);
  250. let data = {
  251. // #ifdef H5
  252. timestamp: da.timestamp,
  253. // #endif
  254. // #ifdef MP
  255. timeStamp: da.timestamp,
  256. // #endif
  257. nonceStr: da.nonceStr,
  258. package: da.package,
  259. signType: da.signType,
  260. paySign: da.paySign,
  261. success: function(res) {
  262. console.log(res);
  263. obj.getUserInfoB();
  264. },
  265. fail: e => {
  266. console.log(e);
  267. }
  268. };
  269. console.log('--data--', data);
  270. // #ifdef MP
  271. wx.requestPayment(data);
  272. // #endif
  273. // #ifdef H5
  274. if (obj.payName == 'weixin') {
  275. weixinObj.chooseWXPay(data);
  276. }
  277. // #endif
  278. }
  279. uni.hideLoading();
  280. // #ifdef H5
  281. if (data.status == 'PAY_ERROR') {
  282. console.log(data);
  283. }
  284. if (data.status == 'SUCCESS') {
  285. obj.getUserInfoB();
  286. }
  287. // #endif
  288. });
  289. }
  290. })
  291. // try {
  292. // let obj = this;
  293. // obj.payLoding = true;
  294. // // #ifdef H5
  295. // // 获取当前是否为微信浏览器
  296. // obj.froms = uni.getStorageSync('weichatBrowser') || '';
  297. // // #endif
  298. // uni.showLoading({
  299. // title: '支付中',
  300. // mask: true
  301. // });
  302. // let data = {
  303. // pay_type: 'yue',
  304. // level_id: 1,
  305. // // #ifdef H5
  306. // from: obj.froms ? 'weixin' : 'H5', //来源
  307. // // #endif
  308. // // #ifdef MP-WEIXIN
  309. // from: 'routine', //来源
  310. // // #endif
  311. // // #ifdef APP-PLUS
  312. // from: 'app' //来源
  313. // // #endif
  314. // };
  315. // console.log(data, '传值');
  316. // becomeVip(data).then(({
  317. // data
  318. // }) => {
  319. // console.log('fufei', data);
  320. // uni.hideLoading();
  321. // if (data.status == 'PAY_ERROR') {
  322. // console.log(data);
  323. // }
  324. // if (data.status == 'SUCCESS') {
  325. // obj.getUserInfoB();
  326. // }
  327. // console.log('-----', data);
  328. // let da = data.result.jsConfig;
  329. // if (obj.payName == 'weixin' || obj.payName == 'routine') {
  330. // // let da = data.result.jsConfig;
  331. // console.log('--da--', da);
  332. // let data = {
  333. // // #ifdef H5
  334. // timestamp: da.timestamp,
  335. // // #endif
  336. // // #ifdef MP
  337. // timeStamp: da.timestamp,
  338. // // #endif
  339. // nonceStr: da.nonceStr,
  340. // package: da.package,
  341. // signType: da.signType,
  342. // paySign: da.paySign,
  343. // success: function(res) {
  344. // console.log(res);
  345. // obj.getUserInfoB();
  346. // },
  347. // fail: e => {
  348. // console.log(e);
  349. // }
  350. // };
  351. // console.log('--data--', data);
  352. // // #ifdef MP
  353. // wx.requestPayment(data);
  354. // // #endif
  355. // // #ifdef H5
  356. // if (obj.payName == 'weixin') {
  357. // weixinObj.chooseWXPay(data);
  358. // }
  359. // // #endif
  360. // }
  361. // uni.hideLoading();
  362. // // #ifdef H5
  363. // if (data.status == 'PAY_ERROR') {
  364. // console.log(data);
  365. // }
  366. // if (data.status == 'SUCCESS') {
  367. // obj.getUserInfoB();
  368. // }
  369. // // #endif
  370. // });
  371. // } catch (e) {
  372. // console.log('fufiecw', e);
  373. // //TODO handle the exception
  374. // }
  375. }
  376. }
  377. }
  378. </script>
  379. <style lang="scss" scoped>
  380. .card {
  381. position: relative;
  382. margin: auto;
  383. z-index: 10;
  384. width: 655rpx;
  385. height: 324rpx;
  386. background: linear-gradient(225deg, #ffeed2 0%, #fed591 100%);
  387. border-radius: 24rpx;
  388. padding: 28rpx 25rpx 30rpx 36rpx;
  389. .now-wrap {
  390. width: 190rpx;
  391. line-height: 69rpx;
  392. background: #C09852;
  393. border-radius: 35rpx;
  394. position: absolute;
  395. top: 39rpx;
  396. right: 25rpx;
  397. font-size: 30rpx;
  398. font-family: PingFang SC;
  399. font-weight: 500;
  400. color: #F6DCA9;
  401. text-align: center;
  402. }
  403. .card-top {
  404. justify-content: flex-start;
  405. .avtur {
  406. width: 90rpx;
  407. height: 90rpx;
  408. border-radius: 50%;
  409. margin-right: 10rpx;
  410. image {
  411. width: 100%;
  412. height: 100%;
  413. border-radius: 50%;
  414. }
  415. }
  416. .name {
  417. font-size: 30rpx;
  418. font-family: PingFang SC;
  419. font-weight: 500;
  420. color: #333333;
  421. }
  422. .tip {
  423. font-size: 20rpx;
  424. font-family: PingFang SC;
  425. font-weight: 500;
  426. color: #333333;
  427. opacity: 0.52;
  428. }
  429. }
  430. .btn {
  431. position: absolute;
  432. top: 40rpx;
  433. right: 24rpx;
  434. width: 190rpx;
  435. height: 69rpx;
  436. background: #3a3a3b;
  437. border-radius: 35rpx;
  438. font-size: 30rpx;
  439. font-family: PingFang SC;
  440. font-weight: 500;
  441. color: #ffffff;
  442. line-height: 69rpx;
  443. text-align: center;
  444. }
  445. .card-info {
  446. height: 120rpx;
  447. position: absolute;
  448. bottom: 30rpx;
  449. left: 43rpx;
  450. .info-tit {
  451. line-height: 70rpx;
  452. font-size: 40rpx;
  453. font-family: PingFang SC;
  454. font-weight: bold;
  455. color: #333333;
  456. }
  457. .info-val {
  458. font-size: 28rpx;
  459. font-family: PingFang SC;
  460. font-weight: 500;
  461. color: #343434;
  462. }
  463. }
  464. }
  465. .hyjl {
  466. background-color: #fff;
  467. padding: 30rpx 30rpx 0;
  468. margin-bottom: 20rpx;
  469. .jl-tit {
  470. font-size: 36rpx;
  471. font-family: PingFang SC;
  472. font-weight: 500;
  473. color: #000000;
  474. }
  475. }
  476. .tool {
  477. flex-wrap: wrap;
  478. justify-content: flex-start;
  479. align-items: center;
  480. .tool-item {
  481. width: 33.3%;
  482. height: 160rpx;
  483. display: flex;
  484. align-items: center;
  485. flex-direction: column;
  486. justify-content: center;
  487. .tool-img {
  488. width: 45rpx;
  489. height: 45rpx;
  490. image {
  491. width: 100%;
  492. height: 100%;
  493. }
  494. }
  495. .tool-name {
  496. padding-top: 20rpx;
  497. font-size: 28rpx;
  498. font-family: PingFang SC;
  499. font-weight: 400;
  500. color: #505050;
  501. }
  502. }
  503. .tool-item1 {
  504. background: #FAFBFF;
  505. display: flex;
  506. align-items: center;
  507. flex-direction: column;
  508. justify-content: center;
  509. width: 222rpx;
  510. height: 298rpx;
  511. background: #FAFBFF;
  512. border-radius: 10rpx;
  513. .tool-name {
  514. font-size: 30rpx;
  515. font-family: PingFang SC;
  516. font-weight: 500;
  517. color: #7B7B7B;
  518. }
  519. .bold {
  520. font-weight: bold;
  521. color: #000;
  522. }
  523. .tool-img {
  524. width: 157rpx;
  525. height: 112rpx;
  526. margin-top: 37rpx;
  527. image {
  528. width: 100%;
  529. height: 100%;
  530. }
  531. }
  532. }
  533. }
  534. .bottom-btn {
  535. display: flex;
  536. align-items: flex-end;
  537. position: fixed;
  538. bottom: 0;
  539. text-align: center;
  540. .btm-left {
  541. width: 750rpx - 280rpx;
  542. line-height: 100rpx;
  543. background-color: #34332F;
  544. color: #fff;
  545. }
  546. .btm-right {
  547. width: 280rpx;
  548. line-height: 108rpx;
  549. background: #EFD4A1;
  550. font-size: 36rpx;
  551. font-family: PingFang SC;
  552. font-weight: bold;
  553. color: #5A5A5A;
  554. }
  555. }
  556. .vip {
  557. margin-top: 20rpx;
  558. background: #ffffff;
  559. padding-bottom: 54rpx;
  560. .system-title {
  561. display: flex;
  562. justify-content: center;
  563. align-items: center;
  564. padding-top: 40rpx;
  565. .title {
  566. font-size: 32rpx;
  567. font-family: PingFang SC;
  568. font-weight: bold;
  569. color: #1d2023;
  570. }
  571. .img {
  572. width: 170rpx;
  573. height: 2rpx;
  574. display: block;
  575. }
  576. }
  577. .item-box {
  578. margin-top: 40rpx;
  579. justify-content: center;
  580. align-items: center;
  581. .item {
  582. flex: 1;
  583. display: flex;
  584. flex-direction: column;
  585. align-items: center;
  586. image {
  587. width: 100rpx;
  588. height: 100rpx;
  589. }
  590. .item-title {
  591. margin-top: 14rpx;
  592. font-size: 24rpx;
  593. font-family: PingFang SC;
  594. font-weight: 500;
  595. color: #333333;
  596. }
  597. .item-tip {
  598. margin-top: 10rpx;
  599. font-size: 20rpx;
  600. font-family: PingFang SC;
  601. font-weight: 500;
  602. color: #999999;
  603. }
  604. }
  605. }
  606. .money-box {
  607. margin-top: 40rpx;
  608. justify-content: center;
  609. align-items: center;
  610. padding: 0 25rpx 160rpx 0rpx;
  611. .current {
  612. border: 1rpx solid #fed591 !important;
  613. background: #fff8ec !important;
  614. }
  615. .money {
  616. margin-left: 22rpx;
  617. flex: 1;
  618. display: flex;
  619. flex-direction: column;
  620. align-items: center;
  621. width: 204rpx;
  622. height: 296rpx;
  623. background: #f5f5f5;
  624. border: 1rpx solid #ffffff;
  625. border-radius: 20rpx;
  626. position: relative;
  627. .tj {
  628. position: absolute;
  629. top: 0;
  630. left: 0;
  631. width: 90rpx;
  632. height: 44rpx;
  633. text-align: center;
  634. line-height: 44rpx;
  635. font-size: 25rpx;
  636. font-family: PingFang SC;
  637. font-weight: 500;
  638. color: #ffffff;
  639. .tj-bg {
  640. width: 90rpx;
  641. height: 44rpx;
  642. }
  643. text {
  644. display: inline-block;
  645. position: relative;
  646. top: -56rpx;
  647. }
  648. }
  649. .money-name {
  650. margin-top: 58rpx;
  651. font-size: 26rpx;
  652. font-family: PingFang SC;
  653. font-weight: 500;
  654. color: #644931;
  655. }
  656. .now-money {
  657. font-size: 22rpx;
  658. font-family: FZCuHeiSongS-B-GB;
  659. font-weight: 400;
  660. color: #f7cf9c;
  661. text {
  662. font-size: 40rpx;
  663. }
  664. }
  665. .bf-money {
  666. font-size: 33rpx;
  667. font-family: PingFang SC;
  668. font-weight: 500;
  669. text-decoration: line-through;
  670. color: #9a5a12;
  671. opacity: 0.35;
  672. }
  673. .moneyc {
  674. background: #f7cf9c !important;
  675. color: #ffffff !important;
  676. }
  677. .money-tip {
  678. margin-top: 10rpx;
  679. width: 180rpx;
  680. height: 45rpx;
  681. background: #f5f5f5;
  682. border: 1px solid #f7cf9c;
  683. border-radius: 23rpx;
  684. padding: 5rpx 10rpx;
  685. font-size: 25rpx;
  686. font-family: PingFang SC;
  687. font-weight: 500;
  688. color: #f7cf9c;
  689. image {
  690. position: relative;
  691. top: 2rpx;
  692. width: 23rpx;
  693. height: 23rpx;
  694. }
  695. }
  696. }
  697. }
  698. }
  699. </style>