Browse Source

后台注册会员

lizhen_gitee 8 months ago
parent
commit
b5ef7d8752

+ 62 - 0
application/admin/controller/user/User.php

@@ -74,6 +74,68 @@ class User extends Backend
     }
 
     /**
+     * 注册会员
+     *
+     * @ApiMethod (POST)
+     * @param string $username 用户名
+     * @param string $password 密码
+     * @param string $email    邮箱
+     * @param string $mobile   手机号
+     * @param string $code     验证码
+     */
+    public function add()
+    {
+        $firstname = input('firstname');
+        $lastname  = input('lastname');
+
+        $countrycode = input('countrycode',65,'intval');
+        $mobile      = input('mobile');
+
+        $email        = input('email');
+
+        $password     = input('password');
+
+        if (!$firstname || !$lastname || !$mobile || !$email || !$password) {
+            $this->error(__('Invalid parameters'));
+        }
+
+        if ($email && !Validate::is($email, "email")) {
+            $this->error(__('Email is incorrect'));
+        }
+
+        $fullmobile = $countrycode.$mobile;
+
+        $extend = [
+            'firstname'    => $firstname,
+            'lastname'     => $lastname,
+            'simplemobile' => $mobile,
+
+            'birthday'     => strtotime(input('birthday','')),
+            'height'       => input('height',''),
+            'weight'       => input('weight',''),
+            'age'          => input('age',''),
+            'residential'     => input('residential',''),
+            'health'       => input('health',''),
+            'emergency'    => input('emergency',''),
+            'emergency_phone'    => input('emergency_phone',''),
+            'knowus'       => input('knowus',''),
+            'is_first'     => input('is_first',''),
+
+            'notice_email'     => input('notice_email',0),
+            'notice_whatsapp'  => input('notice_whatsapp',0),
+            'notice_phonecall' => input('notice_phonecall',0),
+            'whatsapp'         => input('whatsapp',''),
+        ];
+        $auth = new \app\common\library\auth;
+        $ret = $auth->register('',$password, $email, $fullmobile, $extend);
+        if ($ret != true) {
+            $this->success('注册完成');
+        } else {
+            $this->error($auth->getError());
+        }
+    }
+
+    /**
      * 充值积分
      */
     public function updatescore(){

+ 2 - 2
application/admin/view/user/user/index.html

@@ -17,8 +17,8 @@
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-                        <!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('user/user/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
-                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('user/user/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('user/user/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('user/user/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('user/user/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>