updateType(array('where_type' => 2, 'set_type' => 1)); } $update['type'] = $type; Dever::db('user/address')->update($update); } } public function getInfo($data) { $data['area_string'] = Dever::load('area/api')->string($data['area']); $data['province_name'] = $data['city_name'] = $data['county_name'] = $data['town_name'] = ''; if ($data['town'] && $data['town'] > 0) { $info = Dever::db('area/town')->find($data['town']); if ($info) { $data['town_name'] = $info['name']; } } if ($data['county']) { $info = Dever::db('area/county')->find($data['county']); if ($info) { $data['county_name'] = $info['name']; } } if ($data['city']) { $info = Dever::db('area/city')->find($data['city']); if ($info) { $data['city_name'] = $info['name']; } } if ($data['province']) { $info = Dever::db('area/province')->find($data['province']); if ($info) { $data['province_name'] = $info['name']; } } return $data; } # 添加或者更新地址 public function update($id, $uid, $type = 2, $mobile, $contact, $province = '', $city = '', $county = '', $town = '', $address = '', $country = '', $tag = '') { if ($contact) { $update['contact'] = $contact; } if ($mobile) { $update['mobile'] = $mobile; } else { Dever::alert('请输入手机号'); } if ($province) { $update['province'] = $province; } else { Dever::alert('请选择省份'); } if ($city) { $update['city'] = $city; } else { Dever::alert('请选择城市'); } if ($county) { $update['county'] = $county; } else { Dever::alert('请选择区域'); } if ($town) { $update['town'] = $town; } if ($province && $city && $county) { $update['area'] = $province . ',' . $city . ',' . $county; } if ($town) { $update['area'] .= ',' . $town; } $update['type'] = $type; if ($address) { $update['address'] = $address; } if ($tag) { $update['tag'] = $tag; } if ($type == 2) { Dever::db('user/address')->updateType(array('where_type' => 2, 'set_type' => 1)); } if ($id) { $update['where_id'] = $id; Dever::db('user/address')->update($update); } else { $update['uid'] = $uid; $id = Dever::db('user/address')->insert($update); } return $id; } }