updateEvent('mode'); } /** * 交易设置 */ public function trade() { return $this->updateEvent('trade'); } /** * 配送设置 */ public function delivery() { return $this->updateEvent('delivery'); } /** * 其它设置 */ public function other() { return $this->updateEvent('other'); } /** * 微信小程序订阅消息设置 */ public function wxapptpl() { return $this->updateEvent('wxapptpl'); } /** * 微信公众号模板消息设置 */ public function wechattpl() { return $this->updateEvent('wechattpl'); } /** * 预约设置 */ public function pact() { return $this->updateEvent('pact'); } /** * 更新设置事件 */ private function updateEvent(string $key) { if (!$this->request->isAjax()) { $model = SettingModel::getItem($key); return View::fetch($key, compact('model')); } if($this->user['applet']['status']['value']==0 AND $key=='wxapptpl'){ return $this->renderError('请先绑定您的小程序'); } $model = new SettingModel; if($model->edit($key, $this->postData('data'))) { return $this->renderSuccess('更新成功'); } $error = $model->getError() ?: '添加失败'; return $this->renderError($error); } /** * 更新密码 */ public function renew() { $model = AppletModel::get($this->applet_id); if (!$this->request->isAjax()) { return View::fetch('renew', compact('model')); } if ($model->renew($this->postData('data'))) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); } }