作者 王晓刚
1 个管道 的构建 通过 耗费 0 秒

补全信息页面

... ... @@ -74,6 +74,22 @@ class ShareController extends WeChatBaseController
$this->assign('data',$data);
return $this->fetch();
}
public function information_save(){
$param = $this->request->param();
if(empty($param['name'])){
$this->error('姓名不能为空');
}
if(empty($param['phone'])){
$this->error('手机号不能为空');
}
$user_id = cmf_get_current_user_id();
$result = Db::name('my_user')->where('uid',$user_id)->insert($param);
if(empty($result)){
$this->error('保存失败');
}else{
$this->success('保存成功');
}
}
/**
* 分享链接
... ...
... ... @@ -42,7 +42,7 @@
手机号
</div>
<div class="log_two_input_contant">
<input type="text" placeholder="请输入手机号" value="{$data.phone}" maxlength="11" id="phone" onblur="checkPhone()" />
<input type="text" placeholder="请输入手机号" value="{$data.phone}" maxlength="11" id="phone" />
</div>
</div>
... ... @@ -50,24 +50,43 @@
<!-- 保存 -->
<div class="log_two_bottom_btn log_third_btn">
<a href="log_first.html">保存</a>
<a class="save">保存</a>
</div>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script>
function checkPhone() {
var name = $('#name').val();
if(name == ''){
alert("姓名不能为空");
return false
}
var phone = document.getElementById('phone').value;
if(!(/^1[34578]\d{9}$/.test(phone))) {
alert("手机号码有误,请重填");
return false;
}
}
$('.save').click(function(){
var name = $('#name').val();
if(name == ''){
alert("姓名不能为空");
return false
}
var phone = document.getElementById('phone').value;
if(!(/^1[34578]\d{9}$/.test(phone))) {
alert("手机号码有误,请重填");
return false;
}
$.ajax({
url:"{:url('information_save')}",
type:"GET",
data:{'name':name,'phone':phone},
success:function(res){
if(res.code == 1){
alert(res.msg);
window.location.href = "{:url('share/index')}";
}else{
alert(res.msg);
}
},
error:function(res){
alert('与服务器断开连接');
}
})
})
</script>
</body>
... ...