vip.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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. getUserInfoB() {
  95. getUserInfo({})
  96. .then(({ data }) => {
  97. this.setUserInfo(data);
  98. if(data.wx_qr) {
  99. uni.navigateTo({
  100. url: '/pages/vip/success'
  101. });
  102. }else {
  103. this.$api.msg('请完善会员信息')
  104. setTimeout(()=> {
  105. uni.navigateTo({
  106. url:'/pages/set/userdata'
  107. });
  108. }, 1000);
  109. }
  110. })
  111. .catch(e => {
  112. console.log(e);
  113. });
  114. },
  115. // 开通会员
  116. readyPay() {
  117. let obj = this;
  118. if(obj.userInfo.level > 0) {
  119. return obj.$api.msg('您已开通会员')
  120. }
  121. console.log('点击');
  122. try {
  123. let obj = this;
  124. obj.payLoding = true;
  125. // #ifdef H5
  126. // 获取当前是否为微信浏览器
  127. obj.froms = uni.getStorageSync('weichatBrowser') || '';
  128. // #endif
  129. uni.showLoading({
  130. title: '支付中',
  131. mask: true
  132. });
  133. let data = {
  134. pay_type: 'yue',
  135. level_id: 1,
  136. // #ifdef H5
  137. from: obj.froms ? 'weixin' : 'H5', //来源
  138. // #endif
  139. // #ifdef MP-WEIXIN
  140. from: 'routine', //来源
  141. // #endif
  142. // #ifdef APP-PLUS
  143. from: 'app' //来源
  144. // #endif
  145. };
  146. console.log(data, '传值');
  147. becomeVip(data).then(({ data }) => {
  148. console.log('fufei', data);
  149. uni.hideLoading();
  150. if (data.status == 'PAY_ERROR') {
  151. console.log(data);
  152. }
  153. if (data.status == 'SUCCESS') {
  154. obj.getUserInfoB();
  155. }
  156. console.log('-----', data);
  157. let da = data.result.jsConfig;
  158. if (obj.payName == 'weixin' || obj.payName == 'routine') {
  159. // let da = data.result.jsConfig;
  160. console.log('--da--', da);
  161. let data = {
  162. // #ifdef H5
  163. timestamp: da.timestamp,
  164. // #endif
  165. // #ifdef MP
  166. timeStamp: da.timestamp,
  167. // #endif
  168. nonceStr: da.nonceStr,
  169. package: da.package,
  170. signType: da.signType,
  171. paySign: da.paySign,
  172. success: function(res) {
  173. console.log(res);
  174. obj.getUserInfoB();
  175. },
  176. fail: e => {
  177. console.log(e);
  178. }
  179. };
  180. console.log('--data--', data);
  181. // #ifdef MP
  182. wx.requestPayment(data);
  183. // #endif
  184. // #ifdef H5
  185. if (obj.payName == 'weixin') {
  186. weixinObj.chooseWXPay(data);
  187. }
  188. // #endif
  189. }
  190. uni.hideLoading();
  191. // #ifdef H5
  192. if (data.status == 'PAY_ERROR') {
  193. console.log(data);
  194. }
  195. if (data.status == 'SUCCESS') {
  196. obj.getUserInfoB();
  197. }
  198. // #endif
  199. });
  200. } catch (e) {
  201. console.log('fufiecw', e);
  202. //TODO handle the exception
  203. }
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. .card {
  210. position: relative;
  211. margin: auto;
  212. z-index: 10;
  213. width: 655rpx;
  214. height: 324rpx;
  215. background: linear-gradient(225deg, #ffeed2 0%, #fed591 100%);
  216. border-radius: 24rpx;
  217. padding: 28rpx 25rpx 30rpx 36rpx;
  218. .now-wrap {
  219. width: 190rpx;
  220. line-height: 69rpx;
  221. background: #C09852;
  222. border-radius: 35rpx;
  223. position: absolute;
  224. top:39rpx;
  225. right: 25rpx;
  226. font-size: 30rpx;
  227. font-family: PingFang SC;
  228. font-weight: 500;
  229. color: #F6DCA9;
  230. text-align: center;
  231. }
  232. .card-top {
  233. justify-content: flex-start;
  234. .avtur {
  235. width: 90rpx;
  236. height: 90rpx;
  237. border-radius: 50%;
  238. margin-right: 10rpx;
  239. image {
  240. width: 100%;
  241. height: 100%;
  242. border-radius: 50%;
  243. }
  244. }
  245. .name {
  246. font-size: 30rpx;
  247. font-family: PingFang SC;
  248. font-weight: 500;
  249. color: #333333;
  250. }
  251. .tip {
  252. font-size: 20rpx;
  253. font-family: PingFang SC;
  254. font-weight: 500;
  255. color: #333333;
  256. opacity: 0.52;
  257. }
  258. }
  259. .btn {
  260. position: absolute;
  261. top: 40rpx;
  262. right: 24rpx;
  263. width: 190rpx;
  264. height: 69rpx;
  265. background: #3a3a3b;
  266. border-radius: 35rpx;
  267. font-size: 30rpx;
  268. font-family: PingFang SC;
  269. font-weight: 500;
  270. color: #ffffff;
  271. line-height: 69rpx;
  272. text-align: center;
  273. }
  274. .card-info {
  275. height: 120rpx;
  276. position: absolute;
  277. bottom: 30rpx;
  278. left: 43rpx;
  279. .info-tit {
  280. line-height: 70rpx;
  281. font-size: 40rpx;
  282. font-family: PingFang SC;
  283. font-weight: bold;
  284. color: #333333;
  285. }
  286. .info-val {
  287. font-size: 28rpx;
  288. font-family: PingFang SC;
  289. font-weight: 500;
  290. color: #343434;
  291. }
  292. }
  293. }
  294. .hyjl {
  295. background-color: #fff;
  296. padding:30rpx 30rpx 0;
  297. margin-bottom: 20rpx;
  298. .jl-tit {
  299. font-size: 36rpx;
  300. font-family: PingFang SC;
  301. font-weight: 500;
  302. color: #000000;
  303. }
  304. }
  305. .tool {
  306. flex-wrap: wrap;
  307. justify-content: flex-start;
  308. align-items: center;
  309. .tool-item {
  310. width: 25%;
  311. height: 160rpx;
  312. display: flex;
  313. align-items: center;
  314. flex-direction: column;
  315. justify-content: center;
  316. .tool-img {
  317. width: 45rpx;
  318. height: 45rpx;
  319. image {
  320. width: 100%;
  321. height: 100%;
  322. }
  323. }
  324. .tool-name {
  325. padding-top: 20rpx;
  326. font-size: 28rpx;
  327. font-family: PingFang SC;
  328. font-weight: 400;
  329. color: #505050;
  330. }
  331. }
  332. .tool-item1 {
  333. background: #FAFBFF;
  334. display: flex;
  335. align-items: center;
  336. flex-direction: column;
  337. justify-content: center;
  338. width: 222rpx;
  339. height: 298rpx;
  340. background: #FAFBFF;
  341. border-radius: 10rpx;
  342. .tool-name {
  343. font-size: 30rpx;
  344. font-family: PingFang SC;
  345. font-weight: 500;
  346. color: #7B7B7B;
  347. }
  348. .bold {
  349. font-weight: bold;
  350. color: #000;
  351. }
  352. .tool-img {
  353. width: 157rpx;
  354. height: 112rpx;
  355. margin-top: 37rpx;
  356. image {
  357. width: 100%;
  358. height: 100%;
  359. }
  360. }
  361. }
  362. }
  363. .bottom-btn {
  364. display: flex;
  365. align-items: flex-end;
  366. position: fixed;
  367. bottom: 0;
  368. text-align: center;
  369. .btm-left {
  370. width: 750rpx - 280rpx;
  371. line-height: 100rpx;
  372. background-color: #34332F;
  373. color: #fff;
  374. }
  375. .btm-right {
  376. width: 280rpx;
  377. line-height: 108rpx;
  378. background: #EFD4A1;
  379. font-size: 36rpx;
  380. font-family: PingFang SC;
  381. font-weight: bold;
  382. color: #5A5A5A;
  383. }
  384. }
  385. </style>