pay.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view>
  3. <!-- 扫一扫错误回调 -->
  4. <u-modal title="扫描异常" confirm-color="#dc9b21" v-model="scanNotify.scan" :content="scanNotify.scanMessage"></u-modal>
  5. <view class="data">
  6. <text style="color: #000;">收款金额</text>
  7. <view class="price">
  8. <view class="input-bar center" @tap="show">
  9. <view class="icon center">¥</view>
  10. <view class="input" style="display: flex; align-items: center;">
  11. <view style="font-size: 80rpx;font-weight: 800;">{{filterMoney(money)}}</view>
  12. <view class="cusor"></view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <amountInput ref="amountInput" confirmText="收款" btnColor="#ff9900"
  18. placeholder="请输入交易金额" @change="change"
  19. @confirm="scanCode"></amountInput>
  20. </view>
  21. </template>
  22. <script>
  23. import amountInput from '@/components/amountInput/amountInput.vue';
  24. export default {
  25. components: {
  26. amountInput
  27. },
  28. data() {
  29. return {
  30. scanNotify:{scan: false,scanMessage:'扫描错误,请稍后重试!' },
  31. money:'',
  32. //向哪个用户收款
  33. secret:'',
  34. userId:''
  35. }
  36. },
  37. onLoad(options) {
  38. this.show()
  39. },
  40. methods: {
  41. scanCode(){
  42. const _this = this;
  43. uni.scanCode({
  44. onlyFromCamera:true,
  45. scanType: ['barCode'],
  46. success: function (res) {
  47. //用户id
  48. _this.secret=res.result
  49. _this.userId=_this.secret.substr(0,19)
  50. //处理支付
  51. _this.toPay()
  52. },
  53. fail: (res) => {
  54. if(res.errMsg!='scanCode:fail cancel'){
  55. _this.scanNotify = {scan: true,scanMessage: res.errMsg};
  56. }
  57. }
  58. });
  59. },
  60. toPay(){
  61. let expireTime=this.$dateTime.getExpireTime(5)
  62. let params={
  63. mallId:this.vuex_mallId,
  64. shopId:this.vuex_shopId,
  65. money:this.money,
  66. billsTitle:'用户支付',
  67. expireTime,
  68. appId:this.$global.wxParams.clientAppId,
  69. secret:this.userId,
  70. authCode: this.secret
  71. }
  72. uni.navigateTo({
  73. url:"/pages/pay/pay-result?payParams="+JSON.stringify(params)
  74. })
  75. },
  76. show(){
  77. this.$refs.amountInput.show()
  78. },
  79. change(e){
  80. if (!e) {
  81. this.money=0
  82. }else{
  83. this.money=e
  84. }
  85. },
  86. filterMoney(value) {
  87. value=value.toString()
  88. if (!value) {
  89. return ''
  90. } else {
  91. value = value.replace(/\$\s?|(,*)/g, '')
  92. return value.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
  93. }
  94. },
  95. }
  96. }
  97. </script>
  98. <style>
  99. page{
  100. background-color: #FFFFFF;
  101. }
  102. </style>
  103. <style lang="scss" scoped>
  104. .data{
  105. padding: 50rpx;
  106. display: flex;
  107. justify-content: flex-start;
  108. flex-direction: column;
  109. .price{
  110. &-icon{
  111. font-size: 40rpx;
  112. font-weight: 800;
  113. }
  114. }
  115. }
  116. .center{
  117. display: flex;
  118. justify-content: center;
  119. align-items: center;
  120. }
  121. .input-bar {
  122. height: 150rpx;
  123. border-bottom: 1rpx solid #DDDDDD;
  124. .icon {
  125. width: 15%;
  126. font-size: 70rpx;
  127. font-weight: 900;
  128. height: 100%;
  129. }
  130. .input {
  131. width: 85%;
  132. height: 100%;
  133. overflow: hidden;
  134. font-size: 70rpx;
  135. }
  136. .cusor {
  137. margin-left: 10rpx;
  138. width: 6rpx;
  139. border-radius: 20rpx;
  140. height: 60%;
  141. background-color: #ff9900;
  142. animation: blink 1200ms infinite ease-in-out;
  143. }
  144. }
  145. @keyframes blink {
  146. from {
  147. opacity: 0;
  148. }
  149. }
  150. </style>