<?php
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$settings = $this->module['config'];
$op = $_GPC['op']?$_GPC['op']:'index';
 $aid =  $_GPC['aid'];
 if(!empty($aid)){
   $address =  pdo_get("evzg_express_member_address",array('id'=>$aid,'openid'=>$_W['openid']));
 }
if($op=='add'){
    $aid = $_GPC['aid'];
    $citys = explode(" ", $_GPC['city']);
    $province = $citys[0];
    $city = $citys[1];
    $community = $citys[2];
    $data = array();
    $data['openid'] = $_W['openid'];
    $data['uniacid'] = $_W['uniacid'];
    $data['name'] = $_GPC['name'];
    $data['mobile'] = $_GPC['mobile'];
    $data['address'] = $_GPC['address'];
    $data['province'] = $province;
    $data['city'] = $city;
    $data['community'] = $community;
    $data['address'] = $_GPC['address'];
    $data['defeult'] = 1;
    $data['createtime'] = time();
    pdo_update("evzg_express_member_address",array('defeult'=>0),array('openid'=>$_W['openid']));
    if(!empty($aid)){
       $result = pdo_update("evzg_express_member_address",$data,array('id'=>$aid));
    }else{
       $result =  pdo_insert("evzg_express_member_address",$data);
    }
    if($result){
        ijson(array('code'=>200,'msg'=>'成功'));
    }else{
        ijson(array('code'=>400,'msg'=>'失败'));
    }
}
$default='';
include $this->template($default.'addaddress');