WXL
11 小时以前 05c363fdd7ab04e3bd9a753e2c5d5bfff04d681c
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
"use strict";
const common_vendor = require("../../../../../common/vendor.js");
const _sfc_main = {
  name: "uploadImage",
  emits: ["uploadFiles", "choose", "delFile"],
  props: {
    filesList: {
      type: Array,
      default() {
        return [];
      }
    },
    disabled: {
      type: Boolean,
      default: false
    },
    disablePreview: {
      type: Boolean,
      default: false
    },
    limit: {
      type: [Number, String],
      default: 9
    },
    imageStyles: {
      type: Object,
      default() {
        return {
          width: "auto",
          height: "auto",
          border: {}
        };
      }
    },
    delIcon: {
      type: Boolean,
      default: true
    },
    readonly: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    styles() {
      let styles = {
        width: "auto",
        height: "auto",
        border: {}
      };
      return Object.assign(styles, this.imageStyles);
    },
    boxStyle() {
      const {
        width = "auto",
        height = "auto"
      } = this.styles;
      let obj = {};
      if (height === "auto") {
        if (width !== "auto") {
          obj.height = this.value2px(width);
          obj["padding-top"] = 0;
        } else {
          obj.height = 0;
        }
      } else {
        obj.height = this.value2px(height);
        obj["padding-top"] = 0;
      }
      if (width === "auto") {
        if (height !== "auto") {
          obj.width = this.value2px(height);
        } else {
          obj.width = "33.3%";
        }
      } else {
        obj.width = this.value2px(width);
      }
      let classles = "";
      for (let i in obj) {
        classles += `${i}:${obj[i]};`;
      }
      return classles;
    },
    borderStyle() {
      let {
        border
      } = this.styles;
      let obj = {};
      const widthDefaultValue = 1;
      const radiusDefaultValue = 3;
      if (typeof border === "boolean") {
        obj.border = border ? "1px #eee solid" : "none";
      } else {
        let width = border && border.width || widthDefaultValue;
        width = this.value2px(width);
        let radius = border && border.radius || radiusDefaultValue;
        radius = this.value2px(radius);
        obj = {
          "border-width": width,
          "border-style": border && border.style || "solid",
          "border-color": border && border.color || "#eee",
          "border-radius": radius
        };
      }
      let classles = "";
      for (let i in obj) {
        classles += `${i}:${obj[i]};`;
      }
      return classles;
    }
  },
  methods: {
    uploadFiles(item, index) {
      this.$emit("uploadFiles", item);
    },
    choose() {
      if (this.readonly)
        return;
      this.$emit("choose");
    },
    delFile(index) {
      if (this.readonly)
        return;
      this.$emit("delFile", index);
    },
    prviewImage(img, index) {
      if (this.readonly)
        return;
      let urls = [];
      if (Number(this.limit) === 1 && this.disablePreview && !this.disabled) {
        this.$emit("choose");
      }
      if (this.disablePreview)
        return;
      this.filesList.forEach((i) => {
        urls.push(i.url);
      });
      common_vendor.index.previewImage({
        urls,
        current: index
      });
    },
    value2px(value) {
      if (typeof value === "number") {
        value += "px";
      } else {
        if (value.indexOf("%") === -1) {
          value = value.indexOf("px") !== -1 ? value : value + "px";
        }
      }
      return value;
    }
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.f($props.filesList, (item, index, i0) => {
      return common_vendor.e({
        a: item.url,
        b: common_vendor.o(($event) => $options.prviewImage(item, index), index)
      }, $props.delIcon && !$props.readonly ? {
        c: common_vendor.o(($event) => $options.delFile(index), index)
      } : {}, {
        d: item.progress && item.progress !== 100 || item.progress === 0
      }, item.progress && item.progress !== 100 || item.progress === 0 ? {
        e: item.progress === -1 ? 0 : item.progress,
        f: item.errMsg ? "#ff5a5f" : "#EBEBEB"
      } : {}, {
        g: item.errMsg
      }, item.errMsg ? {
        h: common_vendor.o(($event) => $options.uploadFiles(item, index), index)
      } : {}, {
        i: index
      });
    }),
    b: $props.delIcon && !$props.readonly,
    c: common_vendor.s($options.borderStyle),
    d: common_vendor.s($options.boxStyle),
    e: $props.filesList.length < $props.limit
  }, $props.filesList.length < $props.limit ? {
    f: common_vendor.s($options.borderStyle),
    g: common_vendor.o((...args) => $options.choose && $options.choose(...args)),
    h: common_vendor.s($options.boxStyle)
  } : {}, {
    i: common_vendor.gei(_ctx, "")
  });
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/node-modules/@dcloudio/uni-ui/lib/uni-file-picker/upload-image.js.map