应用层PC端前端服务

payDialog.vue 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <div>
  3. <el-dialog :title="payTitle" :visible="openPay" @close="payCancel" width="800px" append-to-body
  4. :destroy-on-close="true" center>
  5. <el-descriptions title="订单信息">
  6. <el-descriptions-item label="案件编号">{{
  7. form.caseNum
  8. }}</el-descriptions-item>
  9. <el-descriptions-item label="申请人">{{
  10. form.applicantName
  11. }}</el-descriptions-item>
  12. <el-descriptions-item label="案件标的">{{
  13. form.caseSubjectAmount
  14. }}</el-descriptions-item>
  15. <el-descriptions-item label="案件应缴费用">{{
  16. form.feePayable
  17. }}</el-descriptions-item>
  18. <el-descriptions-item label="被申请人">{{
  19. form.respondentName
  20. }}</el-descriptions-item>
  21. <el-descriptions-item label="案件状态">
  22. <el-tag size="mini" type='danger' effect="dark">
  23. {{ form.caseStatusName }}
  24. </el-tag>
  25. </el-descriptions-item>
  26. <!-- <el-descriptions-item label="申请人仲裁诉求">{{
  27. form.arbitratClaims
  28. }}</el-descriptions-item> -->
  29. <!-- <el-descriptions-item label="案件理由">{{
  30. form.facts
  31. }}</el-descriptions-item> -->
  32. </el-descriptions>
  33. <div class="paySelectType">
  34. <el-radio-group v-model="paySelect" @input="changPayType">
  35. <el-radio :label="0">线上支付</el-radio>
  36. <el-radio :label="1">线下支付</el-radio>
  37. </el-radio-group>
  38. </div>
  39. <div class="payupload">
  40. <span>上传支付凭证:</span>
  41. <div class="uploadBtn">
  42. <el-upload class="upload-demo" ref="upload" :action="UploadUrl()" :headers="headers" :data="filedata"
  43. :on-preview="handlePreview" :on-remove="handleRemove" :on-change="beforeUpload" :on-success="handlSuccess" :file-list="fileList"
  44. >
  45. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  46. <!-- <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button> -->
  47. <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
  48. </el-upload>
  49. </div>
  50. </div>
  51. <div class="payType" v-if="paySelect == 0">
  52. <span>请选择支付方式:</span>
  53. <i class="iconfont icon-weixinzhifu" @click="pay(0)"></i>
  54. <i class="iconfont icon-zhifubao" @click="pay(1)"></i>
  55. </div>
  56. <div class="payImg">
  57. <div id="qrcodeImg"></div>
  58. </div>
  59. <div class="payTitle">{{ payMain }}</div>
  60. <div slot="footer" class="dialog-footer">
  61. <el-button @click="payCancel" class="endbutton"><span>取 消</span></el-button>
  62. <el-button @click="submitUpload" class="endbutton"><span>确认缴费</span></el-button>
  63. </div>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. import { casePay, confirmPayDig } from "@/api/pay/pay";
  69. import QRCode from "qrcodejs2";
  70. import { getToken } from "@/utils/auth";
  71. export default {
  72. props: ["openPay", "payTitle", "form", "payForm", "queryParams","payId"],
  73. data() {
  74. return {
  75. // key: value
  76. // 支付文字
  77. payMain: "",
  78. timer: null,
  79. paySelect: 1,//支付线上/线下
  80. fileList: [],
  81. headers: {
  82. Authorization: "Bearer " + getToken(),
  83. },
  84. filedata: {
  85. annexType: 8,
  86. },
  87. submitForm:{
  88. payType:1,
  89. payOrderList:[],
  90. caseId:null
  91. }
  92. };
  93. },
  94. methods: {
  95. UploadUrl() {
  96. return window.location.origin + "/API/evidence/upload";
  97. },
  98. //选择支付方式(线上,线下)
  99. changPayType(data) {
  100. if(data == 1){
  101. document.getElementById("qrcodeImg").innerHTML = "";
  102. this.payMain = ""
  103. }
  104. this.submitForm.payType = data;
  105. },
  106. beforeUpload(flie, fileList) {
  107. this.fileList = fileList;
  108. },
  109. // 文件上传成功
  110. handlSuccess(res, file) {
  111. this.submitForm.payOrderList.push({
  112. annexId: res.data.annexId,
  113. annexName:res.data.annexName
  114. });
  115. },
  116. submitUpload() {
  117. if (this.fileList.length < 1) {
  118. this.$modal.msgError("请上传缴费凭证");
  119. return
  120. }
  121. confirmPayDig(this.submitForm).then(res=>{
  122. this.$modal.msgSuccess("成功");
  123. this.payCancel()
  124. this.$emit("getcaseApply", this.queryParams);
  125. })
  126. },
  127. handleRemove(file, fileList) {
  128. (this.submitForm.payOrderList = []),
  129. fileList.forEach((item) => {
  130. console.log(item.response.data,"item");
  131. this.submitForm.payOrderList.push({ annexId:item.response.data.annexId,annexName:item.response.data.annexName });
  132. });
  133. },
  134. handlePreview(file) {
  135. console.log(file);
  136. },
  137. // 生成二维码
  138. qrcode(url) {
  139. // 前端根据 URL 生成微信支付二维码
  140. document.getElementById("qrcodeImg").innerHTML = "";
  141. return new QRCode("qrcodeImg", {
  142. width: 200,
  143. height: 200,
  144. text: url,
  145. colorDark: "#000",
  146. colorLight: "#fff",
  147. });
  148. },
  149. // 支付
  150. pay(val) {
  151. if (this.payForm.feePayable == 0 || !this.payForm.feePayable) {
  152. this.$message({
  153. message: "此案件无需缴费",
  154. type: "error",
  155. });
  156. return;
  157. }
  158. let payType = "";
  159. if (val == 0) {
  160. payType = "wxpay";
  161. this.payMain = "请使用微信扫二维码支付";
  162. } else if (val == 1) {
  163. payType = "alipay";
  164. this.payMain = "请使用支付宝扫二维码支付";
  165. }
  166. casePay({
  167. totalFee: this.payForm.feePayable * 100,
  168. caseIds: [this.payForm.caseId],
  169. tradeType: "native",
  170. platform: payType,
  171. }).then((res) => {
  172. this.paySrc = res.data.code_url;
  173. this.qrcode(this.paySrc);
  174. });
  175. },
  176. payCancel() {
  177. this.$emit("paycancelRow");
  178. this.payMain = "";
  179. },
  180. },
  181. watch:{
  182. openPay(val){
  183. if(val){
  184. this.submitForm.payOrderList = []
  185. this.paySelect = 1;
  186. this.fileList = [];
  187. this.filedata.id = this.payId;
  188. this.submitForm.caseIds = [this.payId];
  189. }
  190. }
  191. }
  192. };
  193. </script>
  194. <style lang="scss" scoped>
  195. .payType {
  196. height: 80px;
  197. line-height: 80px;
  198. display: flex;
  199. .icon-weixinzhifu {
  200. font-size: 24px;
  201. color: #27a56f;
  202. margin-right: 15px;
  203. }
  204. .icon-zhifubao {
  205. font-size: 24px;
  206. color: #1d76cc;
  207. }
  208. }
  209. .paySelectType {
  210. margin-top: 20px;
  211. margin-bottom: 20px;
  212. }
  213. .payupload {
  214. display: flex;
  215. .uploadBtn {}
  216. }
  217. .payImg {
  218. width: 100%;
  219. display: flex;
  220. justify-content: center;
  221. }
  222. .payTitle {
  223. margin-top: 20px;
  224. width: 100%;
  225. text-align: center;
  226. }
  227. ::v-deep .el-dialog {
  228. width: 800px;
  229. background: #ffffff;
  230. border-radius: 20px;
  231. }
  232. .endbutton {
  233. width: 154px;
  234. height: 37px;
  235. background: #ffffff;
  236. border: 1px solid #d0d0d0;
  237. border-radius: 19px;
  238. span {
  239. width: 31px;
  240. height: 13px;
  241. font-size: 16px;
  242. font-family: Microsoft YaHei;
  243. font-weight: 400;
  244. color: #959595;
  245. }
  246. }
  247. </style>