vip.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <template>
  2. <view>
  3. <!-- #ifndef H5 -->
  4. <u-navbar :title="title" back-icon-color="#ffffff" :background="background" :border-bottom="false"
  5. :immersive="true"></u-navbar>
  6. <!-- #endif -->
  7. <u-navbar :title="title" back-icon-color="#ffffff" :background="background" :border-bottom="false"
  8. :immersive="true"></u-navbar>
  9. <view class="bgContont">
  10. <image class="bgContont-img" src="../static/vipBg.png" mode=""></image>
  11. <view class="vipContont">
  12. <view class="vipContont-title flex align-center justify-center">
  13. <image src="../static/vipTitle.png" mode="widthFix"></image>
  14. </view>
  15. <view class="vipContont-info flex align-center justify-center">
  16. <image src="../static/vipInfoBg.png" mode=""></image>
  17. <view class="vipContont-infot">
  18. <view class="vipContont-infot-title">
  19. {{vipEndTime?'尊享会员':'暂未开通'}}
  20. </view>
  21. <view class="vipContont-infot-titles">
  22. {{vipEndTime?'已享受接单特权':'开通即可享受接单权限'}}
  23. </view>
  24. <view v-if="vipEndTime" class="vipContont-infot-time">
  25. 到期时间
  26. </view>
  27. <view v-if="vipEndTime" class="vipContont-infot-times">
  28. {{vipEndTime}}
  29. </view>
  30. </view>
  31. </view>
  32. <view class="vipContont-mask flex justify-center">
  33. <image src="../static/vipInfoMask.png" mode=""></image>
  34. </view>
  35. <view v-if="vipList.length>0" class="vipContont-list flex align-center justify-center">
  36. <view class="vipContont-lists flex align-center justify-between flex-wrap">
  37. <view @click="current = index" class="vipContont-list-item"
  38. :class="current == index?'avticeColor':''" v-for="(item,index) in vipList" :key="index">
  39. <view class="vipContont-list-item-txt">
  40. {{item.vipName}}
  41. </view>
  42. <view class="vipContont-list-item-price">
  43. {{item.money}}
  44. <text>元</text>
  45. </view>
  46. <view class="vipContont-list-item-oldPrice">
  47. ¥{{item.oldMoney}}
  48. </view>
  49. </view>
  50. <view class="vipContont-list-item" style="height: 0;border: none;"></view>
  51. </view>
  52. </view>
  53. <view class="vipContont-xy flex align-center justify-center">
  54. <view class="vipContont-xys flex align-center">
  55. <u-checkbox active-color="#d7b586" style="margin-right: 10rpx;" shape="circle"
  56. v-model="checked"></u-checkbox>
  57. <view @click.stop.prevent="checked = !checked" class="flex align-center">
  58. 我已阅读并同意<text @click="goXieyi()" style="color: #d7b586;">《会员开通协议》</text>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="vipContont-btn flex align-center justify-center">
  63. <view @click="isPay()" class="vipContont-btns flex align-center justify-center">
  64. {{vipEndTime?'立即续费':'立即开通'}}
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <u-popup v-model="showPay" mode="bottom" border-radius="24" closeable>
  70. <view class="showPay">
  71. <view class="showPay-title">
  72. {{vipList[current]?vipList[current].vipName:''}}
  73. </view>
  74. <view class="showPay-titles">
  75. ¥:{{vipList[current]?vipList[current].money:0}}
  76. </view>
  77. <u-radio-group size="44" v-model="openWay" style="width: 100%;">
  78. <view class="showPay-list">
  79. <view @click="openWay = item.id" class="showPay-list-item flex align-center justify-between"
  80. v-for="(item,index) in openLists" :key="index">
  81. <view class="showPay-list-item-l">
  82. <image :src="item.image" mode=""></image>
  83. {{item.name}}
  84. </view>
  85. <u-radio :name="item.id">
  86. </u-radio>
  87. </view>
  88. </view>
  89. </u-radio-group>
  90. <view class="showPay-btn flex align-center justify-center">
  91. <view @click="pay()" class="showPay-btns flex align-center justify-center">
  92. 立即支付
  93. </view>
  94. </view>
  95. </view>
  96. </u-popup>
  97. </view>
  98. </template>
  99. <script>
  100. export default {
  101. data() {
  102. return {
  103. title: '',
  104. background: {
  105. background: 'transparent'
  106. },
  107. vipList: [],
  108. current: 0,
  109. openLists: [], //支付选项
  110. openWay: -1,
  111. showPay: false, //是否显示支付按钮
  112. checked: false, //是否同意会员开通协议
  113. vipEndTime: '', //vip到期时间
  114. };
  115. },
  116. onLoad() {
  117. // #ifdef MP-WEIXIN
  118. this.openLists = [{
  119. id: 1,
  120. image: '../static/weixin.png',
  121. name: '微信'
  122. }]
  123. this.openWay = 1
  124. // #endif
  125. // #ifdef APP-PLUS
  126. this.openLists = [{
  127. id: 1,
  128. image: '../static/weixin.png',
  129. name: '微信'
  130. },
  131. {
  132. id: 2,
  133. image: '../static/zhifubao.png',
  134. name: '支付宝'
  135. }
  136. ]
  137. this.openWay = 1
  138. // #endif
  139. // #ifdef H5
  140. let ua = navigator.userAgent.toLowerCase();
  141. if (ua.indexOf('micromessenger') !== -1) {
  142. //公众号是否自动登录 443
  143. this.$Request.get('/app/common/type/443').then(res => {
  144. if (res.data && res.data.value && res.data.value == '是') {
  145. this.openLists = [{
  146. id: 1,
  147. image: '../static/weixin.png',
  148. name: '微信'
  149. }];
  150. this.openWay = 1;
  151. } else {
  152. this.openLists = [{
  153. id: 2,
  154. image: '../static/zhifubao.png',
  155. name: '支付宝'
  156. }];
  157. this.openWay = 2;
  158. }
  159. })
  160. } else {
  161. this.openLists = [{
  162. id: 2,
  163. image: '../static/zhifubao.png',
  164. name: '支付宝'
  165. }];
  166. this.openWay = 2;
  167. }
  168. // #endif
  169. this.getVipInfo()
  170. this.getUserInfo()
  171. this.getVipList()
  172. },
  173. methods: {
  174. isPay() {
  175. if (!this.checked) {
  176. uni.showToast({
  177. title: '请阅读并同意《会员开通协议》',
  178. icon: 'none'
  179. })
  180. return
  181. }
  182. this.showPay = true
  183. },
  184. //去会员
  185. goXieyi() {
  186. uni.navigateTo({
  187. url: '/my/setting/vipVereinbarung'
  188. })
  189. },
  190. //支付
  191. pay() {
  192. let that = this
  193. uni.showLoading({
  194. title: '支付中'
  195. });
  196. if (this.openWay == 1) { //微信
  197. // 小程序支付
  198. // #ifdef MP-WEIXIN
  199. let data = {
  200. vipId: this.vipList[this.current].id,
  201. type: 3
  202. }
  203. this.$Request.postT('/app/wxPay/payMember', data).then(res => {
  204. if (res.code == 0) {
  205. uni.requestPayment({
  206. provider: 'wxpay',
  207. timeStamp: res.data.timestamp,
  208. nonceStr: res.data.noncestr,
  209. package: res.data.package,
  210. signType: res.data.signType,
  211. paySign: res.data.sign,
  212. success: function(res) {
  213. that.showPay = false
  214. uni.hideLoading();
  215. that.getVipInfo()
  216. uni.showToast({
  217. title: '支付成功'
  218. })
  219. },
  220. fail: function(err) {
  221. console.log(err)
  222. uni.hideLoading()
  223. uni.showToast({
  224. title: '支付失败',
  225. icon: 'none'
  226. })
  227. }
  228. });
  229. } else {
  230. uni.hideLoading()
  231. uni.showToast({
  232. title: res.msg,
  233. icon: 'none'
  234. })
  235. }
  236. })
  237. // #endif
  238. // #ifdef APP
  239. let data = {
  240. vipId: this.vipList[this.current].id,
  241. type: 1
  242. }
  243. this.$Request.postT('/app/wxPay/payMember', data).then(res => {
  244. if (res.code == 0) {
  245. this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
  246. } else {
  247. uni.hideLoading()
  248. uni.showToast({
  249. title: res.msg,
  250. icon: 'none'
  251. })
  252. }
  253. })
  254. // #endif
  255. // #ifdef H5
  256. let data = {
  257. vipId: this.vipList[this.current].id,
  258. type: 2
  259. }
  260. this.$Request.postT('/app/wxPay/payMember', data).then(res => {
  261. if (res.code == 0) {
  262. this.callPay(res);
  263. } else {
  264. uni.hideLoading()
  265. uni.showToast({
  266. title: res.msg,
  267. icon: 'none'
  268. })
  269. }
  270. })
  271. // #endif
  272. } else { //支付宝支付
  273. // 支付宝app支付
  274. // #ifdef APP
  275. let data = {
  276. vipId: this.vipList[this.current].id,
  277. type: 2
  278. }
  279. this.$Request.postT('/app/aliPay/payMember', data).then(res => {
  280. if (res.code == 0) {
  281. this.isCheckPay(res.code, 'alipay', res.data);
  282. } else {
  283. uni.hideLoading()
  284. uni.showToast({
  285. title: res.msg,
  286. icon: 'none'
  287. })
  288. }
  289. })
  290. // #endif
  291. //支付宝h5支付
  292. // #ifdef H5
  293. let data = {
  294. vipId: this.vipList[this.current].id,
  295. type: 1
  296. }
  297. this.$Request.postT('/app/aliPay/payMember', data).then(res => {
  298. if (res.code == 0) {
  299. uni.hideLoading()
  300. const div = document.createElement('div')
  301. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  302. document.body.appendChild(div)
  303. document.forms[0].submit()
  304. } else {
  305. uni.hideLoading()
  306. uni.showToast({
  307. title: res.msg,
  308. icon: 'none'
  309. })
  310. }
  311. })
  312. // #endif
  313. }
  314. },
  315. callPay: function(response) {
  316. if (typeof WeixinJSBridge === "undefined") {
  317. if (document.addEventListener) {
  318. document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
  319. } else if (document.attachEvent) {
  320. document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
  321. document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
  322. }
  323. } else {
  324. this.onBridgeReady(response);
  325. }
  326. },
  327. onBridgeReady: function(response) {
  328. let that = this;
  329. WeixinJSBridge.invoke(
  330. 'getBrandWCPayRequest', {
  331. "appId": response.data.appid, //公众号名称,由商户传入
  332. "timeStamp": response.data.timestamp, //时间戳,自1970年以来的秒数
  333. "nonceStr": response.data.noncestr, //随机串
  334. "package": response.data.package,
  335. "signType": response.data.signType, //微信签名方式:
  336. "paySign": response.data.sign //微信签名
  337. },
  338. function(res) {
  339. console.log(res, '/*-/*-/*-')
  340. if (res.err_msg === "get_brand_wcpay_request:ok") {
  341. // 使用以上方式判断前端返回,微信团队郑重提示:
  342. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  343. uni.hideLoading()
  344. that.getVipInfo()
  345. that.showPay = false
  346. uni.showLoading({
  347. title: '支付成功'
  348. });
  349. } else {
  350. uni.hideLoading();
  351. }
  352. WeixinJSBridge.log(response.err_msg);
  353. }
  354. );
  355. },
  356. isCheckPay(status, name, order) {
  357. if (status == 0) {
  358. this.setPayment(name, order);
  359. } else {
  360. uni.hideLoading();
  361. uni.showToast({
  362. title: '支付信息有误',
  363. icon: 'none'
  364. });
  365. }
  366. },
  367. setPayment(name, order) {
  368. let that = this
  369. console.log(name, '*-*-*', order)
  370. uni.requestPayment({
  371. provider: name,
  372. orderInfo: order, //微信、支付宝订单数据
  373. success: function(res) {
  374. console.log(res)
  375. that.getVipInfo()
  376. that.showPay = false
  377. uni.hideLoading();
  378. uni.showLoading({
  379. title: '支付成功'
  380. });
  381. },
  382. fail: function(err) {
  383. console.log(err)
  384. uni.hideLoading();
  385. },
  386. complete() {
  387. uni.hideLoading();
  388. }
  389. });
  390. },
  391. getUserInfo() {
  392. let data = {
  393. userId: uni.getStorageSync('userId')
  394. }
  395. this.$Request.getT("/app/user/selectUserDetails", data).then(res => {
  396. if (res.code == 0) {
  397. if (res.data.isVip && res.data.isVip == 1) {
  398. this.getVipInfo()
  399. } else {
  400. this.vipEndTime = ''
  401. }
  402. }
  403. })
  404. },
  405. //获取会员信息
  406. getVipInfo() {
  407. this.$Request.getT('/app/UserVip/selectUserVip').then(res => {
  408. if (res.code == 0) {
  409. if (res.data) {
  410. this.vipEndTime = res.data.endTime
  411. } else {
  412. this.vipEndTime = ''
  413. }
  414. }
  415. })
  416. },
  417. //获取会员类型列表
  418. getVipList() {
  419. this.$Request.getT('/app/VipDetails/selectVipDetails').then(res => {
  420. if (res.code == 0) {
  421. this.vipList = res.data
  422. }
  423. })
  424. },
  425. }
  426. }
  427. </script>
  428. <style>
  429. ::v-deep .u-radio__label {
  430. display: none !important;
  431. }
  432. ::v-deep .u-checkbox__label {
  433. display: none !important;
  434. }
  435. </style>
  436. <style lang="scss" scoped>
  437. page {
  438. background-color: #1c1b18;
  439. }
  440. .vipContont-xy {
  441. width: 100%;
  442. margin-top: 40rpx;
  443. .vipContont-xys {
  444. width: 686rpx;
  445. text-align: center;
  446. color: #ffffff;
  447. }
  448. }
  449. .showPay {
  450. width: 100%;
  451. height: auto;
  452. }
  453. .showPay-title {
  454. width: 100%;
  455. text-align: center;
  456. font-size: 32rpx;
  457. font-weight: bold;
  458. margin-top: 30rpx;
  459. }
  460. .showPay-titles {
  461. font-size: 30rpx;
  462. width: 100%;
  463. text-align: center;
  464. }
  465. .showPay-list {
  466. width: 100%;
  467. margin-top: 20rpx;
  468. }
  469. .showPay-list-item {
  470. width: 100%;
  471. margin-bottom: 30rpx;
  472. padding: 0 32rpx;
  473. }
  474. .showPay-list-item-l {
  475. display: flex;
  476. align-items: center;
  477. font-size: 30rpx;
  478. image {
  479. width: 80rpx;
  480. height: 80rpx;
  481. border-radius: 50%;
  482. margin-right: 20rpx;
  483. }
  484. }
  485. .showPay-btn {
  486. width: 100%;
  487. height: 88rpx;
  488. margin-bottom: 40rpx;
  489. .showPay-btns {
  490. width: 686rpx;
  491. height: 100%;
  492. border-radius: 44rpx;
  493. background-color: #2979ff;
  494. color: #ffffff;
  495. font-size: 32rpx;
  496. font-weight: bold;
  497. }
  498. }
  499. .bgContont {
  500. width: 100%;
  501. height: 100vh;
  502. position: relative;
  503. }
  504. .bgContont-img {
  505. width: 100%;
  506. height: 100%;
  507. }
  508. .vipContont {
  509. width: 100%;
  510. height: auto;
  511. position: absolute;
  512. left: 0;
  513. /* #ifdef H5 */
  514. top: 44px;
  515. /* #endif */
  516. /* #ifndef H5 */
  517. top: 44px;
  518. /* #endif */
  519. }
  520. .vipContont-title {
  521. width: 100%;
  522. margin-top: 70rpx;
  523. image {
  524. width: 634rpx;
  525. height: auto;
  526. }
  527. }
  528. .vipContont-info {
  529. width: 100%;
  530. height: 320rpx;
  531. margin-top: 80rpx;
  532. position: relative;
  533. image {
  534. width: 686rpx;
  535. height: 320rpx;
  536. }
  537. .vipContont-infot {
  538. width: 686rpx;
  539. height: auto;
  540. position: absolute;
  541. top: 0;
  542. left: 50%;
  543. transform: translate(-50%, 0);
  544. padding: 30rpx 40rpx;
  545. }
  546. .vipContont-infot-title {
  547. font-size: 48rpx;
  548. font-weight: 1000;
  549. color: #56260A;
  550. font-style: italic;
  551. }
  552. .vipContont-infot-titles {
  553. color: #765542;
  554. font-size: 24rpx;
  555. font-weight: 500;
  556. }
  557. .vipContont-infot-time {
  558. margin-top: 40rpx;
  559. color: #765542;
  560. font-size: 24rpx;
  561. font-weight: 500;
  562. }
  563. .vipContont-infot-times {
  564. font-size: 28rpx;
  565. color: #765542;
  566. font-weight: 500;
  567. margin-top: 10rpx;
  568. }
  569. }
  570. .vipContont-mask {
  571. width: 100%;
  572. // height: calc(100vh - 566rpx);
  573. margin-top: -70rpx;
  574. background-color: #1c1b18;
  575. image {
  576. width: 686rpx;
  577. height: 84rpx;
  578. }
  579. }
  580. .avticeColor {
  581. background: linear-gradient(90deg, #EFDCB5 0%, #DDB27D 100%) !important;
  582. .vipContont-list-item-txt {
  583. color: #775021 !important;
  584. }
  585. .vipContont-list-item-price {
  586. color: #795120 !important;
  587. }
  588. .vipContont-list-item-oldPrice {
  589. color: #7A4E20 !important;
  590. }
  591. }
  592. .vipContont-list {
  593. width: 100%;
  594. height: auto;
  595. .vipContont-lists {
  596. width: 686rpx;
  597. height: 100%;
  598. }
  599. .vipContont-list-item {
  600. width: 215rpx;
  601. height: 268rpx;
  602. background-color: #FEF9E9;
  603. border-radius: 24rpx;
  604. margin-bottom: 20rpx;
  605. display: flex;
  606. flex-direction: column;
  607. align-items: center;
  608. justify-content: center;
  609. border: 2px solid #FEE3AD;
  610. }
  611. .vipContont-list-item-txt {
  612. color: #222222;
  613. font-size: 28rpx;
  614. }
  615. .vipContont-list-item-price {
  616. color: #222222;
  617. font-size: 56rpx;
  618. font-weight: bold;
  619. margin: 20rpx 0;
  620. text {
  621. font-size: 20rpx;
  622. font-weight: normal;
  623. }
  624. }
  625. .vipContont-list-item-oldPrice {
  626. color: #464646;
  627. font-size: 24rpx;
  628. font-weight: 500;
  629. text-decoration: line-through;
  630. }
  631. }
  632. .vipContont-btn {
  633. width: 100%;
  634. height: 110rpx;
  635. margin-top: 40rpx;
  636. .vipContont-btns {
  637. width: 686rpx;
  638. height: 110rpx;
  639. border-radius: 24rpx;
  640. background: linear-gradient(122deg, #EFDCB5, #DDB27D);
  641. color: #56260A;
  642. font-size: 32rpx;
  643. font-weight: bold;
  644. }
  645. }
  646. </style>