diff --git a/service/Application/Common/Lang/zh-cn.php b/service/Application/Common/Lang/zh-cn.php index 4f8056042..2e9667f2f 100755 --- a/service/Application/Common/Lang/zh-cn.php +++ b/service/Application/Common/Lang/zh-cn.php @@ -310,6 +310,7 @@ return array( 'common_linkage_province_format' => '请选择省份', 'common_linkage_city_format' => '请选择城市', 'common_linkage_county_format' => '请选择区/县', + 'common_avatar_upload_title' => '头像上传', // 性别 'common_gender_list' => array( diff --git a/service/Application/Home/Controller/CommonController.class.php b/service/Application/Home/Controller/CommonController.class.php index c063ee60a..e7da16d88 100755 --- a/service/Application/Home/Controller/CommonController.class.php +++ b/service/Application/Home/Controller/CommonController.class.php @@ -303,52 +303,5 @@ class CommonController extends Controller $verify->Entry(); } - /** - * [UserLoginRecord 用户登录记录] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2017-03-09T11:37:43+0800 - * @param [int] $user_id [用户id] - * @return [boolean] [记录成功true, 失败false] - */ - protected function UserLoginRecord($user_id = 0) - { - if(!empty($user_id)) - { - $user = M('User')->field('*')->find($user_id); - if(!empty($user)) - { - // 基础数据处理 - $user['add_time_text'] = date('Y-m-d H:i:s', $user['add_time']); - $user['upd_time_text'] = date('Y-m-d H:i:s', $user['upd_time']); - $user['gender_text'] = L('common_gender_list')[$user['gender']]['name']; - $user['birthday_text'] = empty($user['birthday']) ? '' : date('Y-m-d', $user['birthday']); - $user['mobile_security']= empty($user['mobile']) ? '' : substr($user['mobile'], 0, 3).'***'.substr($user['mobile'], -3); - $user['email_security'] = empty($user['email']) ? '' : substr($user['email'], 0, 3).'***'.substr($user['email'], -3); - - // 显示名称,根据规则优先展示 - $user['user_name_view'] = $user['username']; - if(empty($user['user_name_view'])) - { - $user['user_name_view'] = $user['nickname']; - } - if(empty($user['user_name_view'])) - { - $user['user_name_view'] = $user['mobile_security']; - } - if(empty($user['user_name_view'])) - { - $user['user_name_view'] = $user['email_security']; - } - - // 存储session - $_SESSION['user'] = $user; - return !empty($_SESSION['user']); - } - } - return false; - } - } ?> \ No newline at end of file diff --git a/service/Application/Home/Controller/PersonalController.class.php b/service/Application/Home/Controller/PersonalController.class.php index 2cd69cd44..848f0b9ef 100755 --- a/service/Application/Home/Controller/PersonalController.class.php +++ b/service/Application/Home/Controller/PersonalController.class.php @@ -2,6 +2,8 @@ namespace Home\Controller; +use Service\UserService; + /** * 个人资料 * @author Devil @@ -90,7 +92,7 @@ class PersonalController extends CommonController if($m->where(array('id'=>$this->user['id']))->save()) { // 更新用户session数据 - $this->UserLoginRecord($this->user['id']); + UserService::UserLoginRecord($this->user['id']); $this->ajaxReturn(L('common_operation_edit_success')); } else { diff --git a/service/Application/Home/Controller/SafetyController.class.php b/service/Application/Home/Controller/SafetyController.class.php index 8bf05934b..1ba5bb408 100755 --- a/service/Application/Home/Controller/SafetyController.class.php +++ b/service/Application/Home/Controller/SafetyController.class.php @@ -2,6 +2,8 @@ namespace Home\Controller; +use Service\UserService; + /** * 安全 * @author Devil @@ -395,7 +397,7 @@ class SafetyController extends CommonController if(M('User')->where(array('id'=>$this->user['id']))->save($data) !== false) { // 更新用户session数据 - $this->UserLoginRecord($this->user['id']); + UserService::UserLoginRecord($this->user['id']); // 校验成功标记 unset($_SESSION['safety_'.$type]); diff --git a/service/Application/Home/Controller/UserController.class.php b/service/Application/Home/Controller/UserController.class.php index 99e3e9f51..ae81fb9b4 100755 --- a/service/Application/Home/Controller/UserController.class.php +++ b/service/Application/Home/Controller/UserController.class.php @@ -4,6 +4,7 @@ namespace Home\Controller; use Service\OrderService; use Service\GoodsService; +use Service\UserService; /** * 用户 @@ -297,7 +298,7 @@ class UserController extends CommonController // 清除验证码 $obj->Remove(); - if($this->UserLoginRecord($user_id)) + if(UserService::UserLoginRecord($user_id)) { $this->ajaxReturn(L('common_reg_success')); } @@ -374,7 +375,7 @@ class UserController extends CommonController if(M('User')->where(array('id'=>$user['id']))->save($data) !== false) { // 登录记录 - if($this->UserLoginRecord($user['id'])) + if(UserService::UserLoginRecord($user['id'])) { $this->ajaxReturn(L('common_login_success')); } @@ -707,5 +708,17 @@ class UserController extends CommonController } redirect(__MY_URL__); } + + public function UserAvatarUpload() + { + // 登录校验 + $this->Is_Login(); + + $params = $_POST; + $params['user'] = $this->user; + $params['img_field'] = 'file'; + $ret = UserService::UserAvatarUpload($params); + $this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']); + } } ?> \ No newline at end of file diff --git a/service/Application/Home/Lang/zh-cn/personal.php b/service/Application/Home/Lang/zh-cn/personal.php index d4d3dc2e8..51d2a822b 100755 --- a/service/Application/Home/Lang/zh-cn/personal.php +++ b/service/Application/Home/Lang/zh-cn/personal.php @@ -16,6 +16,7 @@ return array( // 个人资料展示列表 'personal_show_list' => array( + 'avatar' => array('name' => '头像', 'tips' => '修改'), 'nickname' => array('name' => '昵称'), 'gender_text' => array('name' => '性别'), 'birthday_text' => array('name' => '生日'), diff --git a/service/Application/Home/View/Default/Personal/Index.html b/service/Application/Home/View/Default/Personal/Index.html index 5e85e97c1..d31d61528 100755 --- a/service/Application/Home/View/Default/Personal/Index.html +++ b/service/Application/Home/View/Default/Personal/Index.html @@ -33,7 +33,9 @@