stanley-king 9 роки тому
батько
коміт
9a8b2681d6

+ 1 - 1
core/framework/libraries/validate.php

@@ -53,7 +53,7 @@ Class Validate{
     {
         return array('input' => $val, 'require' => true,'message' =>"请保持参数非空.");
     }
-    static public function smscode($val)
+    static public function verify_smscode($val)
     {
         return array('input' => $val,'require' => "true", 'validator'=>'length','min'=>4,'max'=>4,'message' =>"短信验证码长度只能为4.");
     }

+ 1 - 1
helper/fcgi_server.php

@@ -43,7 +43,7 @@ class fcgi_server
                 init_cookie($_SERVER['HTTP_COOKIE']);
                 session::instance()->start();
 
-                Log::record(request_helper::req_uri(),Log::DEBUG);
+                Log::record("req_uri = " . request_helper::req_uri(),Log::DEBUG);
                 $file = request_helper::script_file();
                 if(file_exists($file))
                 {

+ 1 - 1
helper/session.php

@@ -11,7 +11,7 @@ class session
     static $stInstance = NULL;
     private $fdestroy = false;
 
-    const expire_min = 1;
+    const expire_min = 20;
     const prefix = 'PHPSESSID';
     const session_name = 'PHPSESSID';
 

+ 12 - 3
mobile/control/control.php

@@ -78,7 +78,8 @@ class mobileControl
         if(in_array($_SESSION['client_type'],$json_clients)) {
             joutput_error($code,$msg);
         }
-        else if($_SESSION['client_type'] == 'wap') {
+        else if($_SESSION['client_type'] == 'wap')
+        {
 
         }
         else {
@@ -101,8 +102,16 @@ class mobileControl
         if(in_array($_SESSION['client_type'],$json_clients)) {
             joutput_data($data);
         }
-        else if($_SESSION['client_type'] == 'wap') {
-
+        else if($_SESSION['client_type'] == 'wap')
+        {
+            if(is_array($data)) {
+                foreach($data as $key => $val) {
+                    TPL::output($key,$val);
+                }
+            }
+            if(!empty($page)) {
+                TPL::showpage($page);
+            }
         }
         else
         {

+ 52 - 2
mobile/control/login.php

@@ -174,7 +174,7 @@ class loginControl extends mobileHomeControl
         $validator = new Validate();
         $validator->setValidate(Validate::verify_mobile($mobile));
         $validator->setValidate(Validate::verify_password($password));
-        $validator->setValidate(Validate::smscode($code));
+        $validator->setValidate(Validate::verify_smscode($code));
         $err = $validator->validate();
         if ($err != '') {
             return self::outerr(errcode::ErrParamter, $err);
@@ -210,7 +210,7 @@ class loginControl extends mobileHomeControl
         $validator = new Validate();
         $validator->setValidate(Validate::verify_mobile($mobile));
         $validator->setValidate(Validate::verify_password($password));
-        $validator->setValidate(Validate::smscode($code));
+        $validator->setValidate(Validate::verify_smscode($code));
         $err = $validator->validate();
         if ($err != '') {
             return self::outerr(errcode::ErrParamter, $err);
@@ -230,6 +230,56 @@ class loginControl extends mobileHomeControl
         }
     }
 
+    /**
+     * 微信绑定
+     *
+     * 输入参数:
+     * wx_openid 微信id
+     * user_info: 用户信息
+     * mobile: 手机号
+     * code: 验证码
+     */
+    public function bindOp()
+    {
+        $wx_openid = trim($_GET['wx_openid']);
+        $wx_info = trim($_GET['user_info']);
+        $mobile = trim($_GET['mobile']);
+        $code = trim($_GET['code']);
+
+        // 输入内容判断
+        $validator = new Validate();
+        $validator->setValidate(Validate::verify_mobile($mobile));
+        $validator->setValidate(Validate::verify_openid($wx_openid));
+        $validator->setValidate(Validate::verify_smscode($code));
+        $err = $validator->validate();
+        if ($err != '' || empty($acode)) {
+            return self::outerr(errcode::ErrInputParam);
+        }
+
+        // 校验验证码
+        $ret = sms_helper::check_code(Sms::register_code,$code);
+        if(is_array($ret)) {
+            return self::outerr($ret['code'], $ret['msg']);
+        }
+
+        // 判断是否处理
+        $model = Model('member');
+        // 判断是否已经注册
+        $ret = $model->getMemberInfo(array('member_mobile' => $mobile));
+        if (empty($ret)) {
+            return self::outerr(errcode::ErrMemberNotExist);
+        } else {
+            $member_id = $ret['member_id'];
+        }
+
+        $ret = $model->editMember(array('member_id' => $member_id), array('member_wxopenid' => $wx_openid, 'wx_info' => $wx_info));
+        if (!$ret) {
+            return self::outerr(errcode::ErrDB);
+        } else {
+            return self::outsuccess(null);
+        }
+    }
+
 //    //以下代码需要挪动
 //    public function bindOp()
 //    {

+ 34 - 0
mobile/control/task.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/3/17
+ * Time: 下午2:09
+ */
+
+defined('InShopNC') or exit('Access Invalid!');
+
+class taskControl extends mobileHomeControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function indexOp()
+    {
+        TPL::showpage("task_home");
+    }
+
+    public function addOp()
+    {
+        $task = $_POST['task'];
+        if(!empty($task)) {
+            if(!is_array($_SESSION['task'])) {
+                $_SESSION['task'] = array();
+            }
+            $_SESSION['task'][] = $task;
+        }
+        self::outsuccess(NULL,"task_home");
+    }
+}

+ 39 - 0
mobile/templates/default/task_home.php

@@ -0,0 +1,39 @@
+<!doctype html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>Add a Task</title>
+    <link rel="stylesheet" href="style.css">
+</head>
+<body>
+
+<?php
+
+echo '<form action="index.php" method="post">
+    <fieldset>
+	<legend>Add a Task</legend>
+	    <input name="act" value="task" hidden>
+	    <input name="op" value="add" hidden>
+        <p>Task: <input name="task" type="text" size="60" maxlength="100" required></p>
+        <p>Parent Task: <select name="parent_id"><option value="0">None</option>';
+
+$tasks = array("1","2","3","4"."5");
+
+foreach($tasks as $task_id) {
+    echo "<option value=\"$task_id\">$task</option>\n";
+}
+
+echo '</select></p>
+<input name="submit" type="submit" value="Add This Task">
+</fieldset>
+</form>';
+
+
+echo '<h2>Current To-Do List</h2><ul>';
+foreach ($_SESSION['task'] as $task) {
+    echo "<li>{$task}</li>\n";
+}
+
+?>
+</body>
+</html>