rabin 7 년 전
부모
커밋
53c1dd5310

+ 11 - 0
config/base.php

@@ -64,6 +64,17 @@ $config['template'] = array
 		'login' => 'login',
 		'reg' => 'register',
 		'forget' => 'password',
+		
+		# 注册之后补充资料
+		'user/set' => 'material',
+		# 用户首页
+		'user/index' => 'myaccount',
+		# 用户积分页
+		'user/score' => 'cions',
+		# 用户任务
+		'user/task' => 'mytask',
+		# 用户报告
+		'user/report' => 'reportlist',
 
 		# 任务列表页
 		'task/list' => 'tasks',

+ 41 - 0
main/assets/mobile/js/config.js

@@ -21,6 +21,10 @@ Dever.User().config =
 		,3 : '#dever_report_submit'
 		//获取验证码
 		,4 : '#mcode_button'
+		//完善资料
+		,5 : '#set'
+		//找回密码
+		,6 : '#forget',
 	}
 
 	//登录信息
@@ -123,6 +127,43 @@ Dever.User().config =
 		}
 	}
 
+	//完善资料
+	,5 :
+	{
+		'input' :
+		{
+			'username' : '#username'
+			,'code' : '#code'
+			,'sex' : '#sex'
+			,'refer' : '#refer|'
+		}
+		//错误提示的div
+		//,'status' : '.alert'
+		//错误提示
+		,'error' : '您填写的信息有误'
+		//登录要提交的url
+		,'url' : Dever.Host('task', 'user.set')
+	}
+
+	//找回密码
+	,6 :
+	{
+		'input' :
+		{
+			'mobile' : '#mobile'
+			,'mcode' : '#mcode'
+			,'password' : '#password'
+			,'cpassword' : '#password'
+			,'refer' : '#refer|'
+		}
+		//错误提示的div
+		//,'status' : '.alert'
+		//错误提示
+		,'error' : '您填写的信息有误'
+		//登录要提交的url
+		,'url' : Dever.Host('passport', 'reg.forget')
+	}
+
 };
 
 //定义上传回调方法

+ 22 - 0
main/database/config.php

@@ -145,6 +145,28 @@ return array
 			'attr'		=> '',
 		),
 
+		'avatar'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '用户默认头像-宽度为200*200的图片',
+			'default' 	=> '',
+			'desc' 		=> '用户默认头像',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'wechat'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '在线客服微信号',
+			'default' 	=> '',
+			'desc' 		=> '在线客服微信号',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
 		'score_name'		=> array
 		(
 			'type' 		=> 'varchar-200',

+ 37 - 0
main/template/mobile/forget.php

@@ -0,0 +1,37 @@
+<?php
+
+$view
+
+->import('inc/head')
+
+->set('title', '找回密码')
+->set('name', 'password')
+->fetch('header span', '找回密码')
+
+->fetch('.back@href',    'javascript:history.go(-1)')
+
+->fetch(array('input@id', 0), 'mobile')
+->fetch(array('input@name', 0), 'mobile')
+->fetch(array('input@dever-error', 0), '请填写手机号')
+
+->fetch(array('input@id', 1), 'mcode')
+->fetch(array('input@name', 1), 'mcode')
+->fetch(array('input@dever-error', 1), '请填写收集验证码')
+
+->fetch(array('input@id', 2), 'password')
+->fetch(array('input@name', 2), 'password')
+->fetch(array('input@dever-match', 2), '(?=.*[a-zA-Z0-9])(?=.*[a-zA-Z0-9])(?=.*[a-zA-Z0-9]).{6,18}')
+->fetch(array('input@dever-error', 2), '密码长度为6~18位')
+
+->fetch('.nol@id', 'mcode_button')
+->fetch('.nol@dever-send', '<{Dever::load("passport/reg.getUrl", "passport/reg.getMcode", array("sid" => Dever::id()))}>') 
+
+->fetch('.button@class', 'button')
+->fetch('.button@type', 'button')
+->fetch('.button@id', 'forget')
+
+->append('header', '<input type="hidden" name="refer" id="refer" value="<{Dever::input("refer")}>">')
+
+->import('inc/foot')
+
+->display();

+ 2 - 2
main/template/mobile/reg.php

@@ -16,11 +16,11 @@ $view
 
 ->fetch(array('input@id', 0), 'mobile')
 ->fetch(array('input@name', 0), 'mobile')
-->fetch(array('input@dever-error', 2), '请填写手机号')
+->fetch(array('input@dever-error', 0), '请填写手机号')
 
 ->fetch(array('input@id', 1), 'mcode')
 ->fetch(array('input@name', 1), 'mcode')
-->fetch(array('input@dever-error', 2), '请填写收集验证码')
+->fetch(array('input@dever-error', 1), '请填写收集验证码')
 
 ->fetch(array('input@id', 2), 'password')
 ->fetch(array('input@name', 2), 'password')

+ 75 - 0
main/template/mobile/user/index.php

@@ -0,0 +1,75 @@
+<?php
+$title = '我的账户';
+
+$view
+
+# 公共页面,这种方式不会更改前端代码,还有一种方式可以参考manage组件
+->import('inc/head,inc/menu')
+
+# 设置全局变量
+->set('title', $title)
+# 这个变量控制不同页面的样式和js文件
+->set('name', 'myaccount')
+# 定义header>span的html为$title
+->fetch('header span',    $title)
+
+->set('info', 'task/user.info') 
+
+->render('info', array
+(
+    '.wrapper' => array
+    (
+        'img' => array
+        (
+            'src' => '$v.avatar',
+        ),
+
+        'dt' => '$v.username',
+        '.mini-button@style' => 'display:none;',
+
+        '.arrow-r|0' => array
+        (
+            'href' => '<{Dever::url("user/score", "main")}>',
+        ),
+        '.arrow-r|1' => array
+        (
+            'href' => '<{Dever::url("user/info", "main")}>',
+        ),
+        '.arrow-r|2' => array
+        (
+            'href' => '<{Dever::url("user/group", "main")}>',
+        ),
+        '.arrow-r|3' => array
+        (
+            'href' => '<{Dever::url("user/code", "main")}>',
+        ),
+        '.arrow-r|4' => array
+        (
+            'href' => '<{Dever::url("user/msg", "main")}>',
+        ),
+        '.arrow-r|5' => array
+        (
+            'href' => '<{Dever::url("user/help", "main")}>',
+        ),
+
+        'a|6' => array
+        (
+            'href' => '<{Dever::url("user/help", "main")}>',
+            'span|1' => 'Dever::load("main/config-one#wechat")',
+        ),
+
+        '.ntc' => array
+        (
+            'html' => '$v.msg',
+        ),
+
+        '.button' => array
+        (
+            'href' => '$v.quit',
+        ),
+    ), 
+))
+
+->import('inc/foot')
+
+->display();

+ 36 - 0
main/template/mobile/user/set.php

@@ -0,0 +1,36 @@
+<?php
+
+$view
+
+->import('inc/head')
+
+->set('title', '完善资料')
+->set('name', 'register')
+->fetch('header span', '完善资料')
+
+->fetch('.back@style',    'display:none;')
+
+->fetch('.txtc@style',    'display:none;')
+
+->fetch(array('input@id', 0), 'username')
+->fetch(array('input@name', 0), 'username')
+->fetch(array('input@dever-error', 0), '请填写昵称')
+
+->fetch(array('input@id', 1), 'sex')
+->fetch(array('input@name', 1), 'sex')
+->fetch(array('input@dever-error', 1), '请选择性别')
+
+->fetch(array('input@id', 2), 'code')
+->fetch(array('input@name', 2), 'code')
+
+->fetch('.disable@style', 'display:none')) 
+
+->fetch('.button@class', 'button')
+->fetch('.button@type', 'button')
+->fetch('.button@id', 'set')
+
+->append('header', '<input type="hidden" name="refer" id="refer" value="<{Dever::input("refer")}>">')
+
+->import('inc/foot')
+
+->display();

+ 40 - 6
task/lib/Base.php

@@ -25,6 +25,40 @@ class Base
 		}
 	}
 
+    /**
+     * 获取refer
+     *
+     * @return mixed
+     */
+    protected function refer()
+    {
+        $refer = Dever::input('refer');
+
+        $project = 'main';
+
+        if ($refer) {
+            $refer = Dever::decode($refer);
+            return $refer;
+        } else {
+            return Dever::url('home', $project);
+        }
+    }
+
+    /**
+     * 检测用户是否登录
+     *
+     * @return mixed
+     */
+    protected function checkLogin()
+    {
+        if ($this->data['uid'] <= 0) {
+            # 需要登录
+            $login = new Login();
+            $login->location();
+        }
+    }
+
+
 	/**
 	 * 检测用户信息
 	 *
@@ -32,21 +66,21 @@ class Base
 	 */
 	protected function checkUser($state = false)
 	{
-		if ($this->data['uid'] <= 0) {
-			# 需要登录
-			$login = new Login();
-			$login->location();
-		}
-
+		$this->checkLogin();
 		$where['uid'] = $this->data['uid'];
 
 		# 获取用户积分
 		$this->data['user_score'] = Dever::db('task/user_score')->one($where);
 		if (!$this->data['user_score']) {
+            $refer = Dever::url();
+            $url = Dever::url('user/set?refer=' . Dever::encode($refer), 'main');
+            Dever::location($url);
+            /*
 			$this->data['user_score'] = array();
         	$this->data['user_score']['score'] = 0;
         	$this->data['user_score']['uid'] = $where['uid'];
         	$this->data['user_score']['id'] = Dever::db('task/user_score')->insert($this->data['user_score']);
+            */
         }
 
 		# 检测用户是否认证

+ 90 - 0
task/src/User.php

@@ -7,6 +7,27 @@ use Task\Lib\Base;
 
 class User extends Base
 {
+
+    /**
+     * 用户基本信息
+     *
+     * @return mixed
+     */
+    public function info()
+    {
+        # 检测用户是否登录
+        $this->checkLogin();
+        $user = $this->user;
+
+        # 获取消息
+        $user['msg'] = 0;
+
+        # 获取退出链接
+        $user['quit'] = Dever::url('login.quit', 'passport');
+        return $user;
+    }
+
+
     /**
      * 用户资料
      *
@@ -14,11 +35,80 @@ class User extends Base
      */
     public function one()
     {
+        # 检测用户是否登录
+        $this->checkLogin();
         # 检测用户是否认证
         $where['uid'] = $this->data['uid'];
         return Dever::db('task/user_info')->one($where);
     }
 
+    /**
+     * 完善资料
+     *
+     * @return mixed
+     */
+    public function set()
+    {
+        # 检测用户是否登录
+        $this->checkLogin();
+        return $this->set_action();
+    }
+
+    /**
+     * 填写资料
+     *
+     * @return mixed
+     */
+    private function set_action()
+    {
+        $where['uid'] = $this->data['uid'];
+        $user = Dever::db('task/user_score')->one($where);
+
+        $username = Dever::input('username');
+        $code = Dever::input('code');
+        $sex = Dever::input('sex');
+
+        if (!$username) {
+            Dever::alert('用户昵称不能为空');
+        }
+
+        if (!$sex) {
+            Dever::alert('性别不能为空');
+        }
+
+        if ($code) {
+            # 加入小队
+            $group = Dever::db('task/user_group')->one(array('code' => $code));
+            if ($group && $group['uid'] != $this->data['uid']) {
+                $info = Dever::db('task/user_group_member')->one(array('uid' => $this->data['uid'], 'group_id' => $group['id']));
+                if (!$info) {
+                    $member['group_id'] = $group['id'];
+                    $member['uid'] = $this->data['uid'];
+                    $member['status'] = 2;
+                    Dever::db('task/user_group_member')->insert($member);
+                }
+                
+            } else {
+                Dever::alert('邀请码错误');
+            }
+        }
+
+        # 设置默认头像
+        $config = Dever::db('main/config-one');
+        Dever::setInput('avatar', $config['avatar']);
+
+        Dever::load('passport/user')->updateInfo();
+
+        if (!$user) {
+            $insert['uid'] = $this->data['uid'];
+            $insert['score'] = 0;
+            $insert['code'] = $code;
+            Dever::db('task/user_score')->insert($insert);
+        }
+
+        return $this->refer();
+    }
+
     /**
      * 资料认证
      *