134 lines
4.0 KiB
JavaScript
134 lines
4.0 KiB
JavaScript
"use strict";
|
|
var __defProp = Object.defineProperty;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __publicField = (obj, key, value) => {
|
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
return value;
|
|
};
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_assets = require("../../common/assets.js");
|
|
const common_js_util = require("../../common/js/util.js");
|
|
const api_index = require("../../api/index.js");
|
|
if (!Array) {
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
|
|
(_easycom_uni_icons2 + _easycom_uni_popup2)();
|
|
}
|
|
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
|
|
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
|
|
if (!Math) {
|
|
(_easycom_uni_icons + _easycom_uni_popup)();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "collectAdd",
|
|
setup(__props, { expose: __expose }) {
|
|
const {
|
|
proxy
|
|
} = common_vendor.getCurrentInstance();
|
|
class Form {
|
|
constructor() {
|
|
// 收藏夹名称
|
|
__publicField(this, "collectName", "");
|
|
// 0公开1私密
|
|
__publicField(this, "isPrivate", 0);
|
|
// 图片地址
|
|
__publicField(this, "pic", "");
|
|
// 收藏id
|
|
__publicField(this, "collectId", "");
|
|
}
|
|
}
|
|
const form = common_vendor.reactive(new Form());
|
|
function open(value) {
|
|
if (value) {
|
|
form.collectName = value.collectName;
|
|
form.isPrivate = value.isPrivate;
|
|
form.collectId = value.id;
|
|
form.pic = value.formatPic;
|
|
}
|
|
proxy.$refs.addCollectRef.open();
|
|
}
|
|
function close() {
|
|
proxy.$refs.addCollectRef.close();
|
|
}
|
|
function upImage() {
|
|
common_js_util.util.upload_image({
|
|
value: form.pic,
|
|
type: 1,
|
|
success: (rs) => {
|
|
form.pic = rs.value;
|
|
}
|
|
});
|
|
}
|
|
function handlePrivate() {
|
|
form.isPrivate = form.isPrivate == 0 ? 1 : 0;
|
|
}
|
|
function handleSubmit() {
|
|
const data = {
|
|
...form
|
|
};
|
|
if (!form.collectName) {
|
|
common_js_util.util.alert("请输入收藏夹名称");
|
|
return;
|
|
}
|
|
if (!form.pic) {
|
|
common_js_util.util.alert("请上传封面图");
|
|
return;
|
|
}
|
|
data.pic = common_js_util.util.replace_url(data.pic);
|
|
let requestApi = "saveCollectList";
|
|
if (form.collectId)
|
|
requestApi = "updateCollectList";
|
|
api_index.api.video[requestApi]({
|
|
query: data
|
|
}).then((rs) => {
|
|
if (rs.code == 200) {
|
|
common_vendor.index.$emit("collectsVideo");
|
|
close();
|
|
Object.assign(form, new Form());
|
|
return;
|
|
}
|
|
common_js_util.util.alert({
|
|
content: rs.msg,
|
|
showCancel: false
|
|
});
|
|
});
|
|
}
|
|
__expose({
|
|
open,
|
|
close
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.o$1(close),
|
|
b: common_vendor.p({
|
|
type: "closeempty"
|
|
}),
|
|
c: !form.id
|
|
}, !form.id ? {} : {}, {
|
|
d: common_vendor.o$1(handleSubmit),
|
|
e: form.pic
|
|
}, form.pic ? {
|
|
f: form.pic
|
|
} : {
|
|
g: common_vendor.p({
|
|
type: "plusempty",
|
|
size: "40rpx"
|
|
})
|
|
}, {
|
|
h: common_vendor.o$1(upImage),
|
|
i: form.collectName,
|
|
j: common_vendor.o$1(($event) => form.collectName = $event.detail.value),
|
|
k: common_assets._imports_0$13,
|
|
l: form.isPrivate == 0,
|
|
m: common_vendor.o$1(handlePrivate),
|
|
n: common_vendor.sr("addCollectRef", "13d7550c-0"),
|
|
o: common_vendor.p({
|
|
type: "bottom"
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-13d7550c"]]);
|
|
wx.createComponent(Component);
|