payList.vue 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="from">
  3. <uni-forms ref="form" :modelValue="formData" :rules="rules">
  4. <view class="box">
  5. <uni-forms-item label="案件编号:" name="caseNum" label-width="120px" required>
  6. <uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.caseNum" placeholder="" />
  7. </uni-forms-item>
  8. <uni-forms-item label="申请人:" name="applicantName" label-width="120px" required>
  9. <uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.affiliate.applicationName"
  10. placeholder="" />
  11. </uni-forms-item>
  12. <uni-forms-item label="被申请人:" name="respondentName" label-width="120px" required>
  13. <uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.affiliate.respondentName"
  14. placeholder="" />
  15. </uni-forms-item>
  16. <uni-forms-item label="案件标的:" name="caseSubjectAmount" label-width="120px" required>
  17. <uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.caseSubjectAmount"
  18. placeholder="" />
  19. </uni-forms-item>
  20. <uni-forms-item label="应缴费用:" name="feePayable" label-width="120px" required>
  21. <uni-easyinput :inputBorder="false" :disabled='true' v-model="formData.feePayable" placeholder="" />
  22. </uni-forms-item>
  23. </view>
  24. </uni-forms>
  25. <uni-forms-item label="缴费方式">
  26. <uni-data-checkbox v-model="payType" :localdata="payTypes" @change="changeType" />
  27. </uni-forms-item>
  28. <uni-forms-item label="缴费平台" v-if="payType == 0">
  29. <uni-data-checkbox v-model="payPlatform" :localdata="payPlatforms" @change="changePayType" />
  30. </uni-forms-item>
  31. <div class="payImg" v-if="payType == 0">
  32. <canvas canvas-id="qrcode" v-show="qrShow" style="width: 300rpx;margin: 0 auto;" />
  33. </div>
  34. <div class="payTitle" v-if="payType == 0">{{ payMain }}</div>
  35. <uni-forms-item label="上传证据" name="headImage">
  36. <uni-file-picker ref="files" :auto-upload="false" return-type='object' v-model="fileList"
  37. file-mediatype="all" @select="select" :limit='1' />
  38. </uni-forms-item>
  39. <button type="primary" @click="submitPay">确认提交</button>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. selectById
  45. } from '../../../api/handlecase/index.js'
  46. import {
  47. casePay,
  48. confirmPayment
  49. } from '../../../api/pay/index.js'
  50. import moment from 'moment'
  51. import uQRCode from '../../common/uqrcode.js'
  52. import {
  53. getToken
  54. } from '@/utils/auth'
  55. import config from '@/config'
  56. const baseUrl = config.baseUrlTJ
  57. const app = getApp()
  58. export default {
  59. data() {
  60. return {
  61. formData: {},
  62. selectFlag: false,
  63. rules: {},
  64. payPlatforms: [{
  65. text: '微信',
  66. value: 0
  67. }, {
  68. text: '支付宝',
  69. value: 1
  70. }, ],
  71. payPlatform: null,
  72. payType: 1,
  73. payTypes: [{
  74. text: '线上缴费',
  75. value: 0
  76. }, {
  77. text: '线下缴费',
  78. value: 1
  79. }, ],
  80. payMain: '',
  81. qrShow: false,
  82. tempFilePaths: null,
  83. fileList: {},
  84. submitForm: {
  85. payType: 1,
  86. payOrderList: [],
  87. caseId: null
  88. }
  89. }
  90. },
  91. methods: {
  92. /**获取案件缴费信息*/
  93. getData(parms) {
  94. selectById(parms).then(res => {
  95. this.formData = res.data
  96. })
  97. },
  98. /**生成二维码*/
  99. qrcode(url) {
  100. this.qrShow = true
  101. uQRCode.make({
  102. canvasId: 'qrcode',
  103. componentInstance: this,
  104. text: url,
  105. size: 150,
  106. margin: 0,
  107. backgroundColor: '#ffffff',
  108. foregroundColor: '#000000',
  109. fileType: 'jpg',
  110. errorCorrectLevel: uQRCode.errorCorrectLevel.H,
  111. success: res => {}
  112. })
  113. },
  114. /**选择缴费方式*/
  115. changeType(val) {
  116. this.submitForm.payType = val.detail.value;
  117. },
  118. /**文件上传*/
  119. select(e) {
  120. this.submitForm.payOrderList = [];
  121. this.tempFilePaths = e.tempFilePaths;
  122. // loading
  123. uni.showLoading({
  124. title: '上传中'
  125. });
  126. uni.uploadFile({
  127. url: baseUrl + '/common/upload',
  128. filePath: this.tempFilePaths[0],
  129. header: {
  130. Authorization: getToken() || '',
  131. },
  132. formData: {
  133. annexType: 4,
  134. id: this.formData.id
  135. },
  136. name: 'file',
  137. success: (res) => {
  138. let {
  139. data
  140. } = res
  141. data = JSON.parse(data);
  142. this.submitForm.payOrderList.push({
  143. annexId: data.annexId,
  144. annexName: data.fileName
  145. });
  146. // console.log(this.submitForm, "OOOOOOOOOOOOOOOOOOOOOOOOO");
  147. uni.showToast({
  148. title: '上传成功',
  149. icon: 'none',
  150. duration: 1000
  151. })
  152. uni.hideLoading();
  153. },
  154. fail: (err) => {
  155. uni.showToast({
  156. title: '上传失败',
  157. icon: 'none',
  158. duration: 1000
  159. })
  160. uni.hideLoading()
  161. }
  162. })
  163. },
  164. /**选择缴费平台*/
  165. changePayType(val) {
  166. if (this.formData.feePayable == 0 || !this.formData.feePayable) {
  167. uni.showToast({
  168. title: '此案件无需缴费',
  169. icon: 'none',
  170. duration: 1000
  171. })
  172. return;
  173. }
  174. let payType = "";
  175. if (val.detail.value == 0) {
  176. payType = "wxpay";
  177. this.payMain = "请使用微信扫二维码支付";
  178. } else if (val.detail.value == 1) {
  179. payType = "alipay";
  180. this.payMain = "请使用支付宝扫二维码支付";
  181. }
  182. casePay({
  183. totalFee: this.formData.feePayable * 100,
  184. caseId: this.formData.id,
  185. tradeType: "native",
  186. platform: payType,
  187. }).then((res) => {
  188. this.qrcode(res.data.code_url);
  189. });
  190. },
  191. confirmPaymentFn(data) {
  192. confirmPayment(data).then(res => {
  193. uni.showToast({
  194. title: '确认成功',
  195. icon: 'none',
  196. duration: 1000
  197. });
  198. uni.navigateBack({
  199. delta: 1
  200. })
  201. })
  202. },
  203. /**确认缴费*/
  204. submitPay() {
  205. if (this.submitForm.payOrderList.length < 1) {
  206. uni.showToast({
  207. title: '请上传缴费凭证',
  208. icon: 'none',
  209. duration: 1000
  210. });
  211. return
  212. }
  213. this.submitForm.caseId = this.formData.id;
  214. this.submitForm.caseFlowId = this.formData.caseFlowId;
  215. this.confirmPaymentFn(this.submitForm);
  216. }
  217. },
  218. onLoad(data) {
  219. this.getData({
  220. id: data.id
  221. });
  222. },
  223. }
  224. </script>
  225. <style>
  226. .from {
  227. padding: 20rpx;
  228. }
  229. .payImg,
  230. .payTitle {
  231. width: 100%;
  232. display: flex;
  233. justify-content: center;
  234. align-items: center;
  235. margin-bottom: 20rpx;
  236. }
  237. .select-picker {
  238. display: flex;
  239. box-sizing: border-box;
  240. flex-direction: row;
  241. align-items: center;
  242. border: 1px solid #DCDFE6;
  243. border-radius: 8rpx;
  244. width: 100%;
  245. height: 100%;
  246. padding: 0 24rpx;
  247. font-size: 28rpx;
  248. }
  249. </style>