浏览代码

修改bug

chenbo 4 年之前
父节点
当前提交
f1a23836f0
共有 5 个文件被更改,包括 40 次插入82 次删除
  1. 6 0
      .gitignore
  2. 3 27
      api/demo/reader_login.html
  3. 3 3
      api/login.php
  4. 7 31
      api/reader_login.php
  5. 21 21
      lib/reader.class.php

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
+.idea
+userfiles/
+.DS_Store
+.user.ini
+logs/
+.vscode

+ 3 - 27
api/demo/reader_login.html

@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-    <title>接口4:普通客户登录</title>
+    <title>接口1:阅读与分享</title>
     <script type="text/javascript" src="js/jquery.1.9.1.min.js"></script>
     <script type="text/javascript" src="js/func.common.js"></script>
     <script type="text/javascript" src="js/func.js"></script>
@@ -23,10 +23,6 @@
                 var wxopenid = $('input[name="wxopenid"]').val();
                 var name = $('input[name="name"]').val();
                 var sex = $('input[name="sex"]').val();
-                var province = $('input[name="province"]').val();
-                var city = $('input[name="city"]').val();
-                var detailaddress = $('input[name="detailaddress"]').val();
-                var hangye = $('input[name="hangye"]').val();
 
                 $('#sign').val(sign);
                 $.ajax({
@@ -39,10 +35,6 @@
                         wxopenid  : wxopenid,
                         name  : name,
                         sex  : sex,
-                        province  : province,
-                        city  : city,
-                        detailaddress  : detailaddress,
-                        hangye  : hangye,
 
                     },
                     url : "../api.php",
@@ -61,7 +53,7 @@
     </script>
 </head>
 <body>
-<div id="head"><p>接口6:普通客户登录</p></div>
+<div id="head"><p>接口1:阅读与分享</p></div>
 <div id="content">
     <div id="left">
         <div class ="message"><p>接口返回:</p></div>
@@ -72,7 +64,7 @@
         <form>
             <p>
                 <span>method:</span>
-                <input type="text" class="input-text"  name="method" value="common_guest_login"/>
+                <input type="text" class="input-text"  name="method" value="reader_login"/>
             </p>
             <p>
                 <span>timestamp:</span>
@@ -95,22 +87,6 @@
                 <span>sex:  0-女  1-男 </span>
                 <input type="text" class="input-text"  name="sex" value="1"/>
             </p>
-            <p>
-                <span>province: 省份id</span>
-                <input type="text" class="input-text"  name="province" value="1"/>
-            </p>
-            <p>
-                <span>city: 城市id</span>
-                <input type="text" class="input-text"  name="city" value="1"/>
-            </p>
-            <p>
-                <span>detailaddress: 详细街道</span>
-                <input type="text" class="input-text"  name="detailaddress" value=""/>
-            </p>
-            <p>
-                <span>hangye: 行业id</span>
-                <input type="text" class="input-text"  name="hangye" value="1"/>
-            </p>
 
             <p><button class="button success small" id="btn" type="button">发送请求</button></p>
         </form>

+ 3 - 3
api/login.php

@@ -13,9 +13,9 @@ try {
     if (empty($res['openid'])) {
         echo action_msg($res['errmsg'], 1);
     } else {
-        $guest = Common_guest::getInfoByOpenId($res['openid']);
-        if (!empty($guest)) {
-            $ret = Common_guest::getPassInfo($guest['id']);
+        $reader = Reader::getInfoByOpenId($res['openid']);
+        if (!empty($reader)) {
+            $ret = Reader::getPassInfo($reader['id']);
             $ret['openid'] = $res['openid'];
             $ret['session_key'] = $res['session_key'];
             echo action_msg($ret, 200);

+ 7 - 31
api/reader_login.php

@@ -10,14 +10,6 @@ try {
     $wxopenid = safeCheck($_POST["wxopenid"], 0);
     $name = safeCheck($_POST["name"], 0);
     $sex = safeCheck($_POST["sex"], 0);
-    $province = safeCheck($_POST["province"], 0);
-    $city = safeCheck($_POST["city"], 0);
-    $detailaddress = safeCheck($_POST["detailaddress"], 0);
-    $hangye = safeCheck($_POST["hangye"], 0);
-
-    $province = ($province > 0) ? $province : 0;
-    $city = ($city > 0) ? $city : 0;
-    $hangye = ($hangye > 0) ? $hangye : 0;
 
     //检查
     if (!ParamCheck::is_mobile($phone)) {
@@ -25,7 +17,7 @@ try {
         exit;
     }
     if (empty($name)) {
-        echo action_msg('请填写姓名', 102);
+        echo action_msg('请填写昵称', 102);
         exit;
     }
     if (!in_array($sex, array(0, 1))) {
@@ -36,42 +28,26 @@ try {
         echo action_msg('微信opeid不能为空', 104);
         exit;
     }
-    if (empty($province)) {
-        echo action_msg('请填写省份', 105);
-        exit;
-    }
-//    if (empty($city)) {
-//        echo action_msg('请填写城市', 106);
-//        exit;
-//    }
-    if (empty($hangye)) {
-        echo action_msg('请选择行业', 107);
-        exit;
-    }
 
     //添加不存在的客户
-    $guest = Common_guest::getInfoByPhone($phone);
-    if (empty($guest)) {
+    $reader = Reader::getInfoByPhone($phone);
+    if (empty($reader)) {
         //增加新用户
         $attr['phone'] = $phone;
         $attr['wxopenid'] = $wxopenid;
         $attr['name'] = $name;
         $attr['sex'] = $sex;
-        $attr['province'] = $province;
-        $attr['city'] = $city;
-        $attr['detailaddress'] = $detailaddress;
-        $attr['hangye_id'] = $hangye;
 
-        $id = Common_guest::add($attr);
+        $id = Reader::add($attr);
         if (empty($id)) {
-            echo action_msg('新增普通客户失败', 103);
+            echo action_msg('新增读者失败', 103);
             exit;
         }
     } else {
-        $id = $guest['id'];
+        $id = $reader['id'];
     }
 
-    $ret = Common_guest::getPassInfo($id);
+    $ret = Reader::getPassInfo($id);
     echo action_msg($ret, 200);
 
 } catch (MyException $e) {

+ 21 - 21
lib/reader.class.php

@@ -6,7 +6,7 @@
  * Time: 21:34
  */
 
-class Common_guest{
+class Reader{
 
     public function __construct()
     {
@@ -15,63 +15,63 @@ class Common_guest{
 
     static public function getInfoById($id)
     {
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->getInfoById($id);
+        $Table_reader = new Table_reader();
+        return $Table_reader->getInfoById($id);
     }
 
     static public function getInfoByPhone($phone)
     {
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->getInfoByPhone($phone);
+        $Table_reader = new Table_reader();
+        return $Table_reader->getInfoByPhone($phone);
     }
 
     static public function getInfoByOpenId($openId)
     {
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->getInfoByOpenId($openId);
+        $Table_reader = new Table_reader();
+        return $Table_reader->getInfoByOpenId($openId);
     }
 
     static public function add($attrs)
     {
-        $Table_common_guest = new Table_common_guest();
-        $id = $Table_common_guest->add($attrs);
+        $Table_reader = new Table_reader();
+        $id = $Table_reader->add($attrs);
         return $id;
     }
 
     static public function edit($id, $attrs)
     {
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->edit($id, $attrs);
+        $Table_reader = new Table_reader();
+        return $Table_reader->edit($id, $attrs);
     }
 
     static public function update($id, $attrs)
     {
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->update($id, $attrs);
+        $Table_reader = new Table_reader();
+        return $Table_reader->update($id, $attrs);
     }
 
 
     static public function del($id)
     {
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->del($id);
+        $Table_reader = new Table_reader();
+        return $Table_reader->del($id);
     }
 
 
     static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
     {
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->getList($filter, $count, $page, $pageSize);
+        $Table_reader = new Table_reader();
+        return $Table_reader->getList($filter, $count, $page, $pageSize);
     }
 
     static public function getListByPage($filter = array(), $page=0, $pagesize=0){
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->getList($filter, 0, $page, $pagesize);
+        $Table_reader = new Table_reader();
+        return $Table_reader->getList($filter, 0, $page, $pagesize);
     }
 
     static public function getCountAll($filter = array()){
-        $Table_common_guest = new Table_common_guest();
-        return $Table_common_guest->getList($filter, 1);
+        $Table_reader = new Table_reader();
+        return $Table_reader->getList($filter, 1);
     }
 
 }