payList.vue 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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.tempFilePaths = e.tempFilePaths;
  121. // loading
  122. uni.showLoading({
  123. title: '上传中'
  124. });
  125. uni.uploadFile({
  126. url: baseUrl + '/common/upload',
  127. filePath: this.tempFilePaths[0],
  128. header: {
  129. Authorization: getToken() || '',
  130. },
  131. formData: {
  132. annexType: 4,
  133. id: this.formData.id
  134. },
  135. name: 'file',
  136. success: (res) => {
  137. let {
  138. data
  139. } = res
  140. data = JSON.parse(data);
  141. this.submitForm.payOrderList.push({
  142. annexId: data.annexId,
  143. annexName: data.fileName
  144. });
  145. // console.log(this.submitForm, "OOOOOOOOOOOOOOOOOOOOOOOOO");
  146. uni.showToast({
  147. title: '上传成功',
  148. icon: 'none',
  149. duration: 1000
  150. })
  151. uni.hideLoading();
  152. },
  153. fail: (err) => {
  154. uni.showToast({
  155. title: '上传失败',
  156. icon: 'none',
  157. duration: 1000
  158. })
  159. uni.hideLoading()
  160. }
  161. })
  162. },
  163. /**选择缴费平台*/
  164. changePayType(val) {
  165. if (this.formData.feePayable == 0 || !this.formData.feePayable) {
  166. uni.showToast({
  167. title: '此案件无需缴费',
  168. icon: 'none',
  169. duration: 1000
  170. })
  171. return;
  172. }
  173. let payType = "";
  174. if (val.detail.value == 0) {
  175. payType = "wxpay";
  176. this.payMain = "请使用微信扫二维码支付";
  177. } else if (val.detail.value == 1) {
  178. payType = "alipay";
  179. this.payMain = "请使用支付宝扫二维码支付";
  180. }
  181. casePay({
  182. totalFee: this.formData.feePayable * 100,
  183. caseId: this.formData.id,
  184. tradeType: "native",
  185. platform: payType,
  186. }).then((res) => {
  187. this.qrcode(res.data.code_url);
  188. });
  189. },
  190. confirmPaymentFn(data) {
  191. confirmPayment(data).then(res => {
  192. uni.showToast({
  193. title: '确认成功',
  194. icon: 'none',
  195. duration: 1000
  196. });
  197. uni.navigateBack({
  198. delta: 1
  199. })
  200. })
  201. },
  202. /**确认缴费*/
  203. submitPay() {
  204. this.submitForm.caseId = this.formData.id;
  205. this.submitForm.caseFlowId = this.formData.caseFlowId;
  206. this.confirmPaymentFn(this.submitForm);
  207. }
  208. },
  209. onLoad(data) {
  210. this.getData({
  211. id: data.id
  212. });
  213. },
  214. }
  215. </script>
  216. <style>
  217. .from {
  218. padding: 20rpx;
  219. }
  220. .payImg,
  221. .payTitle {
  222. width: 100%;
  223. display: flex;
  224. justify-content: center;
  225. align-items: center;
  226. margin-bottom: 20rpx;
  227. }
  228. .select-picker {
  229. display: flex;
  230. box-sizing: border-box;
  231. flex-direction: row;
  232. align-items: center;
  233. border: 1px solid #DCDFE6;
  234. border-radius: 8rpx;
  235. width: 100%;
  236. height: 100%;
  237. padding: 0 24rpx;
  238. font-size: 28rpx;
  239. }
  240. </style>