index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <view class="vip-content">
  3. <view class="container-box">
  4. <view class="title-box">
  5. <image class="title-img" src="@/static/images/my/vip-title.png" mode="widthFix"></image>
  6. <view class="desc">
  7. 甄选权益,开启您的按摩之旅
  8. </view>
  9. </view>
  10. <!-- <image class="bgimg" src="../static/workbg.png" mode="widthFix"></image> -->
  11. <!-- <image class="bgimg" src="/static/image/vip_bg.png" style="height: 100vh;"></image> -->
  12. <view>
  13. <!-- <image src="../../static/ktvip.png" style="margin: 80rpx 70rpx;width: 610rpx;height: 70rpx;"></image> -->
  14. <view class="vip_kapian">
  15. <!-- <image src="/static/image/vip_top.png"></image> -->
  16. <view style="padding: 52rpx;">
  17. <image class="img" src="/static/image/vip-text.png" mode=""></image>
  18. <view class="kapian_text">会员享受超值VIP特权</view>
  19. <!-- <view class="kapian_ktmoney" v-if="!isVip">¥ <text>{{payMoney}}</text> </view> -->
  20. <view class="kapian_ktname" v-if="endTime">到期时间</view>
  21. <view class="kapian_ktmoney" v-if="endTime">{{endTime}}</view>
  22. <view class="kapian_ktmoney" v-if="!isVip">------</view>
  23. </view>
  24. </view>
  25. <view class="save_vipbtn" v-if="!isVip" @tap="showpay = true">立即开通</view>
  26. <!-- <view class="quanyi_view">
  27. <image :src="quanyiImage" mode="widthFix"></image>
  28. </view> -->
  29. <view class="quanyi_view">
  30. <view class="quanyi_titview">
  31. <view class="flex justify-center align-center">
  32. <image src="../../static/vipleft.png"></image>
  33. <view class="quanyi_titname">VIP超值权益</view>
  34. <image src="../../static/vipright.png"></image>
  35. </view>
  36. <view class="quanyi_itemview">
  37. <view class="quanyi_listitem" v-for="(item,index) in gridData">
  38. <image :src="item.image"></image>
  39. <view class="listitem_name">{{item.title}}</view>
  40. </view>
  41. </view>
  42. <!-- <view class="save_vipbtn">立即开通</view> -->
  43. <view class="flex margin-top-xl flex-wrap justify-between" v-if="!isVip">
  44. <view v-for="(item,index) in vipList" :key='index' @click="select(item)" class="text-center flex flex-direction justify-between padding-tb radius"
  45. :class="selNum == item.id?'active': 'noactive'">
  46. <view class="text-bold" style="font-size: 28rpx;" >{{item.vipName}}</view>
  47. <view class="text-bold" style="font-size: 28rpx;">¥<text style="font-size: 48rpx;" >{{item.money}}</text></view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 支付方式 -->
  55. <u-popup v-model="showpay" mode="bottom">
  56. <view class="popup_pay">
  57. <view style="background-color: #fff;">
  58. <view style="padding: 0 20upx;margin-top: 60rpx;margin-bottom: 20rpx;">
  59. <view
  60. style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
  61. v-for="(item,index) in openLists" :key='index'>
  62. <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
  63. </image>
  64. <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
  65. {{item.text}}
  66. </view>
  67. <radio-group name="openWay" style="margin-left: 45upx;" @tap='selectWay(item.id)'>
  68. <label class="tui-radio">
  69. <radio color="#2FB57A" :checked="openWay === item.id ? true : false" />
  70. </label>
  71. </radio-group>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="pay_btn" @click="pay()">确认支付</view>
  76. </view>
  77. </u-popup>
  78. </view>
  79. </template>
  80. <script>
  81. export default {
  82. data() {
  83. return {
  84. endTime: '',
  85. customStyle: {
  86. width: '250rpx',
  87. color: '#402321',
  88. background: "#DFC5A7",
  89. border: 0,
  90. fontWeight: '700'
  91. },
  92. gridData: [{
  93. title: '专享九折',
  94. image: '../static/1.png'
  95. },
  96. {
  97. title: '身份标识',
  98. image: '../static/3.png'
  99. }
  100. ],
  101. avatar: '',
  102. userName: '匿名',
  103. vipList: [],
  104. selNum: 0,
  105. newPrice: 0,
  106. money: 0,
  107. price: 0,
  108. MemberList: [],
  109. isVip: true,
  110. openLists: [],
  111. openWay: 2,
  112. showpay: false,
  113. }
  114. },
  115. onLoad() {
  116. this.avatar = uni.getStorageSync('avatar')
  117. this.userName = uni.getStorageSync('userName')
  118. // #ifdef MP-WEIXIN
  119. this.openWay = 1;
  120. this.openLists = [{
  121. image: '../static/icon_weixin.png',
  122. text: '微信',
  123. id: 1
  124. }, {
  125. image: '../../static/images/lingqian.png',
  126. text: '余额',
  127. id: 3
  128. }]
  129. // #endif
  130. // #ifndef MP-WEIXIN
  131. this.openWay = 1;
  132. this.openLists = [{
  133. image: '../static/icon_weixin.png',
  134. text: '微信',
  135. id: 1
  136. }, {
  137. image: '../static/zhifubao.png',
  138. text: '支付宝',
  139. id: 2
  140. }, {
  141. image: '../../static/images/lingqian.png',
  142. text: '余额',
  143. id: 3
  144. }]
  145. // #endif
  146. this.getvipEndTime();
  147. this.getVipList()
  148. this.getMemberList()
  149. this.getMoney()
  150. this.getIsVip()
  151. },
  152. methods: {
  153. selectWay: function(id) {
  154. this.openWay = id;
  155. },
  156. getvipEndTime() {
  157. this.$Request.get("/app/UserVip/selectUserVip").then(res => {
  158. if (res.code == 0 && res.data) {
  159. this.endTime = res.data.endTime
  160. }
  161. });
  162. },
  163. //获取VIP列表
  164. getVipList() {
  165. this.$Request.get('/app/VipDetails/selectVipDetails').then(res => {
  166. if (res.code == 0) {
  167. this.vipList = res.data
  168. this.selNum = this.vipList[0].id
  169. this.price = this.vipList[0].money
  170. }
  171. })
  172. },
  173. // 获取特权列表
  174. getMemberList() {
  175. this.$Request.get('/app/member/selectMemberList').then(res => {
  176. if (res.code == 0) {
  177. this.MemberList = res.data
  178. }
  179. })
  180. },
  181. getIsVip() {
  182. this.$Request.get("/app/UserVip/isUserVip").then(res => {
  183. if (res.code == 0) {
  184. this.isVip = res.data
  185. this.$queue.setData('isVIP',this.isVip)
  186. if (this.isVip) {
  187. this.getvipEndTime();
  188. }
  189. }
  190. });
  191. },
  192. // 我的金元
  193. getMoney() {
  194. this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
  195. if (res.code == 0 && res.data) {
  196. this.money = res.data.money
  197. }
  198. });
  199. },
  200. select(e) {
  201. this.selNum = e.id
  202. this.price = e.money
  203. },
  204. pay() {
  205. this.getMoney()
  206. this.showpay = false;
  207. this.$queue.showLoading('支付中...')
  208. let that = this;
  209. let data = {
  210. id: this.selNum,
  211. type: '2'
  212. }
  213. if (this.openWay == 1) {
  214. // #ifdef MP-WEIXIN
  215. that.$Request.postT("/app/wxPay/payUserVip", {
  216. vipDetailsId: that.selNum,
  217. type: 3
  218. }).then(red => {
  219. if (red.code == 0) {
  220. uni.requestPayment({
  221. provider: 'wxpay',
  222. timeStamp: red.data.timestamp,
  223. nonceStr: red.data.noncestr,
  224. package: red.data.package,
  225. signType: red.data.signType,
  226. paySign: red.data.sign,
  227. success: function(redd) {
  228. uni.hideLoading();
  229. uni.showToast({
  230. title: '开通成功!'
  231. })
  232. setTimeout(function() {
  233. that.isVip = true
  234. that.getIsVip()
  235. }, 1000)
  236. },
  237. fail: function(err) {
  238. uni.hideLoading();
  239. that.$queue.showToast(
  240. '支付失败');
  241. }
  242. });
  243. } else {
  244. uni.showToast({
  245. title: red.msg,
  246. icon: 'none'
  247. })
  248. }
  249. });
  250. // #endif
  251. // #ifdef H5
  252. let ua = navigator.userAgent.toLowerCase();
  253. console.log(ua)
  254. if (ua.indexOf('micromessenger') !== -1) {
  255. that.$Request.post("/app/wxPay/payUserVip", {
  256. vipDetailsId: that.selNum,
  257. type: 2
  258. }).then(red => {
  259. if (red.code == 0) {
  260. that.callPay(red.data);
  261. } else {
  262. uni.showToast({
  263. title: red.msg,
  264. icon: 'none'
  265. })
  266. }
  267. });
  268. }else{
  269. that.$Request.post("/app/wxPay/payUserVip", {
  270. vipDetailsId: that.selNum,
  271. type: 4
  272. }).then(red => {
  273. if (red.code == 0) {
  274. const urlArr = window.location.href;
  275. const hostUrl = urlArr.split("/");
  276. const callBack = hostUrl[0] + "//" + hostUrl[2] + "/";
  277. const url = '&redirect_url=' + callBack + 'my/vip/index';
  278. window.location = red.data.mweb_url + url
  279. } else {
  280. uni.showToast({
  281. title: red.msg,
  282. icon: 'none'
  283. })
  284. }
  285. });
  286. }
  287. // #endif
  288. // #ifdef APP-PLUS
  289. that.$Request.post("/app/wxPay/payUserVip", {
  290. vipDetailsId: that.selNum,
  291. type: 1
  292. }).then(red => {
  293. if (red.code == 0) {
  294. console.log(JSON.stringify(red))
  295. that.setPayment('wxpay', JSON.stringify(red
  296. .data));
  297. } else {
  298. uni.showToast({
  299. title: red.msg,
  300. icon: 'none'
  301. })
  302. }
  303. });
  304. // #endif
  305. } else if (this.openWay == 2) {
  306. // #ifdef H5
  307. that.$Request.post("/app/aliPay/payUserVip ", {
  308. vipDetailsId: that.selNum,
  309. classify: 2
  310. }).then(red => {
  311. if (red.code == 0) {
  312. const div = document.createElement('div')
  313. div.innerHTML = red.data //此处form就是后台返回接收到的数据
  314. document.body.appendChild(div)
  315. document.forms[0].submit()
  316. } else {
  317. uni.showToast({
  318. title: red.msg,
  319. icon: 'none'
  320. })
  321. }
  322. });
  323. // #endif
  324. // #ifdef APP-PLUS
  325. that.$Request.post("/app/aliPay/payUserVip", {
  326. vipDetailsId: that.selNum,
  327. classify: 1
  328. }).then(red => {
  329. if (red.code == 0) {
  330. that.setPayment('alipay', red.data);
  331. } else {
  332. uni.showToast({
  333. title: red.msg,
  334. icon: 'none'
  335. })
  336. }
  337. });
  338. // #endif
  339. } else if (this.openWay == 3) {
  340. if (this.money >= this.price) {
  341. this.$Request.postT('/app/artificer/payUserVip', {
  342. vipDetailsId: this.selNum
  343. }).then(res => {
  344. console.log(res.data)
  345. if (res.code == 0) {
  346. this.isVip = true
  347. this.getIsVip()
  348. uni.showToast({
  349. title: '开通成功!'
  350. })
  351. // setTimeout(function() {
  352. // uni.navigateBack()
  353. // },1000)
  354. } else {
  355. this.$queue.showToast(res.msg)
  356. }
  357. })
  358. } else {
  359. uni.showModal({
  360. title: '提示',
  361. content: '当前账户余额不足,请充值',
  362. success: function(res) {
  363. if (res.confirm) {
  364. console.log('用户点击确定');
  365. uni.navigateTo({
  366. url: '/my/wallet/index'
  367. })
  368. } else if (res.cancel) {
  369. console.log('用户点击取消');
  370. }
  371. }
  372. })
  373. }
  374. }
  375. },
  376. callPay: function(response) {
  377. if (typeof WeixinJSBridge === "undefined") {
  378. if (document.addEventListener) {
  379. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  380. } else if (document.attachEvent) {
  381. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  382. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  383. }
  384. } else {
  385. this.onBridgeReady(response);
  386. }
  387. },
  388. onBridgeReady: function(response) {
  389. let that = this;
  390. if (!response.package) {
  391. return;
  392. }
  393. WeixinJSBridge.invoke(
  394. 'getBrandWCPayRequest', {
  395. "appId": response.appid, //公众号名称,由商户传入
  396. "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
  397. "nonceStr": response.noncestr, //随机串
  398. "package": response.package,
  399. "signType": response.signType, //微信签名方式:
  400. "paySign": response.sign //微信签名
  401. },
  402. function(res) {
  403. if (res.err_msg === "get_brand_wcpay_request:ok") {
  404. // 使用以上方式判断前端返回,微信团队郑重提示:
  405. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  406. uni.hideLoading();
  407. that.isVip = true
  408. that.getIsVip()
  409. uni.showToast({
  410. title: '开通成功!'
  411. })
  412. } else {
  413. uni.hideLoading();
  414. }
  415. WeixinJSBridge.log(response.err_msg);
  416. }
  417. );
  418. },
  419. setPayment(name, order) {
  420. let that = this;
  421. uni.requestPayment({
  422. provider: name,
  423. orderInfo: order, //微信、支付宝订单数据
  424. success: function(res) {
  425. uni.hideLoading();
  426. that.isVip = true
  427. that.getIsVip()
  428. uni.showToast({
  429. title: '开通成功!'
  430. })
  431. },
  432. fail: function(err) {
  433. uni.hideLoading();
  434. console.log(12)
  435. }
  436. });
  437. }
  438. },
  439. computed: {
  440. }
  441. }
  442. </script>
  443. <style lang="scss">
  444. .vip-content {
  445. width: 100%;
  446. min-height: 100vh;
  447. background: linear-gradient( 225deg, #13141D 0%, #55565D 35%, #15161F 100%);
  448. .container-box{
  449. padding: 80rpx 32rpx;
  450. .title-box{
  451. .title-img{
  452. width: 340rpx;
  453. height: 46rpx;
  454. }
  455. .desc{
  456. font-size: 28rpx;
  457. color: #707070;
  458. margin-top: 36rpx;
  459. }
  460. }
  461. }
  462. }
  463. .bgimg {
  464. position: absolute;
  465. height: 100vh;
  466. width: 100%;
  467. }
  468. .noactive {
  469. width: 216rpx;
  470. height: 226rpx;
  471. background: #4E4F55;
  472. border-radius: 32rpx 32rpx 32rpx 32rpx;
  473. border: 1rpx solid #F4E5BD;
  474. color: #FEE3AD;
  475. }
  476. .active {
  477. width: 216rpx;
  478. height: 226rpx;
  479. background: linear-gradient( 138deg, #FEE3AD 0%, #FFFFFF 20%, #BEA576 44%, #FFFFFF 71%, #FEE3AD 100%);
  480. border-radius: 32rpx 32rpx 32rpx 32rpx;
  481. color: #292929!important;
  482. }
  483. .save_vipbtn {
  484. width: 686rpx;
  485. height: 100rpx;
  486. background: linear-gradient( 121deg, #F9D385 0%, #FFEDCB 49%, #FEE3AD 100%);
  487. border-radius: 50rpx;
  488. text-align: center;
  489. line-height: 100rpx;
  490. font-size: 32rpx;
  491. font-family: PingFang SC;
  492. font-weight: bold;
  493. color: #56260A;
  494. position: fixed;
  495. left: 32rpx;
  496. bottom: 100rpx;
  497. z-index: 9999;
  498. }
  499. .quanyi_view {
  500. margin-top: 36rpx;
  501. .quanyi_titview {
  502. .save_vipbtn {
  503. width: 686rpx;
  504. height: 100rpx;
  505. background: linear-gradient(90deg, #FEDFB1 0%, #FDC673 100%);
  506. border-radius: 50rpx;
  507. text-align: center;
  508. line-height: 100rpx;
  509. margin: 100rpx 30rpx 0rpx;
  510. font-size: 32rpx;
  511. font-family: PingFang SC;
  512. font-weight: bold;
  513. color: #56260A;
  514. }
  515. .quanyi_itemview {
  516. margin-top: 20rpx;
  517. display: flex;
  518. width: 100%;
  519. flex-wrap: wrap;
  520. .quanyi_listitem {
  521. width: 25%;
  522. text-align: center;
  523. margin-top: 40rpx;
  524. .listitem_name {
  525. font-family: PingFang SC, PingFang SC;
  526. margin-top: 24rpx;
  527. font-weight: bold;
  528. font-size: 28rpx;
  529. color: #FEE3AD;
  530. }
  531. image {
  532. width: 80rpx;
  533. height: 80rpx;
  534. }
  535. }
  536. }
  537. .quanyi_titname {
  538. font-weight: bold;
  539. font-size: 36rpx;
  540. color: #FEE3AD;
  541. margin: 0rpx 12rpx;
  542. }
  543. image {
  544. width: 114rpx;
  545. height: 14rpx
  546. }
  547. }
  548. image {
  549. width: 749rpx;
  550. height: 1255rpx;
  551. }
  552. }
  553. .popup_pay {
  554. width: 100%;
  555. position: relative;
  556. padding-bottom: 45rpx;
  557. }
  558. .pay_btn {
  559. width: 90%;
  560. margin: 0 auto;
  561. text-align: center;
  562. background: #2FB57A;
  563. height: 80rpx;
  564. border-radius: 16rpx;
  565. color: #ffffff;
  566. line-height: 80rpx;
  567. }
  568. .vip_kapian {
  569. width: 686rpx;
  570. height: 370rpx;
  571. box-sizing: border-box;
  572. background: url('@/static/image/vip_top.png') no-repeat;
  573. background-size: 686rpx 370rpx;
  574. margin-top: 63rpx;
  575. .img {
  576. width: 219rpx;
  577. height: 55rpx;
  578. }
  579. .kapian_ktname,.kapian_text,.kapian_ktmoney {
  580. font-size: 28rpx;
  581. color: #707070;
  582. font-family: PingFang SC;
  583. margin-top: 26rpx;
  584. }
  585. }
  586. </style>