order-pay.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <view class="container cashier">
  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">¥{{payableAmount.toFixed(2)}}</text>
  11. </view>
  12. <view class="pay-paid">
  13. <text class="txt-m">已支付金额</text>
  14. <text class="txt-b">¥{{receiptAmount.toFixed(2)}}</text>
  15. </view>
  16. </view>
  17. <view class="pay-bot">
  18. <view class="bot-title"><text>本次支付金额</text></view>
  19. <view class="bot-input">
  20. <text>¥</text>
  21. <view class="input" @tap="openKeyBoard('idCard')">
  22. <text class="text" v-if="passStr>0">{{passStr}}</text>
  23. <text class="none" v-else>输入金额不能大于待付金额</text>
  24. </view>
  25. <!-- <input class=""
  26. type="button"
  27. value=""
  28. @focus="focusInput"
  29. @input="inputMoney"
  30. @blur="blurInput"
  31. v-model=""
  32. placeholder="" maxlength="10"/> -->
  33. </view>
  34. <view class="bot-resid">
  35. <text>订单剩余¥{{balanceAmount.toFixed(2)}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="pay-record">
  40. <view class="record-title"><text>支付记录</text></view>
  41. <view class="record-list">
  42. <view class="list-main" v-if="discernReceipt.length>0">
  43. <view class="list-item" v-for="(item,index) in discernReceipt" :key="index">
  44. <text class="text row-1">¥{{item.receiptAmount}}</text>
  45. <text class="text row-2">{{payTypeText(item.payType)}}</text>
  46. <text class="text row-3">{{item.receiptDate}}</text>
  47. </view>
  48. </view>
  49. <view class="list-none" v-else>暂无支付记录</view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="pay-button">
  54. <view class="btn" @click.stop="MiniWxPayFor">{{buttonText}}</view>
  55. </view>
  56. </view>
  57. <view class="alert spec" :class="specClass" v-if="isShowTip">
  58. <!-- 选择支付弹窗说明 -->
  59. <view class="freight-alert" @tap="hideTips">
  60. <view class="content">
  61. <view class="title">
  62. <text>提示</text>
  63. <text class="iconfont icon-iconfontguanbi" @click.stop="hideTips"></text>
  64. </view>
  65. <view class="text-content">
  66. <view class="text">除了以下两种支付方式,您还可以通过线下直接转账的方式付款。获取转账信息请联系您的采美销售人员或直接拨打客服热线。</view>
  67. <view class="text-p">客服热线:</view>
  68. <view class="text-p">0755-22907771 / 15338851365</view>
  69. <view class="text-p">(周一至周五 09:00-18:00)</view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 数字键盘 -->
  75. <keyboard-package ref="idCard" type="number" @onInput="onInput" @onDelete="onDelete" @onConfirm="onConfirm"/>
  76. </view>
  77. </template>
  78. <script>
  79. import authorize from '@/common/config/authorize.js'
  80. import keyboardPackage from "@/components/keyboard-package/keyboard-package.vue"
  81. import { PayOrderCheckoutCounter,WeChatMiniWxPay } from "@/api/order.js"
  82. export default{
  83. components:{
  84. keyboardPackage
  85. },
  86. data(){
  87. return{
  88. orderID:'',
  89. payableAmount:0,
  90. receiptAmount:0,
  91. balanceAmount:0,
  92. payAmount:0,
  93. nvabarData: { //顶部自定义导航
  94. haveBack:true,
  95. showCapsule:1, // 是否显示左上角图标 1表示显示 0表示不显示,
  96. showSearch: 0,
  97. title: '收银台', // 导航栏 中间的标题
  98. textLeft:true
  99. },
  100. idCardList:[],
  101. isIphoneX:this.$store.state.isIphoneX,
  102. CustomBar:this.CustomBar,// 顶部导航栏高度
  103. tabCurrentIndex:0,
  104. isShowTip:false,
  105. buttonText:'去支付',
  106. discernReceipt:[],
  107. type:'number'
  108. }
  109. },
  110. onLoad(option) {
  111. this.initData(option)
  112. },
  113. computed:{
  114. passStr(){
  115. let str='';
  116. this.idCardList.forEach(item=>{
  117. str+=item.toString();
  118. })
  119. return str;
  120. }
  121. },
  122. methods:{
  123. initData(e){
  124. this.orderID = e.orderID
  125. PayOrderCheckoutCounter({orderId:this.orderID}).then(response =>{
  126. console.log(response)
  127. this.discernReceipt = response.data.discernReceipt //支付记录
  128. this.receiptAmount = response.data.order.receiptAmount //已付金额
  129. this.payableAmount = response.data.order.payableAmount - this.receiptAmount //待付金额
  130. this.payAmount = this.payableAmount.toFixed(2) //自定义金额
  131. this.balanceAmount = this.payableAmount - this.payAmount// 计算剩余支付金额
  132. }).catch(error =>{
  133. this.$util.msg(error.msg,2000)
  134. })
  135. },
  136. MiniWxPayFor(){
  137. let self = this
  138. authorize.getCode('weixin').then(wechatcode =>{
  139. if(this.payAmount == 0){
  140. this.$util.msg("请输入本次支付的金额",2000)
  141. return
  142. }
  143. let params ={
  144. payAmount:this.payAmount*100,
  145. payWay:"WEIXIN",
  146. payType:"MINIAPP_WEIXIN",
  147. code:wechatcode,
  148. orderId:this.orderID
  149. }
  150. WeChatMiniWxPay(params).then(response =>{
  151. let PayInfo = JSON.parse(response.data.data.payInfo);
  152. uni.setStorageSync('payInfo',PayInfo)
  153. console.log(PayInfo)
  154. wx.requestPayment({
  155. 'timeStamp': PayInfo.timeStamp,
  156. 'nonceStr': PayInfo.nonceStr,
  157. 'package': PayInfo.package,
  158. 'signType': PayInfo.signType,
  159. 'paySign': PayInfo.paySign,
  160. 'success':function(res){
  161. console.log('支付成功');
  162. this.$api.redirectTo('/pages/user/order/order-details?orderID='+this.orderID)
  163. },
  164. 'fail':function(res){
  165. self.$util.msg('支付失败')
  166. },
  167. 'complete':function(res){
  168. }
  169. })
  170. }).catch(error =>{
  171. this.$util.msg(error.msg,2000)
  172. })
  173. })
  174. },
  175. openKeyBoard(key) {
  176. this.type=key;
  177. this.$refs[key].open();
  178. },
  179. onInput(val){
  180. switch(this.type){
  181. case 'idCard':
  182. this.idCardList.push(val);
  183. break;
  184. }
  185. },
  186. onDelete(){
  187. switch (this.type){
  188. case 'idCard':
  189. this.idCardList.pop();
  190. break;
  191. }
  192. },
  193. onConfirm(){
  194. uni.showToast({
  195. title:'完成输入!',
  196. duration:2000,
  197. icon:'none'
  198. })
  199. },
  200. close(){
  201. this.$refs[this.type].close();
  202. },
  203. chechValue(value){
  204. console.log(parseInt(value))
  205. if(value == 0){
  206. this.payAmount = 0
  207. this.balanceAmount = this.payableAmount
  208. }else if(parseInt(value)>this.payableAmount){
  209. this.payAmount = this.payableAmount
  210. this.balanceAmount = this.payableAmount - this.payAmount
  211. }else{
  212. this.payAmount = value
  213. this.balanceAmount = this.payableAmount - this.payAmount
  214. }
  215. },
  216. hanldNavigateBack(){
  217. uni.navigateBack({
  218. delta: 1
  219. });
  220. },
  221. payTypeText (state){
  222. let stateText = '',
  223. stateTextObject={
  224. 12:'PC-B2B网银',
  225. 13:'PC-微信支付',
  226. 14:'PC-支付宝',
  227. 15:'小程序-微信支付',
  228. 16:'余额抵扣',
  229. }
  230. Object.keys(stateTextObject).forEach(key => {
  231. if(key == state){
  232. stateText = stateTextObject[key]
  233. }
  234. })
  235. return stateText;
  236. },
  237. },
  238. onShow() {
  239. }
  240. }
  241. </script>
  242. <style lang="scss">
  243. page{height: auto !important;background-color: #F7F7F7;}
  244. .container-cash{
  245. width: 100%;
  246. .container-wrapper{
  247. width:100%;
  248. margin: 0 auto;
  249. .pay-content{
  250. width: 662rpx;
  251. height: 512rpx;
  252. padding: 48rpx 44rpx;
  253. background: url(https://admin-b.caimei365.com/userfiles/1/images/photo/2020/05/%E6%94%B6%E9%93%B6%E5%8F%B0bg%402x.png) no-repeat;
  254. background-size: cover;
  255. float: left;
  256. .pay-top{
  257. width: 100%;
  258. height: auto;
  259. .pay-paid{
  260. width: 100%;
  261. height: auto;
  262. margin-bottom: 38rpx;
  263. text{
  264. display: inline-block;
  265. line-height: 48rpx;
  266. text-align: left;
  267. color: #FFFFFF;
  268. width: 100%;
  269. }
  270. .txt-m{
  271. font-size: $font-size-26;
  272. opacity: 0.7;
  273. }
  274. .txt-b{
  275. font-size: $font-size-32;
  276. }
  277. }
  278. }
  279. .pay-bot{
  280. width: 614rpx;
  281. height: 184rpx;
  282. padding: 24rpx;
  283. background: #FFFFFF;
  284. border-radius: 10rpx;
  285. .bot-title{
  286. line-height: 36rpx;
  287. font-size: $font-size-26;
  288. color: #666666;
  289. }
  290. .bot-input{
  291. width: 100%;
  292. height: 66rpx;
  293. margin: 15rpx 0;
  294. border-bottom: 1px solid #EBEBEB;
  295. line-height: 66rpx;
  296. font-size: $font-size-32;
  297. color: $text-color;
  298. text{
  299. display: block;
  300. float: left;
  301. }
  302. .input{
  303. font-size: $font-size-28;
  304. width: 500rpx;
  305. height: 66rpx;
  306. padding: 0 10rpx;
  307. line-height: 66rpx;
  308. float: left;
  309. .none{
  310. color:$text-color;
  311. opacity: 0.3;
  312. }
  313. .text{
  314. color:$text-color;
  315. }
  316. }
  317. }
  318. .bot-resid{
  319. line-height: 36rpx;
  320. font-size: $font-size-26;
  321. color: #666666;
  322. margin-top: 24rpx;
  323. }
  324. }
  325. }
  326. .pay-record{
  327. float: left;
  328. background: #FFFFFF;
  329. width: 702rpx;
  330. height: auto;
  331. padding: 0 24rpx;
  332. .record-title{
  333. width: 100%;
  334. float: left;
  335. font-size: $font-size-28;
  336. color: $text-color;
  337. line-height: 80rpx;
  338. height: 80rpx;
  339. border-bottom: 1px solid #F8F8F8;
  340. }
  341. .record-list{
  342. width: 100%;
  343. height: auto;
  344. float: left;
  345. .list-none{
  346. line-height: 80rpx;
  347. font-size: $font-size-26;
  348. color: #999999;
  349. text-align: left;
  350. }
  351. .list-main{
  352. height: auto;
  353. display: flex;
  354. flex-direction:column;
  355. .list-item{
  356. width: 100%;
  357. height:80rpx;
  358. display: flex;
  359. flex: 1;
  360. line-height: 80rpx;
  361. font-size: $font-size-26;
  362. color: $text-color;
  363. .text{
  364. &.row-1{
  365. flex: 3;
  366. }
  367. &.row-2{
  368. flex: 3;
  369. }
  370. &.row-3{
  371. flex: 4;
  372. text-align: right;
  373. }
  374. }
  375. }
  376. }
  377. }
  378. }
  379. }
  380. .pay-button{
  381. width: 100%;
  382. position: fixed;
  383. bottom: 40rpx;
  384. .btn{
  385. width: 702rpx;
  386. height: 88rpx;
  387. border-radius: 14rpx;
  388. font-size: $font-size-28;
  389. line-height: 88rpx;
  390. color: #FFFFFF;
  391. margin: 0 auto;
  392. text-align: center;
  393. background: $btn-confirm;
  394. }
  395. }
  396. }
  397. .freight-alert{
  398. width: 100%;
  399. height: 100%;
  400. background: rgba(0,0,0,.5);
  401. position: fixed;
  402. top: 0;
  403. left: 0;
  404. z-index: 8888;
  405. transition: all 0.4s;
  406. &.none{
  407. display: none;
  408. }
  409. &.show{
  410. display: block;
  411. }
  412. .content{
  413. width: 422rpx;
  414. height:434rpx;
  415. position: absolute;
  416. background: $bg-color;
  417. left: 0;
  418. right: 0;
  419. bottom: 0;
  420. top: 0;
  421. margin: auto;
  422. padding: 20rpx 32rpx;
  423. border-radius: 12rpx;
  424. .title{
  425. width: 100%;
  426. height: 68rpx;
  427. line-height: 68rpx;
  428. font-size: $font-size-28;
  429. color: $text-color;
  430. text-align: center;
  431. position: relative;
  432. .icon-iconfontguanbi{
  433. width: 68rpx;
  434. height: 68rpx;
  435. text-align: center;
  436. line-height: 68rpx;
  437. position: absolute;
  438. right: 0;
  439. top: 0;
  440. font-size: $font-size-36;
  441. color: #999999;
  442. }
  443. }
  444. .text-content{
  445. width: 100%;
  446. height: auto;
  447. .text{
  448. padding: 20rpx 0;
  449. line-height: 44rpx;
  450. font-size: $font-size-26;
  451. color:#666666;
  452. text-align: justify;
  453. }
  454. .text-p{
  455. line-height: 44rpx;
  456. font-size: $font-size-26;
  457. color:$color-system;
  458. text-align: left;
  459. }
  460. }
  461. }
  462. }
  463. </style>