cashier-desk.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="cashier-desk">
  3. <view class="view-top">
  4. </view>
  5. <view class="payment-methods">
  6. <u-radio-group v-model="formData.payType" @change="radioGroupChange">
  7. <view class="payment-item">
  8. <view class="left">
  9. <image src="../static/pay1.png" class="payment-icon"></image>
  10. <text>微信支付</text>
  11. </view>
  12. <u-radio active-color="#38C148" name="1" />
  13. </view>
  14. <view class="payment-item">
  15. <view class="left">
  16. <image src="../static/pay2.png" class="payment-icon"></image>
  17. <text>余额支付(余额{{ baseInfo.restMoney || 0 }})</text>
  18. </view>
  19. <u-radio active-color="#38C148" name="2" />
  20. </view>
  21. <view class="payment-item">
  22. <view class="left">
  23. <image src="../static/pay2.png" class="payment-icon"></image>
  24. <text>组合支付</text>
  25. </view>
  26. <u-radio active-color="#38C148" name="3" />
  27. </view>
  28. </u-radio-group>
  29. </view>
  30. <view class="total">
  31. <text>总计</text>
  32. <text class="amount">¥ {{ baseInfo.expressMoney || 0 }}</text>
  33. </view>
  34. <button class="confirm-btn" @click="onConfirmPayment">确认支付</button>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. totalAmount: 7.00,
  42. formData: {
  43. payType: '1',
  44. refundOrderId: ''
  45. },
  46. baseInfo: {}
  47. }
  48. },
  49. onLoad(options) {
  50. if (options.id) {
  51. this.formData.refundOrderId = options.id
  52. this.getBaseInfo(options.id)
  53. }
  54. },
  55. methods: {
  56. //获取基本信息
  57. getBaseInfo(refundOrderId) {
  58. uni.$u.http.post('/token/order/refundGoPay', {
  59. refundOrderId
  60. }).then(res => {
  61. if (res.code === 200) {
  62. this.baseInfo = res.data
  63. }
  64. })
  65. },
  66. onConfirmPayment() {
  67. uni.showLoading({
  68. title: '支付处理中'
  69. })
  70. uni.$u.http.post('/token/order/refundOrderPay', this.formData).then(res => {
  71. if (res.code == 200) {
  72. if (res.data.needPay == 1) {
  73. // TODO: 调用支付接口
  74. uni.requestPayment({
  75. timeStamp: res.data.timeStamp,
  76. nonceStr: res.data.nonceStr,
  77. package: `prepay_id=${res.data.prepayId}`,
  78. signType: res.data.signType,
  79. paySign: res.data.paySign,
  80. provider: 'wxpay',
  81. success: (res) => {
  82. //支付成功之后,跳转支付成功页面
  83. uni.navigateTo({
  84. url: `/pages-mine/pages/pay-success?orderId=${this.formData.refundOrderId}`
  85. })
  86. },
  87. fail: (err) => {
  88. console.log(err)
  89. }
  90. })
  91. } else {
  92. //支付成功之后,跳转支付成功页面
  93. uni.navigateTo({
  94. url: `/pages-mine/pages/pay-success?orderId=${this.formData.refundOrderId}`
  95. })
  96. }
  97. }
  98. })
  99. },
  100. radioGroupChange(e) {
  101. console.log(e);
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .cashier-desk {
  108. min-height: 100vh;
  109. background-color: #f5f5f5;
  110. .view-top {
  111. background: #38C148;
  112. height: 160rpx;
  113. width: 100%;
  114. }
  115. .payment-methods {
  116. background-color: #ffffff;
  117. border-radius: 16rpx;
  118. margin-bottom: 20rpx;
  119. margin: 30rpx;
  120. margin-top: -40px;
  121. .payment-item {
  122. display: flex;
  123. justify-content: space-between;
  124. align-items: center;
  125. padding: 30rpx;
  126. border-bottom: 1px solid #f5f5f5;
  127. &:last-child {
  128. border-bottom: none;
  129. }
  130. .left {
  131. display: flex;
  132. align-items: center;
  133. gap: 20rpx;
  134. .payment-icon {
  135. width: 40rpx;
  136. height: 40rpx;
  137. }
  138. }
  139. }
  140. }
  141. .total {
  142. background-color: #ffffff;
  143. border-radius: 16rpx;
  144. padding: 30rpx;
  145. display: flex;
  146. justify-content: space-between;
  147. align-items: center;
  148. margin-bottom: 20rpx;
  149. .amount {
  150. color: #ff0000;
  151. font-size: 32rpx;
  152. }
  153. }
  154. .confirm-btn {
  155. width: 90%;
  156. margin-left: 5%;
  157. margin-top: 100rpx;
  158. }
  159. }
  160. </style>