-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfirmController.class.php
73 lines (67 loc) · 1.57 KB
/
ConfirmController.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace Home\Controller;
use Think\Controller;
class ConfirmController extends Controller {
public function confirm(){
if(checkSession()==false){
redirect("../Login/login", 0.1, ' ');
}else{
$address=$this->assemblyAddress();
//输出地址
$this->assign('address',$address);
//找默认地址
foreach ($address as $k => $v) {
if($v['ad_default']=='1'){
$def=$v;
}
}
$this->assign('def',$def);
if (IS_POST) {
$json = $_POST['shopcart'];
$c = json_decode($json, true);
$this->assign('json',$json);
$s = A('Shopcart');
$good=$s->getCheckedGoods($c);
$this->assign('good',$good);
}
$this->display('/Common/header');
$this->display();
$this->display('/Common/footer');
}
}
/*
组装地址数组
*/
public function assemblyAddress(){
$Member=A('Member');
$data=$Member->getThreeAddress();
//默认地址
$address=array();
//最新加入的三个地址
$address[]=$Member->getDefAddress();
foreach ($data as $k => $v) {
if($v['ad_default']!=='1'){
$address[]=$v;
}
}
return $address;
}
/*
找需要编辑的地址
*/
public function pendingEditingAddress(){
if(IS_POST){
$address_id=I('address_id');
$address=$this->assemblyAddress();
$editing=array();
foreach ($address as $k => $v) {
// print_r($v['address_id']);
if($v['address_id']==$address_id){
$editing[]=$v;
}
}
echo json_encode($editing[0]);
// print_r($editing[0]);
}
}
}