member-pay.vue 13 KB

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