payOrder.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="item" >
  5. <view class="l">订单号:</view>
  6. <view class="r">
  7. {{form.no}}
  8. </view>
  9. </view>
  10. <view class="item-line">
  11. 业务项
  12. </view>
  13. <view class="item" v-for="item in form.items" :key="item.id">
  14. <view class="l" style="flex: 6;">{{item.itemTypeName}}:</view>
  15. <view class="r">
  16. {{item.itemName}}({{item.itemPrice}}x{{item.num}}={{item.total}}元)
  17. </view>
  18. </view>
  19. <view class="item">
  20. <view class="l" style="flex: 6;">业务费:</view>
  21. <view class="r">
  22. {{form.itemPrice}}
  23. <text>(元)</text>
  24. </view>
  25. </view>
  26. <view class="item" >
  27. <view class="l" style="flex: 6;">境外车停车费:</view>
  28. <view class="r">
  29. {{form.partMoney}}
  30. <text>(元)</text>
  31. </view>
  32. </view>
  33. <view class="item">
  34. <view class="l" style="flex: 6;">中国车停车费:</view>
  35. <view class="r">
  36. {{form.chinaPartMoney}}
  37. <text>(元)</text>
  38. </view>
  39. </view>
  40. <view class="item">
  41. <view class="l" style="flex: 6;">合计费用:</view>
  42. <view class="r">
  43. {{form.totalMoney}}元
  44. </view>
  45. </view>
  46. </view>
  47. <u-button type="primary" v-if="form.payStatus==1" @click="confirmFn">马上支付</u-button>
  48. <u-button type="info" v-if="form.payStatus==3">已支付支付</u-button>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. wx:{
  56. id:'',
  57. code:'',
  58. openid:''
  59. },
  60. form: {
  61. partMoney: 0
  62. },
  63. }
  64. },
  65. onBackPress() {
  66. this.$common.to('/pages/business-order/business-order')
  67. return false;
  68. },
  69. onLoad(options) {
  70. this.wx.id = options.state;
  71. this.wx.code=options.state;
  72. this.getOpenidByCode();
  73. this.getWxConfig();
  74. },
  75. onShow() {
  76. this.getBusinessById();
  77. },
  78. methods: {
  79. getWxConfig() {
  80. let url = window.location.href;
  81. this.$api.getWxConfig({
  82. url: url
  83. }).then(resp => {
  84. jweixin.config({
  85. //debug: true,
  86. appId: resp.data.appId,
  87. timestamp: resp.data.timestamp, // 必填,生成签名的时间戳
  88. nonceStr: resp.data.noncestr, // 必填,生成签名的随机串
  89. signature: resp.data.sign, // 必填,签名
  90. jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
  91. });
  92. jweixin.ready(function() {
  93. console.log('111')
  94. });
  95. jweixin.error(function(res) {
  96. console.log(res)
  97. });
  98. })
  99. },
  100. getOpenidByCode() {
  101. let storeOpenid = uni.getStorageSync('openid');
  102. this.$api.getOpenidByCode({
  103. code: this.wx.code,
  104. openid: storeOpenid
  105. }).then(resp => {
  106. let openid = resp.data;
  107. this.openid = openid;
  108. if (openid) {
  109. uni.setStorageSync('openid', openid)
  110. }
  111. })
  112. },
  113. getBusinessById() {
  114. this.$api.getBusinessById({
  115. id: this.wx.id
  116. }).then(resp => {
  117. this.form = resp.data;
  118. })
  119. },
  120. confirmFn(){
  121. let p = {
  122. businessId: this.wx.id,
  123. money: this.form.totalMoney,
  124. tradeType: "JSAPI",
  125. openid: this.wx.openid
  126. }
  127. this.$api.getPrePay(this.$common.removeNull(p)).then(resp => {
  128. let data = resp.data;
  129. let that = this;
  130. jweixin.chooseWXPay({
  131. timestamp: data
  132. .timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
  133. nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
  134. package: data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  135. signType: data.signType, // 微信支付V3的传入RSA,微信支付V2的传入格式与V2统一下单的签名格式保持一致
  136. paySign: data.paySign, // 支付签名
  137. success: function(res) {
  138. if (res.errMsg === "chooseWXPay:ok") {
  139. that.$common.toast('支付成功')
  140. // wx.closeWindow();
  141. }
  142. }
  143. });
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. page {
  151. background-color: #fff;
  152. }
  153. .item-line {
  154. color: #a2a2a2;
  155. padding: 5px 0 10px 29px;
  156. border-bottom: 1px solid #E5E5E5;
  157. }
  158. @import '@/common/common.scss'
  159. </style>