[ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => [], 'allow' => true, 'roles' => ['@'], ], ], ], ]; } public function actions() { return [ // 'error' => [ // 'class' => 'yii\web\ErrorAction', // ], 'captcha' => [ 'class' => 'yii\captcha\CaptchaAction', 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, 'maxLength' => 4, //生成的验证码最大长度 'minLength' => 4 //生成的验证码最短长度 ], ]; } //个人中心 public function actionIndex() { $userid = YII::$app->user->id; $datas = UserInfo::find()->where('uid=:uid',[':uid'=>$userid])->one(); return $this->render('index',['datas'=>$datas]); } //用户详情 public function actionUserinfo() { $userid = YII::$app->user->id; $tel = User::find()->where('id=:uid',[':uid'=>$userid])->one(); $datas = UserInfo::find()->where('uid=:uid',[':uid'=>$userid])->one(); $picture_form = new LMUploadFile(); return $this->render('userinfo',['datas'=>$datas,'tel'=>$tel,"picture_form" => $picture_form]); } /** * 上传头像 */ public function actionPortraitimgurl() { if (Yii::$app->request->isPost) { $picture_form = new LMUploadFile(); $picture_form->imageFile = UploadedFile::getInstance($picture_form, 'imageFile'); if ($picture_form->upload('portrait_picture',false,160,160)) { return ""; } else { if(isset($picture_form->getErrors()['imageFile'][0])){ $error = $picture_form->getErrors()['imageFile'][0]; }else{ $error = '图片上传失败'; } return ""; } } } //修改头像 public function actionEdit_portrait() { $userid = YII::$app->user->id; $portrait = Yii::$app->request->post('portrait'); $model = UserInfo::find()->where('uid=:id',[':id'=>$userid])->one(); if(!empty($portrait)){ if(!empty($model)){ $model->updated_at = time(); $model->portrait = $portrait; if($model->validate() && $model->save()){ $result=['sign'=>1,'msg'=>'ok']; }else{ // var_dump($model->getErrors());exit; $result=['sign'=>0,'msg'=>'error']; } }else{ $result=['sign'=>0,'msg'=>'找不到该规格']; } }else{ $result=['sign'=>0,'msg'=>'头像路径不能为空']; } return json_encode($result); } //修改昵称 public function actionEdit_nickname() { $userid = YII::$app->user->id; $nickname = Yii::$app->request->post('nickname'); $model = UserInfo::find()->where('uid=:id',[':id'=>$userid])->one(); if(!empty($nickname)){ if(!empty($model)){ $model->updated_at = time(); $model->nickname = $nickname; if($model->validate() && $model->save()){ $result=['sign'=>1,'msg'=>'ok']; }else{ // var_dump($model->getErrors());exit; $result=['sign'=>0,'msg'=>'error']; } }else{ $result=['sign'=>0,'msg'=>'找不到该规格']; } }else{ $result=['sign'=>0,'msg'=>'昵称不能为空']; } return json_encode($result); } //修改电话 public function actionEdit_tel() { $userid = YII::$app->user->id; $tel = Yii::$app->request->post('tel'); $model = UserInfo::find()->where('uid=:id',[':id'=>$userid])->one(); if(!empty($tel)){ if(!empty($model)){ $model->updated_at = time(); $model->tel = $tel; if($model->validate() && $model->save()){ $result=['sign'=>1,'msg'=>'ok']; }else{ // var_dump($model->getErrors());exit; $result=['sign'=>0,'msg'=>'error']; } }else{ $result=['sign'=>0,'msg'=>'找不到该规格']; } }else{ $result=['sign'=>0,'msg'=>'昵称不能为空']; } return json_encode($result); } //设置页面 public function actionAccountmanage() { return $this->render('accountmanage'); } //意见反馈页面 public function actionFeekback() { return $this->render('feekback'); } /**首页意见提交*/ public function actionAdvice(){ $contact = Yii::$app->request->post('contact'); $describe = Yii::$app->request->post('describe'); if(!empty($describe)&&!empty($contact)){ if(preg_match("/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/", $contact)){ $data = new Feedback(); $data->contact = $contact; $data->content = $describe; $data->uid = Yii::$app->user->id; $data->type = Feedback::TYPE_CLIENT; $data->created_at = time(); $data->updated_at = time(); $data->state = Feedback::STATE_WAIT; $data->status = Feedback::STATUS_ACTIVE; if($data->validate() && $data->save()){ $result=['sign'=>1,'msg'=>'已提交意见,待审核']; }else{ $result=['sign'=>0,'msg'=>'提交失败,请重新提交']; } }else{ $result=['sign'=>0,'msg'=>'邮箱格式不正确']; } }else{ $result=['sign'=>0,'msg'=>'内容和联系方式不能为空']; } return json_encode($result); } //关于我们页面 public function actionAboutwe() { $model = Information::find()->where(['status'=>Information::STATUS_ACTIVE ,'type'=>Information::ABOUTWE])->offset(0)->limit(1)->orderBy('updated_at DESC')->one(); return $this->render('aboutwe',['model'=>$model]); } //我的评价页面 public function actionComment() { $userid = YII::$app->user->id; $datas = Comment::find()->where('uid=:id',[':id'=>$userid])->orderBy('created_at desc')->all(); return $this->render('comment',['datas'=>$datas]); } /**回复评价*/ public function actionReply(){ $content = Yii::$app->request->post('content'); $id = Yii::$app->request->post('id'); $pid = Yii::$app->request->post('pid'); $result=['sign'=>0,'msg'=>'']; if(!empty($content)){ if(!empty($id)){ if(!empty($pid)){ $data = Building::find()->where('id=:id',[':id'=>$pid])->one(); if(!empty($data)){ $manager_id = $data->manager_id; $manager = Manager::find()->where('id=:id',[':id'=>$manager_id])->one(); if(!empty($manager)){ $companyid = $manager->company; $company = UserCompany::find()->where('uid=:id',[':id'=>$companyid])->one(); if(!empty($company)){ $model = new Reply(); $touserid = $company->uid; $model->from_userid = Yii::$app->user->id; $model->cid = $id; $model->to_userid = $touserid; $model->content = $content; $model->created_at = time(); $model->status = Reply::STATUS_ACTIVE; if($model->validate() && $model->save()){ $result=['sign'=>1,'msg'=>'已回复']; }else{ $result=['sign'=>0,'msg'=>'回复失败']; } }else{ $result=['sign'=>0,'msg'=>'公司不存在']; } }else{ $result=['sign'=>0,'msg'=>'公司项目经理不存在']; } }else{ $result=['sign'=>0,'msg'=>'房产pid数据有误']; } } }else{ $result=['sign'=>0,'msg'=>'评价id不能为空']; } }else{ $result=['sign'=>0,'msg'=>'内容不能为空']; } return json_encode($result); } //我的预约页面 public function actionAppointment() { $cookie = Yii::$app->request->cookies; $latitude = ""; $longitude = ""; if($cookie->has('localtion')) { $lcookie = $cookie->getValue('localtion'); $latitude=$lcookie['lat']; $longitude=$lcookie['lng']; } $userid = YII::$app->user->id; $datas = Appointment::find()->joinWith('building')->where('bd_appointment.uid=:id',[':id'=>$userid])->orderBy('bd_appointment.booking_time desc')->asArray()->all(); //$datas = Appointment::find()->joinWith('building')->where('bd_appointment.uid=:id and bd_building.posted=:posted and bd_building.status=:status',[':id'=>$userid,':posted'=>Building::POSTED_YES,':status'=>Building::STATUS_SUCCESS])->orderBy('bd_appointment.booking_time desc')->asArray()->all(); $geohash = new ZM_Geohash(); for($i=0;$iselect('pic')->where('topid=:id and status=:status', [':id' => $buildid, ':status' => ImageSource::STATUS_YES])->andWhere(['type' => [20,30,40,50]])->asArray()->all(); $datas[$i]['image'] = $images; if(!empty($latitude)&&!empty($longitude)) { $distance = $geohash->getDistance($latitude,$longitude,$datas[$i]['building']['latitude'],$datas[$i]['building']['longitude']); $datas[$i]['distance'] = $distance; } } return $this->render('appointment',['datas'=>$datas]); } //用户电话绑定页面 public function actionUsertel() { $id = Yii::$app->request->get('id'); if(Yii::$app->request->post()){ $userid = YII::$app->user->id; $tel = Yii::$app->request->post('tel'); if(preg_match("/^1[34578]\d{9}$/", $tel)){ $telcheck = User::find()->where('tel=:tel and id=:id',[':tel'=>$tel,':id'=>$userid])->one(); if(empty($telcheck)) { $code = Yii::$app->request->post('code'); $mod = SortMessage::find()->where('tel=:tell and created_at >= :time',[':tell'=>$tel,':time'=>(time()-1800)])->orderBy('created_at DESC')->one(); if(!empty($mod)&&$code==$mod->code){ $model = User::find()->where('id=:id',[':id'=>$userid])->one(); $model->tel = $tel; $model->updated_at = time(); if($model->validate() && $model->save()){ if(empty($id)){ $this->admin_alert("绑定成功",Url::toRoute(['user/userinfo'])); }else{ if($id=='index'){ $this->admin_alert("绑定成功",Url::toRoute(['site/index'])); }else{ $this->admin_alert("绑定成功",Url::toRoute(['building/detail','id'=>$id])); } } }else{ $this->admin_alert("绑定失败",""); } }else{ $this->admin_alert("请先获取验证码",""); } }else{ $this->admin_alert("您已绑定该手机号",""); } }else{ $this->admin_alert("手机号码格式不正确",""); } } return $this->render('usertel',['id'=>$id]); } //弹窗提示 function admin_alert($alert,$href=''){ header('Content-type:text/html;charset=utf-8'); if(empty($href)){ exit(""); }else{ exit(""); } } //验证注册图片验证码 public function actionYzm(){ $code = Yii::$app->request->post('code'); if(!empty($code)){ //$session = Yii::$app->session; //$code1 = $session['code']; $result = $this->createAction('captcha')->validate($code, false); if($result){ $result=['sign'=>1,'msg'=>'ok']; }else{ $result=['sign'=>0,'msg'=>'验证码不一致']; } }else{ $result=['sign'=>0,'msg'=>'验证码不能为空']; } return json_encode($result); } }