payOrder.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 class="item">
  47. <view class="l" style="flex: 7;">状态:</view>
  48. <view class="r">
  49. <text v-if="form.adminConfirmInput==0">未确认</text>
  50. <text v-else>已确认</text>
  51. </view>
  52. </view>
  53. </view>
  54. <view v-if="form.adminConfirmInput==0">
  55. <u-button type="info" v-if="customerId!=='1'">待确认</u-button>
  56. <u-button type="primary" v-if="customerId=='1'
  57. &&perList.indexOf('tb-business-confirm')!==-1" @click="adminConfirmFn">确认账单</u-button>
  58. </view>
  59. <view v-else>
  60. <u-button type="primary" v-if="form.payStatus==1&&customerId!=='1'&&form.adminConfirmInput==1"
  61. @click="confirmFn">支付账单</u-button>
  62. <u-button type="info" v-if="form.payStatus==3">已支付</u-button>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. var jweixin = require('@/components/jweixin-module/index.js');
  68. export default {
  69. data() {
  70. return {
  71. customerId: '',
  72. perList: [],
  73. wx: {
  74. id: '',
  75. code: '',
  76. openid: ''
  77. },
  78. form: {
  79. partMoney: 0
  80. },
  81. }
  82. },
  83. onBackPress() {
  84. this.$common.to('/pages/business-order/business-order')
  85. return false;
  86. },
  87. onLoad(options) {
  88. this.wx.id = options.state;
  89. this.wx.code = options.code;
  90. this.getOpenidByCode();
  91. this.getWxConfig();
  92. },
  93. onShow() {
  94. this.perList = uni.getStorageSync('perList')
  95. let info = uni.getStorageSync('userInfo');
  96. this.customerId = info.customerId;
  97. this.getBusinessById();
  98. },
  99. methods: {
  100. adminConfirmFn() {
  101. let that = this;
  102. uni.showModal({
  103. title: '提示',
  104. content: '是否确认该业务账单?',
  105. success(res) {
  106. if (res.confirm) {
  107. that.$api.adminConfirm({
  108. ids: that.form.id
  109. }).then(resp => {
  110. if (resp.code == 200) {
  111. that.$common.toast('已确认');
  112. setTimeout(() => {
  113. that.$common.to('/pages/business-order/business-order');
  114. }, 1500)
  115. }
  116. })
  117. }
  118. }
  119. })
  120. },
  121. getWxConfig() {
  122. let url = window.location.href;
  123. this.$api.getWxConfig({
  124. url: url
  125. }).then(resp => {
  126. jweixin.config({
  127. //debug: true,
  128. appId: resp.data.appId,
  129. timestamp: resp.data.timestamp, // 必填,生成签名的时间戳
  130. nonceStr: resp.data.noncestr, // 必填,生成签名的随机串
  131. signature: resp.data.sign, // 必填,签名
  132. jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表
  133. });
  134. jweixin.ready(function() {
  135. console.log('111')
  136. });
  137. jweixin.error(function(res) {
  138. console.log(res)
  139. });
  140. })
  141. },
  142. getOpenidByCode() {
  143. let storeOpenid = uni.getStorageSync('openid');
  144. this.$api.getOpenidByCode({
  145. code: this.wx.code,
  146. openid: storeOpenid
  147. }).then(resp => {
  148. let openid = resp.data;
  149. this.wx.openid = openid;
  150. if (openid) {
  151. uni.setStorageSync('openid', openid)
  152. }
  153. })
  154. },
  155. getBusinessById() {
  156. this.$api.getBusinessById({
  157. id: this.wx.id
  158. }).then(resp => {
  159. this.form = resp.data;
  160. })
  161. },
  162. confirmFn() {
  163. let p = {
  164. b: this.wx.id,
  165. c: JSON.stringify(this.form.cars.map(obj => {
  166. return {
  167. id: obj.id,
  168. p: obj.basePartMoney
  169. }
  170. })),
  171. money: this.form.totalMoney,
  172. tradeType: "JSAPI",
  173. openid: this.wx.openid
  174. }
  175. this.$api.getPrePay(this.$common.removeNull(p)).then(resp => {
  176. let data = resp.data;
  177. let that = this;
  178. jweixin.chooseWXPay({
  179. timestamp: data
  180. .timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
  181. nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
  182. package: data.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  183. signType: data.signType, // 微信支付V3的传入RSA,微信支付V2的传入格式与V2统一下单的签名格式保持一致
  184. paySign: data.paySign, // 支付签名
  185. success: function(res) {
  186. if (res.errMsg === "chooseWXPay:ok") {
  187. that.$common.toast('支付成功')
  188. // wx.closeWindow();
  189. }
  190. }
  191. });
  192. })
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss">
  198. page {
  199. background-color: #fff;
  200. }
  201. .item-line {
  202. color: #a2a2a2;
  203. padding: 5px 0 10px 29px;
  204. border-bottom: 1px solid #E5E5E5;
  205. }
  206. @import '@/common/common.scss'
  207. </style>