zxhxx 3 years ago
parent
commit
1fcf499a7d

+ 2 - 2
application/admin/behavior/User.php

@@ -20,7 +20,7 @@ class User
 
         $wechatInfo['nickname'] = filter_emoji($wechatInfo['nickname']);
 
-        if (isset($wechatInfo['unionid']) && $wechatInfo['unionid'] != '' && ($uid = UserRelation::where('unionid', $wechatInfo['unionid'])->where('user_type', '<>', 0)->value('user_id'))) {
+        if (isset($wechatInfo['unionid']) && $wechatInfo['unionid'] != '' && ($uid = UserRelation::where('unionid', $wechatInfo['unionid'])->where('login_type', '<>', 0)->value('user_id'))) {
             UserRelation::where('user_id',$uid)->update($wechatInfo);
             if (!UserRelation::where(['user_id' => $uid])->find()) {
                 $wechatInfo = UserRelation::where('user_id', $uid)->find();
@@ -29,7 +29,7 @@ class User
                 if ($login_type) $wechatInfo['login_type'] = $login_type;
                 UserModel::updateWechatUser($wechatInfo, $uid);
             }
-        } else if ($uid = UserRelation::where(['openid' => $wechatInfo['openid']])->where('user_type', '<>', 0)->value('user_id')) {
+        } else if ($uid = UserRelation::where(['openid' => $wechatInfo['openid']])->where('login_type', '<>', 0)->value('user_id')) {
             UserRelation::where('user_id',$uid)->update($wechatInfo);
             if ($login_type) $wechatInfo['login_type'] = $login_type;
             UserModel::updateWechatUser($wechatInfo, $uid);

+ 2 - 2
application/admin/view/project/project_donation_info/add.html

@@ -9,13 +9,13 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Pro_id')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-pro_id" data-rule="required" data-source="pro/index" class="form-control selectpage" name="row[pro_id]" type="text" value="">
+            <input id="c-pro_id" data-rule="required" data-source="project/project_donation" data-field="title"  class="form-control selectpage" name="row[pro_id]" type="text" value="">
         </div>
     </div>
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Project_donation_id')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-project_donation_id" data-rule="required" data-source="project/donation/index" class="form-control selectpage" name="row[project_donation_id]" type="text" value="">
+            <input id="c-project_donation_id" data-rule="required" data-source="Category" data-params='{"type":"project"}'  data-field="name"  class="form-control selectpage" name="row[project_donation_id]" type="text" value="">
         </div>
     </div>
     <div class="form-group">

+ 2 - 2
application/admin/view/project/project_donation_info/edit.html

@@ -9,13 +9,13 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Pro_id')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-pro_id" data-rule="required" data-source="pro/index" class="form-control selectpage" name="row[pro_id]" type="text" value="{$row.pro_id|htmlentities}">
+            <input id="c-pro_id" data-rule="required" data-source="project/ProjectDonation" data-field="title"  class="form-control selectpage" name="row[pro_id]" type="text" value="{$row.pro_id|htmlentities}">
         </div>
     </div>
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Project_donation_id')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-project_donation_id" data-rule="required" data-source="project/donation/index" class="form-control selectpage" name="row[project_donation_id]" type="text" value="{$row.project_donation_id|htmlentities}">
+            <input id="c-project_donation_id" data-rule="required" data-source="Category" data-params='{"custom[type]":"project"}'  data-field="name" class="form-control selectpage" name="row[project_donation_id]" type="text" value="{$row.project_donation_id|htmlentities}">
         </div>
     </div>
     <div class="form-group">

+ 2 - 2
application/admin/view/training/volunteer/add.html

@@ -127,13 +127,13 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Start_hour')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-start_hour" data-rule="required" class="form-control" name="row[start_hour]" type="number">
+            <input id="c-start_hour" data-rule="required" class="form-control" name="row[start_hour]" type="text">
         </div>
     </div>
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('End_hour')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-end_hour" data-rule="required" class="form-control" name="row[end_hour]" type="number">
+            <input id="c-end_hour" data-rule="required" class="form-control" name="row[end_hour]" type="text">
         </div>
     </div>
     <div class="form-group">

+ 2 - 2
application/admin/view/training/volunteer/edit.html

@@ -127,13 +127,13 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Start_hour')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-start_hour" data-rule="required" class="form-control" name="row[start_hour]" type="number" value="{$row.start_hour|htmlentities}">
+            <input id="c-start_hour" data-rule="required" class="form-control" name="row[start_hour]" type="text" value="{$row.start_hour|htmlentities}">
         </div>
     </div>
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('End_hour')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <input id="c-end_hour" data-rule="required" class="form-control" name="row[end_hour]" type="number" value="{$row.end_hour|htmlentities}">
+            <input id="c-end_hour" data-rule="required" class="form-control" name="row[end_hour]" type="text" value="{$row.end_hour|htmlentities}">
         </div>
     </div>
     <div class="form-group">

+ 1 - 0
application/api/controller/Donate.php

@@ -8,6 +8,7 @@ use think\Request;
 
 class Donate extends Api
 {
+    protected $noNeedRight = ['*'];
     public function apply(Request $request)
     {
         $where = UtilService::postMore(

+ 1 - 0
application/api/controller/Training.php

@@ -7,6 +7,7 @@ use app\common\model\training\{Training as TrainingModel,TrainingInfo,Volunteer}
 
 class Training extends Api
 {
+    protected $noNeedRight = ['*'];
     public function lst()
     {
 

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

@@ -2,13 +2,17 @@
 
 namespace app\api\controller;
 
-use app\admin\model\user\UserExt;
+use liuniu\IdentityCard;
+use app\admin\model\user\{UserExt};
+use app\admin\model\{User as UserModel};
 use app\admin\model\UserRelation;
 use app\common\controller\Api;
 use app\common\library\Ems;
 use app\common\library\Sms;
 use fast\Random;
+use liuniu\UtilService;
 use think\Config;
+use think\Request;
 use think\Validate;
 
 /**
@@ -354,4 +358,57 @@ class User extends Api
             $info['ext'] = null;
         $this->success('获取成功',$info);
     }
+    public function setuser(Request $request)
+    {
+        $where = UtilService::postMore(
+            [
+                ['full_name',''],
+                ['vocation',''],
+                ['position',''],
+                ['education',''],
+                ['tel',''],
+                ['address',''],
+                ['company_name',''],
+                ['nature',''],
+                ['legal_person',''],
+                ['zip_code',''],
+                ['compnay_address',''],
+                ['company_email',''],
+                ['certificateimage',''],
+                ['id_card',''],
+                ['nation',''],
+                ['birthday',''],
+                ['user_type',0],
+                ['mobile',''],
+            ],$request
+        );
+        $user = [];$user_ext = [];
+        $info = UserModel::find($this->auth->getUserinfo()['id']);
+        if($info['user_type']!=0 && $info['user_type']!=$where['user_type']) $this->error('用户类型不可修改');
+        if(!preg_match("/^1\d{10}$/", $where['mobile'])) $this->error('手机号不对');
+        if(IdentityCard::isValid($where['id_card']))$this->error('身份证号不正确!');
+        foreach ($where as $key=>$v)
+        {
+            if($v!='')
+            {
+                if(in_array($key,['id_card','birthday','user_type','mobile']))
+                {
+                    $user[$key] = $v;
+                }
+                else
+                {
+                    $user_ext['key'] =$v;
+                }
+            }
+        }
+        if(sizeof($user)>0)
+        {
+            UserModel::where('id',$this->auth->getUserinfo()['id'])->update($user);
+        }
+        if(sizeof($user_ext)>0)
+        {
+            UserExt::where('id',$this->auth->getUserinfo()['id'])->update($user_ext);
+        }
+        $this->success('修改成功');
+    }
 }

+ 8 - 4
application/api/controller/Volunteer.php

@@ -2,6 +2,7 @@
 namespace app\api\controller;
 use app\common\controller\Api;
 use liuniu\UtilService;
+use think\Exception;
 use think\Request;
 use app\common\model\Volunteer as VolunteerModel;
 
@@ -24,7 +25,6 @@ class Volunteer extends Api
                 ['specialty',''],
                 ['education',0],
                 ['is_vol',0],
-                ['volunteer_id',0],
                 ['is_experience',0],
                 ['start_hour',7],
                 ['end_hour',22],
@@ -43,11 +43,15 @@ class Volunteer extends Api
         $where['cid'] = $this->cid;
         $where['user_id'] =  $this->auth->getUserinfo()['id'];
         if(VolunteerModel::where('user_id',$where['user_id'])->where('status','>',-1)->find()) $this->error('已经存,不能重复申请');
-        if(!VolunteerModel::create($where))
+        try {
+            if (!VolunteerModel::create($where)) {
+                $this->error(VolunteerModel::getErrorInfo());
+            }
+            $this->success('创建成功');
+        }catch (Exception $e)
         {
-            $this->error(RescueModel::getErrorInfo());
+            $this->error($e->getMessage());
         }
-        $this->success('创建成功');
     }
     public function lst()
     {

+ 3 - 3
application/common/model/User.php

@@ -243,9 +243,10 @@ class User extends BaseModel
             'joinip' => Request::instance()->ip(),
             'logintime' => time(),
             'loginip' => Request::instance()->ip(),
-            'user_type' => $routineUser['user_type'],
+            'login_type' => $routineUser['login_type'],
             'cid'    => $routineUser['cid'],
         ]);
+        UserRelation::create($routineUser);
         $res = $res1 && $res2;
         self::checkTrans($res);
         return $res2;
@@ -279,8 +280,7 @@ class User extends BaseModel
             'cid'    => $WechatUser['cid'],
         ]);
         $WechatUser['user_id'] = $res2['id'];
-        $WechatUser['user_type'] = $WechatUser['login_type'];
-        unset( $WechatUser['login_type']);
+        $WechatUser['login_type'] = $WechatUser['login_type'];
         UserRelation::create($WechatUser);
         $res = $res1 && $res2;
         self::checkTrans($res);

+ 2 - 2
application/common/model/training/Training.php

@@ -47,8 +47,8 @@ class Training extends Model
         $model = new self;
         if(isset($where['cid']) && $where['cid']>0) $model->where('cid',$where['cid']);
         if(isset($where['status']) && $where['status']>-2) $model->where('status',$where['status']);
-        $model = $model->where('reg_start','<',time())->where('reg_end','>',time());
-        $data = $model->order('id desc')->page($where['page'],$where['limit'])->select();
+        $model = $model->where('reg_start','<',date("Y-m-d H:i:s"))->where('reg_end','>',date("Y-m-d H:i:s"));
+        $data = $model->order('id desc')->page($where['page'],$where['limit'])->field("id,title,image,info,reg_start,reg_end,max_number,number")->select();
         return $data;
     }
     public static function info($cid,$id)

+ 2 - 0
application/route.php

@@ -30,6 +30,7 @@ Route::group('api', function () {
         Route::get('children/num', 'api/User/children_num');
         Route::get('children/:id', 'api/User/children');
         Route::get('spread_children/:id', 'api/User/spread_children');
+        Route::post('setuser', 'api/User/setuser'); //会员申请
     });
     //首页
     Route::group('index', function () {
@@ -124,6 +125,7 @@ Route::group('api', function () {
 
 
 
+
 });
 return [
 

+ 1 - 1
public/assets/js/backend/article/article.js

@@ -56,7 +56,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Controller.api.bindevent();
         },
         edit: function () {
-      
+
             $("#c-article_category_id").data("params", function (obj) {
                 return {custom: {cid: $("#c-cid").val()},isTree:1};
             });

+ 6 - 0
public/assets/js/backend/project/project_donation_info.js

@@ -42,9 +42,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Table.api.bindevent(table);
         },
         add: function () {
+            $("#c-pro_id").data("params", function (obj) {
+                return {custom: {cid: $("#c-cid").val()}};
+            });
             Controller.api.bindevent();
         },
         edit: function () {
+            $("#c-pro_id").data("params", function (obj) {
+                return {custom: {cid: $("#c-cid").val()}};
+            });
             Controller.api.bindevent();
         },
         api: {