public function actionLuck() { $this->layout = 'wap'; $gh_id = U::getSessionParam('gh_id'); $openid = U::getSessionParam('openid'); Yii::$app->wx->setGhId($gh_id); $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if ($model === null) { $model = new MUser(); $subscribed = false; } else { if ($model->subscribe) { $subscribed = true; } else { $subscribed = false; } } if (!Yii::$app->user->isGuest) { $username = Yii::$app->user->identity->username; } else { $username = ''; } $result = ''; $lucy_msg = []; if ($model->load(Yii::$app->request->post())) { if (Yii::$app->user->isGuest) { $username = $model->mobile; } $loca = file_get_contents("http://api.showji.com/Locating/www.show.ji.c.o.m.aspx?m=" . $model->mobile . "&output=json&callback=querycallback"); $loca = substr($loca, 14, -2); $loca = json_decode($loca, true); $lucy_msg = U::getMobileLuck($model->mobile); $lucy_msg['Mobile'] = $model->mobile; $result = $this->renderPartial('luck_result', ['loca' => $loca, 'lucy_msg' => $lucy_msg]); } return $this->render('luck', ['model' => $model, 'result' => $result, 'lucy_msg' => $lucy_msg, 'subscribed' => $subscribed, 'username' => $username]); }