request->isPost()) { // code 前端获取,传递给接口 $params = $this->request->post('code'); //获取手机号 $result['phone'] = MpService::getInstance()->getPhoneNumber($params); if (!empty($result)) { $this->success('success', $result); } else { $this->error('error'); } } } //学生信息获取 public function RegisterEdit(): void { if ($this->request->isPost()) { $data = $this->request->post(); try { $user=Db::name('student')->where('student_phone',$data['student_phone'])->find(); if ($user) { // 更新用户 $result=Db::name('student')->where('student_phone', $data['student_phone'])->update(['student_name' => $data['student_name'],'student_class' => $data['student_class']]); $this->success('success', $result); } else { // 新增用户 $result=Db::name('student')->save($data); $this->success('success', $result); } } catch (Throwable $e) { $this->error($e->getMessage()); } } } }