member-pay.vue 15 KB

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