yzx 5 ay önce
ebeveyn
işleme
ba685ebe4d

+ 133 - 321
app/mobile/controller/Temporary.php

@@ -49,10 +49,66 @@ class Temporary extends BaseController
         // }
     }
 
-    public function getOpenId() {
-        $redirect_uri = "http://testwxpress.ngrok.natapp.cn/index.php/Home/Index/getCode";
-        $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . C('WECHAT_APPID') . '&redirect_uri=' . urlencode($redirect_uri) . '&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect';
-        header("Location:" . $url);
+
+    public function kan_list()
+    {
+        //根据所登录的账号,查询跟本身有关的项目
+        $param = get_params();
+
+        $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
+
+        $order = empty($param['order']) ? 'id desc' : $param['order'];
+
+        if (isset($param["project_start_time"])) {
+            $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
+        }
+
+        if (isset($param["project_end_time"])) {
+            $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
+        }
+
+        $where3 = [];//搜索条件
+        if (!empty($param['project_status'])) {
+            $where3[] = ['project_status', '=', $param['project_status']];
+        }
+        if (!empty($param['province'])) {
+            $where3[] = ['province', '=', $param['province']];
+        }
+        if (!empty($param['city'])) {
+            $where3[] = ['city', '=', $param['city']];
+        }
+        if (!empty($param['area'])) {
+            $where3[] = ['area', '=', $param['area']];
+        }
+        if (!empty($param['project_end_time'])) {
+            $where3[] = ['project_end_time', '<', $param['project_end_time']];
+        }
+        if (!empty($param['project_start_time'])) {
+            $where3[] = ['project_start_time', '>', $param['project_start_time']];
+        }
+        if (!empty($param['keyword'])) {
+            $keyword = $param['keyword'];
+            $where3[] = ['project_num|project_name|review_unit', 'like', '%' . $keyword . '%'];
+        }
+        if (!empty($param['review_unit_name'])) {
+            $where3[] = ['review_unit_name', 'like', '%' . $param['review_unit_name'] . '%'];
+        }
+        if (!empty($param['sent_review_unit_name'])) {
+            $where3[] = ['sent_review_unit_name', 'like', '%' . $param['sent_review_unit_name'] . '%'];
+        }
+        if (!empty($param['entrust_unit_name'])) {
+            $where3[] = ['entrust_unit_name', 'like', '%' . $param['entrust_unit_name'] . '%'];
+        }
+
+        $res = Db::name('follow_project')->where('openid',$param['openid'])->value('project_id');
+        $list = $this->model->where($where3)->where('id','in',$res)
+            ->order("create_time desc")->paginate(9999, false, ['query' => $param])
+            ->each(function ($item) {})->toArray();
+        halt($list);
+        $data = $list["data"];
+        // halt($real_list);
+        View::assign("detail", $data);
+        return view();
     }
 
     /**
@@ -127,20 +183,6 @@ class Temporary extends BaseController
             ->order($order)
             ->select();
 
-        //2是公司,0是财政局,1是业主
-        $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
-        if ($unit_type == 0) {
-            $person = self::user($id);
-            View::assign('project_five', self::getProjectFive());
-        } elseif ($unit_type == 2) {
-            $person = self::user($id);
-            View::assign('project_five', self::getProjectFiveCompany());
-        } else {
-            $person = 0;
-            View::assign('project_five', self::getProjectFiveYezhu());
-        }
-
-
         $appropriation_uid = Db::name("appropriation_project")->where("project_id", $id)->value("uid");
         if (empty($appropriation_uid)) {
             $appropriation_data = [];
@@ -185,8 +227,6 @@ class Temporary extends BaseController
         }
 
 
-        $project_log = self::project_log($id);
-
         $red = Db::name("new_msg")->where([["uid", '=', $this->uid], ["project_id", "=", $id]])->field('detail,comment,report,user,contact')->find();
         if (empty($red)) {
             $red = ["detail" => 0, "comment" => 0, "report" => 0, "user" => 0, "contact" => 0];
@@ -220,7 +260,6 @@ class Temporary extends BaseController
 
         if (!empty($detail)) {
             View::assign('appointmentList', $appointmentList);
-            View::assign('project_log', $project_log);
             View::assign('project_id', $id);
             View::assign('comment', $comment);
             View::assign('record', $record);
@@ -230,9 +269,7 @@ class Temporary extends BaseController
             View::assign('file_array', $file_array);
             View::assign('appropriation_file_array', $appropriation_file_array);
             View::assign('report', $report);
-            View::assign('person', $person);
             View::assign('red', $red);
-            View::assign('unit_type', $unit_type);
 
             return view();
         } else {
@@ -241,6 +278,79 @@ class Temporary extends BaseController
 
     }
 
+    public function followProject()
+    {
+        if (request()->isAjax()) {
+
+            $param = request()->param();
+            // halt($param);
+            if(!isset($param['id'])|| !isset($param['openid']) ){
+                return to_assign(1, '参数错误请重试');
+            }
+
+            $res = Db::name('follow_project')->where('project_id',$param['id'])->where('openid',$param['openid'])->find();
+            if($res == null){
+                $isTrue =Db::name('follow_project')->insert(['project_id'=>$param['id'] , 'openid'=>$param['openid']]);
+                if($isTrue){
+                    return to_assign(0, '关注成功!!');
+                }else{
+                    return to_assign(1, '失败请重试!!');
+                }
+
+            }else{
+                return to_assign(1, '已经关注过项目');
+            }
+        }
+
+    }
+
+    public function notFollowProject()
+    {
+        if (request()->isAjax()) {
+
+            $param = request()->param();
+            // halt($param);
+            if(!isset($param['id'])|| !isset($param['openid']) ){
+                return to_assign(1, '参数错误请重试');
+            }
+
+            $res = Db::name('follow_project')->where('project_id',$param['id'])->where('openid',$param['openid'])->find();
+            if($res !== null){
+                $isTrue =Db::name('follow_project')->where('project_id',$param['id'])->where('openid',$param['openid'])->delete();
+                if($isTrue){
+                    return to_assign(0, '取消关注成功!!');
+                }else{
+                    return to_assign(1, '取消关注失败请重试!!');
+                }
+
+            }else{
+                return to_assign(1, '还未关注项目!');
+            }
+        }
+
+    }
+
+
+    public function findFollowProject()
+    {
+        if (request()->isAjax()) {
+
+            $param = request()->param();
+            // halt($param);
+            if(!isset($param['id'])|| !isset($param['openid']) ){
+                return to_assign(1, '参数错误请重试');
+            }
+
+            $res = Db::name('follow_project')->where('project_id',$param['id'])->where('openid',$param['openid'])->find();
+            if($res !== null){
+                return to_assign(0, '已经关注!');
+            }else{
+                return to_assign(1, '还未关注项目!');
+            }
+        }
+
+    }
+
     /**
      * cp代办内容
      */
@@ -317,10 +427,8 @@ class Temporary extends BaseController
         }
         View::assign('field', $fields);
 
-        $project_log = self::project_log($id);
         // halt($detail);
         if (!empty($detail)) {
-            View::assign('project_log', $project_log);
             View::assign('project_id', $id);
             View::assign('comment', $comment);
             View::assign('record', $record);
@@ -328,7 +436,6 @@ class Temporary extends BaseController
             View::assign('detail', $detail);
             View::assign('file_array', $file_array);
             View::assign('report', $report);
-            View::assign('person', $person);
             return view();
         } else {
             echo '<div style="text-align:center;color:red;margin-top:20%;font-size:425%"><span>项目不存在!</span><br><span>已被删除</span></div>';
@@ -410,41 +517,7 @@ class Temporary extends BaseController
 
     }
 
-    /**
-     *项目日志
-     */
-    public function project_log($project_id)
-    {
-        // $project_id = 24;
-        $login_admin = get_login_admin();
 
-        $where = array();
-
-        if ($login_admin['user_type'] == 2) {
-            $where = [
-                ['project_status', '>=', 3],
-                ['unit_name', '=', $login_admin['unit_name']],
-            ];
-        } else {
-
-            if ($login_admin['permission'] != 1) {
-                $where = [
-                    ['unit_name', '=', $login_admin['unit_name']],
-                ];
-            }
-
-        }
-        // dump($where);
-        $project_log = Db::name('ProjectLog')->where($where)->where('project_id', $project_id)->order('create_time', 'desc')->select()->toArray();
-
-        foreach ($project_log as $key => $value) {
-            $project_log[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
-        }
-        // dump($project_log);
-        // View::assign('project_log', $project_log);
-        // return View();
-        return $project_log;
-    }
 
 
     /**
@@ -661,30 +734,6 @@ class Temporary extends BaseController
 
     }
 
-    /**
-     * 添加工作记录
-     */
-    public function record_add()
-    {
-        $param = get_params();
-        $id = isset($param['id']) ? $param['id'] : 0;//记录id
-        $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
-        $project = Db::name("cost_project")->where("id", $project_id)->value("project_name");
-        View::assign('id', $id);
-        View::assign('user_type', $this->user_tpe);
-        View::assign('project_id', $project_id);
-        View::assign('project', $project);
-        return view();
-    }
-    public function appointment_add()
-    {
-
-        $param = get_params();
-        $project_id = isset($param['project_id']) ? $param['project_id'] : 0;
-        View::assign('user_type', $this->user_tpe);
-        View::assign('project_id', $project_id);
-        return view();
-    }
 
     /**
      * 邀请函
@@ -1123,243 +1172,6 @@ class Temporary extends BaseController
         return view();
     }
 
-    public function kan_list()
-    {
-        //根据所登录的账号,查询跟本身有关的项目
-        //2是公司,0是财政局,1是业主
-        $param = get_params();
-
-        $rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
-        $order = empty($param['order']) ? 'id desc' : $param['order'];
-        if (isset($param["project_start_time"])) {
-            $param["project_start_time"] = $param["project_start_time"] ? strtotime($param["project_start_time"]) : 0;
-        }
-        if (isset($param["project_end_time"])) {
-            $param["project_end_time"] = $param["project_end_time"] ? strtotime($param["project_end_time"]) : 0;
-        }
-        $where3 = [];//搜索条件
-        if (!empty($param['project_status'])) {
-            $where3[] = ['project_status', '=', $param['project_status']];
-        }
-        if (!empty($param['province'])) {
-            $where3[] = ['province', '=', $param['province']];
-        }
-        if (!empty($param['city'])) {
-            $where3[] = ['city', '=', $param['city']];
-        }
-        if (!empty($param['area'])) {
-            $where3[] = ['area', '=', $param['area']];
-        }
-        if (!empty($param['project_end_time'])) {
-            $where3[] = ['project_end_time', '<', $param['project_end_time']];
-        }
-        if (!empty($param['project_start_time'])) {
-            $where3[] = ['project_start_time', '>', $param['project_start_time']];
-        }
-        if (!empty($param['keyword'])) {
-            $keyword = $param['keyword'];
-            $where3[] = ['project_num|project_name|review_unit', 'like', '%' . $keyword . '%'];
-        }
-        if (!empty($param['review_unit_name'])) {
-            $where3[] = ['review_unit_name', 'like', '%' . $param['review_unit_name'] . '%'];
-        }
-        if (!empty($param['sent_review_unit_name'])) {
-            $where3[] = ['sent_review_unit_name', 'like', '%' . $param['sent_review_unit_name'] . '%'];
-        }
-        if (!empty($param['entrust_unit_name'])) {
-            $where3[] = ['entrust_unit_name', 'like', '%' . $param['entrust_unit_name'] . '%'];
-        }
-
-        $unit_type = Db::name("department")->where("id", get_login_admin("unit_name"))->value("type");
-        $inarr = array();
-
-        if ($unit_type == 0) {
-            $where[] = ["delete_time", "=", 0];
-            $where[] = ["project_status", ">", 0];
-            $where[] = ["entrust_unit", "=", get_login_admin('unit_name')];
-            $where2[] = ["delete_time", "=", 0];
-            $where2[] = ["project_status", ">", 0];
-            $where2[] = ["entrust_unit", "=", get_login_admin('unit_name')];
-            //项目可见的权限
-            $field = $this->Field->get_field_rules_new($this->uid);
-            //1全部-可查看可编辑,2全部-可查看,0与我有关
-            $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
-            if ($see_auth == 3) {
-                $where[] = ["entrust_maker", "=", $this->uid];
-
-                $where2[] = ["entrust_approver", "=", $this->uid];
-                $where2[] = ["project_status", ">", 1];
-
-            } elseif ($see_auth == 0) {
-                $where[] = ["entrust_maker", "=", $this->uid];
-                $where[] = ["project_status", ">", 0];
-                $where2[] = ["entrust_approver", "=", $this->uid];
-                $where2[] = ["project_status", ">", 1];
-            }
-            $list = $this->model->where($where3)
-                ->where(function ($query) use ($where,$where2) {
-                    // 第一组条件(entrust_maker)
-                    $query->where(function ($q1) use ($where) {
-                        $q1->where($where);
-                    });
-                    // 使用 OR 连接第二组条件(entrust_approver)
-                    $query->whereOr(function ($q2) use ($where2) {
-                        $q2->where($where2);
-                    });
-                })
-                ->order("create_time desc")->paginate(9999, false, ['query' => $param])
-                ->each(function ($item) {
-                    $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
-                    if ($red) {
-                        if ($red["detail"] || $red["comment"] || $red["report"] || $red["user"] || $red["contact"]) {
-                            $item->red = 1;
-                        } else {
-
-                            $item->red = 0;
-                        }
-                    } else {
-                        $item->red = 0;
-                    }
-                    if (($item->province && $item->city && $item->area)) {
-                        $item->project_region = $item->province . '-' . $item->city . '-' . $item->area;
-                    }
-
-                })->toArray();
-        } elseif ($unit_type == 2) {
-            $order = empty($param['order']) ? 'project_receive_time desc,id desc' : $param['order'];
-
-            $where = [
-                ["delete_time", "=", 0],
-                ["project_status", ">", 3],
-                ["review_unit", "=", get_login_admin("unit_name")]
-            ];
-            $review_unit = $this->model->where($where)->where($where3)->field('id,review_head,operate_head,operate_team')->select()->toArray();
-            for ($i = 0; $i < count($review_unit); $i++) {
-                $a = $review_unit[$i];
-                $ids = $a["review_head"] . ',' . $a["operate_head"] . ',' . $a["operate_team"];
-                $ids = explode(",", $ids);
-                $c = in_array($this->uid, $ids);
-                if ($c) {
-                    $inarr[] = $a["id"];
-                }
-            }
-
-
-            $field = $this->Field->get_field_rules_New($this->uid);
-            $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
-            $this->see_auth = $see_auth;
-            if ($see_auth == 3) {
-
-                $list = $this->model
-                    ->where($where)->where($where3)->whereIn("id", $inarr)
-                    ->order($order)->paginate(9999, false, ['query' => $param])
-                    ->each(function ($item) {
-
-                        $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
-                        if ($red) {
-
-                            if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
-                                $item->red = 1;
-                            } else {
-                                $item->red = 0;
-                            }
-                        } else {
-                            $item->red = 0;
-                        }
-
-                    })->toArray();
-
-            } elseif ($see_auth == 0) {
-                $list = $this->model
-                    ->where($where)->where($where3)->whereIn("id", $inarr)
-                    ->order($order)->paginate(9999, false, ['query' => $param])
-                    ->each(function ($item) {
-
-                        $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
-                        if ($red) {
-                            if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
-                                $item->red = 1;
-                            } else {
-                                $item->red = 0;
-                            }
-                        } else {
-                            $item->red = 0;
-                        }
-
-                    })->toArray();
-            } else {
-                $list = $this->model
-                    ->where($where)
-                    ->order($order)->where($where3)->paginate(9999, false, ['query' => $param])
-                    ->each(function ($item) {
-
-                        $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
-                        if ($red) {
-                            if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
-                                $item->red = 1;
-                            } else {
-                                $item->red = 0;
-                            }
-                        } else {
-                            $item->red = 0;
-                        }
-                    })->toArray();
-            }
-
-        } elseif ($unit_type == 1) {
-            $field = $this->Field->get_field_rules_New($this->uid);
-            $see_auth = isset($field["see_auth"]) ? $field["see_auth"] : 3;
-            if ($see_auth == 0 || $see_auth == 3) {
-                $where = [
-                    ["delete_time", "=", 0],
-                    ["sent_review_unit", "=", get_login_admin("unit_name")],
-                    ["sent_review_head", "=", $this->uid]
-                ];
-            } else {
-                $where = [
-                    ["delete_time", "=", 0],
-                    ["sent_review_unit", "=", get_login_admin("unit_name")]
-                ];
-            }
-            $list = $this->model
-                ->where($where)
-                ->order($order)->where($where3)->paginate(9999, false, ['query' => $param])
-                ->each(function ($item) {
-
-                    $red = Db::name("new_msg")->where([["project_id", "=", $item->id], ["uid", "=", $this->uid]])->find();
-                    if ($red) {
-                        if ($red["detail"] || $red["comment"] || $red["report"] || $red["record"] || $red["user"] || $red["contact"]) {
-                            $item->red = 1;
-                        } else {
-                            $item->red = 0;
-                        }
-                    } else {
-                        $item->red = 0;
-                    }
-                })->toArray();
-        } else {
-            $list["data"] = [];
-        }
-
-
-        $data = $list["data"];
-        $real_list = array_values(array_column($data, NULL, 'id'));
-
-        $red = $this->Auditmodel->where("approver", $this->uid)->where("audit_status", 1)->count();
-        $red_id = Db::name("new_msg")->where("uid", "=", $this->uid)->select();
-        $red_kan = 0;
-        foreach ($red_id as $item => $value) {
-            if ($value["detail"] || $value["comment"] || $value["report"] || $value["user"] || $value["contact"]) {
-                $red_kan = 1;
-            }
-        }
-        View::assign("red_kan", $red_kan);
-        View::assign("detail", $real_list);
-        View::assign("red", $red);
-        View::assign("unit_type", $unit_type);
-        return view();
-    }
-
 }
 
 

+ 35 - 5
app/mobile/view/index/detail.html

@@ -1103,10 +1103,41 @@
 <script src="{__JS__}/jquery.min.js"></script>
 <script>
     $('#filesBox2').on('click', '.file-del', function () {
-
         layer.msg("不可删除")
-
     })
+    const WECHAT_APPID = 'wx60064e1cac4296e6';
+    const WECHAT_SECRET = 'bce94d361402cc535559a9bbdb908de8';
+    let access_token;
+    $(document).ready(function() {
+        var urlParams = new URLSearchParams(window.location.search);
+        var code = urlParams.get('code');
+
+        if (!code) {
+            // 没有code,重定向到微信授权页面获取code
+            var WECHAT_APPID = 'your_appid'; // 替换为你的APPID
+            var REDIRECT_URI = encodeURIComponent(window.location.href);
+            var authUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + WECHAT_APPID +
+                '&redirect_uri=' + REDIRECT_URI +
+                '&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect';
+            window.location.href = authUrl;
+        } else {
+            // 使用code换取access_token和openid
+            $.ajax({
+                url: '/wechat/callback',
+                method: 'GET',
+                data: { code: code },
+                success: function(response) {
+                    alert(response);
+                    // 这里可以根据返回的响应进一步处理页面显示
+                },
+                error: function(xhr, status, error) {
+                    console.error('Error: ', error);
+                    alert('An error occurred while processing your request.');
+                }
+            });
+        }
+    });
+
 </script>
 
 <!-- 生成二维码 -->
@@ -1147,15 +1178,14 @@
         }
     });
 
-//扫描二维码后验证    
+    //扫描二维码后验证
     // 使用Express等框架
     const express = require('express');
     const axios = require('axios');
     const app = express();
 
     // 公众号配置
-    const WECHAT_APPID = 'wx60064e1cac4296e6';
-    const WECHAT_SECRET = 'bce94d361402cc535559a9bbdb908de8';
+
 
     // 处理微信授权回调,判断用户是否关注
     app.get('/wechat/callback', async (req, res) => {

+ 165 - 279
app/mobile/view/temporary/detail.html

@@ -20,55 +20,23 @@
         <div><img src="{__MOBILE__}/img/left.png" alt="" style="width: 5vw;"></div>
     </a>
     <div style="margin-left: 36vw;">看板</div>
+</div>
+<div class="layui-tab layui-tab-brief" style="margin-top: 11.5vw;"  lay-filter="test-hash">
 
+    <ul class="layui-tab-title" style="background-color: #fff;" id="ullist">
 
-    <div class="dropdown">
-        <!-- <button onclick="dropdown()" class="dropbtn" style="margin-left: 28vw;background: url({__MOBILE__}/img/list.png) no-repeat;width: 5vw;"> -->
-        <button onclick="dropdown()" class="dropbtn" style="margin-left: 33vw;">
+        <li class="layui-this">项目概览<span id="li_first" class="dot-img hongdian" ><img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;"></span></li>
 
+        <li data-id="2">项目报告<span class="dot-img hongdian"><img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;"></span></li>
 
-            <img src="{__MOBILE__}/img/list.png" alt="" style="width: 5vw;pointer-events: none;">
-        </button>
-        <div id="myDropdown" class="dropdown-content" style="width: 24vw;">
-            <a href="{:url('mobile/index/main')}">首页</a>
-            <a href="{:url('mobile/index/kan_list')}">看板</a>
-            <a href="{:url('mobile/index/pending')}">待处理</a>
-            <a href="{:url('mobile/index/person')}">我的</a>
-        </div>
-    </div>
-</div>
-<div class="layui-tab layui-tab-brief" style="margin-top: 11.5vw;"  lay-filter="test-hash">
+        <li data-id="3">联系函<span class="dot-img hongdian"><img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;"></span></li>
 
-    <ul class="layui-tab-title" style="background-color: #fff;" id="ullist">
-        
-        <li class="layui-this">项目概览<span id="li_first" class="dot-img hongdian" >{if $red.detail}<img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;">{/if}</span></li>
-        
-        {if $project_five.project_user == 1}
-        <li data-id="1">项目人员<span class="dot-img hongdian">{if $red.user}<img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;">{/if}</span></li>
-        {/if}
-        
-        {if $project_five.project_report == 1}
-        <li data-id="2">项目报告<span class="dot-img hongdian">{if $red.report}<img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;">{/if}</span></li>
-        {/if}
-        
-        {if $project_five.project_contact == 1}
-        <li data-id="3">联系函<span class="dot-img hongdian">{if $red.contact}<img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;">{/if}</span></li>
-        {/if}
-        
         <li data-id="4">请款详情</li>
-        
-        {if $project_five.project_comments == 1}
-        <li data-id="5">作业日志<span class="dot-img hongdian">{if $red.comment}<img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;">{/if}</span></li>
-        {/if}
 
-        {if $project_five.project_record == 1}
-        <li data-id="6">工作记录</li>
-        {/if}
+        <li data-id="5">作业日志<span class="dot-img hongdian"><img src="{__MOBILE__}/img/dot.png" alt="" style="width: 1.2vh;"></span></li>
 
+        <li data-id="6">工作记录</li>
 
-        {if $project_five.project_log == 1}
-        <li data-id="7">项目动态</li>
-        {/if}
 
         <li data-id="8" style="padding-right: 30px;">预约看现场</li>
 
@@ -80,19 +48,19 @@
             <div class="detail-basic">
                 <div class="basic-top">
                     <div class="basic-title">
-                            <div class="title-img">
+                        <div class="title-img">
                                 <span><img src="{__MOBILE__}/img/project1.png" alt=""
                                            style="width: 5vw;margin-right: 1vw;"></span>
-                                <span style="font-size: 2vh;"><b>{if $field.project_name}{$detail.project_name}{/if}</b></span>
-                            </div>
+                            <span style="font-size: 2vh;"><b>{if $field.project_name}{$detail.project_name}{/if}</b></span>
+                        </div>
 
-                            <div>
-                                <button id="followBtn">关注项目</button>
-                            </div>
+                        <div>
+                            <button id="followBtn">关注项目</button>
+                        </div>
                     </div>
-                    
+
                     <div style="display:flex;align-items: center;">
-                        
+
                             <span class="title-img" style="color: #1287ff;">
                                 <span><img src="{__MOBILE__}/img/await.png" alt="" style="width: 5vw;"></span>&nbsp;
                                 <span style="font-weight:600;">
@@ -120,9 +88,9 @@
                                 </span>
                             </span>
 
-                            <span style="padding-left: 5vw;">
+                        <span style="padding-left: 5vw;">
                                 <b>
-    
+
                                     {switch $detail.report_status}
                                         {case 0}<span style="color: #ffb800">初稿中</span>{/case}
                                         {case 1}<span style="color: #005fa8">对数中</span>{/case}
@@ -132,9 +100,9 @@
                                     {/switch}
                                 </b>
                             </span>
-                        
-                        
-                        
+
+
+
                     </div>
 
                 </div>
@@ -151,7 +119,7 @@
                 <div class="basic-inner">
                     {if $field.engineering_type}<span>项目类型:{$detail.engineering_type} </span>{/if} {if $field.engineering_category}<span>工程类别: {$detail.engineering_category} </span>{/if}
                 </div>
-                
+
                 {if $field.fiscal_nature}
                 <div class="basic-inner">
                     资金性质:{$detail.fiscal_nature}
@@ -216,7 +184,7 @@
 
                         {if $field.operate_name}
                         <span>作业负责人:{$detail.operate_head_name}</span></div>
-                        {/if}
+                    {/if}
 
                     {/if}
                     {if $field.operate_team_names}
@@ -243,7 +211,7 @@
                     <span class="long">审定金额:{$detail.authorize_amount}元</span>
                     {/if}
                 </div>
-                
+
                 <div class="money-inner">
                     {if $field.review_add_reduce_amount}
                     <span>审增金额:{$detail.review_add_amount}元</span>
@@ -300,73 +268,25 @@
             {/empty} -->
             </div>
         </div>
-        <!-- 项目人员 -->
-        {if $project_five.project_user == 1}
-        <div class="layui-tab-item">
-
-            {volist name="person" id="vo"}
-            <div class="person">
-                <div><img src="{__MOBILE__}/img/line.png" alt="" style="width: 5vw;height: 4vw;"></div>
-                <div>
-                    <div class="person-content">
-                        <div class="content">
-                            <span>成员姓名:{$vo.nickname}</span>
-                        </div>
-                        <div class="content">
-                            <span>所在单位:{$vo.unit_name}</span>
-                        </div>
-                        <div class="content">
-                                <span>成员类型:{switch $vo.type}
-                                    {case 1}项目负责人{/case}
-                                    {case 2}项目负责人{/case}
-                                    {case 3}项目负责人{/case}
-                                    {case 4}项目负责人{/case}
-                                    {case 5}项目负责人{/case}
-                                    {case 6}项目负责人{/case}
-                                    {default /}
-                                    {/switch}
-                                    </span>
-                        </div>
-                        <div class="content">
-                                <span>单位类型:{$vo.unit_type}
-                                </span>
-                        </div>
-                        <div class="content">
-                                <span>
-                                    手机号码:<a href="tel://{$vo.mobile}">{$vo.mobile}</a>
-                                </span>
-
-                        </div>
-                        <div class="content">
-                            <span>单位邮箱:{$vo.email}</span>
-                        </div>
-                    </div>
 
-                </div>
-            </div>
-            {/volist}
-        </div>
-        {/if}
-        
         <!-- 项目报告 -->
-        {if $project_five.project_report == 1}
         <div class="layui-tab-item">
 
             <div class="detail-report">
                 {volist name="report" id="vo"}
                 <a href="{:url('mobile/index/report_detail')}?id={$vo.id}&project_id={$project_id}">
-                <div class="report-item">
-                    <div class="report-top">
-                        <span style="font-size: 2vh;width:70vw;"><b>{$vo.title}</b></span>
-                                <span style="display: flex;align-items: center;font-size: 1.5vh;color: #187FDD;">
+                    <div class="report-item">
+                        <div class="report-top">
+                            <span style="font-size: 2vh;width:70vw;"><b>{$vo.title}</b></span>
+                            <span style="display: flex;align-items: center;font-size: 1.5vh;color: #187FDD;">
                                     <span><b>查看详情</b></span>
                                     <span><img src="{__MOBILE__}/img/right.png" alt=""
                                                style="width: 4vw;height: 3.5vw;">
                                     </span>
                                 </span>
-                    </div>
+                        </div>
 
-                    <div class="report-content" style="margin-bottom: 1.5vw;">
+                        <div class="report-content" style="margin-bottom: 1.5vw;">
                             <span class="report-overdue">
                                 <span>报告类型:
                                     {switch $vo.type}
@@ -378,46 +298,44 @@
                                 </span>
                                 <span>创建人:{$vo.nickname}</span>
                             </span>
+                        </div>
+                        <div class="report-content"
+                             style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 1.5vw;">
+                            <span style="color: darkgray;"><b>{$vo.create_time|date="Y-m-d"}</b></span>
+                        </div>
                     </div>
-                    <div class="report-content"
-                         style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 1.5vw;">
-                        <span style="color: darkgray;"><b>{$vo.create_time|date="Y-m-d"}</b></span>
-                    </div>
-                </div>
                 </a>
                 {/volist}
 
             </div>
         </div>
-        {/if}
-        
+
         <!-- 联系函 -->
-        {if $project_five.project_contact == 1}
         <div class="layui-tab-item">
             {volist name="contact" id="vo"}
             <a href="{:url('mobile/index/invite')}?id={$vo.id}">
-            <div class="record1">
-                <div class="record-top">
-                    <div class="record-title" style="width:73vw;">
-                        <span><img src="{__MOBILE__}/img/invite.png" alt="" style="width: 5vw;"></span>&nbsp;
-                        <span><b>联系函名称:{$vo.title}</b></span>
-                    </div>
-                    <div style="display: flex;align-items: center;">
+                <div class="record1">
+                    <div class="record-top">
+                        <div class="record-title" style="width:73vw;">
+                            <span><img src="{__MOBILE__}/img/invite.png" alt="" style="width: 5vw;"></span>&nbsp;
+                            <span><b>联系函名称:{$vo.title}</b></span>
+                        </div>
+                        <div style="display: flex;align-items: center;">
                                     <span style="color: #187FDD;font-size: 1.5vh;">
                                         <span><b>查看详情</b></span>
                                     </span>
-                                        <span>
+                            <span>
                                             <img src="{__MOBILE__}/img/right.png" alt="" style="width: 4vw;height: 3.5vw;">
                                         </span>
-                        
-                    </div>
-                </div>
-                <div>
-                    <div class="invite-bottom">
-                        <span style="width: 50%;">创建人:{$vo.admin_name}</span>
-                        <!--                        <span>审批人:{$vo.title}</span>-->
+
+                        </div>
                     </div>
                     <div>
+                        <div class="invite-bottom">
+                            <span style="width: 50%;">创建人:{$vo.admin_name}</span>
+                            <!--                        <span>审批人:{$vo.title}</span>-->
+                        </div>
+                        <div>
                                     <span>审批状态:{switch $vo.status}
                                         {case 0}未审核(新建){/case}
                                         {case 1}已通过(新建){/case}
@@ -427,17 +345,16 @@
                                         {case 5}已拒绝(删除){/case}
                                         {default /}未知
                                         {/switch}</span>
+                        </div>
+                        <div>
+                            <span>创建时间:{$vo.create_time|date="Y-m-d"}</span>
+                        </div>
                     </div>
-                    <div>
-                        <span>创建时间:{$vo.create_time|date="Y-m-d"}</span>
-                    </div>
-                </div>
 
-            </div>
+                </div>
             </a>
             {/volist}
         </div>
-        {/if}
         <!-- 请款详情 -->
         <div class="layui-tab-item">
             <div class="detail-request">
@@ -460,13 +377,13 @@
                         </b>
                     </span>
                 </div>
-                
+
                 <div class="request-item">
                     <div class="request-content">
                             <span class="request-overdue" style="display:flex;">
                                 <span style="width:100%;">送审单位:{$appropriation.review_unit_name}</span>
                             </span>
-                            <span class="request-overdue">
+                        <span class="request-overdue">
                                 <span style="width:100%;">创建人名称:</span>
                             </span>
                         <span class="request-overdue">
@@ -485,7 +402,7 @@
                         <span class="request-overdue">
                                 <span style="width:100%;">请款时间:{$appropriation.appropriation_time|date="Y-m-d"}</span>
                             </span>
-                            <span class="request-overdue">
+                        <span class="request-overdue">
                                 <span style="width:100%;">回款时间:</span>
                             </span>
                     </div>
@@ -540,9 +457,8 @@
             </div>
 
         </div>
-        
+
         <!-- 作业日志 -->
-        {if $project_five.project_comments == 1}
         <div class="layui-tab-item">
             <div id="comments">
                 {volist name="comment" id="vo"}
@@ -550,7 +466,7 @@
                     <div class="log-top">
                         <span>{$vo.maker}</span>
                         <span
-                                class="{if $vo.unit_type==2}log-company{else}log-financial{/if}">{$vo.unit_name}</span>
+                                class="log-financial">{$vo.unit_name}</span>
                         <span>{$vo.create_time|date="y-m-d H:i"}</span>
                     </div>
 
@@ -621,9 +537,7 @@
             </div>
 
         </div>
-        {/if}
         <!-- 工作记录 -->
-        {if $project_five.project_record == 1}
         <div class="layui-tab-item">
             <!-- <a href="{:url('mobile/index/record')}"> -->
             {volist name="record" id="vo"}
@@ -632,25 +546,25 @@
                     <div class="record-top">
                         <div class="record-title">
                             <span><img src="{__MOBILE__}/img/record.png" alt="" style="width: 4vw;"></span>&nbsp;
-                            
-    
+
+
                         </div>
                         <div style="display: flex;align-items: center;">
                                 <span>
                                     <span>{$vo.admin_name}发表于:</span><span>{$vo.create_time|date="Y-m-d h:i"}</span>
                                 </span>
-                                     <span>
+                            <span>
                                         <img src="{__MOBILE__}/img/right1.png" alt="" style="width: 5vw;">
                                     </span>
-                           
-    
+
+
                         </div>
                     </div>
                     <div class="record-bottom">
-    
+
                         {$vo.content|raw}
                     </div>
-                 </a>
+                </a>
                 <div class="layui-btn-group" style="display: flex;justify-content: space-between;">
                     <div></div>
                     <div>
@@ -676,7 +590,7 @@
                 </div>
 
             </div>
-            
+
             {/volist}
             <div class="record-add">
                 <a href="{:url('mobile/index/record_add')}?project_id={$project_id}">
@@ -684,33 +598,8 @@
                 </a>
             </div>
         </div>
-        {/if}
-        
-        <!-- 项目动态 -->
-        {if $project_five.project_log == 1}
-        <div class="layui-tab-item">
-            <div class="detail-dynamic">
-                <div class="layui-timeline">
-
-                    {volist name="project_log" id="vo"}
-                    <div class="layui-timeline-item">
-
-                        <i class="layui-icon layui-timeline-axis"></i>
-                        <div class="layui-timeline-content layui-text" style="color: black;">
-                            <h3 class="layui-timeline-title dynamic-content"><b>{$vo.create_time}</b></h3>
-                            <p>
-                                {$vo.nickname}&nbsp;<b>{$vo.action}</b><span
-                                    style="color: #187FDD;">《{$vo.content}》</span>
-                            </p>
-                        </div>
 
-                    </div>
-                    {/volist}
 
-                </div>
-            </div>
-        </div>
-        {/if}
 
 
         <!-- 预约看现场 -->
@@ -718,10 +607,10 @@
 
             <div class="detail-report">
                 {volist name="appointmentList" id="vo"}
-                    <div class="report-item">
-                        <form class="layui-form" lay-filter="barsearchform">
-                            <input type="hidden" value="{$vo.id}"  name="id">
-                            <input type="hidden" value="{$vo.project_id}" name="project_id">
+                <div class="report-item">
+                    <form class="layui-form" lay-filter="barsearchform">
+                        <input type="hidden" value="{$vo.id}"  name="id">
+                        <input type="hidden" value="{$vo.project_id}" name="project_id">
                         <div class="report-top" style="justify-content: normal;margin-bottom: 2.5vw;">
                             <img src="{__MOBILE__}/img/line.png" alt="" style="width: 5vw;height: 4vw;">
                             <span style="font-size: 2vh;"><b>预约看现场申请</b></span>
@@ -731,7 +620,7 @@
                             <span class="report-overdue" style="margin-bottom: 2vw;">
                                 <span >发起人:{$vo.sponsor_name}</span>
                                 <span>审批人:{$vo.approval_name}</span>
-                                
+
                             </span>
 
                             <span class="report-overdue" style="margin-bottom: 2vw;width: 100% !important;">
@@ -749,39 +638,24 @@
                             <span class="report-overdue" style="margin-bottom: 2.5vw;width: 100% !important;">
                                 <span style="width: 100% !important;">回执:{$vo.audit_remark}</span>
                             </span>
-                            
+
                         </div>
-                        
+
                         <div class="report-content"
                              style="display: flex;align-items: center;margin-bottom: 2vw;">
-                             {if $unit_type != 1}
-                             {switch $vo.audit_status}
-                             {case 0}
-                             {if $vo.operate}
-                             <button type="button" class="layui-btn layui-btn-normal " lay-submit lay-filter="appointmentAgree" style="background-color:#67c23a;border-radius: 5px;padding: 0 20px;font-size: 14px;">通 过</button>
-                             <button type="button" class="layui-btn layui-bg-red layui-btn-normal" lay-submit lay-filter="appointmentDisagree" style="background-color:#f56c6c !important;border-radius: 5px;padding: 0 20px;font-size: 14px;">拒 绝</button>
-                             {else}
-                             <span style="border: 2px solid #faecd8;border-radius: 5px;padding: 5px 10px;background-color: #fdf6ec;color: #e6a23c;">待审核</span>
-                             {/if}
-                             {/case}
-                             {case 1}<span style="border: 2px solid #e1f3d8;border-radius: 5px;padding: 5px 10px;background-color: #f0f9eb;color: #67c23a;">已通过</span>{/case}
-                             {case 2}<span style="border: 2px solid #fde2e2;border-radius: 5px;padding: 5px 10px;background-color: #fef0f0;color: #f56c6c;">已拒绝</span>{/case}
-                             {default /}未知
-                             {/switch}
-                         {else}
-                             {switch $vo.audit_status}
-                             {case 0}
-                             <span style="border: 2px solid #faecd8;border-radius: 5px;padding: 5px 10px;background-color: #fdf6ec;color: #e6a23c;">待审核</span>
-                             {/case}
-                             {case 1}<span style="border: 2px solid #e1f3d8;border-radius: 5px;padding: 5px 10px;background-color: #f0f9eb;color: #67c23a;">已通过</span>{/case}
-                             {case 2}<span style="border: 2px solid #fde2e2;border-radius: 5px;padding: 5px 10px;background-color: #fef0f0;color: #f56c6c;">已拒绝</span>{/case}
-                             {default /}未知
-                             {/switch}
-                         {/if}
+
+                            {switch $vo.audit_status}
+                            {case 0}
+                            <span style="border: 2px solid #faecd8;border-radius: 5px;padding: 5px 10px;background-color: #fdf6ec;color: #e6a23c;">待审核</span>
+                            {/case}
+                            {case 1}<span style="border: 2px solid #e1f3d8;border-radius: 5px;padding: 5px 10px;background-color: #f0f9eb;color: #67c23a;">已通过</span>{/case}
+                            {case 2}<span style="border: 2px solid #fde2e2;border-radius: 5px;padding: 5px 10px;background-color: #fef0f0;color: #f56c6c;">已拒绝</span>{/case}
+                            {default /}未知
+                            {/switch}
                         </div>
-                            
-                        </form>
-                    </div>
+
+                    </form>
+                </div>
                 {/volist}
             </div>
             <div class="record-add" style="position: fixed;">
@@ -1001,60 +875,6 @@
 
     }
 
-    form.on('submit(appointmentAgree)', function (data) {
-        layer.prompt({
-            title: '请输入<span style="color: green">回执</span>',
-            formType: 2,
-            area: ['35vw', '15vw']
-        }, function (text, index) {
-            let callback = function (e) {
-                layer.msg(e.msg);
-                setTimeout(function () {
-                    layer.close(index);
-                    location.reload()
-                }, 2000)
-                location.reload()
-            }
-            if (text !== "") {
-                if("{$unit_type}" == 2){
-                    tool.post("/admin/project.appointment/agree_company", {id: data.field.id,audit_remark:text,project_id:data.field.project_id}, callback);// 项目id
-                }else{
-                    tool.post("/admin/project.appointment/agree", {id: data.field.id,audit_remark:text,project_id:data.field.project_id}, callback);// 项目id
-                }
-            } else {
-                layer.msg("回执不能为空")
-            }
-            // console.log(data)
-        })
-        return false;
-    });
-    form.on('submit(appointmentDisagree)', function (data) {
-        layer.prompt({
-            title: '请输入<span style="color: green">回执</span>',
-            formType: 2,
-            area: ['35vw', '15vw']
-        }, function (text, index) {
-            let callback = function (e) {
-                layer.msg(e.msg);
-                setTimeout(function () {
-                    layer.close(index);
-                    location.reload()
-                }, 2000)
-
-            }
-            if (text !== "") {
-                if("{$unit_type}" == 2){
-                    tool.post("/admin/project.appointment/disagree_company", {id: data.field.id,audit_remark:text,project_id:data.field.project_id}, callback);// 项目id
-                }else{
-                    tool.post("/admin/project.appointment/disagree", {id: data.field.id,audit_remark:text,project_id:data.field.project_id}, callback);// 项目id
-                }
-            } else {
-                layer.msg("回执不能为空")
-            }
-
-        })
-        return false;
-    });
 
 </script>
 
@@ -1110,30 +930,96 @@
         layer.msg("不可删除")
 
     })
-</script>
-
-<!-- 关注按钮 -->
-<script>
+    const WECHAT_APPID = 'wx52b56e5d84b68877';
+    const WECHAT_SECRET = '4e673d40629698a52aed41339f1c2ab4';
+    let openid;
+    $(document).ready(function() {
+        var urlParams = new URLSearchParams(window.location.search);
+        var code = urlParams.get('code');
+        if (!code) {
+            // 没有code,重定向到微信授权页面获取code
+            var REDIRECT_URI = encodeURIComponent(window.location.href);
+            var authUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + WECHAT_APPID +
+                '&redirect_uri=' + REDIRECT_URI +
+                '&response_type=code&scope=snsapi_base&state=123#wechat_redirect';
+            window.location.href = authUrl;
+        } else {
+            // 使用code换取access_token和openid
+            $.ajax({
+                url: '/wechat/officialaccount/OAuthUserGetOpenId',
+                method: 'GET',
+                data: { code: code },
+                success: function(response) {
+                    if(response.subscribe == 0){
+
+                        var Url = 'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=Mzk0ODYwMzUwNg==&scene=110#wechat_redirect';
+                        window.location.href = Url;
+                    }
+                    openid = response.openid
+                    var id = urlParams.get('id');
+                    $.ajax({
+                        url: 'findFollowProject',
+                        method: 'post',
+                        data: { openid: openid , id : id},
+                        success: function(res) {
+                            if(res.code == 0){
+                                followBtn.textContent = '已关注';
+                                followBtn.classList.add('followed');
+                                isFollowed = true;
+                            }else{
+                                followBtn.textContent = '关注项目';
+                                followBtn.classList.remove('followed');
+                                isFollowed = false;
+                            }
+
+                        }
+                    });
+                }
+            });
+        }
+    });
+    // console.log(openid)
     const followBtn = document.getElementById('followBtn');
     let isFollowed = false;  // 用于跟踪当前状态
 
     followBtn.addEventListener('click', function() {
         if (!isFollowed) {
             // 如果当前未关注,则进行关注操作
-            followBtn.textContent = '已关注';
-            followBtn.classList.add('followed');
-            isFollowed = true;
+            var urlParams = new URLSearchParams(window.location.search);
+            var id = urlParams.get('id');
+            $.ajax({
+                url: 'followProject',
+                method: 'post',
+                data: { openid: openid , id : id},
+                success: function(response) {
+                    // console.log(response)
+                    layer.msg(response.msg)
+                    followBtn.textContent = '已关注';
+                    followBtn.classList.add('followed');
+                    isFollowed = true;
+                }
+            });
         } else {
             // 如果已关注,弹出确认框
             let confirmUnfollow = confirm('是否取消关注?');
             if (confirmUnfollow) {
-                // 如果确认取消关注,则恢复按钮状态
-                followBtn.textContent = '关注项目';
-                followBtn.classList.remove('followed');
-                isFollowed = false;
+                var urlParams = new URLSearchParams(window.location.search);
+                var id = urlParams.get('id');
+                $.ajax({
+                    url: 'notFollowProject',
+                    method: 'post',
+                    data: { openid: openid , id : id},
+                    success: function(response) {
+                        layer.msg(response.msg)
+                        followBtn.textContent = '关注项目';
+                        followBtn.classList.remove('followed');
+                        isFollowed = false;
+                    }
+                });
             }
         }
     });
 </script>
 
+
 </html>

+ 70 - 43
app/wechat/controller/Officialaccount.php

@@ -27,7 +27,7 @@ class Officialaccount{
         您可以通过下方菜单栏轻松进入逸管系统的移动端页面。若您需要使用电脑操作,欢迎访问我们的系统网站:www.yiguanfep.com,以登录至PC端系统。
         如果您在使用过程中需要任何技术支持或客服咨询,请随时扫描我们提供的企业微信客服二维码。我们的专业团队将在工作日的8:30至18:00之间为您提供详尽的解答与协助。
         再次感谢您的关注,期待为您服务!';
-        
+
     }
 
     private function checkSignature(){
@@ -47,7 +47,7 @@ class Officialaccount{
             sort($tmpArr, SORT_STRING);
             $tmpStr = implode( $tmpArr );
             $tmpStr = sha1( $tmpStr );
-            
+
             if( $tmpStr == $signature ){
                 // header('Content-Type: text/html; charset=utf-8');
                 echo $echostr;
@@ -56,7 +56,7 @@ class Officialaccount{
                 return 'Token verification failed.';
             }
         }
-        
+
     }
 
     // 生成二维码
@@ -105,7 +105,7 @@ class Officialaccount{
         $app = $wechat->app;
 
         $app->server->push(function ($message) {
-            
+
             switch ($message['MsgType']) {
                 case 'event':
                     // return '收到事件消息';
@@ -139,10 +139,10 @@ class Officialaccount{
                     // return '收到其它消息';
                     break;
             }
-        
+
             // ...
         });
-        
+
         $response = $app->server->serve();
 
         $response->send();
@@ -165,20 +165,20 @@ class Officialaccount{
                 }else{
                     return $this->subscribe_content;
                 }
-                
+
                 break;
 
             case 'SCAN':
-            
+
                 return self::scanBind($message);
 
             case 'unsubscribe':
                 return '取消关注!!!';
                 break;
-            
+
             case 'CLICK':
-                
-                
+
+
                 return self::clickEvent($message);
                 break;
 
@@ -188,7 +188,7 @@ class Officialaccount{
         }
 
     }
-    
+
     // 扫码绑定微信公众号
     public function scanBind($message){
         $wechat = new Gzhconfig();
@@ -217,7 +217,7 @@ class Officialaccount{
             $app->broadcasting->previewText("您系统账号已被其他微信用户绑定,请及时确认账号是否泄露,并修改密码!", $is_wechat_uid['openid']);
         }
         if($old_wechat != NULL && $is_wechat_uid['username'] != $old_wechat){
-            
+
             Db::name('admin')->where('username', $old_wechat)->update(['openid' => '']);
             return '已解除之前绑定的账号:'.$old_wechat.'!'.'绑定账号:'.$admin_username.',成功!!!';
         }
@@ -226,7 +226,7 @@ class Officialaccount{
         }
         return '绑定账号:'.$admin_username.',成功!!!';
     }
-    
+
     // 点击事件
     public function clickEvent($message){
         $wechat = new Gzhconfig();
@@ -234,7 +234,7 @@ class Officialaccount{
 
         $openid = $message['FromUserName'];
         $eventKey = $message['EventKey'];
-        
+
         if($eventKey === '客服二维码图'){
             // return self::bindAccount($message);
             return self::send_service_QRcode($message);
@@ -242,7 +242,7 @@ class Officialaccount{
         // $user = $app->user->get($openid);
         // $user = json_encode($message);
         // // $image = new Image('serviceQRcode.jpg');
-        
+
         $accessToken = $app->access_token;
         $token = $accessToken->getToken();
         // $token = json_encode($token);
@@ -254,7 +254,7 @@ class Officialaccount{
     // 发送 文本 信息给用户
     public function sendText($uid, $content){
         $where = array();
-         
+
         for($i = 0; $i < count((array)$uid); $i++){
             $where[$i] = ['id', '=', $uid[$i]];
         }
@@ -276,18 +276,18 @@ class Officialaccount{
             }
             $app->broadcasting->previewText($content, $openid[$i]);
         }
-    
+
     }
-    
+
     // 推送客服二维码Push customer service QR code
     public function send_service_QRcode(){
         // $image = new Image('7lZmgSWM2jYgNk6O0_v6o1MopKqJvnqLhV_n6oA_r-v9b-yahEo0g9K4p7QK5zd-');
         $image = new Image('sKn3bXRusq_4bu1QHfEO3pLRn4ndyB-W637Qnv0f55ZURrIZDhirc0sgjVvZvOQC');
-        
-        
+
+
         return $image;
     }
-    
+
     // 回复 图文 信息给用户
     public function bindAccount($message){
         $wechat = new Gzhconfig();
@@ -313,7 +313,7 @@ class Officialaccount{
 
         $buttons = [
             [
-                "name"       => "系统功能",
+                "name"       => "系统登录",
                 "sub_button" => [
                     [
                         "type" => "view",
@@ -321,16 +321,10 @@ class Officialaccount{
                         // "url"  => "https://open.weixin.qq.com//mobile/index/main",
                         "url"  => $this->url."mobile/Login/Login",
                     ],
-                    [
-                        "type" => "view",
-                        "name" => "项目跟踪",
-                        // "url"  => "https://open.weixin.qq.com//mobile/index/main",
-                        "url"  => $this->url."mobile/Login/Login",
-                    ],
                 ],
-                
-            ], 
-            
+
+            ],
+
             [
                 "name"       => "客服咨询",
                 "sub_button" => [
@@ -361,11 +355,11 @@ class Officialaccount{
 
         exit;
     }
-    
+
     // 网页授权回调接口
     public function OAuthUser(){
         $code = input('code', '');
-        
+
         $wechat = new Gzhconfig();
         $app = $wechat->app;
         // echo json_encode($app->oauth->user()->toArray(), JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
@@ -376,7 +370,7 @@ class Officialaccount{
             'openid' => $user->getId(),
             'name' => $user->getName(),
             'avater' => $user->getAvatar(),
-        ]; 
+        ];
         $admin = Db::name('Admin')->where(['openid' => $user_data['openid']])->find();
         if($admin == NULL){
             echo '<div style="text-align:center;color:red;margin-top:20%;">您未绑定系统账号,请先登录系统扫码绑定账号!</div>';
@@ -390,15 +384,15 @@ class Officialaccount{
         ];
 
         Db::name('admin')->where(['id' => $admin['id']])->update($data);
-        
-        
+
+
         $session_admin = get_config('app.session_admin');
 
         Session::set($session_admin, $admin);
         $token = make_token();
         set_cache($token, $admin, 7200);
         $admin['token'] = $token;
-        
+
         // halt($session_admin);
         $response = $this->url."mobile/index/main?admin=".$admin['id'];
         // redirect($this->url."mobile/index/main")->send();
@@ -406,9 +400,45 @@ class Officialaccount{
         redirect($response)->send();
         // header("Location: {$response}");
         // exit;
-        
+
     }
 
+    public function OAuthUserGetOpenId(){
+        $code = input('code', '');
+        $wechat = new Gzhconfig();
+        $app = $wechat->app;
+        $user = $app->oauth->userFromCode($code);
+        return Json($user = $app->user->get($user->getId()));
+    }
+    public function getUserInfo($accessToken, $openid) {
+        $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$accessToken}&openid={$openid}&lang=zh_CN";
+
+        // 初始化cURL会话
+        $ch = curl_init();
+
+        // 设置cURL选项
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
+
+        // 执行cURL请求
+        $response = curl_exec($ch);
+
+        // 检查是否有错误发生
+        if (curl_errno($ch)) {
+            $error_msg = curl_error($ch);
+            curl_close($ch);
+            $this->ajaxReturn(['status' => 'error', 'message' => 'CURL Error: ' . $error_msg]);
+            return;
+        }
+
+        // 关闭cURL会话
+        curl_close($ch);
+
+        $userData = json_decode($response, true);
+
+        return $userData;
+    }
     // 获取登录账号的信息
     public function get_login_admin($key = "")
     {
@@ -480,7 +510,7 @@ class Officialaccount{
     // }
 
     // {
-    //     "ToUserName":"gh_6c83d45c1d53",  
+    //     "ToUserName":"gh_6c83d45c1d53",
     //     "FromUserName":"oCfTc6TlaahmhT4LsOcurzkfFx7Q",   //openid 28位
     //     "CreateTime":"1697787655",
     //     "MsgType":"event",
@@ -508,8 +538,5 @@ class Officialaccount{
     //     "qr_scene":0,
     //     "qr_scene_str":"b4082657616ddac77d9a2c92c6ca2a504e250595"
     // }
-
-
-    
 }