//此文件使用了select-store组件
//必须在同页面引入/Public/Retail/common/js/select-store.js
//冻结会员
Vue.component('vip-frozen', {
template: `冻结`,
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: `挂失`,
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: `恢复`,
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: `支付密码`,
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: `
不变动
增加时长
减少时长
不选择则重置会员等级
提交
`,
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: `
`,
props: {
'section': {
type: Object,
default() {
return {
integral: '',
balance: '',
purchase: '',
type: '',
time: '',
}
},
},
},
});