lizhen_gitee преди 1 година
родител
ревизия
b258454d68
променени са 2 файла, в които са добавени 21 реда и са изтрити 10 реда
  1. 1 1
      application/api/controller/User.php
  2. 20 9
      application/api/controller/coach/User.php

+ 1 - 1
application/api/controller/User.php

@@ -191,7 +191,7 @@ class User extends Api
      */
     public function profile()
     {
-        $field_array = ['firstname','lastname','height','age','weight','address','avatar','notice_type'];
+        $field_array = ['firstname','lastname','height','age','weight','address','avatar','notice_type','lang','whatsapp'];
 
         $data = [];
         foreach($field_array as $key => $field){

+ 20 - 9
application/api/controller/coach/User.php

@@ -114,21 +114,32 @@ class User extends Apic
      */
     public function profile()
     {
-        //验证
-        if($this->auth->type != 1){
-            $this->error('只有门店老板才能设置');
-        }
         $field = [
             'mobile',
-            'image',
-            'is_open',
-            'open_hours',
+            'email',
+            'avatar',
+            'firstname',
+            'lastname',
+            'lang',
         ];
 
         $data = request_post_hub($field);
-        $data['updatetime'] = time();
 
-        $update_rs = Db::name('company')->where('id',$this->auth->company_id)->update($data);
+        if(isset($data['email'])){
+            $check_email = Db::name('coach')->where('email',$data['email'])->where('id','neq',$this->auth->id)->find();
+            if($check_email){
+                $this->error('邮箱已被其他人使用');
+            }
+        }
+
+        if(isset($data['mobile'])){
+            $check_mobile = Db::name('coach')->where('mobile',$data['mobile'])->where('id','neq',$this->auth->id)->find();
+            if($check_mobile){
+                $this->error('手机号已被其他人使用');
+            }
+        }
+
+        $update_rs = Db::name('coach')->where('id',$this->auth->id)->update($data);
 
         $this->success('资料更新完成');
     }