作者 anyv
1 个管道 的构建 通过 耗费 0 秒

5

... ... @@ -292,6 +292,53 @@ class OrderpageController extends WeChatBaseController{
$this->success('SUCCESS','',$data);
}
/**
* 新增地址页
*/
public function add_shop_address(){
if($this -> request -> isPost()){
$uid = cmf_get_current_user_id();
$_POST['uid'] = $uid;
$add = Db::name('address') -> insert($_POST);
if($add){
return true;
}else{
return false;
}
}else{
$indent_id = $this -> request -> param();
$this -> assign('indent_id',$indent_id['indet_id']);
return $this -> fetch();
}
}
/**
* 编辑地址
*/
public function address_edit(){
if($this -> request -> isPost()){
$data_update = Db::name('address') -> update($_POST);
if($data_update){
return true;
}else{
return false;
}
}else{
$id = $this -> request -> param();
$data = Db::name('address') -> where('id',$id['id']) -> find();
$detailed = explode(',',$data['detailed']);
$data['detailed0'] = $detailed[0];
$data['detailed1'] = $detailed[1];
$this -> assign('data',$data);
$this -> assign('indent_id',$id['indet_id']);
return $this -> fetch();
}
}
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>学考无忧-新增地址</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/mui.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/mui.picker.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
<style>
.mui-poppicker-header,
.mui-picker {
background-color: white;
}
</style>
</head>
<body>
<div class="add_addressBox">
<!-- 顶部 -->
<div class="ad_top" style="background-color:white;">
<a href="javascript:history.back(-1)">
<img class="ad_topImg" src="__TMPL__/public/assets/images/left.png" alt="">
</a>
<h1>收货地址</h1>
<p style="color:#FF7700;" onclick="add_save()">保存</p>
</div>
<!-- 内容 -->
<div class="add_con">
<ul>
<li>
<label for="">姓名</label>
<input type="text" placeholder="请输入姓名" id="name">
</li>
<li>
<label for="">手机号</label>
<input type="text" placeholder="请输入手机号" id="phone">
</li>
<li class="add_conThere">
<label for="">地区</label>
<div class="add_city" id="city_text" type="text" placeholder="">选择省市区</div>
<img src="__TMPL__/public/assets/images/29.png" alt="">
</li>
<li>
<label for="">详细地址</label>
<input type="text" placeholder="街道、小区、门牌号码" id="address_content">
</li>
</ul>
<div class="add_detailAddress">
<textarea placeholder="请输入详细地址,不少于15字" maxlength="200" id="address_content_con"></textarea>
</div>
</div>
</div>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/mui.min.js"></script>
<script src="__TMPL__/public/assets/js/mui.picker.min.js"></script>
<script src="__TMPL__/public/assets/js/city.data-3.js"></script>
<script>
/**
*保存
*/
function add_save(){
if($('#name').val() == ''){
alert('姓名不能为空');
}else if($('#phone').val() == ''){
alert('手机号不能为空');
}else if($('#city_text').text() == '选择省市区'){
alert('地区不能为空');
}else if($('#address_content').val() == ''){
alert('详细地址不能为空');
}else{
name = $('#name').val();
phone = $('#phone').val();
region = $('#city_text').text();
address_content = $('#address_content').val();
address_content_con = $('#address_content_con').val();
detailed = address_content+','+address_content_con;
$.post("{:url('Orderpage/add_shop_address')}",{name:name,phone:phone,region:region,detailed:detailed},function(data){
if(data){
window.location.href = "{:url('Orderpage/go_add_address',array('indet_id'=>$indent_id))}";
}else{
alert('保存失败!');
}
});
}
}
</script>
<script>
//mui 地址
var city_picker = new mui.PopPicker({
layer: 3
});
city_picker.setData(cityData3);
$("#city_text").on("tap", function() {
setTimeout(function() {
city_picker.show(function(items) {
$("#city_text").text((items[0] || {}).text + "," + (items[1] || {}).text + "," + (items[2] || {}).text); //该ID为接收城市ID字段
$('#city_text').css('color', 'black');
$("#city_text").html((items[0] || {}).text + " " + (items[1] || {}).text + " " + (items[2] || {}).text);
});
}, 200);
});
</script>
</body>
</html>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>学考无忧-地址编辑</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/mui.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/mui.picker.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
<style>
.mui-poppicker-header,
.mui-picker {
background-color: white;
}
</style>
</head>
<body>
<div class="add_addressBox">
<!-- 顶部 -->
<div class="ad_top" style="background-color:white;">
<a href="javascript:history.back(-1)">
<img class="ad_topImg" src="__TMPL__/public/assets/images/left.png" alt="">
</a>
<h1>收货地址编辑</h1>
<p style="color:#FF7700;" onclick="add_save()">保存</p>
</div>
<!-- 内容 -->
<div class="add_con">
<ul>
<li>
<label for="">姓名</label>
<input type="text" placeholder="请输入姓名" id="name" value="{$data.name}">
</li>
<li>
<label for="">手机号</label>
<input type="text" placeholder="请输入手机号" id="phone" value="{$data.phone}">
</li>
<li class="add_conThere">
<label for="">地区</label>
<div class="add_city" id="city_text" type="text" placeholder="">{$data.region}</div>
<img src="__TMPL__/public/assets/images/29.png" alt="">
</li>
<input type="hidden" name="id" value="{$data.id}" id="id">
<li>
<label for="">详细地址</label>
<input type="text" placeholder="街道、小区、门牌号码" id="address_content" value="{$data.detailed0}">
</li>
</ul>
<div class="add_detailAddress">
<textarea placeholder="请输入详细地址,不少于15字" maxlength="200" id="address_content_con">{$data.detailed1}</textarea>
</div>
</div>
</div>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/mui.min.js"></script>
<script src="__TMPL__/public/assets/js/mui.picker.min.js"></script>
<script src="__TMPL__/public/assets/js/city.data-3.js"></script>
<script>
/**
*保存
*/
function add_save(){
if($('#name').val() == ''){
alert('姓名不能为空');
}else if($('#phone').val() == ''){
alert('手机号不能为空');
}else if($('#city_text').text() == ''){
alert('地区不能为空');
}else if($('#address_content').val() == ''){
alert('详细地址不能为空');
}else{
id = $('#id').val();
name = $('#name').val();
phone = $('#phone').val();
region = $('#city_text').text();
address_content = $('#address_content').val();
address_content_con = $('#address_content_con').val();
detailed = address_content+','+address_content_con;
$.post("{:url('Orderpage/address_edit')}",{id:id,name:name,phone:phone,region:region,detailed:detailed},function(data){
if(data){
window.location.href = "{:url('Orderpage/go_add_address',array('indet_id'=>$indent_id))}";
}else{
alert('保存失败!');
}
});
}
}
</script>
<script>
//mui 地址
var city_picker = new mui.PopPicker({
layer: 3
});
city_picker.setData(cityData3);
$("#city_text").on("tap", function() {
setTimeout(function() {
city_picker.show(function(items) {
$("#city_text").text((items[0] || {}).text + "," + (items[1] || {}).text + "," + (items[2] || {}).text); //该ID为接收城市ID字段
$('#city_text').css('color', 'black');
$("#city_text").html((items[0] || {}).text + " " + (items[1] || {}).text + " " + (items[2] || {}).text);
});
}, 200);
});
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -23,7 +23,7 @@
<img class="ad_topImg" src="__TMPL__/public/assets/images/left.png" alt="">
</a>
<h1>收货地址</h1>
<a href="{:url('Personalcenter/add_shop_address')}">
<a href="{:url('Orderpage/add_shop_address',array('indet_id'=>$indent_id))}">
<p>新增地址</p>
</a>
</div>
... ... @@ -68,7 +68,7 @@
<p class="ad_conMo">默认</p>
</if>
<p class="ad_conPhone">{$vo.phone}</p>
<img class="ad_conImg" src="__TMPL__/public/assets/images/35.png" alt="">
<img class="ad_conImg" src="__TMPL__/public/assets/images/35.png" alt="" ontouchstart="address_edit({$vo.id})">
</div>
</div>
<p class="ad_conAddress">收货地址:{$vo.region}{$vo.detailed}</p>
... ... @@ -141,7 +141,7 @@
*编辑地址
*/
function address_edit(id){
window.location.href = "{:url('Personalcenter/address_edit')}?id="+id;
window.location.href = "{:url('Orderpage/address_edit',array('indet_id'=>$indent_id))}?id="+id;
}
</script>
</body>
... ...