index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="check-panel flex-direction">
  3. <image :src="shopDetail.cover" class="buyer-logo"></image>
  4. <view class="title center">{{shopDetail.name}}</view>
  5. <view class="input-content">
  6. <view class="tips">交易金额</view>
  7. <view class="input-bar center" @tap="show=true">
  8. <view class="icon center">¥</view>
  9. <view class="input center">
  10. <view>{{orderAmount}}</view>
  11. <view class="cusor"></view>
  12. </view>
  13. </view>
  14. <view style="height: 50rpx;"></view>
  15. <u-button class="button" type="warning" @click="pay">付款</u-button>
  16. </view>
  17. <view class="bottom-line center"> -- 联兑通提供技术支持 --</view>
  18. <u-keyboard ref="uKeyboard" :show-tips="false" :safe-area-inset-bottom="true" :mask="false" v-model="show"
  19. @change="handleInput" @backspace="handleDelete"></u-keyboard>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. onLoad(option) {},
  25. data() {
  26. return {
  27. show: true,
  28. logo: "/static/bank/CMBCHINA.png",
  29. buyer: "联兑通",
  30. orderAmount: '',
  31. shopId:'',
  32. shopDetail:{}
  33. }
  34. },
  35. onLoad(options) {
  36. this.shopId=options.shopId || '-1'
  37. this.fetchShopDetail()
  38. },
  39. methods: {
  40. fetchShopDetail(){
  41. this.$api.shop.detail({id:this.shopId}).then(res=>{
  42. if (this.$isEmpty(res.data)) {
  43. this.$dialog.showModal('获取不到商户信息',false).then(()=>{
  44. uni.navigateBack({
  45. delta:1
  46. })
  47. })
  48. }else{
  49. this.shopDetail=res.data
  50. }
  51. }).catch(err=>{
  52. this.$dialog.showModal('获取不到商户信息',false).then(()=>{
  53. uni.navigateBack({
  54. delta:1
  55. })
  56. })
  57. })
  58. },
  59. handleInput(num) {
  60. if (this.orderAmount.length > 12) {
  61. return
  62. }
  63. this.orderAmount = this.orderAmount + num
  64. },
  65. handleDelete() {
  66. if (this.$isEmpty(this.orderAmount)) {
  67. return
  68. }
  69. this.orderAmount = this.orderAmount.substr(0, this.orderAmount.length - 1)
  70. },
  71. async pay(){
  72. let expireTime= this.$dateTime.getExpireTime(5)
  73. let params={
  74. shopId:this.shopId,
  75. loginUserId:this.vuex_userId,
  76. money:this.orderAmount,
  77. billsTitle:'用户支付',
  78. expireTime,
  79. appId:this.$global.wxParams.APPID,
  80. openId:this.$cache.get('userInfo').openId,
  81. type:1 //type: 1-用户扫商户收款码支付 2-商户扫用户付款码支付
  82. }
  83. let resp=await this.$api.loginUser.payBefore(params)
  84. let obj={
  85. orderType:this.$global.orderType.USER_PAY,
  86. orderId:resp.data.id,
  87. payStatus:this.$global.payStatus.IS_WAIT
  88. }
  89. let res=await this.$api.pay.payOrder(obj)
  90. let prePayTn= JSON.parse(res.data.prePayTn)
  91. this.$mpi.requestPayment(prePayTn).then(()=>{
  92. uni.navigateTo({
  93. url:"/pages/checkstand/order-res?orderId="+resp.data.id
  94. })
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .check-panel {
  102. .buyer-logo {
  103. width: 100rpx;
  104. height: 100rpx;
  105. margin-top: 50rpx;
  106. margin-left: calc(50% - 50rpx);
  107. }
  108. .title {
  109. height: 70rpx;
  110. letter-spacing: 3rpx;
  111. color: #5D5D5D;
  112. }
  113. .input-content {
  114. padding: 50rpx;
  115. position: absolute;
  116. top: 280rpx;
  117. bottom: 0;
  118. left: 0;
  119. right: 0;
  120. background-color: #FFFFFF;
  121. width: 100%;
  122. border-radius: 25rpx 25rpx 0 0;
  123. .tips {
  124. height: 100rpx;
  125. font-size: 30rpx;
  126. display: flex;
  127. justify-content: left;
  128. align-items: center;
  129. }
  130. .input-bar {
  131. height: 150rpx;
  132. border-bottom: 1rpx solid #DDDDDD;
  133. .icon {
  134. width: 15%;
  135. font-size: 70rpx;
  136. font-weight: 900;
  137. height: 100%;
  138. }
  139. .input {
  140. width: 85%;
  141. height: 100%;
  142. overflow: hidden;
  143. font-size: 70rpx;
  144. }
  145. .cusor {
  146. width: 2rpx;
  147. height: 80%;
  148. background-color: #FD711B;
  149. animation: blink 1500ms infinite ease-in-out;
  150. }
  151. }
  152. }
  153. }
  154. .bottom-line {
  155. position: absolute;
  156. bottom: 50rpx;
  157. left: 0;
  158. width: 100%;
  159. color: #dddddd;
  160. }
  161. @keyframes blink {
  162. from {
  163. opacity: 0;
  164. }
  165. }
  166. </style>