dever il y a 4 ans
Parent
commit
67f239cc5b
6 fichiers modifiés avec 138 ajouts et 39 suppressions
  1. 37 12
      database/address.php
  2. 34 2
      database/user.php
  3. 55 0
      src/Address.php
  4. 10 25
      src/Api.php
  5. 1 0
      src/App.php
  6. 1 0
      src/Applet.php

+ 37 - 12
database/address.php

@@ -50,7 +50,7 @@ return array
 		(
 			'type' 		=> 'tinyint-1',
 			'name' 		=> '类型',
-			'default' 	=> '1',
+			'default' 	=> '2',
 			'desc' 		=> '类型',
 			'match' 	=> 'is_numeric',
 			'option' 	=> $type,
@@ -58,6 +58,30 @@ return array
 			//'list'		=> true,
 		),
 
+		'contact'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '联系人',
+			'default' 	=> '',
+			'desc' 		=> '联系人',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'mobile'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '联系电话',
+			'default' 	=> '',
+			'desc' 		=> '联系电话',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
         'country'		=> array
 		(
 			'type' 		=> 'varchar-100',
@@ -70,7 +94,7 @@ return array
 
 		'province'		=> array
 		(
-			'type' 		=> 'varchar-100',
+			'type' 		=> 'int-11',
 			'name' 		=> '省份',
 			'default' 	=> '',
 			'desc' 		=> '省份',
@@ -80,7 +104,7 @@ return array
 
 		'city'		=> array
 		(
-			'type' 		=> 'varchar-100',
+			'type' 		=> 'int-11',
 			'name' 		=> '城市',
 			'default' 	=> '',
 			'desc' 		=> '城市',
@@ -88,26 +112,27 @@ return array
 			//'update'	=> 'text',
 		),
 
-		'area'		=> array
+		'county'		=> array
 		(
-			'type' 		=> 'varchar-800',
-			'name' 		=> '区',
+			'type' 		=> 'int-11',
+			'name' 		=> '区',
 			'default' 	=> '',
-			'desc' 		=> '区',
+			'desc' 		=> '区',
 			'match' 	=> 'option',
 			//'update'	=> 'text',
-			//'list'		=> true,
 		),
 
-		'area_id'		=> array
+		'area'		=> array
 		(
 			'type' 		=> 'varchar-800',
 			'name' 		=> '地区',
 			'default' 	=> '',
 			'desc' 		=> '地区',
-			'match' 	=> 'option',
-			//'update'	=> 'text',
-			//'list'		=> true,
+			'match' 	=> 'is_string',
+			'search'	=> 'linkage',
+			'update'	=> 'linkage',
+			'option'	=> Dever::url('api.get', 'area'),
+			'list'		=> 'Dever::load("area/api.string", "{area_id}")',
 		),
 
 		'address'		=> array

+ 34 - 2
database/user.php

@@ -275,6 +275,28 @@ return array
 			'list'		=> 'Dever::load("passport/lib/manage.show", {id})',
 		),
 
+		'address_contact'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '联系人',
+			'default' 	=> '',
+			'desc' 		=> '联系人',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'address_mobile'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '联系电话',
+			'default' 	=> '',
+			'desc' 		=> '联系电话',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			//'list'		=> true,
+		),
+
 		'country'		=> array
 		(
 			'type' 		=> 'varchar-100',
@@ -305,6 +327,16 @@ return array
 			//'update'	=> 'text',
 		),
 
+		'county'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '区县-来自微信',
+			'default' 	=> '',
+			'desc' 		=> '区县',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
 		'area'		=> array
 		(
 			'type' 		=> 'varchar-800',
@@ -332,11 +364,11 @@ return array
 		'address'		=> array
 		(
 			'type' 		=> 'varchar-1000',
-			'name' 		=> '详细地址',
+			'name' 		=> '详细地址-不带省市区的地址',
 			'default' 	=> '',
 			'desc' 		=> '详细地址',
 			'match' 	=> 'option',
-			//'update'	=> 'text',
+			'update'	=> 'text',
 			//'list'		=> true,
 		),
 		

+ 55 - 0
src/Address.php

@@ -0,0 +1,55 @@
+<?php
+namespace Passport\Src;
+
+use Dever;
+use Passport\Lib\Base;
+
+class Address
+{
+    # 获取默认地址
+    public function getDefaultAddress($uid)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = 2;
+        $data = Dever::db('passport/address')->one($where);
+
+        return $data;
+    }
+
+    # 获取地址列表
+    public function getAddress($uid)
+    {
+        $where['uid'] = $uid;
+        $data = Dever::db('passport/address')->getList($where);
+
+        return $data;
+    }
+
+    # 添加或者更新地址
+    public function upAddress($id, $uid, $type = 2, $province = '', $city = '', $county = '', $address = '', $country = '')
+    {
+    	if ($country) {
+    		$update['country'] = $country;
+    	}
+        
+        if ($province && $city && $county && $address) {
+        	$update['province'] = $province;
+	        $update['city'] = $city;
+	        $update['county'] = $county;
+	        $update['area'] = $province . ',' . $city . ',' . $county;
+	        $update['address'] = $address;
+        }
+
+        $update['type'] = $type;
+        
+        if ($id) {
+            $update['where_id'] = $id;
+            Dever::db('passport/address')->update($update);
+        } else {
+            $update['uid'] = $uid;
+            $id = Dever::db('passport/address')->insert($update);
+        }
+
+        return $id;
+    }
+}

+ 10 - 25
src/Api.php

@@ -36,31 +36,16 @@ class Api
         $base->combine(3, 321313);
     }
 
-    # 获取地址列表
-    public function getAddress($uid)
+    # 更新用户表的地址
+    public function upAddress($uid, $address_contact, $address_mobile, $area_id = '', $address = '')
     {
-        $where['uid'] = $uid;
-        $data = Dever::db('passport/address')->getList($where);
-
-        return $data;
-    }
-
-    # 添加或者更新地址
-    public function upAddress($id, $uid, $country, $province, $city, $area, $address)
-    {
-        $update['country'] = $country;
-        $update['province'] = $province;
-        $update['city'] = $city;
-        $update['area'] = $area;
-        $update['area'] = $address;
-        if ($id) {
-            $update['where_id'] = $id;
-            Dever::db('passport/address')->update($update);
-        } else {
-            $update['uid'] = $uid;
-            $id = Dever::db('passport/address')->insert($update);
-        }
-
-        return $id;
+        $update['where_id'] = $uid;
+        $update['address_contact'] = $address_contact;
+        $update['address_mobile'] = $address_mobile;
+        $update['area_id'] = $area_id;
+        $update['address'] = $address;
+        Dever::db('passport/user')->update($update);
+
+        return 'ok';
     }
 }

+ 1 - 0
src/App.php

@@ -84,6 +84,7 @@ class App extends Base
         $user['city'] = Dever::input('city');
         $user['province'] = Dever::input('province');
         $user['country'] = Dever::input('country');
+        $user['county'] = Dever::input('county');
         
 
         $data = array();

+ 1 - 0
src/Applet.php

@@ -63,6 +63,7 @@ class Applet extends Base
         //$data['mobile'] = Dever::input('mobile');
         $data['province'] = Dever::input('province');
         $data['country'] = Dever::input('country');
+        $user['county'] = Dever::input('county');
 
         $result = $this->create($data);