order-pay.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <template>
  2. <view class="container cashier" @touchmove.stop.prevent="discard" @tap="hideKeyboard" v-show="isRepuest">
  3. <cu-custom :navbar-data='nvabarData' @navigateBack="hanldNavigateBack"></cu-custom>
  4. <view class="container-cash clearfix" :style="{marginTop:CustomBar+'px'}">
  5. <view class="container-wrapper">
  6. <view class="pay-content">
  7. <view class="pay-top">
  8. <view class="pay-paid">
  9. <text class="txt-m">待付金额</text>
  10. <text class="txt-b"><text class="small">¥</text>{{payableAmount.toFixed(2)}}</text>
  11. </view>
  12. <view class="pay-payd">
  13. <view class="pay-paids">
  14. <text class="txt-m">应付总额</text>
  15. <text class="txt-b">¥{{payTotalFee.toFixed(2)}}</text>
  16. </view>
  17. <view class="pay-paids">
  18. <text class="txt-m">已支付金额</text>
  19. <text class="txt-b">¥{{receiptAmount.toFixed(2)}}</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="pay-bot">
  24. <view class="bot-title"><text>本次支付金额</text></view>
  25. <view class="bot-input">
  26. <text>¥</text>
  27. <!-- <view class="input" @click.stop="focusInput">
  28. <text class="text" v-if="payAmount>=0">{{payAmount}}</text>
  29. <text class="none" v-else>输入金额不能大于待付金额</text>
  30. </view> -->
  31. <input class="input"
  32. type="digit"
  33. v-model="payAmount"
  34. @focus="focusInput"
  35. @blur="blurInput"
  36. placeholder="输入金额不能大于待付金额"
  37. placeholder-class="placeholder"/>
  38. </view>
  39. <view class="bot-resid">
  40. <text>应付剩余¥{{balanceAmount.toFixed(2)}}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="pay-record">
  45. <view class="record-title"><text>支付记录</text></view>
  46. <view class="record-list">
  47. <view class="list-main" v-if="discernReceipt.length>0">
  48. <view class="list-item" v-for="(item,index) in discernReceipt" :key="index">
  49. <text class="text row-1">¥{{toFixedFn(item.receiptAmount)}}</text>
  50. <text class="text row-2">{{payTypeText(item.payType)}}</text>
  51. <text class="text row-3">{{item.receiptDate}}</text>
  52. </view>
  53. </view>
  54. <view class="list-none" v-else>暂无支付记录</view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="pay-button">
  59. <view class="btn" @click.stop="buttonSubMit" :style="{'background':btnColor}">{{buttonText}}</view>
  60. </view>
  61. </view>
  62. <view class="alert spec" :class="specClass" v-if="isShowTip">
  63. <!-- 选择支付弹窗说明 -->
  64. <view class="freight-alert" @tap="hideTips">
  65. <view class="content">
  66. <view class="title">
  67. <text>支付链接</text>
  68. <text class="iconfont icon-iconfontguanbi" @click.stop="hideTips"></text>
  69. </view>
  70. <view class="text-content">
  71. <view class="text">请复制以下链接,并发送至电脑端,在浏览器访问该链接并选择银行尽快完成支付</view>
  72. <view class="text-p">{{payHttpUrl}}</view>
  73. <view class="text-b">链接有效期为24小时</view>
  74. </view>
  75. <view class="text-button" @click.stop="clipboard(payHttpUrl)">复制链接</view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 数字键盘 -->
  80. <!-- <keyboard v-if="showDigitKeyboard"
  81. @confirmEvent="confirmEvent"
  82. :money.sync="payAmount"
  83. btn-color='linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%)'
  84. title="完成">
  85. </keyboard> -->
  86. </view>
  87. </template>
  88. <script>
  89. import authorize from '@/common/config/authorize.js'
  90. // import keyboard from "@/components/keyboard/keyboard.vue"
  91. import thorui from "@/components/clipboard/clipboard.thorui.js"
  92. export default{
  93. components: {
  94. // keyboard
  95. },
  96. data(){
  97. return{
  98. orderID:'',
  99. payType:'',
  100. isRepuest:false,
  101. payableAmount:0,
  102. receiptAmount:0,
  103. balanceAmount:0,
  104. payTotalFee:0,
  105. payAmount:0,
  106. nvabarData: { //顶部自定义导航
  107. showCapsule:1, // 是否显示左上角图标 1表示显示 0表示不显示,
  108. showSearch: 0,
  109. title: '收银台', // 导航栏 中间的标题
  110. haveBack:true,
  111. textLeft:this.$store.state.isIphone
  112. },
  113. idCardList:[],
  114. isIphoneX:this.$store.state.isIphoneX,
  115. CustomBar:this.CustomBar,// 顶部导航栏高度
  116. tabCurrentIndex:0,
  117. isShowTip:false,
  118. buttonText:'去支付',
  119. btnColor:'#09BB07',
  120. discernReceipt:[],
  121. showDigitKeyboard:false,
  122. payHttpUrl:''
  123. }
  124. },
  125. onLoad(option) {
  126. this.initData(option)
  127. },
  128. methods:{
  129. initData(e){
  130. this.payType = e.type
  131. console.log(this.payType)
  132. this.orderID = e.orderID
  133. switch(this.payType){
  134. case '0':
  135. this.btnColor="#09BB07"
  136. this.buttonText = '去支付'
  137. break;
  138. case '1':
  139. this.btnColor="#034582"
  140. this.buttonText = '生成支付链接'
  141. break;
  142. }
  143. this.GetPayOrderInfo()
  144. },
  145. GetPayOrderInfo(){
  146. this.PayService.PayOrderCheckoutCounter({orderId:this.orderID}).then(response =>{
  147. this.isRepuest = true
  148. this.discernReceipt = response.data.discernReceipt //支付记录
  149. this.payTotalFee = response.data.order.payTotalFee //已付金额
  150. this.receiptAmount = response.data.order.receiptAmount //已付金额
  151. this.payableAmount = response.data.order.payableAmount - this.receiptAmount //待付金额
  152. this.payAmount = this.payableAmount.toFixed(2) //自定义金额
  153. this.balanceAmount = this.payableAmount - this.payAmount// 计算剩余支付金额
  154. }).catch(error =>{
  155. this.$util.msg(error.msg,2000)
  156. })
  157. },
  158. buttonSubMit(){
  159. switch(this.payType){
  160. case '0':
  161. this.MiniWxPayFor()
  162. break;
  163. case '1':
  164. this.BuildCatenate()
  165. break;
  166. }
  167. },
  168. BuildCatenate(){
  169. if(this.payAmount <=10){
  170. this.$util.msg("企业网银支付的金额必须大于¥10.00",2000)
  171. return
  172. }
  173. this.PayService.PayOrderPayLink({unpaidAmount:this.payAmount,orderId:this.orderID}).then(response =>{
  174. this.payHttpUrl = response.data
  175. this.isShowTip = true
  176. })
  177. },
  178. MiniWxPayFor(){
  179. authorize.getCode('weixin').then(wechatcode =>{
  180. if(this.payAmount == 0){
  181. this.$util.msg("请输入本次支付的金额",2000)
  182. return
  183. }
  184. if(this.payAmount*100 < 2){
  185. this.$util.msg("本次支付的金额必须大于¥0.02",2000)
  186. return
  187. }
  188. let params ={
  189. payAmount:this.payAmount*100,
  190. payWay:"WEIXIN",
  191. code:wechatcode,
  192. orderId:this.orderID
  193. }
  194. this.PayService.WeChatMiniWxPay(params).then(response =>{
  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. },
  202. WxRequestPayment(data){
  203. let self = this
  204. wx.requestPayment({
  205. 'timeStamp': data.timeStamp,
  206. 'nonceStr': data.nonceStr,
  207. 'package': data.package,
  208. 'signType': data.signType,
  209. 'paySign': data.paySign,
  210. 'success':function(res){
  211. wx.reLaunch({url: '/pages/tabBar/user/user'});
  212. },
  213. 'fail':function(res){
  214. self.$util.msg('微信调用支付失败,请重新发起支付~')
  215. },
  216. 'complete':function(res){
  217. }
  218. })
  219. },
  220. confirmEvent(value){//点击自定义键盘完成的回调函数
  221. this.chechValue(value)
  222. this.showDigitKeyboard = false
  223. },
  224. blurInput(e){
  225. this.chechValue(e.detail.value)
  226. },
  227. focusInput(){
  228. // this.showDigitKeyboard = true
  229. },
  230. hideKeyboard(){
  231. this.showDigitKeyboard = false
  232. },
  233. chechValue(value){
  234. let patern = /\d+\.\d+/g;
  235. if(value && value.split('.').length > 2) {
  236. value= patern.exec(value);
  237. }
  238. if(value == "" || value <0 ){
  239. this.payAmount = '';
  240. this.balanceAmount = this.payableAmount;
  241. }else if(parseInt(value)>this.payableAmount){
  242. this.payAmount = this.payableAmount.toFixed(2)
  243. this.balanceAmount = this.payableAmount - this.payAmount
  244. }else{
  245. this.payAmount =Number(value).toFixed(2)
  246. this.balanceAmount = this.payableAmount - this.payAmount
  247. }
  248. },
  249. hanldNavigateBack(){//页面返回
  250. uni.navigateBack({
  251. delta: 1
  252. });
  253. },
  254. payTypeText (state){//处理支付记录文字
  255. let stateText = '',
  256. stateTextObject={
  257. 12:'企业网银',
  258. 13:'微信支付',
  259. 14:'支付宝',
  260. 15:'微信支付',
  261. 16:'余额抵扣',
  262. }
  263. Object.keys(stateTextObject).forEach(key => {
  264. if(key == state){
  265. stateText = stateTextObject[key]
  266. }
  267. })
  268. return stateText;
  269. },
  270. hideTips(){//隐藏弹窗
  271. this.isShowTip = false
  272. },
  273. toFixedFn(text){//处理小数点后两位数
  274. return Number(text).toFixed(2);
  275. },
  276. clipboard(data) {//复制链接
  277. thorui.getClipboardData(data, (res) => {
  278. if (res) {
  279. this.isShowTip = false;
  280. this.$util.msg("复制成功",2000,true,'success');
  281. } else {
  282. this.$util.msg("复制失败",2000,true,'none');
  283. }
  284. })
  285. },
  286. discard(){
  287. //丢弃
  288. }
  289. },
  290. onShow() {
  291. }
  292. }
  293. </script>
  294. <style lang="scss">
  295. page{height: auto !important;background-color: #FFFFFF;}
  296. .container-cash{
  297. width: 100%;
  298. .container-wrapper{
  299. width:100%;
  300. margin: 0 auto;
  301. .pay-content{
  302. width: 662rpx;
  303. height: 420rpx;
  304. padding: 64rpx 44rpx 0 44rpx;
  305. background: url(https://img.caimei365.com/group1/M00/03/BD/Cmis218elN6AY6VeAAqw4n3n4nw186.png) no-repeat;
  306. background-size: cover;
  307. float: left;
  308. position: relative;
  309. .pay-top{
  310. width: 100%;
  311. height: auto;
  312. float: left;
  313. margin-bottom: 44rpx;
  314. .pay-paid{
  315. width: 100%;
  316. height: auto;
  317. margin-bottom: 38rpx;
  318. text{
  319. line-height: 48rpx;
  320. text-align: left;
  321. color: #FFFFFF;
  322. width: 100%;
  323. }
  324. .txt-m{
  325. font-size: $font-size-26;
  326. opacity: 0.7;
  327. display: inline-block;
  328. }
  329. .txt-b{
  330. font-size: $font-size-48;
  331. display: inline-block;
  332. .small{
  333. font-size: $font-size-32;
  334. }
  335. }
  336. }
  337. .pay-payd{
  338. width: 100%;
  339. height: auto;
  340. .pay-paids{
  341. height: auto;
  342. float: left;
  343. margin-right: 48rpx;
  344. text{
  345. line-height: 48rpx;
  346. text-align: left;
  347. color: #FFFFFF;
  348. }
  349. .txt-m{
  350. width: 100%;
  351. display: inline-block;
  352. font-size: $font-size-26;
  353. opacity: 0.7;
  354. }
  355. .txt-b{
  356. width: 100%;
  357. display: inline-block;
  358. font-size: $font-size-32;
  359. }
  360. }
  361. }
  362. }
  363. .pay-bot{
  364. width: 614rpx;
  365. height: 184rpx;
  366. padding: 24rpx;
  367. background: #FFFFFF;
  368. border-radius: 20rpx;
  369. box-shadow:0 2px 6px rgba(255, 77, 0, .17);
  370. position: absolute;
  371. bottom: -92rpx;
  372. left:44rpx;
  373. .bot-title{
  374. line-height: 36rpx;
  375. font-size: $font-size-26;
  376. color: #666666;
  377. }
  378. .bot-input{
  379. width: 100%;
  380. height: 66rpx;
  381. margin: 15rpx 0;
  382. border-bottom: 1px solid #EBEBEB;
  383. line-height: 66rpx;
  384. font-size: $font-size-32;
  385. color: $text-color;
  386. text{
  387. display: block;
  388. float: left;
  389. }
  390. .input{
  391. font-size: $font-size-40;
  392. width: 500rpx;
  393. height: 66rpx;
  394. padding: 0 10rpx;
  395. line-height: 66rpx;
  396. float: left;
  397. .none{
  398. color:$text-color;
  399. opacity: 0.3;
  400. }
  401. .text{
  402. color:$text-color;
  403. }
  404. }
  405. .placeholder{
  406. font-size: $font-size-26;
  407. }
  408. }
  409. .bot-resid{
  410. line-height: 36rpx;
  411. font-size: $font-size-26;
  412. color: #666666;
  413. margin-top: 24rpx;
  414. color: $color-system;
  415. }
  416. }
  417. }
  418. .pay-record{
  419. float: left;
  420. background: #FFFFFF;
  421. width: 702rpx;
  422. height: auto;
  423. padding: 0 24rpx;
  424. margin-top: 112rpx;
  425. .record-title{
  426. width: 100%;
  427. float: left;
  428. font-size: $font-size-28;
  429. color: $text-color;
  430. line-height: 80rpx;
  431. height: 80rpx;
  432. border-bottom: 1px solid #F8F8F8;
  433. }
  434. .record-list{
  435. width: 100%;
  436. height: auto;
  437. float: left;
  438. .list-none{
  439. line-height: 80rpx;
  440. font-size: $font-size-26;
  441. color: #999999;
  442. text-align: left;
  443. }
  444. .list-main{
  445. height: auto;
  446. display: flex;
  447. flex-direction:column;
  448. .list-item{
  449. width: 100%;
  450. height:80rpx;
  451. display: flex;
  452. flex: 1;
  453. line-height: 80rpx;
  454. font-size: $font-size-26;
  455. color: $text-color;
  456. .text{
  457. &.row-1{
  458. flex: 3;
  459. }
  460. &.row-2{
  461. flex: 3;
  462. }
  463. &.row-3{
  464. flex: 4;
  465. text-align: right;
  466. color: #999999;
  467. }
  468. }
  469. }
  470. }
  471. }
  472. }
  473. }
  474. .pay-button{
  475. width: 100%;
  476. position: fixed;
  477. bottom: 80rpx;
  478. .btn{
  479. width: 702rpx;
  480. height: 88rpx;
  481. border-radius: 14rpx;
  482. font-size: $font-size-28;
  483. line-height: 88rpx;
  484. color: #FFFFFF;
  485. margin: 0 auto;
  486. text-align: center;
  487. background: $btn-confirm;
  488. }
  489. }
  490. }
  491. .freight-alert{
  492. width: 100%;
  493. height: 100%;
  494. background: rgba(0,0,0,.5);
  495. position: fixed;
  496. top: 0;
  497. left: 0;
  498. z-index: 8888;
  499. transition: all 0.4s;
  500. &.none{
  501. display: none;
  502. }
  503. &.show{
  504. display: block;
  505. }
  506. .content{
  507. width: 422rpx;
  508. height:434rpx;
  509. position: absolute;
  510. background: $bg-color;
  511. left: 0;
  512. right: 0;
  513. bottom: 0;
  514. top: 0;
  515. margin: auto;
  516. padding: 20rpx 32rpx;
  517. border-radius: 12rpx;
  518. .title{
  519. width: 100%;
  520. height: 68rpx;
  521. line-height: 68rpx;
  522. font-size: $font-size-28;
  523. color: $text-color;
  524. text-align: center;
  525. position: relative;
  526. .icon-iconfontguanbi{
  527. width: 68rpx;
  528. height: 68rpx;
  529. text-align: center;
  530. line-height: 68rpx;
  531. position: absolute;
  532. right: 0;
  533. top: 0;
  534. font-size: $font-size-36;
  535. color: #999999;
  536. }
  537. }
  538. .text-content{
  539. width: 100%;
  540. height: auto;
  541. .text{
  542. padding: 20rpx 0 0 0;
  543. line-height: 44rpx;
  544. font-size: $font-size-26;
  545. color:#666666;
  546. text-align: justify;
  547. }
  548. .text-p{
  549. width: 100%;
  550. line-height: 44rpx;
  551. font-size: $font-size-26;
  552. color:$color-system;
  553. text-align: left;
  554. text-overflow:ellipsis;
  555. display: -webkit-box;
  556. word-break: break-all;
  557. -webkit-box-orient: vertical;
  558. -webkit-line-clamp: 1;
  559. overflow: hidden;
  560. }
  561. .text-b{
  562. line-height: 44rpx;
  563. font-size: $font-size-24;
  564. color:#999999;
  565. text-align: left;
  566. }
  567. }
  568. .text-button{
  569. width: 100%;
  570. height: 88rpx;
  571. line-height: 88rpx;
  572. background: $btn-confirm;
  573. font-size: $font-size-28;
  574. border-radius: 14rpx;
  575. color:#FFFFFF;
  576. text-align: center;
  577. margin-top: 20rpx;
  578. }
  579. }
  580. }
  581. </style>