idCard.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <el-form ref="form" label-width="80px">
  3. <el-form-item>
  4. <el-form-item label="上传图片" prop="materialUrl">
  5. <img :src="idCardUrl" alt="身份证" style="height: 150px; width: 150px" v-if="idCardUrl != null">
  6. <ImageUpload @input="handleUrl" type="image" :num="10" :width="150" :height="150" />
  7. </el-form-item>
  8. <el-button type="primary" size="mini" @click="submit">保存</el-button>
  9. </el-form-item>
  10. </el-form>
  11. </template>
  12. <script>
  13. import ImageUpload from '@/components/ImageUpload/index';
  14. import {verifyIdInfo, getLive} from '@/api/live/live'
  15. export default {
  16. components: { ImageUpload },
  17. data() {
  18. return {
  19. test: "1test",
  20. idCardUrl: "",
  21. liveId: null,
  22. };
  23. },
  24. watch: {
  25. // 监听路由的 query 参数变化
  26. '$route.query': {
  27. handler(newQuery) {
  28. this.liveId = this.$route.params.liveId
  29. if(this.liveId == null) {
  30. return;
  31. }
  32. getLive(this.liveId).then(res => {
  33. this.idCardUrl = res.data.idCardUrl;
  34. })
  35. },
  36. // 初始化时立即执行一次
  37. immediate: true
  38. }
  39. },
  40. created() {
  41. this.liveId = this.$route.params.liveId
  42. getLive(this.liveId).then(res => {
  43. this.idCardUrl = res.data.idCardUrl;
  44. })
  45. },
  46. methods: {
  47. submit(){
  48. verifyIdInfo({ liveId: this.liveId, idCardUrl: this.idCardUrl}).then(response => {
  49. if (response.code == 200) {
  50. this.$message.success("保存成功");
  51. } else {
  52. this.$message.success(response.msg);
  53. }
  54. })
  55. },
  56. handleUrl(data){
  57. if (data.length > 0) {
  58. this.idCardUrl = data;
  59. }
  60. }
  61. }
  62. };
  63. </script>