import { getClientTypeList } from "@/api/device/version"; import { audioType, platform } from "@/api/music/platform"; import { options } from "@/api/music/radio"; import { list as categoryList } from "@/api/device/category"; import { list as functionList } from "@/api/device/function"; import { options as blogClass } from "@/api/music/blogclass"; import { options as mapList } from "@/api/operation/map"; // 设备列表 const devMixin = { data() { return { devOptions: [], }; }, methods: { getDevList(e) { getClientTypeList(e ? e : {}).then((res) => { // console.log("获取设备列表==" + JSON.stringify(res)); if (res.code === 0) { res.data.map((i) => { this.devOptions.push({ value: i.clientTypeId, label: i.name, }); }); } }); }, }, }; // 设备模式 const devModeMixin = { data() { return { devModeOptions: [{ value: 1, label: "蓝牙", disabled: false, }, { value: 2, label: "WIFI", disabled: false, }, { value: 3, label: "传统蓝牙", disabled: false, }, { value: 4, label: "4G", disabled: false, }, ], }; }, }; // 设备分类 const devCategoryMixin = { data() { return { categoryOptions: [], }; }, methods: { getCateGory(status) { categoryList({ status: status, isDelete: 0, }).then((res) => { res.data.map((i) => { this.categoryOptions.push({ value: i.id, label: i.name, }); }); }); }, }, }; // 设备类型 const devTypeMixin = { data() { return { devTypeOptions: [{ value: 0, label: "音响", }, { value: 1, label: "耳机", }, { value: 2, label: "穿戴", }, ], }; }, }; // 功能权限 const devFucMixin = { data() { return { devFucOptions: [], }; }, mounted() { functionList().then((res) => { if (res.code === 0) { res.data.map((i) => { this.devFucOptions.push({ value: i.id, label: i.name, }); }); } }); }, }; // 是否 const yesOrNoMixin = { data() { return { yesOrNoOptions: [{ value: 0, label: "否", }, { value: 1, label: "是", }, ], }; }, }; // 服务时长 const serviceTimeMixin = { data() { return { serviceTimeOptions: [{ value: -1, label: "1天", }, { value: 1, label: "7天", }, { value: 2, label: "14天", }, { value: 3, label: "1个月", }, { value: 4, label: "3个月", }, { value: 5, label: "6个月", }, { value: 6, label: "1年", }, { value: 7, label: "2年", }, { value: 8, label: "3年", }, { value: 9, label: "5年", }, { value: 0, label: "永久", }, ], }; }, }; const serviceTypeMixin = { data() { return { // 服务类型 serviceTypeOptions: [{ value: 0, label: "签到", }, { value: 1, label: "收听奖励", }, { value: 2, label: "积分抽奖", }, { value: 3, label: "打开手机通知", }, { value: 4, label: "积分兑换", }, { value: 5, label: "会员中心", }, ], }; }, }; // 是否免费 const isFreeMixin = { data() { return { freeOptions: [{ value: 0, label: "付费", }, { value: 1, label: "免费", }, ], }; }, }; // 音频类型 const audioMixin = { data() { return { audioOptions: [{ value: 2, label: "广播电台", }, { value: 6, label: "节目", }, { value: 8, label: "播客专辑", }, { value: 9, label: "歌手", }, { value: 10, label: "歌单", }, { value: 11, label: "歌曲", }, { value: 12, label: "主播", }, { value: 15, label: "音乐专辑", }, ], audioTypeOptions: [], }; }, methods: { // 通过平台获取对应的音频类型 getAudioType(e) { return new Promise((resolve, reject) => { platform(e).then((res) => { if (res.code === 0) { resolve( (this.audioTypeOptions = res.data[0].audioType .split(",") .map((i) => this.audioOptions.find((j) => j.value == i))) ); } }); }).catch((err) => { reject(); }); }, }, }; // 性别 const sexMixin = { data() { return { sexOptions: [{ value: 0, label: "未知", }, { value: 1, label: "男", }, { value: 2, label: "女", }, ], }; }, }; // 所属地区 const regionMixin = { data() { return { regionOptions: [{ value: 0, label: "内地", }, { value: 1, label: "港台", }, { value: 2, label: "欧美", }, { value: 3, label: "日本", }, { value: 4, label: "韩国", }, { value: 5, label: "其他", }, ], }; }, }; // 语种 const languageMixin = { data() { return { languageOptions: [{ value: 1, label: "国语", }, { value: 2, label: "欧美", }, { value: 3, label: "粤语", }, { value: 4, label: "韩语", }, { value: 5, label: "日语", }, { value: 6, label: "其他", }, ], }; }, }; // 所属平台 const platformMixin = { data() { return { platformTypeOptions: [], platformOptions: [], }; }, methods: { // 通过音频类型获取对应的平台 getPlatform(e) { this.platformOptions = []; return new Promise((resolve, reject) => { audioType(e) .then((res) => { if (res.code === 0) { res.data.map((i) => this.platformOptions.push({ value: Number(i.id), label: i.name, joinType: i.joinType, }) ); e ? (this.platformTypeOptions = this.platformOptions) : ""; resolve(this.platformOptions, this.platformTypeOptions); } }) .catch((err) => { reject(); }); }); }, // 第三方资源平台不可编辑 disabledPlatformId(e) { let value = this.platformOptions.find((i) => i.value == e); if (value) { return value.joinType.includes("1") ? true : false; } }, // 禁止选择第三方平台 disabledJoinType(e) { return e.split(",").includes("1"); }, }, }; // 上下架状态 const onOrOffMixin = { data() { return { onOrOffOptions: [{ value: 1, label: "上架", }, { value: 2, label: "下架", }, ], }; }, }; // 上下架状态 const disabledMixin = { data() { return { disabledOptions: [{ value: 0, label: "上架", }, { value: 1, label: "下架", }, ], }; }, }; // 付费类型 const payTypeMixin = { data() { return { payTypeOptions: [{ value: 1, label: "免费", }, { value: 2, label: "全集购买", }, { value: 3, label: "单集购买", }, { value: 4, label: "Vip专享", }, { value: 5, label: "亲子付费", }, ], }; }, }; // 专辑类型 const albumTypeMixin = { data() { return { albumTypeOptions: [{ value: 1, label: "Single", }, { value: 2, label: "EP", }, { value: 3, label: "Album", }, { value: 4, label: "古典专辑", }, { value: 5, label: "自制专辑", }, ], }; }, }; // 地域分类 const addressMixin = { data() { return { addressOptions: [], }; }, mounted() { this.getAddress(); }, methods: { getAddress() { options({ type: 2 }).then((res) => { if (res.code === 0) { res.data.map((i) => { this.addressOptions.push({ value: i.id, label: i.name, }); }); } }); }, }, }; // 广播分类 const contentMixin = { data() { return { contentOptions: [], }; }, methods: { getContent(data) { options(data).then((res) => { if (res.code === 0) { res.data.map((i) => { this.contentOptions.push({ value: i.id, label: i.name, }); }); } }); }, }, }; // 播客分类 const blogClassMixin = { data() { return { blogClassOptions: [], }; }, mounted() { blogClass().then((res) => { if (res.code === 0) { res.data.map((i) => { this.blogClassOptions.push({ value: i.id, label: i.name, }); }); } }); }, }; // 时效性 const currentMixin = { data() { return { currentOptions: [{ value: 0, label: "已生效", }, { value: 1, label: "待生效", }, { value: 2, label: "已失效", }, ], }; }, }; // 封面类型 const coverMixin = { data() { return { coverOptions: [{ value: 0, label: "自定义封面", }, { value: 1, label: "内容封面", }, ], }; }, }; // 通过频道属性查找音频类型 const channelMixin = { data() { return { channelOptions: { 2: [{ value: 2, label: "广播电台", }, ], 6: [{ value: 6, label: "节目", }, { value: 11, label: "歌曲", }, ], 8: [{ value: 8, label: "播客专辑", }, { value: 10, label: "歌单", }, { value: 15, label: "音乐专辑", }, ], 16: [{ value: 8, label: "播客专辑", }, ], 17: [{ value: 2, label: "广播电台", }, ], }, }; }, }; // 手机系统 const systemMixin = { data() { return { systemOptions: [{ value: 1, label: "Android", }, { value: 2, label: "iOS", }, ], }; }, }; // 省市区 const mapMixin = { data() { return { mapOptions: [], }; }, async mounted() { await this.getMapOptions(); }, methods: { // 省市区 getMapOptions() { return new Promise((reslove, reject) => { mapList().then((res) => { if (res.code === 0) { if (this.$route.path.search("/music/radio") !== -1) { res.data.unshift({ adcode: "1", childList: [], citycode: "", id: "1", name: "中央台", }); } reslove((this.mapOptions = res.data)); } }); }); }, areaFormatter(row) { if (this.mapOptions.length > 0) { let province = row.province ? this.mapOptions.find((i) => i.id == row.province) : ""; let provinceName = province ? province.name : ""; let city = province && province.childList.length > 0 ? province.childList.find((i) => i.id == row.city) : ""; let cityName = city ? `-${city.name}` : ""; let area = city && city.childList.length > 0 ? city.childList.find((i) => i.id == row.area) : ""; let areaName = area ? `-${area.name}` : ""; return `${provinceName}${cityName}${areaName}`; } }, }, }; export { addressMixin, albumTypeMixin, audioMixin, blogClassMixin, channelMixin, contentMixin, coverMixin, currentMixin, devCategoryMixin, devFucMixin, devMixin, devModeMixin, devTypeMixin, disabledMixin, isFreeMixin, languageMixin, mapMixin, onOrOffMixin, payTypeMixin, platformMixin, regionMixin, serviceTimeMixin, serviceTypeMixin, sexMixin, systemMixin, yesOrNoMixin };