User.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?php
  2. namespace app\api\controller\h5;
  3. use app\api\services\UserServices;
  4. use app\api\validate\UserValidate;
  5. use app\common\model\SystemArticleModel;
  6. use app\Request;
  7. use think\Exception;
  8. use think\exception\ValidateException;
  9. use think\facade\Db;
  10. use think\facade\View;
  11. class User
  12. {
  13. protected $service = null;
  14. public function __construct (UserServices $services)
  15. {
  16. $this->service = $services;
  17. }
  18. // 隐私政策
  19. public function privateInfo (Request $request)
  20. {
  21. $id = $request->param('id/d', '');
  22. $m_article = new SystemArticleModel();
  23. $row = $m_article->where(['type' => 3])->findOrEmpty();
  24. empty($row) && abort(403, '页面异常');
  25. View::assign('row', $row);
  26. return View::fetch();
  27. }
  28. // 用户协议
  29. public function userAgreementInfo (Request $request)
  30. {
  31. $id = $request->param('id/d', '');
  32. $m_article = new SystemArticleModel();
  33. $row = $m_article->where(['type' => 4])->findOrEmpty();
  34. empty($row) && abort(403, '页面异常');
  35. View::assign('row', $row);
  36. return View::fetch();
  37. }
  38. // 帮助中心
  39. public function helpCenter ()
  40. {
  41. $list = Db::name('system_faq')->where('status', 1)->select()->toArray();
  42. $list = array_column($list, null, 'id');
  43. $tree = array();
  44. foreach ($list as $key => $row) {
  45. $pid = $row['parent_id'];
  46. if ($pid == 0) {
  47. $tree[] =& $list[$key];
  48. } else if (isset($list[$pid])) {
  49. $parent =& $list[$pid];
  50. $parent['son'][] =& $list[$key];
  51. }
  52. }
  53. View::assign('list', $tree);
  54. return View::fetch();
  55. }
  56. /**
  57. * 帮助中心详情
  58. * @param Request $request
  59. * @return string
  60. */
  61. public function helpDetails (Request $request)
  62. {
  63. $id = $request->param('id', 0, 'intval'); // 详情id
  64. !$id && abort(403, '页面异常');
  65. try {
  66. $info = Db::name('system_faq')->where('id', $id)->where('status', 1)->find();
  67. // $info['content'] = imageSrcReplace($info['content']);
  68. View::assign('info', $info);
  69. } catch (\Exception $e) {
  70. abort(403, '页面异常');
  71. }
  72. return View::fetch();
  73. }
  74. // 关于我们
  75. public function aboutUs (Request $request)
  76. {
  77. $id = $request->param('id/d', '');
  78. $m_article = new SystemArticleModel();
  79. $row = $m_article->where(['type' => 5])->findOrEmpty();
  80. empty($row) && abort(403, '页面异常');
  81. View::assign('row', $row);
  82. return View::fetch();
  83. }
  84. /**
  85. * h5注册
  86. * @param Request $request
  87. * @return string
  88. */
  89. public function registerH5 (Request $request)
  90. {
  91. // 这是测试 上线要干掉
  92. // echo '网站正在更新';
  93. // die();
  94. if ($request->isPost()) {
  95. $data = $request->post();
  96. try {
  97. validate(UserValidate::class)
  98. ->scene('register')
  99. ->check($data);
  100. $userserivce = new UserServices();
  101. if (!vertifyPass($data['password'])){
  102. throw new Exception('密码必须包含字母和数字,长度大于8位');
  103. }
  104. $param = [
  105. 'invite_code'=>$data['invite_code'],
  106. 'code'=>$data['code'],
  107. 'mobile'=>$data['mobile'],
  108. 'password'=>$data['password'],
  109. 'req_type'=>'h5web',
  110. 'user_name'=>$data['user_name']
  111. ];
  112. $userserivce->userRegister($param);
  113. return api_succ_return('注册成功');
  114. // return api_succ_return(['msg'=>'注册成功','code'=>0]);
  115. } catch (ValidateException $e) {
  116. return api_error_return($e->getMessage());
  117. } catch (\Exception $e) {
  118. return api_error_return($e->getMessage());
  119. }
  120. }
  121. $code = $request->param('code');
  122. if ($code) {
  123. // $code = decode($code);
  124. // 7H+6DCDrGMtrESqhogM
  125. // $code = cryption($code, 'D', 'zy02022');
  126. // return $code;
  127. !$code && abort(40003, '页面错误');
  128. $is_px = false;
  129. $invite = Db::name('user')->where('code', $code)->field('code,id')->find();
  130. if (!$invite){
  131. $invite = Db::name('user')->where('px_code', $code)->field('px_code,id')->find();
  132. $is_px = true;
  133. }
  134. if (!$invite){
  135. return '邀请码错误,还请核实';
  136. }
  137. if ($is_px){
  138. $code = $invite['px_code'];
  139. }else{
  140. $code = $invite['code'];
  141. }
  142. }
  143. View::assign([
  144. 'code' => $code,
  145. 'appkey' => env('aliyun.verify_appkey'),
  146. 'scene' => env('aliyun.verify_scene'),
  147. 'downappurl' => getWebUrl().'/api/downapp',
  148. 'info'=>[
  149. 'name'=>env('app.name')
  150. ]
  151. ]);
  152. return View::fetch();
  153. }
  154. /**
  155. * 人机验证
  156. * @return string
  157. */
  158. public function loginVerify ()
  159. {
  160. View::assign('appkey', env('aliyun.verify_appkey'));
  161. View::assign('scene', env('aliyun.verify_scene'));
  162. View::assign('view', input('view', ''));
  163. return View::fetch();
  164. }
  165. /**
  166. * 新手教程
  167. * @return string
  168. */
  169. public function newhandurl(Request $request){
  170. $m_article = new SystemArticleModel();
  171. $row = $m_article->where(['type' => 5])->findOrEmpty();
  172. empty($row) && abort(403, '页面异常');
  173. View::assign('row', $row);
  174. return View::fetch();
  175. }
  176. /**
  177. * 新手指引
  178. * @return string
  179. */
  180. public function newguideurl(Request $request){
  181. // $id = $request->param('id/d', '');
  182. $m_article = new SystemArticleModel();
  183. $row = $m_article->where(['type' => 6])->findOrEmpty();
  184. empty($row) && abort(403, '页面异常');
  185. View::assign('row', $row);
  186. return View::fetch();
  187. }
  188. /**
  189. * 关于福袋
  190. * @return string
  191. */
  192. public function aboutboxurl(Request $request){
  193. // $id = $request->param('id/d', '');
  194. $m_article = new SystemArticleModel();
  195. $row = $m_article->where(['type' => 7])->findOrEmpty();
  196. empty($row) && abort(403, '页面异常');
  197. View::assign('row', $row);
  198. return View::fetch();
  199. }
  200. }