payOrder.vue 6.2 KB

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