WIN-2308041133\Administrator před 1 dnem
rodič
revize
f7a19ffbc3

+ 8 - 9
app/api/controller/User.php

@@ -1479,12 +1479,13 @@ class User extends BaseController
         return app('json')->success("数据保存成功");
     }
 
-//  添加客户评论
+    //  添加客户评论
     public function comment(Request $request)
     {
         $post = UtilService::getMore([
             ['contract_id', '0'],  //合约id
             ['content', ''],  //评论内容
+            ['imgs', []],  //图片数组,新增
 //            ['uid',0]
         ], $request);
         $uid = UtilService::getMore([
@@ -1495,7 +1496,6 @@ class User extends BaseController
         }else{
             $uid = $uid['uid'];
         }
-//        $uid = $post['uid'];
         $time = time();
         $info = (new UserContractRecordModel)->where("id", $post["contract_id"])->find();
         if (!empty($info)) {
@@ -1506,18 +1506,16 @@ class User extends BaseController
         if ($info['status'] != 1) {
             return app('json')->fail("只有签约状态才能发表评论");
         }
-//        var_dump($time);
-//        var_dump($info);die();
         if ($info['start_time'] > $time || $info['end_time'] < $time) {
             return app('json')->fail("只能在签约期间才能发表评论");
+        }
 
+        // 处理图片数组,用逗号连接成字符串
+        $imgs_str = '';
+        if (!empty($post['imgs']) && is_array($post['imgs'])) {
+            $imgs_str = implode(',', $post['imgs']);
         }
-//        ->where('start_time','>',$time)->where('end_time','<',$time)
 
-        // 检查签约时间是否为空
-//        if (empty($post['id'])) {
-//            return app('json')->fail("签字错误");
-//        }
         $r = (new ContractCommentModel)->save([
             'uid' => $uid,
             'name' => $info['name'],
@@ -1526,6 +1524,7 @@ class User extends BaseController
             'to_uid' => $info['to_uid'],
             'to_name' => $info['to_name'],
             'content' => $post['content'],
+            'imgs' => $imgs_str,  //新增图片字段
             'create_time' => time()
         ]);
         return app('json')->success("数据保存成功");

+ 1 - 0
app/model/api/ContractComment.php

@@ -45,6 +45,7 @@ class ContractComment extends Model
                     $data[$k]["uid_avatar"] = (new User())->where("uid", $v["uid"])->value("avatar");
                     $data[$k]["to_uid_nickname"] = (new User())->where("uid", $v["to_uid"])->value("nickname");
                     $data[$k]["to_uid_avatar"] = (new User())->where("uid", $v["to_uid"])->value("avatar");
+                    $data[$k]["imgs"] = getImageAr($v["imgs"]); // 新增图片数组处理
                 }
             }
         }

+ 4 - 0
app/system/controller/Contract.php

@@ -353,6 +353,10 @@ class Contract extends BaseController
             ->order("id","desc")
             ->select()
             ->toArray();
+        // 处理图片数组
+        foreach ($data as $k => $v) {
+            $data[$k]['imgs'] = getImageAr($v['imgs']);
+        }
         $pageCount = $order->where($where)->count();
 
         $result = UtilService::getParam([