dever 2 years ago
parent
commit
1a0be656ed
2 changed files with 18 additions and 1 deletions
  1. 5 0
      database/address.php
  2. 13 1
      lib/Manage.php

+ 5 - 0
database/address.php

@@ -22,6 +22,11 @@ return array
     'name' => 'address',
     # 显示给用户看的名称
     'lang' => '用户地址库',
+    'end' => array
+	(
+		'insert' => 'lib/manage.updateAddress',
+		'update' => 'lib/manage.updateAddress',
+	),
     'menu' => false,
     # 数据结构
     'struct' => array

+ 13 - 1
lib/Manage.php

@@ -5,7 +5,19 @@ use Dever;
 
 class Manage
 {
-    # 更新地区
+    public function updateAddress($id, $name, $param)
+    {
+        $area = Dever::param('area', $param);
+        if ($area) {
+            $temp = explode(',', $area);
+            $update['where_id'] = $id;
+            $update['province'] = $temp[0];
+            $update['city'] = $temp[1];
+            $update['county'] = isset($temp[2]) ? $temp[2] : '';
+            $update['town'] = isset($temp[3]) ? $temp[3] : '';
+            Dever::db('passport/address')->update($update);
+        }
+    }
     
 	# 同步将其他地方的分类更新为system
     public function updateSystem($id, $name, $param)