| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- <?php
- namespace app\api\controller\h5;
- use app\api\services\UserServices;
- use app\api\validate\UserValidate;
- use app\common\model\SystemArticleModel;
- use app\Request;
- use think\Exception;
- use think\exception\ValidateException;
- use think\facade\Db;
- use think\facade\View;
- class User
- {
- protected $service = null;
- public function __construct (UserServices $services)
- {
- $this->service = $services;
- }
-
- // 隐私政策
- public function privateInfo (Request $request)
- {
- $id = $request->param('id/d', '');
- $m_article = new SystemArticleModel();
- $row = $m_article->where(['type' => 3])->findOrEmpty();
- empty($row) && abort(403, '页面异常');
- View::assign('row', $row);
- return View::fetch();
- }
- // 用户协议
- public function userAgreementInfo (Request $request)
- {
- $id = $request->param('id/d', '');
- $m_article = new SystemArticleModel();
- $row = $m_article->where(['type' => 4])->findOrEmpty();
- empty($row) && abort(403, '页面异常');
- View::assign('row', $row);
- return View::fetch();
- }
- // 帮助中心
- public function helpCenter ()
- {
- $list = Db::name('system_faq')->where('status', 1)->select()->toArray();
- $list = array_column($list, null, 'id');
- $tree = array();
- foreach ($list as $key => $row) {
- $pid = $row['parent_id'];
- if ($pid == 0) {
- $tree[] =& $list[$key];
- } else if (isset($list[$pid])) {
- $parent =& $list[$pid];
- $parent['son'][] =& $list[$key];
- }
- }
- View::assign('list', $tree);
- return View::fetch();
- }
- /**
- * 帮助中心详情
- * @param Request $request
- * @return string
- */
- public function helpDetails (Request $request)
- {
- $id = $request->param('id', 0, 'intval'); // 详情id
- !$id && abort(403, '页面异常');
- try {
- $info = Db::name('system_faq')->where('id', $id)->where('status', 1)->find();
- // $info['content'] = imageSrcReplace($info['content']);
- View::assign('info', $info);
- } catch (\Exception $e) {
- abort(403, '页面异常');
- }
- return View::fetch();
- }
- // 关于我们
- public function aboutUs (Request $request)
- {
- $id = $request->param('id/d', '');
- $m_article = new SystemArticleModel();
- $row = $m_article->where(['type' => 5])->findOrEmpty();
- empty($row) && abort(403, '页面异常');
- View::assign('row', $row);
- return View::fetch();
- }
- /**
- * h5注册
- * @param Request $request
- * @return string
- */
- public function registerH5 (Request $request)
- {
- // 这是测试 上线要干掉
- // echo '网站正在更新';
- // die();
- if ($request->isPost()) {
- $data = $request->post();
- try {
- validate(UserValidate::class)
- ->scene('register')
- ->check($data);
- $userserivce = new UserServices();
- if (!vertifyPass($data['password'])){
- throw new Exception('密码必须包含字母和数字,长度大于8位');
- }
- $param = [
- 'invite_code'=>$data['invite_code'],
- 'code'=>$data['code'],
- 'mobile'=>$data['mobile'],
- 'password'=>$data['password'],
- 'req_type'=>'h5web',
- 'user_name'=>$data['user_name']
- ];
- $userserivce->userRegister($param);
- return api_succ_return('注册成功');
- // return api_succ_return(['msg'=>'注册成功','code'=>0]);
- } catch (ValidateException $e) {
- return api_error_return($e->getMessage());
- } catch (\Exception $e) {
- return api_error_return($e->getMessage());
- }
- }
- $code = $request->param('code');
- if ($code) {
- // $code = decode($code);
- // 7H+6DCDrGMtrESqhogM
- // $code = cryption($code, 'D', 'zy02022');
- // return $code;
- !$code && abort(40003, '页面错误');
- $is_px = false;
- $invite = Db::name('user')->where('code', $code)->field('code,id')->find();
- if (!$invite){
- $invite = Db::name('user')->where('px_code', $code)->field('px_code,id')->find();
- $is_px = true;
- }
- if (!$invite){
- return '邀请码错误,还请核实';
- }
- if ($is_px){
- $code = $invite['px_code'];
- }else{
- $code = $invite['code'];
- }
- }
- View::assign([
- 'code' => $code,
- 'appkey' => env('aliyun.verify_appkey'),
- 'scene' => env('aliyun.verify_scene'),
- 'downappurl' => getWebUrl().'/api/downapp',
- 'info'=>[
- 'name'=>env('app.name')
- ]
- ]);
- return View::fetch();
- }
- /**
- * 人机验证
- * @return string
- */
- public function loginVerify ()
- {
- View::assign('appkey', env('aliyun.verify_appkey'));
- View::assign('scene', env('aliyun.verify_scene'));
- View::assign('view', input('view', ''));
- return View::fetch();
- }
- /**
- * 新手教程
- * @return string
- */
- public function newhandurl(Request $request){
- $m_article = new SystemArticleModel();
- $row = $m_article->where(['type' => 5])->findOrEmpty();
- empty($row) && abort(403, '页面异常');
- View::assign('row', $row);
- return View::fetch();
- }
- /**
- * 新手指引
- * @return string
- */
- public function newguideurl(Request $request){
- // $id = $request->param('id/d', '');
- $m_article = new SystemArticleModel();
- $row = $m_article->where(['type' => 6])->findOrEmpty();
- empty($row) && abort(403, '页面异常');
- View::assign('row', $row);
- return View::fetch();
- }
- /**
- * 关于福袋
- * @return string
- */
- public function aboutboxurl(Request $request){
- // $id = $request->param('id/d', '');
- $m_article = new SystemArticleModel();
- $row = $m_article->where(['type' => 7])->findOrEmpty();
- empty($row) && abort(403, '页面异常');
- View::assign('row', $row);
- return View::fetch();
- }
- }
|