order-pay.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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" @click.stop="focusInput">
  22. <text class="text" v-if="payAmount>=0">{{payAmount}}</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 v-if="showDigitKeyboard"
  76. @confirmEvent="confirmEvent"
  77. :money.sync="payAmount"
  78. btn-color='linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%)'
  79. title="完成">
  80. </keyboard>
  81. </view>
  82. </template>
  83. <script>
  84. import authorize from '@/common/config/authorize.js'
  85. import keyboard from "@/components/keyboard/keyboard.vue"
  86. import { PayOrderCheckoutCounter,WeChatMiniWxPay } from "@/api/order.js"
  87. export default{
  88. components: {
  89. keyboard
  90. },
  91. data(){
  92. return{
  93. orderID:'',
  94. payableAmount:2222,
  95. receiptAmount:0,
  96. balanceAmount:0,
  97. payAmount:0,
  98. nvabarData: { //顶部自定义导航
  99. haveBack:true,
  100. showCapsule:1, // 是否显示左上角图标 1表示显示 0表示不显示,
  101. showSearch: 0,
  102. title: '收银台', // 导航栏 中间的标题
  103. textLeft:this.$store.state.isIphoneX
  104. },
  105. idCardList:[],
  106. isIphoneX:this.$store.state.isIphoneX,
  107. CustomBar:this.CustomBar,// 顶部导航栏高度
  108. tabCurrentIndex:0,
  109. isShowTip:false,
  110. buttonText:'去支付',
  111. discernReceipt:[],
  112. showDigitKeyboard:false
  113. }
  114. },
  115. onLoad(option) {
  116. // this.initData(option)
  117. },
  118. computed:{
  119. passStr(){
  120. let str='';
  121. this.idCardList.forEach(item=>{
  122. str+=item.toString();
  123. })
  124. return str;
  125. }
  126. },
  127. methods:{
  128. initData(e){
  129. this.orderID = e.orderID
  130. PayOrderCheckoutCounter({orderId:this.orderID}).then(response =>{
  131. console.log(response)
  132. this.discernReceipt = response.data.discernReceipt //支付记录
  133. this.receiptAmount = response.data.order.receiptAmount //已付金额
  134. this.payableAmount = response.data.order.payableAmount - this.receiptAmount //待付金额
  135. this.payAmount = this.payableAmount.toFixed(2) //自定义金额
  136. this.balanceAmount = this.payableAmount - this.payAmount// 计算剩余支付金额
  137. }).catch(error =>{
  138. this.$util.msg(error.msg,2000)
  139. })
  140. },
  141. MiniWxPayFor(){
  142. let self = this
  143. authorize.getCode('weixin').then(wechatcode =>{
  144. if(this.payAmount == 0){
  145. this.$util.msg("请输入本次支付的金额",2000)
  146. return
  147. }
  148. let params ={
  149. payAmount:this.payAmount*100,
  150. payWay:"WEIXIN",
  151. payType:"MINIAPP_WEIXIN",
  152. code:wechatcode,
  153. orderId:this.orderID
  154. }
  155. WeChatMiniWxPay(params).then(response =>{
  156. let PayInfo = JSON.parse(response.data.data.payInfo);
  157. uni.setStorageSync('payInfo',PayInfo)
  158. console.log(PayInfo)
  159. wx.requestPayment({
  160. 'timeStamp': PayInfo.timeStamp,
  161. 'nonceStr': PayInfo.nonceStr,
  162. 'package': PayInfo.package,
  163. 'signType': PayInfo.signType,
  164. 'paySign': PayInfo.paySign,
  165. 'success':function(res){
  166. console.log('支付成功');
  167. this.$api.redirectTo('/pages/user/order/order-details?orderID='+this.orderID)
  168. },
  169. 'fail':function(res){
  170. self.$util.msg('支付失败')
  171. },
  172. 'complete':function(res){
  173. }
  174. })
  175. }).catch(error =>{
  176. this.$util.msg(error.msg,2000)
  177. })
  178. })
  179. },
  180. focusInput(){
  181. this.showDigitKeyboard = true
  182. },
  183. confirmEvent(value){
  184. //点击键盘完成的回调函数
  185. console.log(value)
  186. this.chechValue(value)
  187. this.showDigitKeyboard = false
  188. },
  189. chechValue(value){
  190. console.log(parseInt(value))
  191. if(value == 0){
  192. console.log('1111',value)
  193. this.payAmount = 0
  194. this.balanceAmount = this.payableAmount
  195. }else if(parseInt(value)>this.payableAmount){
  196. console.log('2222',value)
  197. this.payAmount = this.payableAmount
  198. this.balanceAmount = this.payableAmount - this.payAmount
  199. }else{
  200. console.log('33333',value)
  201. this.payAmount = value
  202. this.balanceAmount = this.payableAmount - this.payAmount
  203. }
  204. },
  205. hanldNavigateBack(){
  206. uni.navigateBack({
  207. delta: 1
  208. });
  209. },
  210. payTypeText (state){
  211. let stateText = '',
  212. stateTextObject={
  213. 12:'PC-B2B网银',
  214. 13:'PC-微信支付',
  215. 14:'PC-支付宝',
  216. 15:'小程序-微信支付',
  217. 16:'余额抵扣',
  218. }
  219. Object.keys(stateTextObject).forEach(key => {
  220. if(key == state){
  221. stateText = stateTextObject[key]
  222. }
  223. })
  224. return stateText;
  225. },
  226. },
  227. onShow() {
  228. }
  229. }
  230. </script>
  231. <style lang="scss">
  232. page{height: auto !important;background-color: #F7F7F7;}
  233. .container-cash{
  234. width: 100%;
  235. .container-wrapper{
  236. width:100%;
  237. margin: 0 auto;
  238. .pay-content{
  239. width: 662rpx;
  240. height: 512rpx;
  241. padding: 48rpx 44rpx;
  242. 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;
  243. background-size: cover;
  244. float: left;
  245. .pay-top{
  246. width: 100%;
  247. height: auto;
  248. .pay-paid{
  249. width: 100%;
  250. height: auto;
  251. margin-bottom: 38rpx;
  252. text{
  253. display: inline-block;
  254. line-height: 48rpx;
  255. text-align: left;
  256. color: #FFFFFF;
  257. width: 100%;
  258. }
  259. .txt-m{
  260. font-size: $font-size-26;
  261. opacity: 0.7;
  262. }
  263. .txt-b{
  264. font-size: $font-size-32;
  265. }
  266. }
  267. }
  268. .pay-bot{
  269. width: 614rpx;
  270. height: 184rpx;
  271. padding: 24rpx;
  272. background: #FFFFFF;
  273. border-radius: 10rpx;
  274. .bot-title{
  275. line-height: 36rpx;
  276. font-size: $font-size-26;
  277. color: #666666;
  278. }
  279. .bot-input{
  280. width: 100%;
  281. height: 66rpx;
  282. margin: 15rpx 0;
  283. border-bottom: 1px solid #EBEBEB;
  284. line-height: 66rpx;
  285. font-size: $font-size-32;
  286. color: $text-color;
  287. text{
  288. display: block;
  289. float: left;
  290. }
  291. .input{
  292. font-size: $font-size-28;
  293. width: 500rpx;
  294. height: 66rpx;
  295. padding: 0 10rpx;
  296. line-height: 66rpx;
  297. float: left;
  298. .none{
  299. color:$text-color;
  300. opacity: 0.3;
  301. }
  302. .text{
  303. color:$text-color;
  304. }
  305. }
  306. }
  307. .bot-resid{
  308. line-height: 36rpx;
  309. font-size: $font-size-26;
  310. color: #666666;
  311. margin-top: 24rpx;
  312. }
  313. }
  314. }
  315. .pay-record{
  316. float: left;
  317. background: #FFFFFF;
  318. width: 702rpx;
  319. height: auto;
  320. padding: 0 24rpx;
  321. .record-title{
  322. width: 100%;
  323. float: left;
  324. font-size: $font-size-28;
  325. color: $text-color;
  326. line-height: 80rpx;
  327. height: 80rpx;
  328. border-bottom: 1px solid #F8F8F8;
  329. }
  330. .record-list{
  331. width: 100%;
  332. height: auto;
  333. float: left;
  334. .list-none{
  335. line-height: 80rpx;
  336. font-size: $font-size-26;
  337. color: #999999;
  338. text-align: left;
  339. }
  340. .list-main{
  341. height: auto;
  342. display: flex;
  343. flex-direction:column;
  344. .list-item{
  345. width: 100%;
  346. height:80rpx;
  347. display: flex;
  348. flex: 1;
  349. line-height: 80rpx;
  350. font-size: $font-size-26;
  351. color: $text-color;
  352. .text{
  353. &.row-1{
  354. flex: 3;
  355. }
  356. &.row-2{
  357. flex: 3;
  358. }
  359. &.row-3{
  360. flex: 4;
  361. text-align: right;
  362. }
  363. }
  364. }
  365. }
  366. }
  367. }
  368. }
  369. .pay-button{
  370. width: 100%;
  371. position: fixed;
  372. bottom: 40rpx;
  373. .btn{
  374. width: 702rpx;
  375. height: 88rpx;
  376. border-radius: 14rpx;
  377. font-size: $font-size-28;
  378. line-height: 88rpx;
  379. color: #FFFFFF;
  380. margin: 0 auto;
  381. text-align: center;
  382. background: $btn-confirm;
  383. }
  384. }
  385. }
  386. .freight-alert{
  387. width: 100%;
  388. height: 100%;
  389. background: rgba(0,0,0,.5);
  390. position: fixed;
  391. top: 0;
  392. left: 0;
  393. z-index: 8888;
  394. transition: all 0.4s;
  395. &.none{
  396. display: none;
  397. }
  398. &.show{
  399. display: block;
  400. }
  401. .content{
  402. width: 422rpx;
  403. height:434rpx;
  404. position: absolute;
  405. background: $bg-color;
  406. left: 0;
  407. right: 0;
  408. bottom: 0;
  409. top: 0;
  410. margin: auto;
  411. padding: 20rpx 32rpx;
  412. border-radius: 12rpx;
  413. .title{
  414. width: 100%;
  415. height: 68rpx;
  416. line-height: 68rpx;
  417. font-size: $font-size-28;
  418. color: $text-color;
  419. text-align: center;
  420. position: relative;
  421. .icon-iconfontguanbi{
  422. width: 68rpx;
  423. height: 68rpx;
  424. text-align: center;
  425. line-height: 68rpx;
  426. position: absolute;
  427. right: 0;
  428. top: 0;
  429. font-size: $font-size-36;
  430. color: #999999;
  431. }
  432. }
  433. .text-content{
  434. width: 100%;
  435. height: auto;
  436. .text{
  437. padding: 20rpx 0;
  438. line-height: 44rpx;
  439. font-size: $font-size-26;
  440. color:#666666;
  441. text-align: justify;
  442. }
  443. .text-p{
  444. line-height: 44rpx;
  445. font-size: $font-size-26;
  446. color:$color-system;
  447. text-align: left;
  448. }
  449. }
  450. }
  451. }
  452. </style>