/** * 小程序用户管理列表 */ Vue.component('mini-program-user-index', { template: `
查询 重置 导出用户信息
`, props: { 'userType': { type: Number, default: 1,//1商户 2门店 }, }, data() { return { operate: {}, searchForm: { nick_name: '', time: '', store_id: '', page: 1, // 分页 limit: 10, // 每页显示条数 }, vipList: [], loading: false, total: 0, // 总数 int类型 showEditDialog: false, // 变更弹出框 editData: { id: 0, // id nickname: '', // 昵称 }, requestUrl: { getData: { 1: 'Retail/Vip/getXcxUser', 2: 'Retail/Vips/store_xcxvip_list', }, export: { 1: '/index.php/Retail/Vip/xcxUserExport', 2: '/index.php/Retail/Vips/store_xcxvip_list_export', }, } }; }, methods: { // 修改页码 currentChange(val) { this.searchForm.page = val; this.getData(); }, // 修改每页显示数量 sizeChange(val) { this.searchForm.limit = val; this.searchForm.page = 1; this.getData(); }, getData() { this.sendRequest(this.requestUrl.getData[this.userType], { data: { page: this.searchForm.page, limit: this.searchForm.limit, search_info: JSON.stringify({ store_id: this.searchForm.store_id, nick_name: this.searchForm.nick_name, time: this.searchForm.time }) }, success: (res) => { this.loading = false; if (res.status == 1) { this.vipList = res.list; this.total = res.count; } else { this.$message.error(res.message) } } }) }, exportData() { this.$confirm('确定导出数据吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'info' }).then(() => { window.location.href = this.requestUrl.export[this.userType] + '?nick_name=' + this.searchForm.nick_name + '&time=' + this.searchForm.time; }); }, // 显示用户类型转变弹框 userTypeChange(item) { this.editData = { id: item.id, nickname: item.nickname, }; this.showEditDialog = true; }, userTypeChangeEnd() { this.showEditDialog = false; this.getData(); }, // 重置搜索表单 reset() { this.searchForm = { nick_name: '', time: '', page: 1, // 分页 limit: 10, // 每页显示条数 }; this.getData(); }, }, created() { this.checkOperateAuth((this.userType == 1 ? { export: '/index.php/Retail/Vip/xcxvip_list_export', changeRole: '/index.php/Retail/Vip/changeRole', } : { export: '/index.php/Retail/Vips/store_xcxvip_list_export', changeRole: '/index.php/Retail/Vips/changeRole', }), (data) => { this.operate = data; }); this.getData(); }, }); /** * 变更小程序用户 */ Vue.component('change-user-type', { template: ` 常规会员 PLUS会员 默认无等级 默认余额为0 提交 `, props: { 'show': { type: Boolean, default: false, }, 'userType': { type: Number, default: 1,//1商户 2门店 }, 'data': { type: Object, default() { return { id: 0, nickname: '' } } }, }, data() { return { editForm: { id: 0, // id type: '', // 类型 grade_id: '', // 等级 store_id: '', // 门店ID name: '', // 姓名 nickname: '', // 昵称 mobile_phone: '', // 手机号 birthday: '', // 生日 balance: '', // 余额 end_time: '', // plus会员过期时间 }, rules: { type: [{required: true, message: '请选择会员类型', trigger: 'change'}], // store_id: [{required: true, message: '请选择会员直属门店', trigger: 'change'}], grade_id: [{required: false, message: '请选择会员等级', trigger: 'change'}], name: [{required: true, message: '请输入会员姓名', trigger: 'change'}], nickname: [{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' }], 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' }], end_time: [{required: true, message: '请选择PLUS会员过期时间', trigger: 'change'}], },//变更的规则 subLoading: false, requestUrl: { 1: 'Retail/Vip/changeRole', 2: 'Retail/Vips/changeRole', } }; }, methods: { clearDialog() { this.$refs.editForm.resetFields(); this.$emit('end'); }, changeType(val) { this.editForm.grade_id = ''; if (val == 1) { this.$refs.editForm.validateField('grade_id'); } }, // 提交表单 submitForm() { this.$refs.editForm.validate((valid) => { if (!valid) { return this.$message.warning('请检查表单信息'); } this.$confirm('确认变更该普通用户的信息吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'info' }).then(() => { this.subLoading = true; this.sendRequest(this.requestUrl[this.userType], { data: this.editForm, success: (res) => { this.subLoading = false; if (res.status == 1) { this.$message.success(res.message); this.clearDialog(); } else { this.$message.error(res.message); } } }) }) }) }, }, watch: { show(n) { if (n) { this.editForm.id = this.data.id; this.editForm.nickname = this.data.nickname; } } } });