asJson([ 'code' => 1, 'msg' => $res['response']['errmsg'], ]); } return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => $res['url_path'] . "?time=" . time(),//解决切换小程序appid后,前端图片显示的是旧的图片 ]); } catch (\Exception $e) { return $this->asJson([ 'code' => 1, 'msg' => $e->getMessage(), ]); } } /** * 登录 * * @return void */ public function actionWxLogin() { set_time_limit(0); $wechat_config = WechatConfig::findOne(['store_id' => get_store_id(), 'type' => 1]); $url = $this->url . 'login.php'; $is_wxlive = post_params('is_wxlive', 0); $is_student = post_params('is_student', 0); $host = str_replace(['http://', 'https://'], ['', ''], \Yii::$app->request->hostInfo); $ws_url = isset(\Yii::$app->params['ws_url']) ? \Yii::$app->params['ws_url'] : 'ws.cyyvip.com'; $res = http_get($url, [ 'query' => [ 'type' => 'new_system', 'appid' => $wechat_config->app_id, 'http_url' => $host, 'is_live' => $is_wxlive, 'is_student' => $is_student, 'store_id' => get_store_id(), 'version' => cyy_version(), 'ws_url' => $ws_url, ] ]); if ($res->getStatusCode() != 200) { return $this->asJson([ 'code' => 1, 'msg' => '请求出错!', ]); } $content = json_decode((string)$res->getBody()); return $this->asJson($content); } /** * 获取预览码 * * @return void */ public function actionPreview($num = 1) { set_time_limit(0); $model = new WechatForm(); $model->store_id = get_store_id(); return $this->asJson($model->preview()); } /** * 上传小程序 * * @return void */ public function actionUpload() { set_time_limit(0); $model = new WechatForm(); $model->store_id = get_store_id(); return $this->asJson($model->upload()); } }