vip.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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="" style="position: absolute;top: 0;width: 750rpx;height: 200rpx;"></image>
  6. <view class="card" style="position: relative;">
  7. <view class="card-top flex">
  8. <view class="avtur"><image :src="userInfo.avatar || '/static/error/missing-face.png'" mode=""></image></view>
  9. <view class="main">
  10. <view class="name">{{ userInfo.nickname }}</view>
  11. <view class="tip" v-if="userInfo.level == 0">尚未开通会员</view>
  12. </view>
  13. </view>
  14. <view class="now-wrap">立即开通</view>
  15. <view class="card-info">
  16. <view class="info-tit">会员卡</view>
  17. <view class="info-val">¥{{ money }}/永久 终身{{name}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="hyjl">
  22. <view class="jl-tit">会员奖励</view>
  23. <view class="tool flex">
  24. <view class="tool-item">
  25. <view class="tool-img"><image src="../../static/icon/kt1.png" mode=""></image></view>
  26. <view class="tool-name">佣金奖励</view>
  27. </view>
  28. <view class="tool-item">
  29. <view class="tool-img"><image src="../../static/icon/kt2.png" mode=""></image></view>
  30. <view class="tool-name">专属折扣</view>
  31. </view>
  32. <view class="tool-item">
  33. <view class="tool-img"><image src="../../static/icon/kt3.png" mode=""></image></view>
  34. <view class="tool-name">专属服务</view>
  35. </view>
  36. <view class="tool-item">
  37. <view class="tool-img"><image src="../../static/icon/kt4.png" mode=""></image></view>
  38. <view class="tool-name">团队奖励</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="hyjl" style="padding-bottom: 20rpx;">
  43. <view class="jl-tit">会员优选</view>
  44. <view class="tool flex">
  45. <view class="tool-item1">
  46. <view class="tool-name">会员独享</view>
  47. <view class="tool-name bold">优惠价</view>
  48. <view class="tool-img"><image src="../../static/icon/kt5.png" mode=""></image></view>
  49. </view>
  50. <view class="tool-item1">
  51. <view class="tool-name">会员专属</view>
  52. <view class="tool-name bold">专属服务包</view>
  53. <view class="tool-img"><image src="../../static/icon/kt6.png" mode=""></image></view>
  54. </view>
  55. <view class="tool-item1">
  56. <view class="tool-name">推广得</view>
  57. <view class="tool-name bold">更多佣金</view>
  58. <view class="tool-img"><image src="../../static/icon/kt7.png" mode=""></image></view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="bottom-btn">
  63. <view class="btm-left">永久{{name}}¥{{ money }}</view>
  64. <view class="btm-right" @click="readyPay()">马上开通</view>
  65. </view>
  66. <uni-popup ref="popupPay" type="bottom">
  67. <view class="popup-box">
  68. <view class="popup-pay">
  69. <view class="paybox-top flex">
  70. <view class="type">选择支付方式</view>
  71. <view class="image" @click="close"><image src="../../static/img/x.png" mode="aspectFill"></image></view>
  72. </view>
  73. <view class="paybox-main flex">
  74. <view class="zftype flex">
  75. <image src="../../static/img/weixin.png" mode="aspectFill"></image>
  76. <view class="zf">微信支付</view>
  77. </view>
  78. <label class="radio1" @click="changePayType(1)"><radio style="transform:scale(0.7)" value="" :checked="payType == 1" color="#FE4141"></radio></label>
  79. </view>
  80. <view class="paybox-main flex">
  81. <view class="zftype flex">
  82. <image src="../../static/img/yue.png" mode="aspectFill"></image>
  83. <view class="zf">余额支付</view>
  84. </view>
  85. <label class="radio" @click="changePayType(2)">
  86. <radio style="transform:scale(0.7)" class="rad" value="" :checked="payType == 2" color="#FE4141"></radio>
  87. </label>
  88. </view>
  89. </view>
  90. <view class="buttom flex">
  91. <view class="heji">
  92. 合计:
  93. <text>
  94. <text class="money">{{ money }}</text>
  95. </text>
  96. </view>
  97. <view class="zhifu" @click="pay()">立即支付</view>
  98. </view>
  99. </view>
  100. </uni-popup>
  101. </view>
  102. </template>
  103. <script>
  104. import { becomeVip, getVip } from '@/api/user.js';
  105. import { mapState, mapMutations } from 'vuex';
  106. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  107. import { getUserInfo } from '@/api/user.js';
  108. // #ifdef H5
  109. import weixinObj from '@/plugin/jweixin-module/index.js';
  110. // #endif
  111. export default {
  112. components: {
  113. uniPopup
  114. },
  115. computed: {
  116. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  117. },
  118. data() {
  119. return {
  120. money: '',
  121. name:'',
  122. level_id:'',
  123. payType: 2,
  124. payName: 'yue',
  125. now_money: '', // 当前余额
  126. payLoding: false, //判断是否支付中
  127. };
  128. },
  129. onLoad() {
  130. this.getVip();
  131. },
  132. methods: {
  133. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  134. getUserInfoB() {
  135. getUserInfo({})
  136. .then(({ data }) => {
  137. this.setUserInfo(data);
  138. if (data.wx_qr) {
  139. uni.navigateTo({
  140. url: '/pages/vip/success'
  141. });
  142. } else {
  143. this.$api.msg('请完善会员信息');
  144. setTimeout(() => {
  145. uni.navigateTo({
  146. url: '/pages/set/userdata'
  147. });
  148. }, 1000);
  149. }
  150. })
  151. .catch(e => {
  152. console.log(e);
  153. });
  154. },
  155. // 获取vip等级
  156. getVip() {
  157. getVip({}).then(({ data }) => {
  158. console.log(data)
  159. this.money = data[0].money
  160. this.name = data[0].name
  161. this.level_id = data[0].id
  162. });
  163. },
  164. // 开通会员
  165. readyPay() {
  166. this.$refs.popupPay.open();
  167. },
  168. close() {
  169. this.$refs.popupPay.close();
  170. },
  171. changePayType(type) {
  172. this.payType = type;
  173. console.log('this.payType', this.payType);
  174. if (this.payType == 1) {
  175. this.payName = 'weixin';
  176. console.log('weixin', this.payName);
  177. }
  178. if (this.payType == 2) {
  179. this.payName = 'yue';
  180. console.log('yue', this.payName);
  181. }
  182. if (this.payType == 3) {
  183. this.payName = 'ali';
  184. console.log('ali', this.payName);
  185. }
  186. },
  187. pay() {
  188. let obj = this;
  189. console.log('点击');
  190. try {
  191. let obj = this;
  192. obj.payLoding = true;
  193. // #ifdef H5
  194. // 获取当前是否为微信浏览器
  195. obj.froms = uni.getStorageSync('weichatBrowser') || '';
  196. // #endif
  197. uni.showLoading({
  198. title: '支付中',
  199. mask: true
  200. });
  201. let data = {
  202. pay_type: this.payName,
  203. level_id: obj.level_id,
  204. // #ifdef H5
  205. from: obj.froms ? 'weixin' : 'H5', //来源
  206. // #endif
  207. // #ifdef MP-WEIXIN
  208. from: 'routine', //来源
  209. // #endif
  210. // #ifdef APP-PLUS
  211. from: 'app' //来源
  212. // #endif
  213. };
  214. console.log(data, '传值');
  215. becomeVip(data).then(({ data }) => {
  216. console.log('fufei', data);
  217. uni.hideLoading();
  218. if (data.status == 'PAY_ERROR') {
  219. console.log(data);
  220. }
  221. if (data.status == 'SUCCESS') {
  222. obj.$refs.popupPay.close();
  223. obj.getUserInfoB();
  224. }
  225. let da = data.result.jsConfig;
  226. if (obj.payName == 'weixin' || obj.payName == 'routine') {
  227. // let da = data.result.jsConfig;
  228. console.log('--da--', da);
  229. let data = {
  230. // #ifdef H5
  231. timestamp: da.timestamp,
  232. // #endif
  233. // #ifdef MP
  234. timeStamp: da.timestamp,
  235. // #endif
  236. nonceStr: da.nonceStr,
  237. package: da.package,
  238. signType: da.signType,
  239. paySign: da.paySign,
  240. success: function(res) {
  241. console.log(res);
  242. obj.getUserInfoB();
  243. },
  244. fail: e => {
  245. console.log(e);
  246. }
  247. };
  248. console.log('--data--', data);
  249. // #ifdef MP
  250. wx.requestPayment(data);
  251. // #endif
  252. // #ifdef H5
  253. if (obj.payName == 'weixin') {
  254. weixinObj.chooseWXPay(data);
  255. }
  256. // #endif
  257. }
  258. uni.hideLoading();
  259. // #ifdef H5
  260. if (data.status == 'PAY_ERROR') {
  261. console.log(data);
  262. }
  263. if (data.status == 'SUCCESS') {
  264. obj.$refs.popupPay.close();
  265. obj.getUserInfoB();
  266. }
  267. // #endif
  268. });
  269. } catch (e) {
  270. console.log('fufiecw', e);
  271. }
  272. }
  273. }
  274. };
  275. </script>
  276. <style lang="scss" scoped>
  277. .card {
  278. position: relative;
  279. margin: auto;
  280. z-index: 10;
  281. width: 655rpx;
  282. height: 324rpx;
  283. background: linear-gradient(225deg, #ffeed2 0%, #fed591 100%);
  284. border-radius: 24rpx;
  285. padding: 28rpx 25rpx 30rpx 36rpx;
  286. .now-wrap {
  287. width: 190rpx;
  288. line-height: 69rpx;
  289. background: #c09852;
  290. border-radius: 35rpx;
  291. position: absolute;
  292. top: 39rpx;
  293. right: 25rpx;
  294. font-size: 30rpx;
  295. font-family: PingFang SC;
  296. font-weight: 500;
  297. color: #f6dca9;
  298. text-align: center;
  299. }
  300. .card-top {
  301. justify-content: flex-start;
  302. .avtur {
  303. width: 90rpx;
  304. height: 90rpx;
  305. border-radius: 50%;
  306. margin-right: 10rpx;
  307. image {
  308. width: 100%;
  309. height: 100%;
  310. border-radius: 50%;
  311. }
  312. }
  313. .name {
  314. font-size: 30rpx;
  315. font-family: PingFang SC;
  316. font-weight: 500;
  317. color: #333333;
  318. }
  319. .tip {
  320. font-size: 20rpx;
  321. font-family: PingFang SC;
  322. font-weight: 500;
  323. color: #333333;
  324. opacity: 0.52;
  325. }
  326. }
  327. .btn {
  328. position: absolute;
  329. top: 40rpx;
  330. right: 24rpx;
  331. width: 190rpx;
  332. height: 69rpx;
  333. background: #3a3a3b;
  334. border-radius: 35rpx;
  335. font-size: 30rpx;
  336. font-family: PingFang SC;
  337. font-weight: 500;
  338. color: #ffffff;
  339. line-height: 69rpx;
  340. text-align: center;
  341. }
  342. .card-info {
  343. height: 120rpx;
  344. position: absolute;
  345. bottom: 30rpx;
  346. left: 43rpx;
  347. .info-tit {
  348. line-height: 70rpx;
  349. font-size: 40rpx;
  350. font-family: PingFang SC;
  351. font-weight: bold;
  352. color: #333333;
  353. }
  354. .info-val {
  355. font-size: 28rpx;
  356. font-family: PingFang SC;
  357. font-weight: 500;
  358. color: #343434;
  359. }
  360. }
  361. }
  362. .hyjl {
  363. background-color: #fff;
  364. padding: 30rpx 30rpx 0;
  365. margin-bottom: 20rpx;
  366. .jl-tit {
  367. font-size: 36rpx;
  368. font-family: PingFang SC;
  369. font-weight: 500;
  370. color: #000000;
  371. }
  372. }
  373. .tool {
  374. flex-wrap: wrap;
  375. justify-content: flex-start;
  376. align-items: center;
  377. .tool-item {
  378. width: 25%;
  379. height: 160rpx;
  380. display: flex;
  381. align-items: center;
  382. flex-direction: column;
  383. justify-content: center;
  384. .tool-img {
  385. width: 45rpx;
  386. height: 45rpx;
  387. image {
  388. width: 100%;
  389. height: 100%;
  390. }
  391. }
  392. .tool-name {
  393. padding-top: 20rpx;
  394. font-size: 28rpx;
  395. font-family: PingFang SC;
  396. font-weight: 400;
  397. color: #505050;
  398. }
  399. }
  400. .tool-item1 {
  401. background: #fafbff;
  402. display: flex;
  403. align-items: center;
  404. flex-direction: column;
  405. justify-content: center;
  406. width: 222rpx;
  407. height: 298rpx;
  408. background: #fafbff;
  409. border-radius: 10rpx;
  410. .tool-name {
  411. font-size: 30rpx;
  412. font-family: PingFang SC;
  413. font-weight: 500;
  414. color: #7b7b7b;
  415. }
  416. .bold {
  417. font-weight: bold;
  418. color: #000;
  419. }
  420. .tool-img {
  421. width: 157rpx;
  422. height: 112rpx;
  423. margin-top: 37rpx;
  424. image {
  425. width: 100%;
  426. height: 100%;
  427. }
  428. }
  429. }
  430. }
  431. .bottom-btn {
  432. display: flex;
  433. align-items: flex-end;
  434. position: fixed;
  435. bottom: 0;
  436. text-align: center;
  437. .btm-left {
  438. width: 750rpx - 280rpx;
  439. line-height: 100rpx;
  440. background-color: #34332f;
  441. color: #fff;
  442. }
  443. .btm-right {
  444. width: 280rpx;
  445. line-height: 108rpx;
  446. background: #efd4a1;
  447. font-size: 36rpx;
  448. font-family: PingFang SC;
  449. font-weight: bold;
  450. color: #5a5a5a;
  451. }
  452. }
  453. .popup-box {
  454. width: 100%;
  455. background: #ffffff;
  456. }
  457. .popup-pay {
  458. position: relative;
  459. justify-content: space-between;
  460. padding: 0rpx 25rpx 32rpx 25rpx;
  461. .paybox-top {
  462. padding-top: 38rpx;
  463. width: 100%;
  464. .type {
  465. font-size: 28rpx;
  466. font-family: PingFang SC;
  467. font-weight: bold;
  468. color: #333333;
  469. }
  470. .image {
  471. padding-right: 24rpx;
  472. padding-bottom: 10rpx;
  473. image {
  474. width: 16rpx;
  475. height: 16rpx;
  476. }
  477. }
  478. }
  479. .paybox-main {
  480. width: 100%;
  481. margin-top: 54rpx;
  482. .zftype {
  483. padding-left: 5rpx;
  484. image {
  485. width: 38rpx;
  486. height: 40rpx;
  487. }
  488. .zf {
  489. padding-left: 18rpx;
  490. font-size: 28rpx;
  491. font-family: PingFang SC;
  492. font-weight: 400;
  493. color: #3f454b;
  494. }
  495. }
  496. }
  497. }
  498. .buttom {
  499. width: 100%;
  500. height: 113rpx;
  501. padding-top: 20rpx;
  502. align-items: center;
  503. .heji {
  504. height: 100%;
  505. width: 50%;
  506. padding-left: 23rpx;
  507. padding-top: 20rpx;
  508. font-size: 28rpx;
  509. font-family: PingFang SC;
  510. font-weight: 400;
  511. color: #3f454b;
  512. text {
  513. font-size: 24rpx;
  514. font-family: PingFang SC;
  515. font-weight: bold;
  516. color: #ff0000;
  517. .money {
  518. font-size: 36rpx;
  519. }
  520. }
  521. }
  522. .zhifu {
  523. width: 50%;
  524. height: 92rpx;
  525. background: linear-gradient(180deg, #fd4646, #ff3535);
  526. text-align: center;
  527. line-height: 92rpx;
  528. font-size: 32rpx;
  529. font-family: PingFang SC;
  530. font-weight: bold;
  531. color: #ffffff;
  532. }
  533. }
  534. </style>