123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- mui.init();
- var flag=mobile.getUrlVars("flag");
- /**
- *初始化、添加监听
- */
- mui.ready(function(){
- if(flag=="1"){
- $("#sex-div").hide();
- $("#type-div").hide();
- $(".mui-title").html("完善个人信息");
- $(".mui-btn-primary").html("我要推广");
- $("#sendCode").html(Math.floor(Math.random()*9000)+1000);
- }else{
- $("#code-div").hide();
- }
- $("#sendCode").on("tap",function(e){
- $("#sendCode").html(Math.floor(Math.random()*9000)+1000);
- });
- getByOpenid();
- $('#save').on('tap',function(){
- var id = $('#id').val();
- var username = $('#username').val();
- var mobilephone = $('#mobile').val();
- var nickname = $('#nickname').val();
- var sex = $('#sex').val();
- var code = $.trim($('#code').val());
- var is_share="0";
- if(!username){
- layer.open({content:'请输入姓名',time:3});
- return;
- }
- if(!mobilephone){
- layer.open({content:'请输入手机号码',time:3});
- return;
- }
- if(!mobile.checkMobile(mobilephone)){
- layer.open({content:'请输入正确手机号码',time:3});
- return;
- }
- if(flag=="1"){
- is_share="1";
- if(code!=$("#sendCode").html()){
- layer.open({content:'验证码错误',time:3});
- return;
- }
- }
- mobile.ajaxPost(base+'/users/save',{
- id:id,
- username:username,
- mobile:mobilephone,
- nickname:nickname,
- sex:sex,
- is_share:is_share
- },function(json){
- if(json.success){
- if(flag=="1"){
- layer.open({content:'注册成功,分享给朋友或朋友圈可推广赚钱',time:3});
- }else{
- layer.open({content:'保存成功',time:3});
- }
- }
- });
- });
- });
- /**
- *获取列表
- */
- function getByOpenid(){
- mobile.ajaxPost(base+'/users/getByOpenid',{},function(json){
- if(json.data){
- mobile.toForm(json.data);
- }
- });
- }
|