payOrder.vue 6.1 KB

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