member-pay.vue 14 KB

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