idCard.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. getLive(this.liveId).then(res => {
  30. this.idCardUrl = res.data.idCardUrl;
  31. })
  32. },
  33. // 初始化时立即执行一次
  34. immediate: true
  35. }
  36. },
  37. created() {
  38. this.liveId = this.$route.params.liveId
  39. getLive(this.liveId).then(res => {
  40. this.idCardUrl = res.data.idCardUrl;
  41. })
  42. },
  43. methods: {
  44. submit(){
  45. verifyIdInfo({ liveId: this.liveId, idCardUrl: this.idCardUrl}).then(response => {
  46. if (response.code == 200) {
  47. this.$message.success("保存成功");
  48. } else {
  49. this.$message.success(response.msg);
  50. }
  51. })
  52. },
  53. handleUrl(data){
  54. if (data.length > 0) {
  55. this.idCardUrl = data;
  56. }
  57. }
  58. }
  59. };
  60. </script>