User.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\library\Ems;
  5. use app\common\library\Sms;
  6. use app\common\library\Wechat;
  7. use app\common\service\UserService;
  8. use fast\Random;
  9. use think\Exception;
  10. use think\Log;
  11. use think\Validate;
  12. use miniprogram\wxBizDataCrypt;
  13. use onlogin\onlogin;
  14. use think\Db;
  15. /**
  16. * 会员接口
  17. */
  18. class User extends Api
  19. {
  20. protected $noNeedLogin = ['login', 'onLogin', 'mobilelogin', 'register', 'resetpwd', 'changemobile', 'third', 'getUserOpenid', 'wxMiniProgramLogin','getNickName','wechatlogin','bindmobile'];
  21. protected $noNeedRight = '*';
  22. public function _initialize()
  23. {
  24. parent::_initialize();
  25. }
  26. /**
  27. * 会员中心
  28. */
  29. public function index()
  30. {
  31. $this->success('', ['welcome' => $this->auth->nickname]);
  32. }
  33. /**
  34. * 手机验证码登录
  35. *
  36. * @param string $mobile 手机号
  37. * @param string $captcha 验证码
  38. */
  39. public function mobilelogin()
  40. {
  41. $mobile = input('mobile');
  42. $captcha = input('captcha');
  43. if (!$mobile || !$captcha) {
  44. $this->error(__('Invalid parameters'));
  45. }
  46. if (!Validate::regex($mobile, "^1\d{10}$")) {
  47. $this->error(__('Mobile is incorrect'));
  48. }
  49. if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
  50. $this->error(__('Captcha is incorrect'));
  51. }
  52. $user = \app\common\model\User::getByMobile($mobile);
  53. if ($user) {
  54. if ($user->status == -1) {
  55. $this->error('账户已注销');
  56. }
  57. if ($user->status != 1) {
  58. $this->error(__('Account is locked'));
  59. }
  60. //如果已经有账号则直接登录
  61. $is_register = 0;
  62. $ret = $this->auth->direct($user->id);
  63. } else {
  64. $is_register = 1;
  65. $ret = $this->auth->register($mobile, Random::alnum(), $mobile, []);
  66. }
  67. if ($ret) {
  68. Sms::flush($mobile, 'mobilelogin');
  69. // $data = ['is_register' => $is_register, 'userinfo' => $this->auth->getUserinfo()];
  70. $this->success(__('Logged in successful'), $this->auth->getUserinfo());
  71. } else {
  72. $this->error($this->auth->getError());
  73. }
  74. }
  75. //苹果登录+注册
  76. public function applelogin(){
  77. $iosUserId = input('ios_user_id','');
  78. if(!$iosUserId){
  79. $this->error(__('Invalid parameters'));
  80. }
  81. $user = Db::name('user')->where('ios_user_id',$iosUserId)->find();
  82. if ($user) {
  83. if ($user['status'] == -1) {
  84. $this->error('账户已经注销');
  85. }
  86. if ($user['status'] != 1) {
  87. $this->error(__('Account is locked'));
  88. }
  89. //如果已经有账号则直接登录
  90. $ret = $this->auth->direct($user['id']);
  91. } else {
  92. $ret = $this->auth->ios_register($iosUserId);
  93. }
  94. if ($ret) {
  95. $this->success(__('Logged in successful'), $this->auth->getUserinfo());
  96. } else {
  97. $this->error($this->auth->getError());
  98. }
  99. }
  100. /*
  101. * 修改用户的坐标
  102. * */
  103. public function change_longlat(){
  104. $longitude = input('longitude',0);
  105. $latitude = input('latitude',0);
  106. if(empty($longitude) || empty($latitude)){
  107. $this->error();
  108. }
  109. $data = [
  110. 'longitude' => $longitude,
  111. 'latitude' => $latitude,
  112. ];
  113. Db::name('user')->where('id',$this->auth->id)->update($data);
  114. $this->success();
  115. }
  116. /**
  117. * 绑定用户
  118. */
  119. public function bindUser()
  120. {
  121. $invite_no = input('invite_no'); // 邀请码
  122. if (!$invite_no) {
  123. $this->error("请输入邀请码!");
  124. }
  125. $user_id = $this->auth->id;
  126. if(!empty($this->auth->pre_userid)){
  127. $this->error('您已经填写过邀请人');
  128. }
  129. // 查询邀请码用户信息
  130. $inviteUserInfo = \app\common\model\User::where(["invite_no" => $invite_no])->find();
  131. if (!$inviteUserInfo) {
  132. $this->error("查询不到该邀请码用户信息!");
  133. }
  134. //判断邀请码用户不能是自己的下级
  135. if ($inviteUserInfo['pre_userid'] == $user_id) {
  136. throw new Exception('对方已被您邀请过');
  137. }
  138. if ($inviteUserInfo->id == $user_id) $this->error("不能邀请自己哦!");
  139. //if ($inviteUserInfo->is_auth != 2) $this->error("该邀请码用户尚未完成实名认证");
  140. //邀请奖励
  141. $res = \app\common\model\User::update(["pre_userid" => $inviteUserInfo->id], ["id" => $user_id]);
  142. if ($res) {
  143. $this->success("恭喜,绑定成功!");
  144. } else {
  145. $this->success("网络繁忙,请稍后重试!");
  146. }
  147. }
  148. /**
  149. * 退出登录
  150. */
  151. public function logout()
  152. {
  153. $this->auth->logout();
  154. $this->success(__('Logout successful'));
  155. }
  156. /**
  157. * 修改会员个人信息
  158. *
  159. * @ApiMethod (POST)
  160. * @param string $avatar 头像地址
  161. * @param string $username 用户名
  162. * @param string $nickname 昵称
  163. * @param string $bio 个人简介
  164. */
  165. public function profile()
  166. {
  167. $field_array = ['avatar','nickname','desc','age_id','gender','job_id','province_id','city_id','has_info'];
  168. $data = [];
  169. foreach($field_array as $key => $field){
  170. //前端传不了post,改了
  171. if(!request()->has($field,'post')){
  172. continue;
  173. }
  174. /*if(!input('?'.$field)){
  175. continue;
  176. }*/
  177. $newone = input($field);
  178. if($field == 'avatar'){
  179. $newone = input('avatar', '', 'trim,strip_tags,htmlspecialchars');
  180. }
  181. $data[$field] = $newone;
  182. }
  183. if(empty($data)){
  184. $this->error('没有任何改变');
  185. }
  186. /*if (!empty($data['nickname']) && !empty($data['avatar']) && !empty($data['age_id']) && $data['has_info']==0) {
  187. $data['has_info'] = 1;
  188. }*/
  189. Db::startTrans();
  190. $update_rs = Db::name('user')->where('id',$this->auth->id)->update($data);
  191. if($update_rs === false){
  192. Db::rollback();
  193. $this->error('修改资料失败');
  194. }
  195. Db::commit();
  196. $this->success();
  197. }
  198. /**
  199. * 修改手机号
  200. *
  201. * @param string $mobile 手机号
  202. * @param string $captcha 验证码
  203. */
  204. public function changemobile()
  205. {
  206. $user = $this->auth->getUser();
  207. $mobile = input('mobile');
  208. $captcha = input('captcha');
  209. if (!$mobile || !$captcha) {
  210. $this->error(__('Invalid parameters'));
  211. }
  212. if (!Validate::regex($mobile, "^1\d{10}$")) {
  213. $this->error(__('Mobile is incorrect'));
  214. }
  215. if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
  216. $this->error(__('Mobile already exists'));
  217. }
  218. $result = Sms::check($mobile, $captcha, 'changeMobile');
  219. if (!$result) {
  220. $this->error(__('Captcha is incorrect'));
  221. }
  222. $verification = $user->verification;
  223. $verification->mobile = 1;
  224. $user->verification = $verification;
  225. $user->mobile = $mobile;
  226. $user->save();
  227. Sms::flush($mobile, 'changeMobile');
  228. $this->success("手机号更换成功!");
  229. }
  230. /**
  231. * 重置密码
  232. *
  233. * @param string $mobile 手机号
  234. * @param string $newpassword 新密码
  235. * @param string $captcha 验证码
  236. */
  237. public function resetpwd()
  238. {
  239. $type = input("type");
  240. $mobile = input("mobile");
  241. $email = input("email");
  242. $newpassword = input("newpassword");
  243. $captcha = input("captcha");
  244. if (!$newpassword || !$captcha) {
  245. $this->error(__('Invalid parameters'));
  246. }
  247. if ($type == 'mobile') {
  248. if (!Validate::regex($mobile, "^1\d{10}$")) {
  249. $this->error(__('Mobile is incorrect'));
  250. }
  251. $user = \app\common\model\User::getByMobile($mobile);
  252. if (!$user) {
  253. $this->error(__('User not found'));
  254. }
  255. $ret = Sms::check($mobile, $captcha, 'resetpwd');
  256. if (!$ret) {
  257. $this->error(__('Captcha is incorrect'));
  258. }
  259. Sms::flush($mobile, 'resetpwd');
  260. } else {
  261. if (!Validate::is($email, "email")) {
  262. $this->error(__('Email is incorrect'));
  263. }
  264. $user = \app\common\model\User::getByEmail($email);
  265. if (!$user) {
  266. $this->error(__('User not found'));
  267. }
  268. $ret = Ems::check($email, $captcha, 'resetpwd');
  269. if (!$ret) {
  270. $this->error(__('Captcha is incorrect'));
  271. }
  272. Ems::flush($email, 'resetpwd');
  273. }
  274. //模拟一次登录
  275. $this->auth->direct($user->id);
  276. $ret = $this->auth->changepwd($newpassword, '', true);
  277. if ($ret) {
  278. $this->success(__('Reset password successful'));
  279. } else {
  280. $this->error($this->auth->getError());
  281. }
  282. }
  283. /**
  284. * 设置密码
  285. * @param string $newpassword 新密码
  286. * @param string $newpassword 新密码
  287. */
  288. public function setpwd()
  289. {
  290. $params = $this->request->param();
  291. $validate = new \app\api\validate\User();
  292. $result = $validate->scene('setPwd')->check($params);
  293. if (!$result) {
  294. $this->error($validate->getError());
  295. }
  296. $ret = $this->auth->changepwd($params['password'], '', true);
  297. if ($ret) {
  298. $this->success(__('Set password successful'));
  299. } else {
  300. $this->error($this->auth->getError());
  301. }
  302. }
  303. /**
  304. * 修改密码
  305. *
  306. * @param string $mobile 手机号
  307. * @param string $newpassword 新密码
  308. * @param string $captcha 验证码
  309. */
  310. public function changepwd()
  311. {
  312. $params = $this->request->param();
  313. $validate = new \app\api\validate\User();
  314. $result = $validate->scene('changePwd')->check($params);
  315. if (!$result) {
  316. $this->error($validate->getError());
  317. }
  318. $mobile = input("mobile");
  319. $newpassword = input("password");
  320. $captcha = input("captcha");
  321. $user = \app\common\model\User::getByMobile($mobile);
  322. if (!$user) {
  323. $this->error(__('User not found'));
  324. }
  325. $ret = Sms::check($mobile, $captcha, 'resetpwd');
  326. if (!$ret) {
  327. $this->error(__('Captcha is incorrect'));
  328. }
  329. Sms::flush($mobile, 'resetpwd');
  330. $ret = $this->auth->changepwd($newpassword, '', true);
  331. if ($ret) {
  332. $this->success(__('Change password successful'));
  333. } else {
  334. $this->error($this->auth->getError());
  335. }
  336. }
  337. /**
  338. * 运营商一键登录
  339. */
  340. public function onLogin()
  341. {
  342. $accessToken = $this->request->param('accessToken');// 运营商预取号获取到的token
  343. $token = $this->request->param('tokenT');// 易盾返回的token
  344. if (!$accessToken || !$token) {
  345. $this->error("参数获取失败!");
  346. }
  347. $params = array(
  348. // 运营商预取号获取到的token
  349. "accessToken" => $accessToken,
  350. // 易盾返回的token
  351. "token" => $token
  352. );
  353. // 获取密钥配置
  354. $configInfo = config("onLogin");
  355. $onlogin = new onlogin($configInfo["secretid"], $configInfo["secretkey"], $configInfo["businessid"]);
  356. $ret = $onlogin->check($params);
  357. // $ret = [];
  358. // $ret["code"] = 200;
  359. // $ret["msg"] = "ok";
  360. // $ret["data"] = [
  361. // "phone" => "17574504021",
  362. // "resultCode" => 0
  363. // ];
  364. if ($ret["code"] == 200) {
  365. $data = $ret["data"];
  366. $phone = $data["phone"];
  367. if (empty($phone)) {
  368. // 取号失败,建议进行二次验证,例如短信验证码
  369. $this->error("取号登录失败,请用验证码方式登录!");
  370. } else {
  371. // 取号成功, 执行登录等流程
  372. // 用户登录逻辑 === 开始
  373. $userModel = new \app\common\model\User();
  374. $auth = \app\common\library\Auth::instance();
  375. $userInfo = $userModel->where(["mobile" => $phone])->find();
  376. // 用户信息不存在时使用
  377. $extend = ["mobile" => $phone];
  378. // 判断用户是否已经存在
  379. if ($userInfo) { // 登录
  380. $user = \app\common\model\User::get($userInfo["id"]);
  381. if (!$user) {
  382. $this->error("网络错误!请稍后重试");
  383. }
  384. if ($user->status != 'normal') {
  385. $this->error(__('Account is locked'));
  386. }
  387. $user->save(["logintime" => time()]);
  388. $res = $auth->direct($user->id);
  389. $is_register = 0;
  390. } else { // 注册
  391. // 先随机一个用户名,随后再变更为u+数字id
  392. $username = Random::alnum(20);
  393. $password = Random::alnum(6);
  394. Db::startTrans();
  395. try {
  396. // 默认注册一个会员
  397. $result = $auth->register($username, $password, "", $extend);
  398. if (!$result) {
  399. return false;
  400. }
  401. $user = $auth->getUser();
  402. $fields = ['username' => 'u' . $user->id];
  403. // 更新会员资料
  404. $user = \app\common\model\User::get($user->id);
  405. $user->save($fields);
  406. Db::commit();
  407. } catch (PDOException $e) {
  408. Db::rollback();
  409. $auth->logout();
  410. return false;
  411. }
  412. // 写入登录Cookies和Token
  413. $res = $auth->direct($user->id);
  414. $is_register = 1;
  415. }
  416. $userInfo["userinfo"] = $auth->getUserinfo();
  417. $userInfo["is_register"] = $is_register;
  418. if ($res) {
  419. $this->success("登录成功!", $userInfo);
  420. } else {
  421. $this->error("登录失败!");
  422. }
  423. // 用户登录逻辑 === 结束
  424. }
  425. } else {
  426. $this->error("登录失败,请用验证码方式登录!");
  427. }
  428. }
  429. /**
  430. * 注销账号
  431. *
  432. * @param string $mobile 手机号
  433. * @param string $captcha 验证码
  434. */
  435. public function cancleUser()
  436. {
  437. $user = $this->auth->getUser();
  438. $user->status = -1;
  439. //unset($user->power);
  440. $user->save();
  441. $this->auth->logout();
  442. $this->success("账号注销成功!");
  443. }
  444. /**
  445. * 获取昵称
  446. * @return string
  447. */
  448. public function getNickName()
  449. {
  450. $result['nickname'] = get_rand_nick_name();
  451. $this->success('获取成功',$result);
  452. }
  453. //微信登录,预先假注册
  454. public function wechatlogin(){
  455. $code = input('code','');
  456. if(!$code){
  457. $this->error(__('Invalid parameters'));
  458. }
  459. //微信
  460. $wechat = new Wechat();
  461. $wxuserinfo = $wechat->getAccessToken($code);
  462. if(!$wxuserinfo){
  463. $this->error('openid获取失败');
  464. }
  465. if(!is_array($wxuserinfo) || !isset($wxuserinfo['openid'])){
  466. $this->error('openid获取失败');
  467. }
  468. $openid = $wxuserinfo['openid'];
  469. $user = Db::name('user')->where('openid',$openid)->find();
  470. if ($user) {
  471. if ($user['status'] == -1) {
  472. $this->error('账户已注销');
  473. }
  474. if ($user['status'] != 1) {
  475. $this->error(__('Account is locked'));
  476. }
  477. //如果已经有账号则直接登录
  478. $ret = $this->auth->direct($user['id']);
  479. $is_register = 0;
  480. $userInfo = $this->auth->getUserinfo();
  481. } else {
  482. //记录code和openid,绑定手机号的时候更新openid
  483. $wechatCodeData = [
  484. 'code' => $code,
  485. 'openid' => $openid,
  486. 'createtime' => time(),
  487. ];
  488. $wechatCode = Db::name('wechat_code')->where(['openid'=>$openid])->find();
  489. if (empty($wechatCode)) {
  490. Db::name('wechat_code')->insertGetId($wechatCodeData);
  491. } else {
  492. Db::name('wechat_code')->where(['openid'=>$openid])->update($wechatCodeData);
  493. }
  494. $ret = true;
  495. $is_register = 1;
  496. $userInfo = [];
  497. $data = ['code'=>$code,'is_register' => $is_register, 'userinfo' => $userInfo];
  498. $this->success('获取信息成功', $data, 2);
  499. }
  500. if ($ret) {
  501. $data = ['code'=>$code,'is_register' => $is_register, 'userinfo' => $userInfo];
  502. $this->success(__('Logged in successful'), $data);
  503. } else {
  504. $this->error($this->auth->getError());
  505. }
  506. }
  507. //获取openid
  508. public function getopenid() {
  509. //code
  510. $code = $this->request->post('code', '', 'trim');// code值
  511. if (!$code) {
  512. $this->error(__('Invalid parameters'));
  513. }
  514. $config = config('wxMiniProgram');
  515. $getopenid_url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$config['appid'].'&secret='.$config['secret'].'&js_code='.$code.'&grant_type=authorization_code';
  516. $openidInfo = httpRequest($getopenid_url, 'GET');//$this->getJson($getopenid_url);
  517. $openidInfo = json_decode($openidInfo,true);
  518. if(!isset($openidInfo['openid'])) {
  519. $this->error('用户openid获取失败', $openidInfo);
  520. }
  521. $user = Db::name('user')->where('mini_openid',$openidInfo['openid'])->find();
  522. //$openidInfo['mobile'] = isset($user['mobile']) ? $user['mobile'] : '';
  523. $this->success('获取成功', $openidInfo);
  524. }
  525. /**
  526. * 微信注册来的,绑定手机号
  527. *
  528. * @ApiMethod (POST)
  529. * @param string $mobile 手机号
  530. * @param string $captcha 验证码
  531. */
  532. public function bindmobile()
  533. {
  534. try {
  535. $code = $this->request->param('code');
  536. $mobile = $this->request->param('mobile');
  537. $captcha = $this->request->param('captcha');
  538. if (!$mobile || !$captcha || !$code) {
  539. throw new Exception(__('Invalid parameters'));
  540. }
  541. if (!Validate::regex($mobile, "^1\d{10}$")) {
  542. throw new Exception(__('Mobile is incorrect'));
  543. }
  544. $result = Sms::check($mobile, $captcha, 'changemobile');
  545. if (!$result) {
  546. throw new Exception(__('Captcha is incorrect'));
  547. }
  548. $wechatCodeWhere['code'] = $code;
  549. $wechatCode = Db::name('wechat_code')->where($wechatCodeWhere)->find();
  550. if (empty($wechatCode)) {
  551. throw new Exception('请先微信登录');
  552. }
  553. //检查appid绑定的用户
  554. $user = Db::name('user')->where('openid',$wechatCode['openid'])->find();
  555. if ($user) {
  556. if ($user['status'] == -1) {
  557. $this->error('账户已注销');
  558. }
  559. if ($user['status'] != 1) {
  560. $this->error(__('Account is locked'));
  561. }
  562. //如果已经有账号则直接登录
  563. $ret = $this->auth->direct($user['id']);
  564. $this->success('success',$this->userInfo('return'));
  565. }
  566. $where['mobile'] = $mobile;
  567. $userData = model('User')->where($where)->find();//老用户
  568. if (!empty($userData)) {
  569. if (empty($userData['openid'])) {
  570. model('User')->update(['openid' => $wechatCode['openid']],$where);//老用户更新openid
  571. } else {
  572. if ($userData['openid'] != $wechatCode['openid']) {
  573. throw new Exception('该手机号已被其他用户绑定');
  574. }
  575. }
  576. $ret = $this->auth->direct($userData['id']);
  577. } else {
  578. $extend = [
  579. 'openid' => $wechatCode['openid'],
  580. ];
  581. $ret = $this->auth->register($mobile, Random::alnum(), $mobile, $extend);
  582. }
  583. if (!$ret) {
  584. throw new Exception($this->auth->getError());
  585. }
  586. Sms::flush($mobile, 'changemobile');
  587. $this->success('success',$this->userInfo('return'));
  588. } catch (Exception $e) {
  589. $this->error($e->getMessage());
  590. }
  591. }
  592. /**
  593. * 手机注册来的,绑定微信
  594. *
  595. * @ApiMethod (POST)
  596. * @param string $wechat_openid
  597. */
  598. public function bindopenid()
  599. {
  600. Db::startTrans();
  601. try {
  602. $code = $this->request->param('code','');
  603. if(!$code){
  604. throw new Exception(__('Invalid parameters'));
  605. }
  606. //微信
  607. $wechat = new Wechat();
  608. $openid = $wechat->getOpenid($code);
  609. if(!$openid){
  610. throw new Exception('openid获取失败');
  611. }
  612. $user = model('User')->find($this->auth->id);
  613. if(!empty($user['openid']) && $openid != $user['openid']){
  614. throw new Exception('已经绑定了微信号');
  615. }
  616. $otherUserWhere['openid'] = $openid;
  617. $otherUserWhere['id'] = ['neq',$this->auth->id];
  618. $otherUser = model('User')->where($otherUserWhere)->find();
  619. if (!empty($otherUser)) {
  620. throw new Exception('该微信已被其他用户绑定过');
  621. }
  622. $user->openid = $openid;
  623. $userRes = $user->save();
  624. if (!$userRes) {
  625. throw new Exception('绑定微信失败');
  626. }
  627. Db::commit();
  628. $this->success('success',$this->userInfo('return'));
  629. } catch (Exception $e) {
  630. Db::rollback();
  631. $this->error($e->getMessage());
  632. }
  633. }
  634. //用户详细资料
  635. public function userInfo($type = 1){
  636. $info = $this->auth->getUserinfo();
  637. if($type == 'return'){
  638. return $info;
  639. }
  640. $this->success(__('success'),$info);
  641. }
  642. /**
  643. * 微信解绑
  644. * @return void
  645. */
  646. public function clearopenid()
  647. {
  648. try {
  649. $userId = $this->auth->id;
  650. $where['id'] = $userId;
  651. $data['openid'] = '';
  652. $user = model('User')->update($data,$where);
  653. $this->success('解绑成功');
  654. } catch (Exception $e) {
  655. $this->error($e->getMessage());
  656. }
  657. }
  658. }