vip.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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">
  15. 立即开通
  16. </view>
  17. <view class="card-info">
  18. <view class="info-tit">
  19. 会员卡
  20. </view>
  21. <view class="info-val">
  22. 100通证 终身付费会员
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="hyjl">
  28. <view class="jl-tit">会员奖励</view>
  29. <view class="tool flex">
  30. <view class="tool-item">
  31. <view class="tool-img"><image src="../../static/icon/kt1.png" mode=""></image></view>
  32. <view class="tool-name">佣金奖励</view>
  33. </view>
  34. <view class="tool-item" >
  35. <view class="tool-img"><image src="../../static/icon/kt2.png" mode=""></image></view>
  36. <view class="tool-name">专属折扣</view>
  37. </view>
  38. <view class="tool-item" >
  39. <view class="tool-img"><image src="../../static/icon/kt3.png" mode=""></image></view>
  40. <view class="tool-name">专属服务</view>
  41. </view>
  42. <view class="tool-item" >
  43. <view class="tool-img"><image src="../../static/icon/kt4.png" mode=""></image></view>
  44. <view class="tool-name">团队奖励</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="hyjl" style="padding-bottom: 20rpx;">
  49. <view class="jl-tit">会员优选</view>
  50. <view class="tool flex">
  51. <view class="tool-item1">
  52. <view class="tool-name">会员独享</view>
  53. <view class="tool-name bold">优惠价</view>
  54. <view class="tool-img"><image src="../../static/icon/kt5.png" mode=""></image></view>
  55. </view>
  56. <view class="tool-item1" >
  57. <view class="tool-name">会员专属</view>
  58. <view class="tool-name bold">专属服务包</view>
  59. <view class="tool-img"><image src="../../static/icon/kt6.png" mode=""></image></view>
  60. </view>
  61. <view class="tool-item1" >
  62. <view class="tool-name">推广得</view>
  63. <view class="tool-name bold">更多佣金</view>
  64. <view class="tool-img"><image src="../../static/icon/kt7.png" mode=""></image></view>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="bottom-btn">
  69. <view class="btm-left">
  70. 永久付费会员100通证
  71. </view>
  72. <view class="btm-right" @click="readyPay()">
  73. 马上开通
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import { becomeVip, getVip, setUserRed, claseauto } from '@/api/user.js';
  80. import { mapState, mapMutations } from 'vuex';
  81. import { getUserInfo } from '@/api/user.js';
  82. export default {
  83. computed: {
  84. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  85. },
  86. data() {
  87. return {
  88. }
  89. },
  90. onLoad() {
  91. },
  92. methods:{
  93. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  94. getUserInfoA() {
  95. },
  96. getUserInfoB() {
  97. getUserInfo({})
  98. .then(({ data }) => {
  99. this.setUserInfo(data);
  100. if(data.wx_qr) {
  101. uni.navigateTo({
  102. url: '/pages/vip/success'
  103. });
  104. }else {
  105. this.$api.msg('请完善会员信息')
  106. setTimeout(()=> {
  107. uni.navigateTo({
  108. url:'/pages/set/userdata'
  109. });
  110. }, 1000);
  111. }
  112. })
  113. .catch(e => {
  114. console.log(e);
  115. });
  116. },
  117. // 开通会员
  118. readyPay() {
  119. let obj = this;
  120. if(obj.userInfo.level > 0) {
  121. return obj.$api.msg('您已开通会员')
  122. }
  123. getUserInfo()
  124. .then(({ data }) => {
  125. this.setUserInfo(data);
  126. if(data.now_money*1 < 100) {
  127. return obj.$api.msg('您的通证不足100')
  128. }
  129. })
  130. console.log('点击');
  131. try {
  132. let obj = this;
  133. obj.payLoding = true;
  134. // #ifdef H5
  135. // 获取当前是否为微信浏览器
  136. obj.froms = uni.getStorageSync('weichatBrowser') || '';
  137. // #endif
  138. uni.showLoading({
  139. title: '支付中',
  140. mask: true
  141. });
  142. let data = {
  143. pay_type: 'yue',
  144. level_id: 1,
  145. // #ifdef H5
  146. from: obj.froms ? 'weixin' : 'H5', //来源
  147. // #endif
  148. // #ifdef MP-WEIXIN
  149. from: 'routine', //来源
  150. // #endif
  151. // #ifdef APP-PLUS
  152. from: 'app' //来源
  153. // #endif
  154. };
  155. console.log(data, '传值');
  156. becomeVip(data).then(({ data }) => {
  157. console.log('fufei', data);
  158. uni.hideLoading();
  159. if (data.status == 'PAY_ERROR') {
  160. console.log(data);
  161. }
  162. if (data.status == 'SUCCESS') {
  163. obj.getUserInfoB();
  164. }
  165. console.log('-----', data);
  166. let da = data.result.jsConfig;
  167. if (obj.payName == 'weixin' || obj.payName == 'routine') {
  168. // let da = data.result.jsConfig;
  169. console.log('--da--', da);
  170. let data = {
  171. // #ifdef H5
  172. timestamp: da.timestamp,
  173. // #endif
  174. // #ifdef MP
  175. timeStamp: da.timestamp,
  176. // #endif
  177. nonceStr: da.nonceStr,
  178. package: da.package,
  179. signType: da.signType,
  180. paySign: da.paySign,
  181. success: function(res) {
  182. console.log(res);
  183. obj.getUserInfoB();
  184. },
  185. fail: e => {
  186. console.log(e);
  187. }
  188. };
  189. console.log('--data--', data);
  190. // #ifdef MP
  191. wx.requestPayment(data);
  192. // #endif
  193. // #ifdef H5
  194. if (obj.payName == 'weixin') {
  195. weixinObj.chooseWXPay(data);
  196. }
  197. // #endif
  198. }
  199. uni.hideLoading();
  200. // #ifdef H5
  201. if (data.status == 'PAY_ERROR') {
  202. console.log(data);
  203. }
  204. if (data.status == 'SUCCESS') {
  205. obj.getUserInfoB();
  206. }
  207. // #endif
  208. });
  209. } catch (e) {
  210. console.log('fufiecw', e);
  211. //TODO handle the exception
  212. }
  213. }
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .card {
  219. position: relative;
  220. margin: auto;
  221. z-index: 10;
  222. width: 655rpx;
  223. height: 324rpx;
  224. background: linear-gradient(225deg, #ffeed2 0%, #fed591 100%);
  225. border-radius: 24rpx;
  226. padding: 28rpx 25rpx 30rpx 36rpx;
  227. .now-wrap {
  228. width: 190rpx;
  229. line-height: 69rpx;
  230. background: #C09852;
  231. border-radius: 35rpx;
  232. position: absolute;
  233. top:39rpx;
  234. right: 25rpx;
  235. font-size: 30rpx;
  236. font-family: PingFang SC;
  237. font-weight: 500;
  238. color: #F6DCA9;
  239. text-align: center;
  240. }
  241. .card-top {
  242. justify-content: flex-start;
  243. .avtur {
  244. width: 90rpx;
  245. height: 90rpx;
  246. border-radius: 50%;
  247. margin-right: 10rpx;
  248. image {
  249. width: 100%;
  250. height: 100%;
  251. border-radius: 50%;
  252. }
  253. }
  254. .name {
  255. font-size: 30rpx;
  256. font-family: PingFang SC;
  257. font-weight: 500;
  258. color: #333333;
  259. }
  260. .tip {
  261. font-size: 20rpx;
  262. font-family: PingFang SC;
  263. font-weight: 500;
  264. color: #333333;
  265. opacity: 0.52;
  266. }
  267. }
  268. .btn {
  269. position: absolute;
  270. top: 40rpx;
  271. right: 24rpx;
  272. width: 190rpx;
  273. height: 69rpx;
  274. background: #3a3a3b;
  275. border-radius: 35rpx;
  276. font-size: 30rpx;
  277. font-family: PingFang SC;
  278. font-weight: 500;
  279. color: #ffffff;
  280. line-height: 69rpx;
  281. text-align: center;
  282. }
  283. .card-info {
  284. height: 120rpx;
  285. position: absolute;
  286. bottom: 30rpx;
  287. left: 43rpx;
  288. .info-tit {
  289. line-height: 70rpx;
  290. font-size: 40rpx;
  291. font-family: PingFang SC;
  292. font-weight: bold;
  293. color: #333333;
  294. }
  295. .info-val {
  296. font-size: 28rpx;
  297. font-family: PingFang SC;
  298. font-weight: 500;
  299. color: #343434;
  300. }
  301. }
  302. }
  303. .hyjl {
  304. background-color: #fff;
  305. padding:30rpx 30rpx 0;
  306. margin-bottom: 20rpx;
  307. .jl-tit {
  308. font-size: 36rpx;
  309. font-family: PingFang SC;
  310. font-weight: 500;
  311. color: #000000;
  312. }
  313. }
  314. .tool {
  315. flex-wrap: wrap;
  316. justify-content: flex-start;
  317. align-items: center;
  318. .tool-item {
  319. width: 25%;
  320. height: 160rpx;
  321. display: flex;
  322. align-items: center;
  323. flex-direction: column;
  324. justify-content: center;
  325. .tool-img {
  326. width: 45rpx;
  327. height: 45rpx;
  328. image {
  329. width: 100%;
  330. height: 100%;
  331. }
  332. }
  333. .tool-name {
  334. padding-top: 20rpx;
  335. font-size: 28rpx;
  336. font-family: PingFang SC;
  337. font-weight: 400;
  338. color: #505050;
  339. }
  340. }
  341. .tool-item1 {
  342. background: #FAFBFF;
  343. display: flex;
  344. align-items: center;
  345. flex-direction: column;
  346. justify-content: center;
  347. width: 222rpx;
  348. height: 298rpx;
  349. background: #FAFBFF;
  350. border-radius: 10rpx;
  351. .tool-name {
  352. font-size: 30rpx;
  353. font-family: PingFang SC;
  354. font-weight: 500;
  355. color: #7B7B7B;
  356. }
  357. .bold {
  358. font-weight: bold;
  359. color: #000;
  360. }
  361. .tool-img {
  362. width: 157rpx;
  363. height: 112rpx;
  364. margin-top: 37rpx;
  365. image {
  366. width: 100%;
  367. height: 100%;
  368. }
  369. }
  370. }
  371. }
  372. .bottom-btn {
  373. display: flex;
  374. align-items: flex-end;
  375. position: fixed;
  376. bottom: 0;
  377. text-align: center;
  378. .btm-left {
  379. width: 750rpx - 280rpx;
  380. line-height: 100rpx;
  381. background-color: #34332F;
  382. color: #fff;
  383. }
  384. .btm-right {
  385. width: 280rpx;
  386. line-height: 108rpx;
  387. background: #EFD4A1;
  388. font-size: 36rpx;
  389. font-family: PingFang SC;
  390. font-weight: bold;
  391. color: #5A5A5A;
  392. }
  393. }
  394. </style>