## 会员管理
>[info]功能:
1,显示数据:通过关联`wp_users_discount`查询 `wp_users` 会员管理表 显示会员
2,插入数据:新建会员
3,编辑数据:修改会员信息
4,删除数据:删除会员
5,如果会员参与折扣 则把折扣数 插入到 `wp_users_discount` 表中
5,关联`wp_users_discount` 会员折扣表 来查看会员在不同商家下的折扣情况
checkPhone: function(){
if(!(/^1(3|4|5|7|8)\d{9}$/.test($('#phone').val())))
{
this.able = 0;
Public.tips.error('手机号有误');
}
},
update:function(val){
var bbb = $('.brons').val();
this.items.bron = bbb;
},
bron:function(){
var bbb = $('.brons').val();
},
click:function(){
var this_ = this ;
var wq = $('#userse').val();
if(!wq){
Public.tips.error('请输入正确的会员信息进行查询');
return false;
}
$.get(base_url+"/home/user_search/index",{wq:wq},function(rs){
if(!rs.data ){
$('.nodata').css('display','block');
$('.ser-list').css('display','none');
}else{
arad = rs.data;
this_.users = arad.reverse();
$('.nodata').css('display','none');
$('.ser-list').css('display','block');
}
var Swipermem = new Swiper('.swiper-memlist', {
scrollbar: '.swiper-scrollbar-memlist',
direction: 'vertical',
slidesPerView: 'auto',
slidesPerView:5,
mousewheelControl: true,
freeMode: true,
initialSlide :0,
observer:true,//修改swiper自己或子元素时,自动初始化
observeParents:true//修改swiper的父元素时,自动初始化swiper
});
},'json')
},
fanhuiss:function(){
$('.sousuo').css('display','block');
$('.infos').css('display','none');
},
click_url:function(id){
$('.sousuo').css('display','none');
$('.infos').css('display','block');
var this_ = this;
$.get(base_url+"/home/user_search/infos",{id:id},function(rs){
if(rs.data){
this_.uinfos = rs.data[0];
this_.id = rs.data[0]['id'];
}
},'json');
$.get(base_url+"/home/user_search/plural",{id:id},function(rs){
this_.items = rs.data[0];
},'json')
},
/*编辑会员选择性别*/
sex:function(){
$(".sex").css('display','block');
},
man:function(obj){
if(obj == 1){
this.items.sex = this.ins = "男";
}else if(obj == 2){
this.items.sex = this.ins = "女";
}else{
this.items.sex = this.ins = "保密";
}
$(".sex").css('display','none');
},
fanhui:function(){
this.show = 'infos';
},
czfanhui:function(){
this.show = 'infos';
},
click_info:function(id){
this.show = 'infos';
$(".sousuo").css('display','none');
$(".infos").css('display','block');
var this_ = this;
$.get(base_url+"/home/user_search/infos",{id:id},function(rs){
if(rs.data){
this_.uinfos = rs.data[0];
this_.id = rs.data[0]['id'];
}
},'json');
$.get(base_url+"/home/user_search/plural",{id:id},function(rs){
this_.items = rs.data[0];
},'json')
},
click_new:function(){
this.ins = "";
this.show = 'insert';
},
guanbi:function(){
this.show = 'sousuo';
},
click_update:function(){
this.show = 'sousuo';
},
bianji:function(){
var diib = $('.diib').val();
if(diib != 0){
this.uinfos.discount = diib * 10;
}
this.show = 'update';
},
back: function(){
$.ajax({
type: "GET",
url: base_url+"/home/welcome/user_index",
data: {},
dataType: "json",
success: function(data) {
if(data.status) {
$(" body").html(data.html);
}
}
});
}
/*
* 获取手机验证码
*/
$('#get_code').click(function(){
if(!usersearchVue.able){
return false;
}
var phone = $("#phone").val();
if(!phone){
Public.tips.error('请输入手机号');
return false;
}
var url = $(this).attr('rel');
$("#code").attr('name','code');
var obj = this;
$.post(url,{phone:$('#phone').val()},function(dt){
if(dt.status == false){
alert_error(dt.msg);
}else{
invokeSettime(obj);
alert_success(dt.msg);
}
},'json').error(function(){
alert_error( '获取验证码失败,请稍后再试!');
});
return false;
});
function invokeSettime(obj){
var countdown=60;
settime(obj);
function settime(obj) {
if (countdown == 0) {
$(obj).attr("disabled",false);
$(obj).html("获取验证码");
usersearchVue.able = 1;
countdown = 60;
return;
} else {
$(obj).attr("disabled",true);
$(obj).html("(" + countdown + ") s 重新发送");
usersearchVue.able = 0;
countdown--;
}
setTimeout(function() {
settime(obj) }
,1000)
}
}
$(".ajax *").focus(function(){
$(this).parent('div.form-group').removeClass('has-error');
});
$('.ajax').ajaxForm({
dataType: 'json',
success: function(data) {
usersearchVue.uinfos.discount = usersearchVue.uinfos.discount/10;
if(data.status == 1 && data.msg ){
Public.tips.success(data.msg);
usersearchVue.show = 'sousuo';
$.get(base_url+"/home/user_search/index",function(rs){
usersearchVue.ulist = rs.data;
},'json');
document.getElementById('ucenter_name').value = '';
document.getElementById('discount').value = '';
document.getElementById('phone').value = '';
document.getElementById('email').value = '';
document.getElementById('code').value = '';
document.getElementById('bron').value = '';
}else if(data.msg){
Public.tips.error(data.msg);
}
if(data.url){
setTimeout(function(){
window.location.href = data.url;
},1000);
}
if(data.render){
$("."+data.render).html(data.html);
}
}
});
})