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