why.xingtongworld.com项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

608 lines
22 KiB

<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------
namespace app\home\controller;
use think\Db;
use think\Validate;
use Flc\Alidayu\Client;
use Flc\Alidayu\App;
use Flc\Alidayu\Requests\AlibabaAliqinFcSmsNumSend;
class Center extends Base{
protected $menus=[
1=>['title'=>'基本信息','jump'=>'home/Center/index.html'],
['title'=>'我的挂牌','jump'=>'home/Center/my.html'],
['title'=>'我的托管','jump'=>'home/Center/mytg.html'],
['title'=>'合作机构申请','jump'=>'home/Center/myorg.html'],
['title'=>'修改资料','jump'=>'home/Center/edit.html'],
['title'=>'系统通知','jump'=>'home/Center/notice.html'],
['title'=>'托管系统通知','jump'=>'home/Center/capnotice.html'],
['title'=>'我的申报','jump'=>'home/Center/cuapply.html'],
['title'=>'活动报名','jump'=>'home/Center/myact.html'],
['title'=>'活动通知','jump'=>'home/Center/actnotice.html'],
['title'=>'详细报告','jump'=>'home/Center/artverify.html'],
['title'=>'我的帖吧','jump'=>'home/Center/mybbs.html']
];
protected $prefix='';
protected $upload_path='';
protected function _initialize(){
parent::_initialize();
$this->prefix=config('database.prefix');
$this->upload_path=config('upload_path');
$user=session('user');
if(isset($user['member_list_groupid'])&&$user['member_list_groupid']==6){
array_push($this->menus, ['title'=>'待评分','jump'=>'home/Center/myscore']);
}
$this->assign('menus',$this->menus);
$this->check_login();
}
public function index(){
//判断是否激活
if(!$this->user['user_status']){
$current_user=$this->user;
$email = $current_user['member_list_email'];
$this->assign("email",$email);
$this->assign('current',['title'=>'账号激活']);
return $this->view->fetch('user:active');
}
$current=$this->menus[1];
$this->assign('current',$current);
$this->assign($this->user);
return $this->view->fetch('user:center');
}
//编辑用户资料
public function edit(){
$pid=$this->user['member_list_province'];
$cid=$this->user['member_list_city'];
$regions=Db::name('Region')->where('pid','in','1,'.$pid.','.$cid)->select ();
$province=[];
$city=[];
$town=[];
if(count($regions)){
foreach ($regions as $item){
switch ($item['pid']){
case 1:
array_push($province, $item);
break;
case $pid:
array_push($city, $item);
break;
case $cid:
array_push($town, $item);
break;
}
}
}
$this->assign('province',$province);
$this->assign('city',$city);
$this->assign('town',$town);
$this->assign($this->user);
$current=$this->menus[5];
$this->assign('current',$current);
return $this->view->fetch('user:edit');
}
public function runedit(){
if(request()->isPost()){
$post=input('post.');
$file = request()->file('member_list_headpic');
if($file->getInfo('size')>(10*1024*1024)){
$this->error('上传文件不能大于10M!');
}
if(!in_array(strtoupper(substr(strrchr($file->getInfo('name'), '.'), 1)),['PNG','JPG','GIF'])){
$this->error('上传文件类型错误!');
}
$validate = config('upload_validate');
if ($file) {
$info = $file->validate($validate)->rule('md5')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d'));
if ($info) {
$img_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename();
$post['member_list_headpic']=$img_url;
}
}
$rst=Db::name('member_list')->where(array('member_list_id'=>$this->user['member_list_id']))->update($post);
if ($rst!==false) {
$this->user=Db::name('member_list')->find($this->user['member_list_id']);
session('user',$this->user);
$this->success(lang('save success'),url("home/Center/edit"));
} else {
$this->error(lang('save failed'));
}
}
}
//修改密码
public function runchangepwd(){
if (request()->isPost()) {
$old_password=input('old_password');
$password=input('password');
$repassword=input('repassword');
if(empty($old_password)){
$this->error(lang('old pwd empty'));
}
if(empty($password)){
$this->error(lang('new pwd empty'));
}
if($password!==$repassword){
$this->error(lang('pwd not same'));
}
$member=Db::name('member_list');
$user=$member->where(array('member_list_id'=>$this->user['member_list_id']))->find();
$member_list_salt=$user['member_list_salt'];
if(encrypt_password($old_password,$member_list_salt)===$user['member_list_pwd']){
if(encrypt_password($password,$member_list_salt)==$user['member_list_pwd']){
$this->error(lang('new pwd the same as old pwd'));
}else{
$data['member_list_pwd']=encrypt_password($password,$member_list_salt);
$data['member_list_id']=$this->user['member_list_id'];
$rst=$member->update($data);
if ($rst!==false) {
$this->success(lang('revise success'),url('home/Center/index'));
} else {
$this->error(lang('revise failed'));
}
}
}else{
$this->error(lang('old pwd not correct'));
}
}
}
public function avatar(){
$imgurl=input('imgurl');
//去'/'
$imgurl=str_replace('/','',$imgurl);
$rst=Db::name('member_list')->where(array('member_list_id'=>$this->user['member_list_id']))->update(array('member_list_headpic'=>$imgurl));
if($rst!==false){
session('user_avatar',$imgurl);
$this->user['member_list_headpic']=$imgurl;
$url='/data/upload/avatar/'.$imgurl;
//写入数据库
$data['uptime']=time();
$data['filesize']=filesize('./'.$url);
$data['path']=$url;
Db::name('plug_files')->insert($data);
$this->success (lang('avatar update success'),url('home/Center/index'));
}else{
$this->error (lang('avatar update failed'),url('home/Center/index'));
}
}
public function bang(){
$oauth_user_model=Db::name("OauthUser");
$oauths=$oauth_user_model->where(array("uid"=>$this->user['member_list_id']))->select();
$new_oauths=array();
foreach ($oauths as $oa){
$new_oauths[strtolower($oa['oauth_from'])]=$oa;
}
$this->assign("oauths",$new_oauths);
return $this->view->fetch('user:bang');
}
public function my(){
$lists=Db::name('cult4apply')->alias("a")
->join($this->prefix.'cult4baseinfo b','a.apply_id =b.apply_id')
->join($this->prefix.'cult4status c','a.status =c.status')
->where(['user_id'=>session('hid'),'b.new_flag'=>1])->order('a.apply_id desc')->paginate(config('paginate.list_rows'));
$show=$lists->render();
$apply_time =Db::name('cult4apply')->alias("a")
->join($this->prefix.'cult4baseinfo b','a.apply_id =b.apply_id')
->join($this->prefix.'cult4status c','a.status =c.status')
->where(['user_id'=>session('hid'),'b.new_flag'=>1])->where('a.status','neq','31')->order('a.apply_id desc')->find();
if(!empty($apply_time) && strtotime("+10 days",$apply_time['create_time'])>time()){
$this->assign('apply_time',date('Y-m-d H:i:s',strtotime("+10 days",$apply_time['create_time'])));
}
$this->assign('page',$show);
$this->assign("lists",$lists);
$current=$this->menus[2];
$this->assign('current',$current);
return $this->view->fetch('user:my');
}
public function myscore(){
$current=$this->menus[8];
$this->assign('current',$current);
return $this->view->fetch('user:myscore');
}
//发送短信验证码
public function sendsms(){
$account=input('account','');
$where['sms_type']='edittel';
$where['sms_tel']=$account;
$rst=Db::name('smslog')->where($where)->find();
if($rst){
if($rst['sms_time']>(time()-120)){
return json(['code'=>0,'msg'=>'已获取过,'.(time()-$rst['sms_time']).'后稍后再试']);
}
}
$rst_sms=false;
$error='未设置短信平台配置';
$code=random(6,'number');
if(config('alisms.on')){
$client = new Client(new App(config('alisms')));
$req = new AlibabaAliqinFcSmsNumSend;
$req->setRecNum($account)
->setSmsParam([
'number' => $code
])
->setSmsFreeSignName(config('alisms.signName'))
->setSmsTemplateCode(config('alisms.TemplateCode'));
$resp = $client->execute($req);
if($resp->result->success){
$rst_sms=true;
}else{
$error=$resp->sub_msg;
}
}elseif(config('ymsms.on')){
//$arr=send_sms($account,'【'.config('ymsms.signname').'】您好,您修改新手机号的验证码为'.$code.',验证码2分钟内有效!');
$arr=send_sms($account,'您好,您修改新手机号的验证码为'.$code.',验证码2分钟内有效!');
if($arr['code']==1){
$rst_sms=true;
}else{
$error=$arr['msg'];
}
}
if($rst_sms){
if($rst){
//更新
$rst['sms_time']=time();
$rst['sms_code']=$code;
$rst=Db::name('smslog')->update($rst);
if($rst!==false){
return json(['code'=>1]);
}else{
return json(['code'=>0,'msg'=>'获取失败,请重试']);
}
}else{
//插入数据库
$data=[
'sms_type'=>'edittel',
'sms_tel'=>$account,
'sms_time'=>time(),
'sms_code'=>$code
];
$rst=Db::name('smslog')->insert($data);
if($rst){
return json(['code'=>1]);
}else{
return json(['code'=>0,'msg'=>'获取失败,请重试']);
}
}
}else{
return json(['code'=>0,'msg'=>$error]);
}
}
public function changetel(){
$uid=session('hid');
$member_list_tel=input('member_list_tel');
$verify=input('verify','');
$where['sms_type']='edittel';
$where['sms_tel']=$member_list_tel;
$where['sms_time']=['>',time()-120];
$rst=Db::name('smslog')->where($where)->find();
if(!$rst || $rst['sms_code']!=$verify) $this->error(lang('verifiy incorrect'),url('home/Center/edit'));
$rule = [
['member_list_tel','require','手机号必须']
];
$validate = new Validate($rule);
$rst = $validate->check(array(
'member_list_tel'=>$member_list_tel
));
if(true !==$rst){
$error=is_array($validate->getError())?join('|',$validate->getError()):$validate->getError();
$this->error($error,url('home/Center/edit'));
}
$rst=Db::name('member_list')->where('member_list_id',$uid)->update(['member_list_tel'=>$member_list_tel]);
if($rst!==false){
$this->success ('修改成功',url('home/Center/edit'));
}else {
$this->error('修改失败',url('home/Center/edit'));
}
}
public function notice(){
//判断是否激活
if(!$this->user['user_status']){
$current_user=$this->user;
$email = $current_user['member_list_email'];
$this->assign("email",$email);
return $this->view->fetch('user:active');
}
$lists=Db::name('cult4notice')->alias('a')
->where(['a.user_id'=>session('hid')])
->order('a.create_time desc')
->field('a.*')
->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page',$show);
$this->assign("lists",$lists);
$current=$this->menus[6];
$this->assign('current',$current);
return $this->view->fetch('user:notice');
}
public function capnotice(){
$lists=Db::name('capitalnotice')->alias('a')
->where(['a.user_id'=>session('hid')])
->order('a.create_time desc')
->field('a.*')
->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page',$show);
$this->assign("lists",$lists);
$current=$this->menus[7];
$this->assign('current',$current);
return $this->view->fetch('user:capnotice');
}
public function actnotice(){
$lists=Db::name('activitynotice')->alias('a')
->where(['a.user_id'=>session('hid')])
->order('a.create_time desc')
->field('a.*')
->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page',$show);
$this->assign("lists",$lists);
$current=$this->menus[10];
$this->assign('current',$current);
return $this->view->fetch('user:actnotice');
}
public function capnotice_r(){
$notice_id=input('notice_id',0,'intval');
if(!$notice_id) $this->error('通知不存在',url('home/Center/capnotice'));
//设置为已读
Db::name('capitalnotice')->update(['notice_id'=>$notice_id,'is_read'=>1]);
}
public function actnotice_r(){
$notice_id=input('notice_id',0,'intval');
if(!$notice_id) $this->error('通知不存在',url('home/Center/actnotice'));
//设置为已读
Db::name('activitynotice')->update(['notice_id'=>$notice_id,'is_read'=>1]);
}
public function notice_r(){
$notice_id=input('notice_id',0,'intval');
if(!$notice_id) $this->error('通知不存在',url('home/Center/notice'));
$list=Db::name('cult4notice')->find($notice_id);
if(!$list) $this->error('通知不存在',url('home/Center/notice'));
if($list['create_type']==0){
$user_notice=Db::name('member_list')->field('member_list_nickname,member_list_username,member_list_headpic')->find($list['create_id']);
}else{
$user_notice=Db::name('admin')->field('admin_realname,admin_username,admin_avatar')->find($list['create_id']);
}
$this->assign("list",$list);
$this->assign("user_notice",$user_notice);
//设置为已读
Db::name('cult4notice')->update(['notice_id'=>$notice_id,'is_read'=>1]);
return $this->view->fetch('user:notice_r');
}
public function need_jzdc(){
$lists=Db::name('cult4apply')->alias("a")
->join($this->prefix.'cult4baseinfo b','a.apply_id =b.apply_id')
->join($this->prefix.'cult4status c','a.status =c.status')
->where(['b.new_flag'=>1,'a.status'=>2,'member_recmd'=>session('hid')])
->order('a.apply_id desc')->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page',$show);
$this->assign("lists",$lists);
return $this->view->fetch('user:jzdc');
}
public function need_pro(){
$lists=Db::name('cult4apply')->alias("a")
->join($this->prefix.'cult4baseinfo b','a.apply_id =b.apply_id')
->join($this->prefix.'cult4status c','a.status =c.status')
->join($this->prefix.'cult4proassign d','d.apply_id=a.apply_id')
->where(['b.new_flag'=>1,'a.status'=>15,'d.user_id'=>session('hid'),'d.del_flag'=>0])
->order('a.apply_id desc')->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page',$show);
$this->assign("lists",$lists);
return $this->view->fetch('user:pro');
}
public function mytg(){
$current=$this->menus[3];
$this->assign('current',$current);
return $this->view->fetch('user:mytg');
}
public function myorg(){
$lists=Db::name('org_apply')->alias("a")
->join($this->prefix.'org_status c','a.status =c.status')
->where(['a.uid'=>session('hid')])->order('a.id desc')->paginate(config('paginate.list_rows'));
$apply_time =Db::name('org_apply')->where('status','neq','10' )->where(['uid'=>session('hid')])->find();
if(!empty($apply_time) && strtotime("+10 days",$apply_time['create_time'])>time()){
$this->assign('apply_time',date('Y-m-d H:i:s',strtotime("+10 days",$apply_time['create_time'])));
}
$show=$lists->render();
$this->assign('page',$show);
$this->assign("lists",$lists);
$current=$this->menus[4];
$this->assign('current',$current);
return $this->view->fetch('user:myorg');
}
/**
*活动报名
*/
public function myact(){
$lists=Db::name('activityapply')->alias('a')
->join($this->prefix.'activity c','c.id =a.aid')
->where(['a.uid'=>session('hid')])
->order('a.create_time desc')
->field('c.title,c.id,a.create_time')
->group("a.aid")
->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page',$show);
$this->assign("lists",$lists);
$current=$this->menus[9];
$this->assign('current',$current);
return $this->view->fetch('user:myact');
}
/**
*活动报名
*/
public function mybbs(){
$lists=Db::name('bbslist')
->where(['mid'=>session('hid')])
->order('update_time desc,id desc')
->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page1',$show);
$this->assign("lists",$lists);
$lists=Db::name('bbslog')
->where(['mid'=>session('hid')])
->order('update_time desc,id desc')
->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page2',$show);
$this->assign("logs",$lists);
$current=$this->menus[12];
$this->assign('current',$current);
$uid=session('hid');
$where=['uid|rid'=>$uid,'status'=>1];
$list=db('bbsask')->where($where)->order('id desc')->paginate(config('paginate.list_rows'));
$show = $list->render();
if(count($list)){
$list=$list->toArray();
$data=$list['data'];
foreach ($data as $k=>$row){
$nickname='';
$poster='';
$sid=$row['rid'];
if($uid==$row['rid']){
$sid=$row['uid'];
}
$find=Db::name('member_list')->field('member_list_nickname,member_list_headpic')->where(['member_list_id'=>$sid])->find();
if($find){
$nickname=$find['member_list_nickname'];
$poster=$find['member_list_headpic'];
}
$data[$k]['nickname']=$nickname;
$data[$k]['poster']=$poster;
}
$list=$data;
}
$this->assign("list",$list);
$this->assign("page3",$show);
$this->assign("uid",$uid);
return $this->view->fetch('user:mybbs');
}
public function delcom(){
$mid=session("hid");
$id=input('id');
if(!$id){$this->error("缺少参数");}
$find=Db::name('bbslog')->where(['mid'=>$mid,'id'=>$id])->delete();
if(!$find){
$this->error('删除失败');
}else{
$this->success('删除成功');
}
}
public function savecom(){
$mid=session("hid");
$id=input('id');
$content=input("content");
if(!$id||!$content){$this->error("缺少参数");}
$find=Db::name('bbslog')->where(['mid'=>$mid,'id'=>$id])->update(['content'=>$content]);
if(!$find){
$this->error('更新失败');
}else{
$this->success('更新成功');
}
}
/**
* 我的申请
*/
public function cuapply(){
$lists=Db::name('cultureapply')->alias('a')
->where(['a.user_id'=>session('hid')])
->order('a.create_time desc')
->field('a.*')
->paginate(config('paginate.list_rows'));
$show=$lists->render();
if(count($lists)){
$lists=$lists->toArray();
$lists=$lists['data'];
foreach ($lists as $k=>$doc){
$doc['create_time']=date("Y-m-d",$doc['create_time']);
if($doc['company']==1)$doc['company']='中央政府部门所属机构';
if($doc['company']==2)$doc['company']='国有独资企业';
if($doc['company']==3)$doc['company']='国有控股企业';
if($doc['company']==4)$doc['company']='股份有限公司';
if($doc['company']==5)$doc['company']='股份有限公司';
if($doc['company']==6)$doc['company']='其他';
$legal=$doc['legal'];
try {
$legal=json_decode($legal,true);
} catch (Exception $e) {
}
if(!is_array($legal))$legal=[];
$doc['legal']=$legal;
$org=$doc['org'];
try {
$org=json_decode($org,true);
} catch (Exception $e) {
}
if(!is_array($org))$org=[];
$doc['org']=$org;
$cont=$doc['cont'];
try {
$cont=json_decode($cont,true);
} catch (Exception $e) {
}
if(!is_array($cont))$cont=[];
$doc['cont']=$cont;
$lists[$k]=$doc;
}
}
$this->assign('page',$show);
$this->assign("lists",$lists);
$current=$this->menus[8];
$this->assign('current',$current);
return $this->view->fetch('user:cuapply');
}
public function artverify(){
$lists=Db::name('artverify')->alias('a')
->where(['a.userid'=>session('hid')])
->order('a.create_time desc')
->field('a.*')
->paginate(config('paginate.list_rows'));
$show=$lists->render();
$this->assign('page',$show);
$this->assign("lists",$lists);
$current=$this->menus[11];
$this->assign('current',$current);
return $this->view->fetch('user:artverify');
}
}