member-pay.vue 13 KB

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