member-pay.vue 14 KB

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