quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<template>
  <!--
          作者:自定义
          时间:2025-10-31
          描述:插件中心-名片-名片设置-页面背景图
      -->
  <div class="test-wrap mt30">
    <el-form size="small" ref="form" :model="form" label-width="200px">
      <el-form-item label="名片详情跳转平台">
        <el-button type="primary" plain icon="el-icon-upload" @click="openUpload(1)">上传图片</el-button>
        <div v-if="form.digital_asset_1 != ''" class="img">
          <img :src="form.digital_asset_1" width="200" />
        </div>
        <div class="tips">建议尺寸:根据实际需求上传</div>
      </el-form-item>
      <el-form-item label="名片详情跳转店铺">
        <el-button type="primary" plain icon="el-icon-upload" @click="openUpload(2)">上传图片</el-button>
        <div v-if="form.digital_asset_2 != ''" class="img">
          <img :src="form.digital_asset_2" width="200" />
        </div>
        <div class="tips">建议尺寸:根据实际需求上传</div>
      </el-form-item>
 
      <!--提交-->
      <div class="common-button-wrapper">
        <el-button type="primary" @click="onSubmit">保存</el-button>
      </div>
    </el-form>
    <!--上传图片组件-->
    <Upload v-if="isupload" :isupload="isupload" :type="type" @returnImgs="returnImgsFunc">上传图片</Upload>
  </div>
</template>
 
<script>
import Upload from '@/components/file/Upload.vue';
import BusinessApi from '@/api/business';
export default {
  components: {
    Upload
  },
  props: {
    settingData: Object
  },
  data() {
    return {
      form: {
        digital_asset_1: '',
        digital_asset_2: ''
      },
      /*是否上传图片*/
      isupload: false,
      /*是否正在加载*/
      loading: false,
      /*图片类别*/
      type: ''
    };
  },
  watch: {
    settingData: {
      handler(val) {
        if (val && val.background) {
          this.form = val.background.values;
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    /*上传*/
    openUpload(e) {
      this.type = e;
      this.isupload = true;
    },
 
    /*获取图片*/
    returnImgsFunc(e) {
      if (e != null) {
        if (this.type == 1) {
          this.form.digital_asset_1 = e[0].file_path;
        }
        if (this.type == 2) {
          this.form.digital_asset_2 = e[0].file_path;
        }
      }
      this.isupload = false;
    },
    onSubmit() {
     BusinessApi.settingBackground(this.form).then(res => {
        this.$message.success(res.msg);
      });
    }
  }
};
</script>
 
<style scoped>
.img {
  margin-top: 10px;
}
.tips {
  font-size: 12px;
  color: #999;
  margin-top: 5px;
}
</style>