order-pay.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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">¥{{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. let self = this
  180. authorize.getCode('weixin').then(wechatcode =>{
  181. if(this.payAmount == 0){
  182. this.$util.msg("请输入本次支付的金额",2000)
  183. return
  184. }
  185. if(this.payAmount*100 < 2){
  186. this.$util.msg("本次支付的金额必须大于¥0.02",2000)
  187. return
  188. }
  189. let params ={
  190. payAmount:this.payAmount*100,
  191. payWay:"WEIXIN",
  192. code:wechatcode,
  193. orderId:this.orderID
  194. }
  195. this.PayService.WeChatMiniWxPay(params).then(response =>{
  196. let PayInfo = JSON.parse(response.data.data.payInfo);
  197. this.WxRequestPayment(PayInfo)
  198. }).catch(error =>{
  199. this.$util.msg(error.msg,2000)
  200. })
  201. })
  202. },
  203. WxRequestPayment(data){
  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. if(value == 0){
  235. this.payAmount = this.payableAmount.toFixed(2)
  236. this.balanceAmount = this.payableAmount-this.payAmount
  237. }else if(parseInt(value)>this.payableAmount){
  238. this.payAmount = this.payableAmount.toFixed(2)
  239. this.balanceAmount = this.payableAmount - this.payAmount
  240. }else{
  241. this.payAmount =Number(value).toFixed(2)
  242. this.balanceAmount = this.payableAmount - this.payAmount
  243. }
  244. },
  245. hanldNavigateBack(){//页面返回
  246. uni.navigateBack({
  247. delta: 1
  248. });
  249. },
  250. payTypeText (state){//处理支付记录文字
  251. let stateText = '',
  252. stateTextObject={
  253. 12:'网银支付',
  254. 13:'微信支付',
  255. 14:'支付宝支付',
  256. 15:'微信支付',
  257. 16:'余额抵扣',
  258. }
  259. Object.keys(stateTextObject).forEach(key => {
  260. if(key == state){
  261. stateText = stateTextObject[key]
  262. }
  263. })
  264. return stateText;
  265. },
  266. hideTips(){//隐藏弹窗
  267. this.isShowTip = false
  268. },
  269. clipboard(data) {//复制链接
  270. thorui.getClipboardData(data, (res) => {
  271. // #ifdef H5
  272. if (res) {
  273. this.$util.msg("复制成功",2000);
  274. } else {
  275. this.$util.msg("复制失败",2000);
  276. }
  277. // #endif
  278. })
  279. },
  280. discard(){
  281. //丢弃
  282. }
  283. },
  284. onShow() {
  285. }
  286. }
  287. </script>
  288. <style lang="scss">
  289. page{height: auto !important;background-color: #FFFFFF;}
  290. .container-cash{
  291. width: 100%;
  292. .container-wrapper{
  293. width:100%;
  294. margin: 0 auto;
  295. .pay-content{
  296. width: 662rpx;
  297. height: 420rpx;
  298. padding: 64rpx 44rpx 0 44rpx;
  299. background: url(https://admin-b.caimei365.com/userfiles/1/images/photo/2020/05/bg%403x.png) no-repeat;
  300. background-size: cover;
  301. float: left;
  302. position: relative;
  303. .pay-top{
  304. width: 100%;
  305. height: auto;
  306. float: left;
  307. margin-bottom: 44rpx;
  308. .pay-paid{
  309. width: 100%;
  310. height: auto;
  311. margin-bottom: 38rpx;
  312. text{
  313. line-height: 48rpx;
  314. text-align: left;
  315. color: #FFFFFF;
  316. width: 100%;
  317. }
  318. .txt-m{
  319. font-size: $font-size-26;
  320. opacity: 0.7;
  321. display: inline-block;
  322. }
  323. .txt-b{
  324. font-size: $font-size-48;
  325. display: inline-block;
  326. .small{
  327. font-size: $font-size-32;
  328. }
  329. }
  330. }
  331. .pay-payd{
  332. width: 100%;
  333. height: auto;
  334. .pay-paids{
  335. height: auto;
  336. float: left;
  337. margin-right: 48rpx;
  338. text{
  339. line-height: 48rpx;
  340. text-align: left;
  341. color: #FFFFFF;
  342. }
  343. .txt-m{
  344. width: 100%;
  345. display: inline-block;
  346. font-size: $font-size-26;
  347. opacity: 0.7;
  348. }
  349. .txt-b{
  350. width: 100%;
  351. display: inline-block;
  352. font-size: $font-size-32;
  353. }
  354. }
  355. }
  356. }
  357. .pay-bot{
  358. width: 614rpx;
  359. height: 184rpx;
  360. padding: 24rpx;
  361. background: #FFFFFF;
  362. border-radius: 20rpx;
  363. box-shadow:0 2px 6px rgba(255, 77, 0, .17);
  364. position: absolute;
  365. bottom: -92rpx;
  366. left:44rpx;
  367. .bot-title{
  368. line-height: 36rpx;
  369. font-size: $font-size-26;
  370. color: #666666;
  371. }
  372. .bot-input{
  373. width: 100%;
  374. height: 66rpx;
  375. margin: 15rpx 0;
  376. border-bottom: 1px solid #EBEBEB;
  377. line-height: 66rpx;
  378. font-size: $font-size-32;
  379. color: $text-color;
  380. text{
  381. display: block;
  382. float: left;
  383. }
  384. .input{
  385. font-size: $font-size-40;
  386. width: 500rpx;
  387. height: 66rpx;
  388. padding: 0 10rpx;
  389. line-height: 66rpx;
  390. float: left;
  391. .none{
  392. color:$text-color;
  393. opacity: 0.3;
  394. }
  395. .text{
  396. color:$text-color;
  397. }
  398. }
  399. .placeholder{
  400. font-size: $font-size-26;
  401. }
  402. }
  403. .bot-resid{
  404. line-height: 36rpx;
  405. font-size: $font-size-26;
  406. color: #666666;
  407. margin-top: 24rpx;
  408. color: $color-system;
  409. }
  410. }
  411. }
  412. .pay-record{
  413. float: left;
  414. background: #FFFFFF;
  415. width: 702rpx;
  416. height: auto;
  417. padding: 0 24rpx;
  418. margin-top: 112rpx;
  419. .record-title{
  420. width: 100%;
  421. float: left;
  422. font-size: $font-size-28;
  423. color: $text-color;
  424. line-height: 80rpx;
  425. height: 80rpx;
  426. border-bottom: 1px solid #F8F8F8;
  427. }
  428. .record-list{
  429. width: 100%;
  430. height: auto;
  431. float: left;
  432. .list-none{
  433. line-height: 80rpx;
  434. font-size: $font-size-26;
  435. color: #999999;
  436. text-align: left;
  437. }
  438. .list-main{
  439. height: auto;
  440. display: flex;
  441. flex-direction:column;
  442. .list-item{
  443. width: 100%;
  444. height:80rpx;
  445. display: flex;
  446. flex: 1;
  447. line-height: 80rpx;
  448. font-size: $font-size-26;
  449. color: $text-color;
  450. .text{
  451. &.row-1{
  452. flex: 3;
  453. }
  454. &.row-2{
  455. flex: 3;
  456. }
  457. &.row-3{
  458. flex: 4;
  459. text-align: right;
  460. }
  461. }
  462. }
  463. }
  464. }
  465. }
  466. }
  467. .pay-button{
  468. width: 100%;
  469. position: fixed;
  470. bottom: 80rpx;
  471. .btn{
  472. width: 702rpx;
  473. height: 88rpx;
  474. border-radius: 14rpx;
  475. font-size: $font-size-28;
  476. line-height: 88rpx;
  477. color: #FFFFFF;
  478. margin: 0 auto;
  479. text-align: center;
  480. background: $btn-confirm;
  481. }
  482. }
  483. }
  484. .freight-alert{
  485. width: 100%;
  486. height: 100%;
  487. background: rgba(0,0,0,.5);
  488. position: fixed;
  489. top: 0;
  490. left: 0;
  491. z-index: 8888;
  492. transition: all 0.4s;
  493. &.none{
  494. display: none;
  495. }
  496. &.show{
  497. display: block;
  498. }
  499. .content{
  500. width: 422rpx;
  501. height:434rpx;
  502. position: absolute;
  503. background: $bg-color;
  504. left: 0;
  505. right: 0;
  506. bottom: 0;
  507. top: 0;
  508. margin: auto;
  509. padding: 20rpx 32rpx;
  510. border-radius: 12rpx;
  511. .title{
  512. width: 100%;
  513. height: 68rpx;
  514. line-height: 68rpx;
  515. font-size: $font-size-28;
  516. color: $text-color;
  517. text-align: center;
  518. position: relative;
  519. .icon-iconfontguanbi{
  520. width: 68rpx;
  521. height: 68rpx;
  522. text-align: center;
  523. line-height: 68rpx;
  524. position: absolute;
  525. right: 0;
  526. top: 0;
  527. font-size: $font-size-36;
  528. color: #999999;
  529. }
  530. }
  531. .text-content{
  532. width: 100%;
  533. height: auto;
  534. .text{
  535. padding: 20rpx 0 0 0;
  536. line-height: 44rpx;
  537. font-size: $font-size-26;
  538. color:#666666;
  539. text-align: justify;
  540. }
  541. .text-p{
  542. width: 100%;
  543. line-height: 44rpx;
  544. font-size: $font-size-26;
  545. color:$color-system;
  546. text-align: left;
  547. text-overflow:ellipsis;
  548. display: -webkit-box;
  549. word-break: break-all;
  550. -webkit-box-orient: vertical;
  551. -webkit-line-clamp: 1;
  552. overflow: hidden;
  553. }
  554. .text-b{
  555. line-height: 44rpx;
  556. font-size: $font-size-24;
  557. color:#999999;
  558. text-align: left;
  559. }
  560. }
  561. .text-button{
  562. width: 100%;
  563. height: 88rpx;
  564. line-height: 88rpx;
  565. background: $btn-confirm;
  566. font-size: $font-size-28;
  567. border-radius: 14rpx;
  568. color:#FFFFFF;
  569. text-align: center;
  570. margin-top: 20rpx;
  571. }
  572. }
  573. }
  574. </style>