member-pay.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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.data.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. console.log('data',data)
  181. wx.requestPayment({
  182. timeStamp: data.timeStamp,
  183. nonceStr: data.nonceStr,
  184. package: data.package,
  185. signType: data.signType,
  186. paySign: data.paySign,
  187. success: function(res) {
  188. wx.reLaunch({ url: '/pages/tabBar/user/user' })
  189. },
  190. fail: function(res) {
  191. self.$util.msg('用户取消支付~')
  192. },
  193. complete: function(res) {}
  194. })
  195. },
  196. BuildCatenate() {
  197. // 生成网银支付链接
  198. this.PayService.PayOrderPayLink({
  199. vipRecordId: this.payParams.vipRecordId,
  200. payType: this.payType
  201. }).then(response => {
  202. this.payHttpUrl = response.data
  203. this.isShowTip = true
  204. })
  205. },
  206. tabClick(index) {
  207. //tab切换
  208. this.tabCurrentIndex = this.payType = index
  209. switch (index) {
  210. case 0:
  211. this.btnColor = '#09BB07'
  212. this.buttonText = '使用微信支付'
  213. break
  214. case 1:
  215. this.btnColor = '#034582'
  216. this.buttonText = '生成企业网银链接'
  217. break
  218. case 2:
  219. this.btnColor = '#034582'
  220. this.buttonText = '生成个人网银链接'
  221. break
  222. }
  223. },
  224. hideTips() {
  225. //隐藏弹窗
  226. this.isShowTip = false
  227. },
  228. clipboard(data) {
  229. thorui.getClipboardData(data, res => {
  230. if (res) {
  231. this.isShowTip = false
  232. this.$util.msg('复制成功', 2000, true, 'success')
  233. // // 友盟埋点收集复制网银链接
  234. // if(process.env.NODE_ENV != 'development'){
  235. // this.$uma.trackEvent('Um_Event_CopyUnionPay', {
  236. // Um_Key_PageName: '网银支付',
  237. // Um_Key_SourcePage: '线上支付',
  238. // Um_Key_PayName:`${this.buttonText}`,
  239. // Um_Key_PayOrderID:`${this.orderId}`
  240. // })
  241. // }
  242. } else {
  243. this.$util.msg('复制失败', 2000, true, 'none')
  244. }
  245. })
  246. }
  247. },
  248. onShow() {}
  249. }
  250. </script>
  251. <style lang="scss">
  252. page {
  253. height: auto !important;
  254. background-color: #ffffff;
  255. }
  256. .container-cash {
  257. width: 100%;
  258. margin-top: 40rpx;
  259. .container-wrapper {
  260. width: 100%;
  261. box-sizing: border-box;
  262. padding: 0 24rpx;
  263. .pay-content {
  264. width: 100%;
  265. height: 254rpx;
  266. padding: 92rpx 40rpx 16rpx 40rpx;
  267. box-sizing: border-box;
  268. background: url(https://static.caimei365.com/app/img/icon/icon-member-pay@2x.png) no-repeat;
  269. background-size: cover;
  270. float: left;
  271. position: relative;
  272. .pay-p {
  273. font-size: $font-size-26;
  274. color: #4e4539;
  275. line-height: 36rpx;
  276. }
  277. .pay-money {
  278. color: #4e4539;
  279. line-height: 84rpx;
  280. font-weight: bold;
  281. .pay-sm {
  282. font-size: $font-size-26;
  283. }
  284. .pay-bg {
  285. font-size: 50rpx;
  286. }
  287. }
  288. .pay-mouth {
  289. position: absolute;
  290. right: 40rpx;
  291. bottom: 16rpx;
  292. line-height: 36rpx;
  293. font-size: $font-size-26;
  294. color: #4e4539;
  295. }
  296. }
  297. .pay-check {
  298. width: 100%;
  299. height: auto;
  300. float: left;
  301. .check-title {
  302. width: 622rpx;
  303. height: 40rpx;
  304. line-height: 40rpx;
  305. padding: 0 20rpx;
  306. margin-top: 24rpx;
  307. .text {
  308. font-size: $font-size-28;
  309. color: $text-color;
  310. text-align: left;
  311. float: left;
  312. }
  313. .icon {
  314. width: 40rpx;
  315. height: 40rpx;
  316. border-radius: 50%;
  317. line-height: 40rpx;
  318. text-align: center;
  319. color: #ffffff;
  320. font-size: $font-size-24;
  321. background: radial-gradient(
  322. circle,
  323. rgba(225, 86, 22, 1) 0%,
  324. rgba(255, 170, 0, 1) 67%,
  325. rgba(249, 185, 156, 1) 100%
  326. );
  327. float: right;
  328. }
  329. }
  330. .pay-checked {
  331. width: 100%;
  332. height: auto;
  333. .pay-item {
  334. width: 100%;
  335. height: 120rpx;
  336. box-sizing: border-box;
  337. border: 1px solid #e1e1e1;
  338. border-radius: 8rpx;
  339. padding: 20rpx;
  340. margin: 24rpx 0;
  341. display: flex;
  342. background-color: #ffffff;
  343. &.current {
  344. border-color: #e4aa43;
  345. .item-r {
  346. .icon-duigou {
  347. color: #e4aa43;
  348. }
  349. }
  350. }
  351. .item-l {
  352. flex: 8;
  353. .item-icon {
  354. width: 72rpx;
  355. height: 72rpx;
  356. float: left;
  357. text-align: center;
  358. line-height: 72rpx;
  359. margin-right: 20rpx;
  360. .iconfont {
  361. font-size: 78rpx;
  362. }
  363. .icon-weixinzhifu {
  364. color: #09bb07;
  365. }
  366. .icon-gerenwangyinzhifu {
  367. color: #034582;
  368. }
  369. .icon-qiyewangyinzhifu {
  370. color: #004889;
  371. }
  372. }
  373. .item-texts {
  374. line-height: 66rpx;
  375. font-size: $font-size-26;
  376. color: $text-color;
  377. }
  378. .item-text {
  379. line-height: 36rpx;
  380. font-size: $font-size-26;
  381. .txt-p {
  382. color: $text-color;
  383. }
  384. .txt-t {
  385. color: #999999;
  386. }
  387. }
  388. }
  389. .item-r {
  390. flex: 2;
  391. text-align: center;
  392. line-height: 72rpx;
  393. .icon-duigou {
  394. font-size: 54rpx;
  395. color: #ffffff;
  396. }
  397. }
  398. }
  399. }
  400. }
  401. }
  402. .pay-button {
  403. width: 100%;
  404. float: left;
  405. margin-top: 30rpx;
  406. .btn {
  407. width: 662rpx;
  408. height: 88rpx;
  409. border-radius: 44rpx;
  410. font-size: $font-size-28;
  411. line-height: 88rpx;
  412. color: #ffffff;
  413. margin: 0 auto;
  414. text-align: center;
  415. background: $btn-confirm;
  416. }
  417. }
  418. .pay-bring-wrapper {
  419. width: 100%;
  420. padding: 24rpx 0;
  421. background-color: #ffffff;
  422. display: flex;
  423. align-items: center;
  424. flex-direction: column;
  425. .pay-bring-content {
  426. width: 654rpx;
  427. height: auto;
  428. padding: 0 24rpx;
  429. .text {
  430. font-size: $font-size-24;
  431. color: #666;
  432. line-height: 44rpx;
  433. text-align: center;
  434. &.bg-color {
  435. color: $color-system;
  436. line-height: 88rpx;
  437. }
  438. }
  439. .text-v {
  440. font-size: $font-size-28;
  441. color: #999;
  442. line-height: 70rpx;
  443. text-align: left;
  444. &.title {
  445. font-size: $font-size-28;
  446. color: #666666;
  447. }
  448. &.bg-color {
  449. line-height: 44rpx;
  450. color: $color-system;
  451. }
  452. .clipboard {
  453. width: 84rpx;
  454. height: 36rpx;
  455. background: linear-gradient(34deg, rgba(255, 41, 41, 1) 0%, rgba(255, 109, 27, 1) 100%);
  456. text-align: center;
  457. font-size: $font-size-24;
  458. color: #ffffff;
  459. border-radius: 4rpx;
  460. line-height: 36rpx;
  461. display: inline-block;
  462. margin-left: 10rpx;
  463. }
  464. }
  465. }
  466. }
  467. }
  468. .payun-alert {
  469. width: 100%;
  470. height: 100%;
  471. background: rgba(0, 0, 0, 0.5);
  472. position: fixed;
  473. top: 0;
  474. left: 0;
  475. z-index: 8888;
  476. transition: all 0.4s;
  477. &.none {
  478. display: none;
  479. }
  480. &.show {
  481. display: block;
  482. }
  483. .content {
  484. width: 422rpx;
  485. height: 434rpx;
  486. position: absolute;
  487. background: $bg-color;
  488. left: 0;
  489. right: 0;
  490. bottom: 0;
  491. top: 0;
  492. margin: auto;
  493. padding: 20rpx 32rpx;
  494. border-radius: 12rpx;
  495. .title {
  496. width: 100%;
  497. height: 68rpx;
  498. line-height: 68rpx;
  499. font-size: $font-size-28;
  500. color: $text-color;
  501. text-align: center;
  502. position: relative;
  503. .icon-iconfontguanbi {
  504. width: 68rpx;
  505. height: 68rpx;
  506. text-align: center;
  507. line-height: 68rpx;
  508. position: absolute;
  509. right: 0;
  510. top: 0;
  511. font-size: $font-size-36;
  512. color: #999999;
  513. }
  514. }
  515. .text-content {
  516. width: 100%;
  517. height: auto;
  518. .text {
  519. padding: 20rpx 0 0 0;
  520. line-height: 44rpx;
  521. font-size: $font-size-26;
  522. color: #666666;
  523. text-align: justify;
  524. }
  525. .text-p {
  526. width: 100%;
  527. line-height: 44rpx;
  528. font-size: $font-size-26;
  529. color: $color-system;
  530. text-align: left;
  531. text-overflow: ellipsis;
  532. display: -webkit-box;
  533. word-break: break-all;
  534. -webkit-box-orient: vertical;
  535. -webkit-line-clamp: 1;
  536. overflow: hidden;
  537. }
  538. .text-b {
  539. line-height: 44rpx;
  540. font-size: $font-size-24;
  541. color: #999999;
  542. text-align: left;
  543. }
  544. }
  545. .text-button {
  546. width: 100%;
  547. height: 88rpx;
  548. line-height: 88rpx;
  549. background: $btn-confirm;
  550. font-size: $font-size-28;
  551. border-radius: 44rpx;
  552. color: #ffffff;
  553. text-align: center;
  554. margin-top: 20rpx;
  555. }
  556. }
  557. }
  558. </style>