payOrder.vue 5.4 KB

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