payOrder.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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: 7;">{{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: 7;">业务费:</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: 7;">境外车停车费:</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: 7;">中国车停车费:</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: 7;">合计费用:</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. var jweixin = require('@/components/jweixin-module/index.js');
  53. export default {
  54. data() {
  55. return {
  56. wx: {
  57. id: '',
  58. code: '',
  59. openid: ''
  60. },
  61. form: {
  62. partMoney: 0
  63. },
  64. }
  65. },
  66. onBackPress() {
  67. this.$common.to('/pages/business-order/business-order')
  68. return false;
  69. },
  70. onLoad(options) {
  71. this.wx.id = options.state;
  72. this.wx.code = options.code;
  73. this.getOpenidByCode();
  74. this.getWxConfig();
  75. },
  76. onShow() {
  77. this.getBusinessById();
  78. },
  79. methods: {
  80. getWxConfig() {
  81. let url = window.location.href;
  82. this.$api.getWxConfig({
  83. url: url
  84. }).then(resp => {
  85. jweixin.config({
  86. //debug: true,
  87. appId: resp.data.appId,
  88. timestamp: resp.data.timestamp, // 必填,生成签名的时间戳
  89. nonceStr: resp.data.noncestr, // 必填,生成签名的随机串
  90. signature: resp.data.sign, // 必填,签名
  91. jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
  92. });
  93. jweixin.ready(function() {
  94. console.log('111')
  95. });
  96. jweixin.error(function(res) {
  97. console.log(res)
  98. });
  99. })
  100. },
  101. getOpenidByCode() {
  102. let storeOpenid = uni.getStorageSync('openid');
  103. this.$api.getOpenidByCode({
  104. code: this.wx.code,
  105. openid: storeOpenid
  106. }).then(resp => {
  107. let openid = resp.data;
  108. this.wx.openid = openid;
  109. if (openid) {
  110. uni.setStorageSync('openid', openid)
  111. }
  112. })
  113. },
  114. getBusinessById() {
  115. this.$api.getBusinessById({
  116. id: this.wx.id
  117. }).then(resp => {
  118. this.form = resp.data;
  119. })
  120. },
  121. confirmFn() {
  122. let p = {
  123. b: this.wx.id,
  124. c:JSON.stringify(this.form.cars.map(obj=>{return {id:obj.id,p:obj.basePartMoney}})),
  125. money: this.form.totalMoney,
  126. tradeType: "JSAPI",
  127. openid: this.wx.openid
  128. }
  129. this.$api.getPrePay(this.$common.removeNull(p)).then(resp => {
  130. let data = resp.data;
  131. let that = this;
  132. jweixin.chooseWXPay({
  133. timestamp: data
  134. .timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
  135. nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
  136. package: data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  137. signType: data.signType, // 微信支付V3的传入RSA,微信支付V2的传入格式与V2统一下单的签名格式保持一致
  138. paySign: data.paySign, // 支付签名
  139. success: function(res) {
  140. if (res.errMsg === "chooseWXPay:ok") {
  141. that.$common.toast('支付成功')
  142. // wx.closeWindow();
  143. }
  144. }
  145. });
  146. })
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss">
  152. page {
  153. background-color: #fff;
  154. }
  155. .item-line {
  156. color: #a2a2a2;
  157. padding: 5px 0 10px 29px;
  158. border-bottom: 1px solid #E5E5E5;
  159. }
  160. @import '@/common/common.scss'
  161. </style>