469 行
20 KiB
JavaScript
可执行文件
469 行
20 KiB
JavaScript
可执行文件
//此文件使用了select-store组件
|
|
//必须在同页面引入/Public/Retail/common/js/select-store.js
|
|
|
|
//冻结会员
|
|
Vue.component('vip-frozen', {
|
|
template: `<el-button @click.native="frozenVip" type="text" size="mini">冻结</el-button>`,
|
|
props: {
|
|
'vid': {
|
|
type: String,
|
|
default: '',
|
|
},//会员ID
|
|
'type': {
|
|
type: Number,
|
|
default: 1,
|
|
},//提交的来源类型 1商户普通会员 2商户plus会员 3门店普通会员 4门店plus会员
|
|
},
|
|
data() {
|
|
return {
|
|
submitUrl: {
|
|
1: 'Retail/Vip/frozenVip',
|
|
2: 'Retail/Plus/frozenVip',
|
|
3: 'Retail/Vips/frozenVip',
|
|
4: 'Retail/Plus/storeFrozenVip',
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
frozenVip() {
|
|
this.$confirm('确定冻结该会员?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
this.sendRequest(this.submitUrl[this.type], {
|
|
data: {
|
|
vip_id: this.vid
|
|
},
|
|
success: (res) => {
|
|
if (res.status == 1) {
|
|
this.$message.success(res.message);
|
|
this.$emit('end');
|
|
} else {
|
|
this.$message.error(res.message);
|
|
}
|
|
}
|
|
})
|
|
}).catch(() => {
|
|
});
|
|
},
|
|
},
|
|
});
|
|
|
|
//挂失会员
|
|
Vue.component('vip-loss', {
|
|
template: `<el-button @click.native="lossVip" type="text" size="mini">挂失</el-button>`,
|
|
props: {
|
|
'vid': {
|
|
type: String,
|
|
default: '',
|
|
},//会员ID
|
|
'type': {
|
|
type: Number,
|
|
default: 1,
|
|
},//提交的来源类型 1商户普通会员 2商户plus会员 3门店普通会员 4门店plus会员
|
|
},
|
|
data() {
|
|
return {
|
|
submitUrl: {
|
|
1: 'Retail/Vip/lossVip',
|
|
2: 'Retail/Plus/lossVip',
|
|
3: 'Retail/Vips/lossVip',
|
|
4: 'Retail/Plus/storeLossVip',
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
lossVip() {
|
|
this.$confirm('确定挂失该会员?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
this.sendRequest(this.submitUrl[this.type], {
|
|
data: {
|
|
vip_id: this.vid
|
|
},
|
|
success: (res) => {
|
|
if (res.status == 1) {
|
|
this.$message.success(res.message);
|
|
this.$emit('end');
|
|
} else {
|
|
this.$message.error(res.message);
|
|
}
|
|
}
|
|
})
|
|
}).catch(() => {
|
|
});
|
|
},
|
|
},
|
|
});
|
|
|
|
//恢复会员
|
|
Vue.component('vip-thaw', {
|
|
template: `<el-button @click.native="thawVip" type="text" size="mini">恢复</el-button>`,
|
|
props: {
|
|
'vid': {
|
|
type: String,
|
|
default: '',
|
|
},//会员ID
|
|
'type': {
|
|
type: Number,
|
|
default: 1,
|
|
},//提交的来源类型 1商户普通会员 2商户plus会员 3门店普通会员 4门店plus会员
|
|
},
|
|
data() {
|
|
return {
|
|
submitUrl: {
|
|
1: 'Retail/Vip/thawVip',
|
|
2: 'Retail/Plus/thawVip',
|
|
3: 'Retail/Vips/thawVip',
|
|
4: 'Retail/Plus/storeThawVip',
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
thawVip() {
|
|
this.$confirm('确定恢复该会员为正常会员?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
this.sendRequest(this.submitUrl[this.type], {
|
|
data: {
|
|
vip_id: this.vid
|
|
},
|
|
success: (res) => {
|
|
if (res.status == 1) {
|
|
this.$message.success(res.message);
|
|
this.$emit('end');
|
|
} else {
|
|
this.$message.error(res.message);
|
|
}
|
|
}
|
|
})
|
|
}).catch(() => {
|
|
});
|
|
},
|
|
},
|
|
});
|
|
|
|
//修改支付密码
|
|
Vue.component('vip-password', {
|
|
template: `<el-button @click.native="modifyPassword" type="text" size="mini">支付密码</el-button>`,
|
|
props: {
|
|
'vid': {
|
|
type: String,
|
|
default: '',
|
|
},//会员ID
|
|
'type': {
|
|
type: Number,
|
|
default: 1,
|
|
},//提交的来源类型 1商户普通会员 2商户plus会员 3门店普通会员 4门店plus会员
|
|
},
|
|
data() {
|
|
return {
|
|
submitUrl: {
|
|
1: 'Retail/Vip/modifyPassword',
|
|
2: 'Retail/Plus/modifyPassword',
|
|
3: 'Retail/Vips/modifyPassword',
|
|
4: 'Retail/Plus/storeModifyPassword',
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
modifyPassword() {
|
|
this.$prompt('请输入6位数字的支付密码', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
inputPattern: /^[0123456789]{6}/,
|
|
inputErrorMessage: '支付密码格式不正确'
|
|
}).then(({value}) => {
|
|
this.$loading({
|
|
lock: true,
|
|
text: '保存中...',
|
|
spinner: 'el-icon-loading',
|
|
background: 'rgba(255, 255, 255, 0.3)'
|
|
});
|
|
this.sendRequest(this.submitUrl[this.type], {
|
|
data: {
|
|
vip_id: this.vid,
|
|
password: value
|
|
},
|
|
success: (res) => {
|
|
this.$loading().close();
|
|
if (res.status == 1) {
|
|
this.$message.success(res.message);
|
|
} else {
|
|
this.$message.error(res.message);
|
|
}
|
|
},
|
|
})
|
|
}).catch(() => {
|
|
|
|
});
|
|
}
|
|
},
|
|
});
|
|
|
|
//编辑会员资料
|
|
Vue.component('edit-vip-info', {
|
|
template: `<el-dialog title="编辑会员信息" :append-to-body="true"
|
|
:visible.sync="show"
|
|
width="600px"
|
|
:before-close="closeDialog"
|
|
:close-on-click-modal="false">
|
|
<el-form label-width="100px" size="small" ref="editForm" :rules="rules" :model="editForm">
|
|
<el-form-item label="类型" prop="vip_type" v-if="editData.plus_type==3">
|
|
<el-select size="small" v-model="editForm.vip_type" :disabled="editData.plus_type==2?true:false">
|
|
<el-option label="常规会员" :value="1"></el-option>
|
|
<el-option label="PLUS会员" :value="2"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="PLUS时长" prop="operate_days_type" v-if="editData.plus_type==2">
|
|
<el-radio-group size="mini" v-model="editForm.operate_days_type">
|
|
<el-radio border :label="0">不变动</el-radio>
|
|
<el-radio border :label="1">增加时长</el-radio>
|
|
<el-radio border :label="2">减少时长</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
<el-form-item label="时长(天)" prop="operate_days"
|
|
v-if="editData.plus_type==3&&editForm.vip_type==2||editForm.operate_days_type!=0">
|
|
<el-input-number v-model="editForm.operate_days"
|
|
style="width: 192px;"
|
|
placeholder="PLUS有效天数" step-strictly
|
|
:precision="0" :step="1"
|
|
:max="10000000000" :min="0"></el-input-number>
|
|
</el-form-item>
|
|
<el-form-item label="等级" v-if="editData.plus_type==3 && editForm.vip_type==1" prop="grade_id">
|
|
<select-vip-grade :grade-id.sync="editForm.grade_id"
|
|
:show-discount="true"
|
|
:placeholder="'请选择会员等级'"></select-vip-grade>
|
|
<span style="font-size: 12px;color: #8492A6;">不选择则重置会员等级</span>
|
|
</el-form-item>
|
|
<el-form-item label="姓名" prop="vip_name">
|
|
<el-input v-model="editForm.vip_name"
|
|
style="width: 192px;"
|
|
placeholder="请输入会员姓名" clearable></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="所属门店" v-if="type == 1 || type == 2">
|
|
<select-store :store-id.sync="editForm.storeId"
|
|
:store-status="3"
|
|
:show-status="true"
|
|
:placeholder="'会员所属门店'">
|
|
</select-store>
|
|
</el-form-item>
|
|
<el-form-item label="余额" prop="balance">
|
|
<el-input-number v-model="editForm.balance"
|
|
style="width: 192px;" step-strictly
|
|
placeholder="会员余额"
|
|
:precision="2" :step="0.01"
|
|
:max="1000000000" :min="0"></el-input-number>
|
|
</el-form-item>
|
|
<el-form-item label="积分" prop="integral">
|
|
<el-input-number v-model="editForm.integral"
|
|
style="width: 192px;"
|
|
placeholder="会员积分" step-strictly
|
|
:precision="0" :step="1"
|
|
:max="10000000000" :min="0"></el-input-number>
|
|
</el-form-item>
|
|
<el-form-item label="手机号" prop="mobile_phone">
|
|
<el-input v-model="editForm.mobile_phone"
|
|
style="width: 192px;" clearable
|
|
placeholder="请输入会员手机号"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div style="text-align: center">
|
|
<el-button type="primary" size="medium" :loading="submitLoading" @click="submitEdit">提交</el-button>
|
|
</div>
|
|
</el-dialog>`,
|
|
props: {
|
|
'show': {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
'editData': {
|
|
type: Object,
|
|
default() {
|
|
return {}
|
|
}
|
|
},//编辑会员的资料
|
|
'type': {
|
|
type: Number,
|
|
default: 1,
|
|
},//提交的来源类型 1商户普通会员 2商户plus会员 3门店普通会员 4门店plus会员
|
|
},
|
|
data() {
|
|
let _t = this;
|
|
return {
|
|
editForm: {
|
|
vip_id: '',
|
|
vip_type: 1,
|
|
vip_name: '',
|
|
grade_id: '',
|
|
balance: '',
|
|
integral: '',
|
|
mobile_phone: '',
|
|
operate_days_type: 0,
|
|
operate_days: '',
|
|
},
|
|
rules: {
|
|
vip_type: [{required: true, message: '请选择会员类型', trigger: 'change'}],
|
|
operate_days_type: [{required: true, message: '请选择是否操作PLUS会员时长', trigger: 'change'}],
|
|
operate_days: [{required: true, message: '请输入PLUS时长', trigger: 'change'}, {
|
|
validator: function (rule, value, callback) {
|
|
var reg = /^-?([0-9]\d*|[0]{1})$/;
|
|
if (_t.editForm.operate_days_type != 0) {
|
|
if (value === '' || value === null || value == undefined) {
|
|
callback(new Error("请输入PLUS时长"));
|
|
} else if (reg.test(value) == false) {
|
|
callback(new Error("请输入正确的PLUS时长"));
|
|
} else {
|
|
callback();
|
|
}
|
|
} else {
|
|
callback();
|
|
}
|
|
}, trigger: 'change'
|
|
}],
|
|
vip_name: [{required: true, message: '请输入会员姓名', trigger: 'change'}],
|
|
grade_id: [{required: false, message: '请选择会员等级', trigger: 'change'}],
|
|
balance: [{required: true, message: '请输入会员余额', trigger: 'change'}, {
|
|
validator: function (rule, value, callback) {
|
|
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{0,2})$/;
|
|
if (value === '' || value === null || value == undefined) {
|
|
callback(new Error("请输入会员余额"));
|
|
} else if (reg.test(value) == false) {
|
|
callback(new Error("请输入正确的会员余额"));
|
|
} else {
|
|
callback();
|
|
}
|
|
}, trigger: 'change'
|
|
}],
|
|
integral: [{required: true, message: '请输入会员积分', trigger: 'change'}, {
|
|
validator: function (rule, value, callback) {
|
|
var reg = /^-?([0-9]\d*|[0]{1})$/;
|
|
if (value === '' || value === null || value == undefined) {
|
|
callback(new Error("请输入会员积分1"));
|
|
} else if (reg.test(value) == false) {
|
|
callback(new Error("请输入正确的会员积分"));
|
|
} else {
|
|
callback();
|
|
}
|
|
}, trigger: 'change'
|
|
}],
|
|
mobile_phone: [{required: true, message: '请输入会员手机号', trigger: 'change'}, {
|
|
validator: function (rule, value, callback) {
|
|
if (value == '') {
|
|
callback(new Error("请输入会员手机号"));
|
|
} else if (!(/^[1][3456789][0-9]{9}$/).test(value)) {
|
|
callback(new Error("请输入正确的会员手机号"));
|
|
} else {
|
|
callback();
|
|
}
|
|
}, trigger: 'change'
|
|
}],
|
|
},//编辑会员的资料的验证规则
|
|
submitLoading: false,//提交的loading,
|
|
submitUrl: {
|
|
1: 'Retail/Vip/modifyVip',
|
|
2: 'Retail/Plus/modifyVipInfo',
|
|
3: 'Retail/Vips/modifyVip',
|
|
4: 'Retail/Plus/storeModifyVipInfo',
|
|
}
|
|
};
|
|
},
|
|
methods: {
|
|
closeDialog() {
|
|
this.$refs.editForm.resetFields();
|
|
this.$emit('end');
|
|
},
|
|
//修改会员信息
|
|
submitEdit() {
|
|
this.$refs.editForm.validate((valid) => {
|
|
if (!valid) {
|
|
return this.$message.warning('请检查表单信息');
|
|
}
|
|
this.$confirm('确认修改会员信息吗?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'info'
|
|
}).then(() => {
|
|
this.submitLoading = true;
|
|
this.sendRequest(this.submitUrl[this.type], {
|
|
data: {
|
|
vip_edit_info: JSON.stringify(this.editForm),
|
|
},
|
|
success: (res) => {
|
|
this.submitLoading = false;
|
|
if (res.status == 1) {
|
|
this.$message.success(res.message);
|
|
this.closeDialog();
|
|
} else {
|
|
this.$message.error(res.message);
|
|
}
|
|
}
|
|
})
|
|
}).catch(() => {
|
|
});
|
|
})
|
|
},
|
|
},
|
|
watch: {
|
|
show(n) {
|
|
if (n) {
|
|
this.editForm = {
|
|
vip_id: this.editData.id,
|
|
vip_type: this.editData.plus_type == 2 ? '' : 1,
|
|
vip_name: this.editData.name,
|
|
grade_id: this.editData.grade_id,
|
|
balance: this.editData.balance,
|
|
integral: this.editData.integral,
|
|
mobile_phone: this.editData.mobile_phone,
|
|
operate_days_type: 0,
|
|
operate_days: '',
|
|
}
|
|
|
|
//在上面Data中没有设置storeId的初始化数据是因为门店不需要这个字段,在门店不允许修改所属门店
|
|
if ([1, 2].includes(this.type)) this.editForm.storeId = this.editData.storeid
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
//其他搜索
|
|
Vue.component('vip-more-search', {
|
|
template: `<div>
|
|
<el-select style="width:164px;margin-right: 20px"
|
|
v-model="section.type" placeholder="区间、类型"
|
|
clearable>
|
|
<el-option label="激活时间" value="1"></el-option>
|
|
<el-option label="生日时间" value="2"></el-option>
|
|
<el-option label="沉睡时间" value="3"></el-option>
|
|
<el-option label="复购次数" value="4"></el-option>
|
|
</el-select>
|
|
|
|
<date-picker-range v-if="section.type" :date-time.sync="section.time"></date-picker-range>
|
|
|
|
<el-input style="width:164px;margin-right: 20px" v-if="section.type == 4"
|
|
v-model="section.purchase" placeholder="复购次数" clearable></el-input>
|
|
<el-input style="width:164px;margin-right: 20px" v-model="section.integral"
|
|
placeholder="积分区间(例:1-100)" clearable></el-input>
|
|
<el-input style="width:164px;margin-right: 20px" v-model="section.balance"
|
|
placeholder="余额区间(例:1-100)" clearable></el-input>
|
|
</div>`,
|
|
props: {
|
|
'section': {
|
|
type: Object,
|
|
default() {
|
|
return {
|
|
integral: '',
|
|
balance: '',
|
|
purchase: '',
|
|
type: '',
|
|
time: '',
|
|
}
|
|
},
|
|
},
|
|
},
|
|
}); |