IndexController.php
5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\admin\model\HospitalModel;
use app\admin\model\JobModel;
use app\portal\model\PortalPostModel;
use app\user\model\UserModel;
use cmf\controller\HomeBaseController;
use EasyWeChat\Foundation\Application;
use cmf\controller\WeChatBaseController;
use think\Log;
class IndexController extends WeChatBaseController
{
public function index()
{
$User=new UserModel();
$user=$User->getUserInfo();
if (empty($user['user_login'])){
$targetUrl=url('register');
header('location:'. $targetUrl);
}
$Article=new PortalPostModel();
$article=$Article->getRecommend()->toArray();
$this->assign('article',$article);
return $this->fetch();
}
public function register()
{
/*检查用户是否注册成功*/
$User=new UserModel();
$user=$User->getMyself()->toArray();
if($user['user_login']!=null){
$this->error('已经注册过相关信息!','/');
}
$Hospital = new HospitalModel();
$hospital = $Hospital->getHospital();
$platform = $Hospital->getPlatment()->toArray();
$Job = new JobModel();
$jobs = $Job->getJob()->toArray();
$this->assign('jobs', $jobs);
$this->assign('platform', $platform);
$this->assign('hospital', $hospital);
return $this->fetch();
}
public function registerPost(){
$info=input();
/*验证验证码*/
$check=cmf_check_verification_code($info['tel'], $info['verify_code'], $clear = false);
if (!empty($check)){
$this->error($check);
}
/*验证器检查参数*/
$result = $this->validate($info, 'admin/Register');
if ($result !== true) {
$this->error($result);
}
/*查找openid用户进行添加信息*/
$user_id=cmf_get_current_user_id();
if (empty($user_id)){
$this->error('内部错误');
}else{
/*添加相应的信息到用户表*/
$insert['platform']=$info['platform'];
$insert['hospital']=$info['hospital'];
$insert['office']=$info['office'];
$insert['job']=$info['job'];
$insert['province']=$info['province'];
$insert['city']=$info['city'];
$insert['town']=$info['town'];
$insert['mobile']=$info['tel'];
$insert['user_login']=$info['user_name'];
$User=new UserModel();
$result=$User->register($user_id,$insert);
if ($result==1){
addScore($user_id,100,'注册完善信息');
$this->success('注册成功!');
}else{
$this->error('注册失败!');
}
}
}
/**
* 发送短信验证码
* @param $tel
*/
public function sendVerifyCode(){
$tel=input('tel');
$code=cmf_get_verification_code($tel, $length = 6);
if ($code===false){
$this->error('短信发送失败!');
}
$text='【金域医聊圈】您好,您的验证为'.$code.',请于5分钟内使用,如非本人操作,可忽略此消息。';
$data = array(
'content' => $text,
'mobile' => $tel,
'productid' => '676767',
'xh' => ''
);
$return=send_sms($data);
$ret=explode(',',$return);
if ($ret[0]=='1'){
cmf_verification_code_log($tel,$code);
$this->success('验证码已经发送成功');
}else{
$info=date('Y-m-d H:i:s')." 短信发送失败 error:".$return;
Log::write($info,'ERROR');
$this->error('短信发送失败!');
}
}
/**
* 平台
*/
public function platform()
{
$this->success('');
}
/**
* 专家搜索
*/
public function search()
{
return $this->fetch();
}
/**
* 获取平台下的医院
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHospital(){
$platform=input('platform');
if(empty($platform)){
$this->error();
}
$Hospital=new HospitalModel();
$hospital=$Hospital->getHospitalByPaltform($platform);
$this->success('','',$hospital);
}
public function getOffice(){
$platform_id=input('platform_id');
$hospital_id=input('hospital_id');
if (empty($platform_id)||empty($hospital_id)){
$this->error('缺少参数');
}
$Hospital=new HospitalModel();
$office=$Hospital->getOfficeByHP($platform_id,$hospital_id);
$this->success('','',$office);
}
public function getJob(){
}
}