很久的代码,能看着找找灵感就行。
<template>
<div class="one">
<el-form :model="form" class="dadada">
<el-card>
<!-- er -->
<el-form-item label="佣金类型:">
<el-select
clearable
class="ele-block"
v-model="form.lv"
placeholder="请选择"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="内容:">
<el-input
v-if="form.lv == 1"
v-model="listinfio.percentage"
placeholder="请输入拿推广用户收益百分比"
/>
<el-input
v-if="form.lv == 2"
v-model="listinfio2.percentage"
placeholder="请输入拿推广用户收益百分比"
clearable
/>
<el-input
v-if="form.lv == 3"
v-model="listinfio23.percentage"
placeholder="请输入拿推广用户收益百分比"
clearable
/>
<!--
<el-input
v-if="form.lv == 3"
v-model="form.list[2].percentage"
placeholder="请输入拿推广用户收益百分比"
clearable
/> -->
</el-form-item>
<!-- 提交 -->
<el-form-item>
<el-button type="primary" @click="submit" class="tj">
提交
</el-button>
</el-form-item>
</el-card>
</el-form>
</div>
</template>
<script>
import qs from "qs";
export default {
data() {
return {
options: [
{
value: "1",
label: "直推佣金"
},
{
value: "2",
label: "二级佣金"
},
{
value: "3",
label: "三级佣金"
}
],
upinof: [],
quertlistall: {},
form: {
lv: "1"
},
loading: false,
isUpdate: false,
listinfio: {
percentage: ""
},
listinfio2: {
percentage: ""
},
listinfio23: {
percentage: ""
},
info: {}
};
},
mounted() {
this.queryinfo();
},
methods: {
submit() {
if (this.form.lv == 1) {
this.info["lv_percentage"] = {
[this.form.lv]: this.listinfio.percentage
};
let param = new URLSearchParams();
param.append(
"lv_percentage",
JSON.stringify({ "1": this.listinfio.percentage })
);
this.$http
.post("admin-api/commission-config/update", param)
.then(res => {
console.log(res);
if (res.data.status === 1) {
this.$message({ type: "success", message: "成功" });
} else {
this.$message.error(res.error);
}
});
} else if (this.form.lv == 2) {
this.info["lv_percentage"] = {
[this.form.lv]: this.listinfio.percentage
};
let param = new URLSearchParams();
param.append(
"lv_percentage",
JSON.stringify({ "2": this.listinfio.percentage })
);
this.$http
.post("admin-api/commission-config/update", param)
.then(res => {
console.log(res);
if (res.data.status === 1) {
this.$message({ type: "success", message: "成功" });
this.queryinfo();
} else {
this.$message.error(res.error);
}
});
} else {
this.info["lv_percentage"] = {
[this.form.lv]: this.listinfio.percentage
};
let param = new URLSearchParams();
param.append(
"lv_percentage",
JSON.stringify({ "3": this.listinfio.percentage })
);
this.$http
.post("admin-api/commission-config/update", param)
.then(res => {
console.log(res);
if (res.data.status === 1) {
this.$message({ type: "success", message: "成功" });
this.queryinfo();
} else {
this.$message.error(res.error);
}
});
}
},
queryinfo() {
this.$http.get("admin-api/commission-config/get", {}).then(res => {
console.log(res, "佣金设置");
if (res.data.status === 1) {
this.listinfio = res.data.result[0];
this.listinfio2 = res.data.result[1];
this.listinfio23 = res.data.result[2];
}
});
}
},
};
</script>