Jonlin 6 rokov pred
rodič
commit
0970d609f9

+ 4 - 4
application/index/controller/User.php

@@ -87,7 +87,7 @@ class User extends Controller
             $qq = input("param.qq/s");
             $wechat = input("param.wechat/s");
 
-            $file = input("param.file/s");
+            $images = input("param.file/s");
 
             if(empty($name)){
                 return json(['code' => -1, 'data' => '', 'msg' => '用户名称不能为空']);
@@ -113,7 +113,7 @@ class User extends Controller
                 return json(['code' => -6, 'data' => '', 'msg' => '电话不能为空']);
             }
 
-            if(empty($file)){
+            if(empty($images)){
                 return json(['code' => -7, 'data' => '', 'msg' => '附件不能为空']);
             }
 
@@ -121,7 +121,7 @@ class User extends Controller
                 'name' => $name,
                 'email' => $email,
                 'content' => $content,
-                'image' => $file,
+                'image' => $images,
                 'phone' => $phone,
                 'qq' => $qq,
                 'wechat' => $wechat,
@@ -140,7 +140,7 @@ class User extends Controller
 
     }
 
-    // 用户留言
+    // 上传图片
     public function uplodeImg()
     {
         if(request()->isPost()){

+ 53 - 4
application/service/controller/Services.php

@@ -3,6 +3,7 @@ namespace app\service\controller;
 
 class Services extends Base
 {
+    //客服信息
     public function index()
     {
         $token = input("param.token/s");
@@ -14,11 +15,59 @@ class Services extends Base
         //客服信息
         $service = db('users')->where('id',$user_id )->select();
         //print_r($service);exit;
-        $this->assign([
-            'service' => $service,
-        ]);
+        return $service;
+    }
+
+    //用户信息
+    public function account()
+    {
+        if(request()->isPost()) {
+            $account_id = input("param.account_id/s");
+            //客服信息
+            $account = db('accounts')->where('id', $account_id)->select();
+
+            return $account;
+        }
+    }
+
+    //修改/新增用户信息
+    public function update()
+    {
+        if(request()->isPost()) {
+            $account_id = input("param.account_id/s");
+            $account_name = input("param.account_name/s");
+            $account_email = input("param.account_email/s");
+            $phone = input("param.phone/s");
+            $address = input("param.address/s");
+            $label = input("param.label/s");
+            $remark = input("param.remark/s");
 
-        return $this->fetch();
+
+            $param = [
+                'account_name' => $account_name,
+                'account_email' => $account_email,
+                'phone' => $phone,
+                'address' => $address,
+                'label' => $label,
+                'remark' => $remark
+            ];
+
+            $account = db('accounts')->where('id', $account_id)->select();
+            if(!empty($account)){
+                try{
+                    db('accounts')->where('id', $account_id)->update($param);
+                }catch(\Exception $e){
+                    return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
+                }
+            }else{
+                try{
+                    db('accounts')->insertGetId($param);
+                }catch(\Exception $e){
+                    return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
+                }
+            }
+            return json(['code' => 1, 'data' => '', 'msg' => '保存成功']);
+        }
     }
 
     // 客服信息修改