member-pay.vue 13 KB

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