payList.vue 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. dataType:{},
  90. formDataVal:{}
  91. }
  92. },
  93. methods: {
  94. /**获取案件缴费信息*/
  95. getData(parms) {
  96. selectById(parms).then(res => {
  97. this.formData = res.data
  98. if(this.dataType.type==4){
  99. this.formDataVal ={
  100. annexType: 4,
  101. id: this.formData.id
  102. }
  103. }else if(this.dataType.type==9){
  104. this.formDataVal ={
  105. annexType: 9,
  106. id: this.formData.id
  107. }
  108. }
  109. })
  110. },
  111. /**生成二维码*/
  112. qrcode(url) {
  113. this.qrShow = true
  114. uQRCode.make({
  115. canvasId: 'qrcode',
  116. componentInstance: this,
  117. text: url,
  118. size: 150,
  119. margin: 0,
  120. backgroundColor: '#ffffff',
  121. foregroundColor: '#000000',
  122. fileType: 'jpg',
  123. errorCorrectLevel: uQRCode.errorCorrectLevel.H,
  124. success: res => {}
  125. })
  126. },
  127. /**选择缴费方式*/
  128. changeType(val) {
  129. this.submitForm.payType = val.detail.value;
  130. },
  131. /**文件上传*/
  132. select(e) {
  133. this.tempFilePaths = e.tempFilePaths;
  134. // loading
  135. uni.showLoading({
  136. title: '上传中'
  137. });
  138. uni.uploadFile({
  139. url: baseUrl + '/common/upload',
  140. filePath: this.tempFilePaths[0],
  141. header: {
  142. Authorization: getToken() || '',
  143. },
  144. formData:this.formDataVal,
  145. name: 'file',
  146. success: (res) => {
  147. let {
  148. data
  149. } = res
  150. data = JSON.parse(data);
  151. this.submitForm.payOrderList.push({
  152. annexId: data.annexId,
  153. annexName: data.fileName
  154. });
  155. // console.log(this.submitForm, "OOOOOOOOOOOOOOOOOOOOOOOOO");
  156. uni.showToast({
  157. title: '上传成功',
  158. icon: 'none',
  159. duration: 1000
  160. })
  161. uni.hideLoading();
  162. },
  163. fail: (err) => {
  164. uni.showToast({
  165. title: '上传失败',
  166. icon: 'none',
  167. duration: 1000
  168. })
  169. uni.hideLoading()
  170. }
  171. })
  172. },
  173. /**选择缴费平台*/
  174. changePayType(val) {
  175. if (this.formData.feePayable == 0 || !this.formData.feePayable) {
  176. uni.showToast({
  177. title: '此案件无需缴费',
  178. icon: 'none',
  179. duration: 1000
  180. })
  181. return;
  182. }
  183. let payType = "";
  184. if (val.detail.value == 0) {
  185. payType = "wxpay";
  186. this.payMain = "请使用微信扫二维码支付";
  187. } else if (val.detail.value == 1) {
  188. payType = "alipay";
  189. this.payMain = "请使用支付宝扫二维码支付";
  190. }
  191. casePay({
  192. totalFee: this.formData.feePayable * 100,
  193. caseId: this.formData.id,
  194. tradeType: "native",
  195. platform: payType,
  196. }).then((res) => {
  197. this.qrcode(res.data.code_url);
  198. });
  199. },
  200. confirmPaymentFn(data) {
  201. confirmPayment(data).then(res => {
  202. uni.showToast({
  203. title: '确认成功',
  204. icon: 'none',
  205. duration: 1000
  206. });
  207. uni.navigateBack({
  208. delta: 1
  209. })
  210. })
  211. },
  212. /**确认缴费*/
  213. submitPay() {
  214. this.submitForm.caseId = this.formData.id;
  215. this.submitForm.caseFlowId = this.formData.caseFlowId;
  216. this.confirmPaymentFn(this.submitForm);
  217. }
  218. },
  219. onLoad(data) {
  220. this.dataType = data
  221. this.getData({
  222. id: data.id
  223. });
  224. },
  225. }
  226. </script>
  227. <style>
  228. .from {
  229. padding: 20rpx;
  230. }
  231. .payImg,
  232. .payTitle {
  233. width: 100%;
  234. display: flex;
  235. justify-content: center;
  236. align-items: center;
  237. margin-bottom: 20rpx;
  238. }
  239. .select-picker {
  240. display: flex;
  241. box-sizing: border-box;
  242. flex-direction: row;
  243. align-items: center;
  244. border: 1px solid #DCDFE6;
  245. border-radius: 8rpx;
  246. width: 100%;
  247. height: 100%;
  248. padding: 0 24rpx;
  249. font-size: 28rpx;
  250. }
  251. </style>