member-pay.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <view class="container cashier">
  3. <view class="container-cash clearfix">
  4. <view class="container-wrapper">
  5. <view class="pay-content">
  6. <view class="pay-p"><text>待付金额</text></view>
  7. <view class="pay-money">
  8. <text class="pay-sm">¥</text> <text class="pay-bg">{{ handelPayMsg.price | NumFormat }}</text>
  9. </view>
  10. <view class="pay-mouth">套餐:{{ handelPayMsg.duration }}个月</view>
  11. </view>
  12. <view class="pay-check">
  13. <view class="check-title"><view class="text">选择支付方式</view></view>
  14. <view class="pay-checked">
  15. <view class="pay-item" :class="{ current: tabCurrentIndex === 0 }" @click="tabClick(0)">
  16. <view class="item-l">
  17. <view class="item-icon"><text class="iconfont icon-weixinzhifu"></text></view>
  18. <view class="item-texts"><text>微信支付</text></view>
  19. </view>
  20. <view class="item-r"> <text class="iconfont icon-duigou"></text> </view>
  21. </view>
  22. <view class="pay-item" :class="{ current: tabCurrentIndex === 1 }" @click="tabClick(1)">
  23. <view class="item-l">
  24. <view class="item-icon"><text class="iconfont icon-qiyewangyinzhifu"></text></view>
  25. <view class="item-text">
  26. <view class="txt-p">企业网银支付</view> <view class="txt-t">需要在电脑端汇款</view>
  27. </view>
  28. </view>
  29. <view class="item-r"> <text class="iconfont icon-duigou"></text> </view>
  30. </view>
  31. <view class="pay-item" :class="{ current: tabCurrentIndex === 2 }" @click="tabClick(2)">
  32. <view class="item-l">
  33. <view class="item-icon"><text class="iconfont icon-gerenwangyinzhifu"></text></view>
  34. <view class="item-text">
  35. <view class="txt-p">个人网银支付</view> <view class="txt-t">需要在电脑端汇款</view>
  36. </view>
  37. </view>
  38. <view class="item-r"> <text class="iconfont icon-duigou"></text> </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="pay-button">
  44. <view class="btn" @click.stop="payConfirmClick" :style="{ background: btnColor }">{{
  45. buttonText
  46. }}</view>
  47. </view>
  48. </view>
  49. <view class="alert spec" :class="specClass" v-if="isShowTip">
  50. <!-- 选择支付弹窗说明 -->
  51. <view class="payun-alert" @tap="hideTips">
  52. <view class="content">
  53. <view class="title">
  54. <text>支付链接</text> <text class="iconfont icon-iconfontguanbi" @click.stop="hideTips"></text>
  55. </view>
  56. <view class="text-content">
  57. <view class="text"
  58. >请复制以下链接,并发送至电脑端,在浏览器访问该链接并选择银行尽快完成支付</view
  59. >
  60. <view class="text-p">{{ payHttpUrl }}</view> <view class="text-b">链接有效期为72小时</view>
  61. </view>
  62. <view class="text-button" @click.stop="clipboard(payHttpUrl)">复制链接</view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import authorize from '@/common/config/authorize.js'
  70. const thorui = require('@/components/clipboard/clipboard.thorui.js')
  71. import payMixins from '@/mixins/payMixins.js'
  72. export default {
  73. mixins: [payMixins],
  74. data() {
  75. return {
  76. isIphoneX: this.$store.state.isIphoneX,
  77. CustomBar: this.CustomBar, // 顶部导航栏高度
  78. tabCurrentIndex: 0,
  79. isShowTip: false,
  80. buttonText: '使用微信支付',
  81. btnColor: '#09BB07',
  82. handelPayMsg: {},
  83. payType: 0,
  84. isPaySwitch: true,
  85. payParams: {
  86. payType:'XCX',
  87. code: 0,
  88. vipRecordId: 0
  89. },
  90. payHttpUrl: 'https://www.caimei365.com'
  91. }
  92. },
  93. onLoad(option) {
  94. this.initGetStotage(option)
  95. },
  96. filters: {
  97. NumFormat(value) {
  98. if (!value) return '0.00'
  99. /*原来用的是Number(value).toFixed(0),这样取整时有问题,例如0.51取整之后为1,感谢Nils指正*/
  100. /*后来改成了 Number(value)|0,但是输入超过十一位就为负数了,具体见评论 */
  101. var intPart = Number(value) - (Number(value) % 1) //获取整数部分(这里是windy93的方法)
  102. var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') //将整数部分逢三一断
  103. var floatPart = '.00' //预定义小数部分
  104. var value2Array = value.toString().split('.')
  105. //=2表示数据有小数位
  106. if (value2Array.length == 2) {
  107. floatPart = value2Array[1].toString() //拿到小数部分
  108. if (floatPart.length == 1) {
  109. //补0,实际上用不着
  110. return intPartFormat + '.' + floatPart + '0'
  111. } else {
  112. return intPartFormat + '.' + floatPart
  113. }
  114. } else {
  115. return intPartFormat + floatPart
  116. }
  117. }
  118. },
  119. methods: {
  120. async initGetStotage(option) {
  121. let data = JSON.parse(option.data)
  122. this.payParams.vipRecordId = data.vipRecordId
  123. this.handelPayMsg = data
  124. this.PayOrderOnLineSwitch()
  125. console.log(this.handelPayMsg)
  126. },
  127. PayOrderOnLineSwitch() {
  128. // 线上支付开关
  129. this.PayService.PayOrderOnLineSwitch()
  130. .then(response => {
  131. if (response.data === 0) {
  132. this.isPaySwitch = true
  133. } else {
  134. this.isPaySwitch = false
  135. }
  136. })
  137. .catch(error => {
  138. console.log('线上支付开关异常')
  139. })
  140. },
  141. payConfirmClick() {
  142. // 友盟埋点收集选择支付方式
  143. if(process.env.NODE_ENV != 'development'){
  144. this.$uma.trackEvent('Um_Event_userClubMemberChooseWechatPay', {
  145. Um_Key_PageName: '支付超级会员',
  146. Um_Key_SourcePage: '支付超级会员',
  147. Um_Key_PayName:`${this.buttonText}`,
  148. Um_Key_Month: `${this.handelPayMsg.duration}个月`,
  149. })
  150. }
  151. if (this.isPaySwitch) {
  152. this.$util.msg('支付系统遇到点小问题,请稍后重试')
  153. return
  154. }
  155. switch (this.tabCurrentIndex) {
  156. case 0: // 微信小程序支付
  157. this.MiniWxPayFor()
  158. break
  159. case 1: // 生成企业网银链接
  160. this.BuildCatenate()
  161. break
  162. case 2: // 生成个人网银链接
  163. this.BuildCatenate()
  164. break
  165. }
  166. },
  167. async MiniWxPayFor() {
  168. // 使用微信支付
  169. this.payParams.code = await authorize.getCode('weixin')
  170. this.weChatMiniVipWxPay(this.payParams)
  171. // this.PayService.PayOrderVipWechat(this.payParams)
  172. // .then(response => {
  173. // let PayInfo = JSON.parse(response.data.rt10_payInfo)
  174. // this.WxRequestPayment(PayInfo)
  175. // })
  176. // .catch(error => {
  177. // this.$util.msg(error.msg, 2000)
  178. // })
  179. },
  180. WxRequestPayment(data) {
  181. // 微信支付Api
  182. let self = this
  183. console.log('data',data)
  184. wx.requestPayment({
  185. timeStamp: data.timeStamp,
  186. nonceStr: data.nonceStr,
  187. package: data.package,
  188. signType: data.signType,
  189. paySign: data.paySign,
  190. success: function(res) {
  191. wx.reLaunch({ url: '/pages/tabBar/user/user' })
  192. },
  193. fail: function(res) {
  194. self.$util.msg('用户取消支付~')
  195. },
  196. complete: function(res) {}
  197. })
  198. },
  199. BuildCatenate() {
  200. // 生成网银支付链接
  201. this.PayService.PayOrderPayLink({
  202. vipRecordId: this.payParams.vipRecordId,
  203. payType: this.payType
  204. }).then(response => {
  205. this.payHttpUrl = response.data
  206. this.isShowTip = true
  207. })
  208. },
  209. tabClick(index) {
  210. //tab切换
  211. this.tabCurrentIndex = this.payType = index
  212. switch (index) {
  213. case 0:
  214. this.btnColor = '#09BB07'
  215. this.buttonText = '使用微信支付'
  216. break
  217. case 1:
  218. this.btnColor = '#034582'
  219. this.buttonText = '生成企业网银链接'
  220. break
  221. case 2:
  222. this.btnColor = '#034582'
  223. this.buttonText = '生成个人网银链接'
  224. break
  225. }
  226. },
  227. hideTips() {
  228. //隐藏弹窗
  229. this.isShowTip = false
  230. },
  231. clipboard(data) {
  232. thorui.getClipboardData(data, res => {
  233. if (res) {
  234. this.isShowTip = false
  235. this.$util.msg('复制成功', 2000, true, 'success')
  236. // // 友盟埋点收集复制网银链接
  237. // if(process.env.NODE_ENV != 'development'){
  238. // this.$uma.trackEvent('Um_Event_CopyUnionPay', {
  239. // Um_Key_PageName: '网银支付',
  240. // Um_Key_SourcePage: '线上支付',
  241. // Um_Key_PayName:`${this.buttonText}`,
  242. // Um_Key_PayOrderID:`${this.orderId}`
  243. // })
  244. // }
  245. } else {
  246. this.$util.msg('复制失败', 2000, true, 'none')
  247. }
  248. })
  249. }
  250. },
  251. onShow() {}
  252. }
  253. </script>
  254. <style lang="scss">
  255. page {
  256. height: auto !important;
  257. background-color: #ffffff;
  258. }
  259. .container-cash {
  260. width: 100%;
  261. margin-top: 40rpx;
  262. .container-wrapper {
  263. width: 100%;
  264. box-sizing: border-box;
  265. padding: 0 24rpx;
  266. .pay-content {
  267. width: 100%;
  268. height: 254rpx;
  269. padding: 92rpx 40rpx 16rpx 40rpx;
  270. box-sizing: border-box;
  271. background: url(https://static.caimei365.com/app/img/icon/icon-member-pay@2x.png) no-repeat;
  272. background-size: cover;
  273. float: left;
  274. position: relative;
  275. .pay-p {
  276. font-size: $font-size-26;
  277. color: #4e4539;
  278. line-height: 36rpx;
  279. }
  280. .pay-money {
  281. color: #4e4539;
  282. line-height: 84rpx;
  283. font-weight: bold;
  284. .pay-sm {
  285. font-size: $font-size-26;
  286. }
  287. .pay-bg {
  288. font-size: 50rpx;
  289. }
  290. }
  291. .pay-mouth {
  292. position: absolute;
  293. right: 40rpx;
  294. bottom: 16rpx;
  295. line-height: 36rpx;
  296. font-size: $font-size-26;
  297. color: #4e4539;
  298. }
  299. }
  300. .pay-check {
  301. width: 100%;
  302. height: auto;
  303. float: left;
  304. .check-title {
  305. width: 622rpx;
  306. height: 40rpx;
  307. line-height: 40rpx;
  308. padding: 0 20rpx;
  309. margin-top: 24rpx;
  310. .text {
  311. font-size: $font-size-28;
  312. color: $text-color;
  313. text-align: left;
  314. float: left;
  315. }
  316. .icon {
  317. width: 40rpx;
  318. height: 40rpx;
  319. border-radius: 50%;
  320. line-height: 40rpx;
  321. text-align: center;
  322. color: #ffffff;
  323. font-size: $font-size-24;
  324. background: radial-gradient(
  325. circle,
  326. rgba(225, 86, 22, 1) 0%,
  327. rgba(255, 170, 0, 1) 67%,
  328. rgba(249, 185, 156, 1) 100%
  329. );
  330. float: right;
  331. }
  332. }
  333. .pay-checked {
  334. width: 100%;
  335. height: auto;
  336. .pay-item {
  337. width: 100%;
  338. height: 120rpx;
  339. box-sizing: border-box;
  340. border: 1px solid #e1e1e1;
  341. border-radius: 8rpx;
  342. padding: 20rpx;
  343. margin: 24rpx 0;
  344. display: flex;
  345. background-color: #ffffff;
  346. &.current {
  347. border-color: #e4aa43;
  348. .item-r {
  349. .icon-duigou {
  350. color: #e4aa43;
  351. }
  352. }
  353. }
  354. .item-l {
  355. flex: 8;
  356. .item-icon {
  357. width: 72rpx;
  358. height: 72rpx;
  359. float: left;
  360. text-align: center;
  361. line-height: 72rpx;
  362. margin-right: 20rpx;
  363. .iconfont {
  364. font-size: 78rpx;
  365. }
  366. .icon-weixinzhifu {
  367. color: #09bb07;
  368. }
  369. .icon-gerenwangyinzhifu {
  370. color: #034582;
  371. }
  372. .icon-qiyewangyinzhifu {
  373. color: #004889;
  374. }
  375. }
  376. .item-texts {
  377. line-height: 66rpx;
  378. font-size: $font-size-26;
  379. color: $text-color;
  380. }
  381. .item-text {
  382. line-height: 36rpx;
  383. font-size: $font-size-26;
  384. .txt-p {
  385. color: $text-color;
  386. }
  387. .txt-t {
  388. color: #999999;
  389. }
  390. }
  391. }
  392. .item-r {
  393. flex: 2;
  394. text-align: center;
  395. line-height: 72rpx;
  396. .icon-duigou {
  397. font-size: 54rpx;
  398. color: #ffffff;
  399. }
  400. }
  401. }
  402. }
  403. }
  404. }
  405. .pay-button {
  406. width: 100%;
  407. float: left;
  408. margin-top: 30rpx;
  409. .btn {
  410. width: 662rpx;
  411. height: 88rpx;
  412. border-radius: 44rpx;
  413. font-size: $font-size-28;
  414. line-height: 88rpx;
  415. color: #ffffff;
  416. margin: 0 auto;
  417. text-align: center;
  418. background: $btn-confirm;
  419. }
  420. }
  421. .pay-bring-wrapper {
  422. width: 100%;
  423. padding: 24rpx 0;
  424. background-color: #ffffff;
  425. display: flex;
  426. align-items: center;
  427. flex-direction: column;
  428. .pay-bring-content {
  429. width: 654rpx;
  430. height: auto;
  431. padding: 0 24rpx;
  432. .text {
  433. font-size: $font-size-24;
  434. color: #666;
  435. line-height: 44rpx;
  436. text-align: center;
  437. &.bg-color {
  438. color: $color-system;
  439. line-height: 88rpx;
  440. }
  441. }
  442. .text-v {
  443. font-size: $font-size-28;
  444. color: #999;
  445. line-height: 70rpx;
  446. text-align: left;
  447. &.title {
  448. font-size: $font-size-28;
  449. color: #666666;
  450. }
  451. &.bg-color {
  452. line-height: 44rpx;
  453. color: $color-system;
  454. }
  455. .clipboard {
  456. width: 84rpx;
  457. height: 36rpx;
  458. background: linear-gradient(34deg, rgba(255, 41, 41, 1) 0%, rgba(255, 109, 27, 1) 100%);
  459. text-align: center;
  460. font-size: $font-size-24;
  461. color: #ffffff;
  462. border-radius: 4rpx;
  463. line-height: 36rpx;
  464. display: inline-block;
  465. margin-left: 10rpx;
  466. }
  467. }
  468. }
  469. }
  470. }
  471. .payun-alert {
  472. width: 100%;
  473. height: 100%;
  474. background: rgba(0, 0, 0, 0.5);
  475. position: fixed;
  476. top: 0;
  477. left: 0;
  478. z-index: 8888;
  479. transition: all 0.4s;
  480. &.none {
  481. display: none;
  482. }
  483. &.show {
  484. display: block;
  485. }
  486. .content {
  487. width: 422rpx;
  488. height: 434rpx;
  489. position: absolute;
  490. background: $bg-color;
  491. left: 0;
  492. right: 0;
  493. bottom: 0;
  494. top: 0;
  495. margin: auto;
  496. padding: 20rpx 32rpx;
  497. border-radius: 12rpx;
  498. .title {
  499. width: 100%;
  500. height: 68rpx;
  501. line-height: 68rpx;
  502. font-size: $font-size-28;
  503. color: $text-color;
  504. text-align: center;
  505. position: relative;
  506. .icon-iconfontguanbi {
  507. width: 68rpx;
  508. height: 68rpx;
  509. text-align: center;
  510. line-height: 68rpx;
  511. position: absolute;
  512. right: 0;
  513. top: 0;
  514. font-size: $font-size-36;
  515. color: #999999;
  516. }
  517. }
  518. .text-content {
  519. width: 100%;
  520. height: auto;
  521. .text {
  522. padding: 20rpx 0 0 0;
  523. line-height: 44rpx;
  524. font-size: $font-size-26;
  525. color: #666666;
  526. text-align: justify;
  527. }
  528. .text-p {
  529. width: 100%;
  530. line-height: 44rpx;
  531. font-size: $font-size-26;
  532. color: $color-system;
  533. text-align: left;
  534. text-overflow: ellipsis;
  535. display: -webkit-box;
  536. word-break: break-all;
  537. -webkit-box-orient: vertical;
  538. -webkit-line-clamp: 1;
  539. overflow: hidden;
  540. }
  541. .text-b {
  542. line-height: 44rpx;
  543. font-size: $font-size-24;
  544. color: #999999;
  545. text-align: left;
  546. }
  547. }
  548. .text-button {
  549. width: 100%;
  550. height: 88rpx;
  551. line-height: 88rpx;
  552. background: $btn-confirm;
  553. font-size: $font-size-28;
  554. border-radius: 44rpx;
  555. color: #ffffff;
  556. text-align: center;
  557. margin-top: 20rpx;
  558. }
  559. }
  560. }
  561. </style>