dever 6 years ago
parent
commit
cf76ede957
63 changed files with 1386 additions and 4 deletions
  1. 29 0
      doc/apidoc.php
  2. 6 0
      main/src/Journal.php
  3. 8 0
      main/src/User.php
  4. 18 0
      main/src/View.php
  5. 4 4
      service/src/Base.php
  6. 17 0
      vip/assets/mobile/auth.html
  7. 2 0
      vip/assets/mobile/css/auth.css
  8. 1 0
      vip/assets/mobile/css/auth.css.map
  9. 0 0
      vip/assets/mobile/css/global.css
  10. 1 0
      vip/assets/mobile/css/global.css.map
  11. 2 0
      vip/assets/mobile/css/index.css
  12. 1 0
      vip/assets/mobile/css/index.css.map
  13. 0 0
      vip/assets/mobile/css/pay.css
  14. 1 0
      vip/assets/mobile/css/pay.css.map
  15. 2 0
      vip/assets/mobile/css/success.css
  16. 1 0
      vip/assets/mobile/css/success.css.map
  17. BIN
      vip/assets/mobile/images/11.png
  18. BIN
      vip/assets/mobile/images/22.png
  19. BIN
      vip/assets/mobile/images/33.png
  20. BIN
      vip/assets/mobile/images/btnbg.png
  21. BIN
      vip/assets/mobile/images/code.png
  22. BIN
      vip/assets/mobile/images/dot.png
  23. BIN
      vip/assets/mobile/images/icon-alipay.png
  24. BIN
      vip/assets/mobile/images/icon-checkbox.png
  25. BIN
      vip/assets/mobile/images/icon-checked.png
  26. BIN
      vip/assets/mobile/images/icon-timelimit.png
  27. BIN
      vip/assets/mobile/images/icon-wechat.png
  28. BIN
      vip/assets/mobile/images/logo.png
  29. BIN
      vip/assets/mobile/images/novipbg.png
  30. BIN
      vip/assets/mobile/images/success.png
  31. BIN
      vip/assets/mobile/images/tmp.png
  32. BIN
      vip/assets/mobile/images/tmp1.png
  33. BIN
      vip/assets/mobile/images/tmp2.png
  34. BIN
      vip/assets/mobile/images/vipcard.png
  35. 23 0
      vip/assets/mobile/index.html
  36. 2 0
      vip/assets/mobile/js/auth.js
  37. 1 0
      vip/assets/mobile/js/auth.js.map
  38. 0 0
      vip/assets/mobile/js/global.js
  39. 0 0
      vip/assets/mobile/js/global.js.map
  40. 2 0
      vip/assets/mobile/js/index.js
  41. 1 0
      vip/assets/mobile/js/index.js.map
  42. 2 0
      vip/assets/mobile/js/pay.js
  43. 1 0
      vip/assets/mobile/js/pay.js.map
  44. 2 0
      vip/assets/mobile/js/success.js
  45. 1 0
      vip/assets/mobile/js/success.js.map
  46. 93 0
      vip/assets/mobile/pay.html
  47. 22 0
      vip/assets/mobile/success.html
  48. 137 0
      vip/database/config.php
  49. 110 0
      vip/database/member.php
  50. 320 0
      vip/database/order.php
  51. 144 0
      vip/database/time.php
  52. 8 0
      vip/index.php
  53. 32 0
      vip/lib/Member.php
  54. 80 0
      vip/lib/Pay.php
  55. 39 0
      vip/src/Base.php
  56. 146 0
      vip/src/Buy.php
  57. 20 0
      vip/src/Data.php
  58. 17 0
      vip/template/mobile/auth.php
  59. 18 0
      vip/template/mobile/home.php
  60. 14 0
      vip/template/mobile/inc/foot.php
  61. 10 0
      vip/template/mobile/inc/head.php
  62. 33 0
      vip/template/mobile/pay.php
  63. 15 0
      vip/template/mobile/success.php

+ 29 - 0
doc/apidoc.php

@@ -488,6 +488,33 @@
  * @apiSuccess {String}   news.share_content 分享内容
  */
 
+/**
+ * @api {get} wonderful/main/?l=view.vip 查看会员配置信息
+ * @apiVersion 1.0.0
+ * @apiName view.vip
+ * @apiGroup Content
+ *
+ * @apiDescription 查看会员配置信息
+ *
+ * @apiParam {String} signature signature
+ *
+ * @apiSuccess {Object[]} vip_config 配置信息
+ * @apiSuccess {String}   vip_config.name 配置名 
+ * @apiSuccess {String}   vip_config.pic1 会员宣传页第一张图
+ * @apiSuccess {String}   vip_config.pic2 会员宣传页第二张图
+ * @apiSuccess {String}   vip_config.pic3 会员宣传页第三张图
+ * @apiSuccess {String}   vip_config.pic4 会员宣传页第四张图
+ * @apiSuccess {Object[]} vip_time 时效配置
+ * @apiSuccess {String}   vip_time.id 时效名 
+ * @apiSuccess {String}   vip_time.name 时效名
+ * @apiSuccess {String}   vip_time.cash 优惠价、支付价格
+ * @apiSuccess {String}   vip_time.price 原价
+ * @apiSuccess {String}   vip_time.type 1为普通售价、2为超值售价
+
+ * @apiSuccess {String}   mobile 当前登录用户的手机号
+ 
+ */
+
 /**
  * @api {get} wonderful/main/?l=view.comment 查看评论列表
  * @apiVersion 1.0.0
@@ -1323,6 +1350,8 @@
  * @apiSuccess {String}   user.avatar 头像
  * @apiSuccess {String}   user.level 等级
  * @apiSuccess {String}   user.score 积分
+ * @apiSuccess {String}   user.vip_type 会员状态,-1为未开通,-2为已过期,大于0则为正式会员的过期时间戳
+ * @apiSuccess {String}   user.vip_end 当vip_type>0时存在,正式会员的过期时间
  * @apiSuccess {Number}   user_msg 用户新消息数
  */
 

+ 6 - 0
main/src/Journal.php

@@ -380,6 +380,12 @@ class Journal extends Core
             }
         }
 
+        # 会员随便看
+        $vip = Dever::load('vip/lib/member')->get($uid);
+        if ($vip > 0) {
+            $this->setButton('read', 1);
+        }
+
         $applet_type = Dever::input('applet_type');
         if ($applet_type == 2 && isset($this->data['config']['ios_pay']) && $this->data['config']['ios_pay'] == 1 && $info['buy'] == 1) {
             # 关闭支付

+ 8 - 0
main/src/User.php

@@ -24,6 +24,14 @@ class User extends Core
                 }
             }
 
+            # 会员
+            $this->data['user']['vip_type'] = Dever::load('vip/lib/member')->get($this->data['user']);
+            if ($this->data['user']['vip_type'] > 0) {
+                $this->data['user']['vip_end'] = date('Y-m-d', $this->data['user']['vip_type']);
+            } else {
+                $this->data['user']['vip_end'] = '';
+            }
+
             $score = Dever::db('score/user')->all(array('uid' => $this->data['uid']));
             $score_num = 0;
             if ($score) {

+ 18 - 0
main/src/View.php

@@ -230,4 +230,22 @@ class View extends Core
             Dever::alert('错误的数据');
         }
     }
+
+    # 获取会员的信息接口
+    public function vip()
+    {
+        $this->data['vip_config'] = Dever::db('vip/config')->one();
+
+        $this->data['vip_time'] = Dever::db('vip/config')->getAll();
+
+
+        if ($this->data['uid'] > 0) {
+            $user = Dever::load('passport/api')->info($this->data['uid']);
+            $this->data['mobile'] = $user['mobile'];
+        } else {
+            $this->data['mobile'] = '';
+        }
+
+        return $this->data;
+    }
 }

+ 4 - 4
service/src/Base.php

@@ -74,7 +74,7 @@ class Base
     }
 
     # 生成url
-    protected function url($uri, $param = array())
+    protected function url($uri, $param = array(), $project = 'service')
     {
         if ($uri == 'list' && $this->type == 2) {
             $uri = 'list_code';
@@ -86,14 +86,14 @@ class Base
         $param['p'] = Dever::encode(Dever::json_encode($send), $this->key);
 
     	$param = http_build_query($param);
-    	$url = Dever::url($uri . '?' . $param, 'service');
+    	$url = Dever::url($uri . '?' . $param, $project);
 
     	return $url;
     }
 
-    protected function location($uri, $param = array())
+    protected function location($uri, $param = array(), $project = 'service')
     {
-    	return Dever::location($this->url($uri, $param));
+    	return Dever::location($this->url($uri, $param, $project));
     }
 
     protected function createOrder($prefix = 'JC')

+ 17 - 0
vip/assets/mobile/auth.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+    <title>精美时尚</title>
+<link href="css/global.css?v=099b487e" rel="stylesheet"><link href="css/auth.css?v=099b487e" rel="stylesheet"></head>
+
+<body>
+    <img class="logo" src="images/logo.png"/>
+    <p class="tip">
+        授权后可直接购买成为会员<br>感谢您的支持
+    </p>
+    <button class="button">授权登录</button>
+<script type="text/javascript" src="js/global.js?v=099b487e"></script><script type="text/javascript" src="js/auth.js?v=099b487e"></script></body>
+</html>

+ 2 - 0
vip/assets/mobile/css/auth.css

@@ -0,0 +1,2 @@
+body{background:#fff}.logo{width:2.66667rem;height:2.66667rem;border-radius:50%;display:block;margin:3.25333rem auto .54667rem}.tip{font-size:.4rem;line-height:.61333rem;text-align:center;margin:0 auto .69333rem}
+/*# sourceMappingURL=auth.css.map?v=099b487e*/

+ 1 - 0
vip/assets/mobile/css/auth.css.map

@@ -0,0 +1 @@
+{"version":3,"sources":[],"names":[],"mappings":"","file":"css/auth.css?v=099b487e","sourceRoot":""}

File diff suppressed because it is too large
+ 0 - 0
vip/assets/mobile/css/global.css


+ 1 - 0
vip/assets/mobile/css/global.css.map

@@ -0,0 +1 @@
+{"version":3,"sources":[],"names":[],"mappings":"","file":"css/global.css?v=099b487e","sourceRoot":""}

+ 2 - 0
vip/assets/mobile/css/index.css

@@ -0,0 +1,2 @@
+body{background-color:#000}.container{width:9.2rem;margin:.4rem auto;padding-bottom:1.2rem;box-sizing:border-box}.container .vipcard{width:100%}.container .content img{display:block;width:100%;margin-top:1.2rem}.paybtn{background:url(../images/btnbg.png) no-repeat;background-size:auto 1.2rem;height:1.2rem;text-align:center;line-height:1.2rem;color:#fff;position:fixed;bottom:0;left:0;width:100%;font-size:.4rem}
+/*# sourceMappingURL=index.css.map?v=099b487e*/

+ 1 - 0
vip/assets/mobile/css/index.css.map

@@ -0,0 +1 @@
+{"version":3,"sources":[],"names":[],"mappings":"","file":"css/index.css?v=099b487e","sourceRoot":""}

File diff suppressed because it is too large
+ 0 - 0
vip/assets/mobile/css/pay.css


+ 1 - 0
vip/assets/mobile/css/pay.css.map

@@ -0,0 +1 @@
+{"version":3,"sources":[],"names":[],"mappings":"","file":"css/pay.css?v=099b487e","sourceRoot":""}

+ 2 - 0
vip/assets/mobile/css/success.css

@@ -0,0 +1,2 @@
+.success{margin:1.94667rem auto .70667rem;text-align:center;font-size:.48rem;line-height:.8rem}.success:before{display:block;content:"";background:url(../images/success.png) no-repeat top;background-size:.786667rem .786667rem;width:.8rem;height:.8rem;margin:0 auto .21333rem}.download{text-align:center;height:.90667rem;margin-bottom:.93333rem}.download a{color:#d1171a;text-decoration:underline;font-size:.37333rem}.code img{display:block;width:3.14667rem;height:3.14667rem;margin:0 auto .33333rem}.code p{text-align:center;color:#999;font-size:.37333rem;line-height:.48rem}
+/*# sourceMappingURL=success.css.map?v=099b487e*/

+ 1 - 0
vip/assets/mobile/css/success.css.map

@@ -0,0 +1 @@
+{"version":3,"sources":[],"names":[],"mappings":"","file":"css/success.css?v=099b487e","sourceRoot":""}

BIN
vip/assets/mobile/images/11.png


BIN
vip/assets/mobile/images/22.png


BIN
vip/assets/mobile/images/33.png


BIN
vip/assets/mobile/images/btnbg.png


BIN
vip/assets/mobile/images/code.png


BIN
vip/assets/mobile/images/dot.png


BIN
vip/assets/mobile/images/icon-alipay.png


BIN
vip/assets/mobile/images/icon-checkbox.png


BIN
vip/assets/mobile/images/icon-checked.png


BIN
vip/assets/mobile/images/icon-timelimit.png


BIN
vip/assets/mobile/images/icon-wechat.png


BIN
vip/assets/mobile/images/logo.png


BIN
vip/assets/mobile/images/novipbg.png


BIN
vip/assets/mobile/images/success.png


BIN
vip/assets/mobile/images/tmp.png


BIN
vip/assets/mobile/images/tmp1.png


BIN
vip/assets/mobile/images/tmp2.png


BIN
vip/assets/mobile/images/vipcard.png


+ 23 - 0
vip/assets/mobile/index.html

@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+    <title>精美时尚</title>
+<link href="css/global.css?v=099b487e" rel="stylesheet"><link href="css/index.css?v=099b487e" rel="stylesheet"></head>
+
+<body>
+    <div class="container">
+        <img class="vipcard" src="images/vipcard.png" alt="">
+
+        <div class="content">
+            <img src="images/11.png" alt="">
+            <img src="images/22.png" alt="">
+            <img src="images/33.png" alt="">
+        </div>
+    </div>
+    <a href="#" class="paybtn">立即购买</a>
+<script type="text/javascript" src="js/global.js?v=099b487e"></script><script type="text/javascript" src="js/index.js?v=099b487e"></script></body>
+
+</html>

+ 2 - 0
vip/assets/mobile/js/auth.js

@@ -0,0 +1,2 @@
+webpackJsonp([3],{1:function(n,t,c){"use strict";c(0),c(7)},12:function(n,t,c){n.exports=c(1)},7:function(n,t){}},[12]);
+//# sourceMappingURL=auth.js.map?v=099b487e

+ 1 - 0
vip/assets/mobile/js/auth.js.map

@@ -0,0 +1 @@
+{"version":3,"sources":["webpack:///js/auth.js","webpack:///./mobile/src/router/auth.js"],"names":["webpackJsonp","1","module","exports","__webpack_require__","12","7"],"mappings":"AAAAA,cAAc,IAERC,EACA,SAAUC,EAAQC,EAASC,GAEjC,YCLAA,GAAA,GACAA,EAAA,IDaMC,GACA,SAAUH,EAAQC,EAASC,GAEjCF,EAAOC,QAAUC,EAAoB,IAK/BE,EACA,SAAUJ,EAAQC,OAMrB","file":"js/auth.js?v=099b487e","sourcesContent":["webpackJsonp([3],{\n\n/***/ 1:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\n__webpack_require__(0);\n\n__webpack_require__(7);\n\n/***/ }),\n\n/***/ 12:\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__(1);\n\n\n/***/ }),\n\n/***/ 7:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n},[12]);\n\n\n// WEBPACK FOOTER //\n// js/auth.js?v=099b487e","import './global';\r\nimport '../css/auth.css';\r\n\n\n\n// WEBPACK FOOTER //\n// ./mobile/src/router/auth.js"],"sourceRoot":""}

File diff suppressed because it is too large
+ 0 - 0
vip/assets/mobile/js/global.js


File diff suppressed because it is too large
+ 0 - 0
vip/assets/mobile/js/global.js.map


+ 2 - 0
vip/assets/mobile/js/index.js

@@ -0,0 +1,2 @@
+webpackJsonp([2],{14:function(n,t,c){n.exports=c(2)},2:function(n,t,c){"use strict";c(0),c(9)},9:function(n,t){}},[14]);
+//# sourceMappingURL=index.js.map?v=099b487e

+ 1 - 0
vip/assets/mobile/js/index.js.map

@@ -0,0 +1 @@
+{"version":3,"sources":["webpack:///js","webpack:///./mobile/src/router/index.js"],"names":["webpackJsonp","14","module","exports","__webpack_require__","2","9"],"mappings":"AAAAA,cAAc,IAERC,GACA,SAAUC,EAAQC,EAASC,GAEjCF,EAAOC,QAAUC,EAAoB,IAK/BC,EACA,SAAUH,EAAQC,EAASC,GAEjC,YCbAA,GAAA,GACAA,EAAA,IDqBME,EACA,SAAUJ,EAAQC,OAMrB","file":"js/index.js?v=099b487e","sourcesContent":["webpackJsonp([2],{\n\n/***/ 14:\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__(2);\n\n\n/***/ }),\n\n/***/ 2:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\n__webpack_require__(0);\n\n__webpack_require__(9);\n\n/***/ }),\n\n/***/ 9:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ })\n\n},[14]);\n\n\n// WEBPACK FOOTER //\n// js?v=099b487e","import './global';\r\nimport '../css/index.css';\r\n\n\n\n// WEBPACK FOOTER //\n// ./mobile/src/router/index.js"],"sourceRoot":""}

+ 2 - 0
vip/assets/mobile/js/pay.js

@@ -0,0 +1,2 @@
+webpackJsonp([1],{10:function(n,t){},15:function(n,t,c){n.exports=c(3)},3:function(n,t,c){"use strict";c(0),c(10)}},[15]);
+//# sourceMappingURL=pay.js.map?v=099b487e

+ 1 - 0
vip/assets/mobile/js/pay.js.map

@@ -0,0 +1 @@
+{"version":3,"sources":["webpack:///js/pay.js","webpack:///./mobile/src/router/pay.js"],"names":["webpackJsonp","10","module","exports","15","__webpack_require__","3"],"mappings":"AAAAA,cAAc,IAERC,GACA,SAAUC,EAAQC,KAMlBC,GACA,SAAUF,EAAQC,EAASE,GAEjCH,EAAOC,QAAUE,EAAoB,IAK/BC,EACA,SAAUJ,EAAQC,EAASE,GAEjC,YCpBAA,GAAA,GACAA,EAAA,OD4BG","file":"js/pay.js?v=099b487e","sourcesContent":["webpackJsonp([1],{\n\n/***/ 10:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 15:\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__(3);\n\n\n/***/ }),\n\n/***/ 3:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\n__webpack_require__(0);\n\n__webpack_require__(10);\n\n/***/ })\n\n},[15]);\n\n\n// WEBPACK FOOTER //\n// js/pay.js?v=099b487e","import './global';\r\nimport '../css/pay.css';\n\n\n// WEBPACK FOOTER //\n// ./mobile/src/router/pay.js"],"sourceRoot":""}

+ 2 - 0
vip/assets/mobile/js/success.js

@@ -0,0 +1,2 @@
+webpackJsonp([0],{11:function(n,t){},16:function(n,t,c){n.exports=c(4)},4:function(n,t,c){"use strict";c(0),c(11)}},[16]);
+//# sourceMappingURL=success.js.map?v=099b487e

+ 1 - 0
vip/assets/mobile/js/success.js.map

@@ -0,0 +1 @@
+{"version":3,"sources":["webpack:///js/success.js","webpack:///./mobile/src/router/success.js"],"names":["webpackJsonp","11","module","exports","16","__webpack_require__","4"],"mappings":"AAAAA,cAAc,IAERC,GACA,SAAUC,EAAQC,KAMlBC,GACA,SAAUF,EAAQC,EAASE,GAEjCH,EAAOC,QAAUE,EAAoB,IAK/BC,EACA,SAAUJ,EAAQC,EAASE,GAEjC,YCpBAA,GAAA,GACAA,EAAA,OD4BG","file":"js/success.js?v=099b487e","sourcesContent":["webpackJsonp([0],{\n\n/***/ 11:\n/***/ (function(module, exports) {\n\n// removed by extract-text-webpack-plugin\n\n/***/ }),\n\n/***/ 16:\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__(4);\n\n\n/***/ }),\n\n/***/ 4:\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\n__webpack_require__(0);\n\n__webpack_require__(11);\n\n/***/ })\n\n},[16]);\n\n\n// WEBPACK FOOTER //\n// js/success.js?v=099b487e","import './global';\r\nimport '../css/success.css';\r\n\n\n\n// WEBPACK FOOTER //\n// ./mobile/src/router/success.js"],"sourceRoot":""}

+ 93 - 0
vip/assets/mobile/pay.html

@@ -0,0 +1,93 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+    <title>精美时尚</title>
+<link href="css/global.css?v=099b487e" rel="stylesheet"><link href="css/pay.css?v=099b487e" rel="stylesheet"></head>
+
+<body>
+    <div class="container">
+        <div class="novip-card"></div>
+        <div class="payform">
+            <dl>
+                <dt>确认会员手机号</dt>
+                <dd>
+                    <input type="number" id="mobile"/>
+                </dd>
+            </dl>
+            <dl>
+                <dt>选择开通时长</dt>
+                <dd id="package">
+                    <div class="time-option active" data-price="100" data-package="1">
+                        <span>1个月<i></i></span>
+                        <span><i></i><b>100</b>¥180</span>
+                    </div>
+                    <div class="time-option" data-price="200" data-package="2">
+                        <span>6个月</span>
+                        <span><i></i><b>200</b>¥180</span>
+                    </div>
+                    <div class="time-option" data-price="300" data-package="3">
+                        <span>1年</span>
+                        <span><i></i><b>300</b>¥180</span>
+                    </div>
+                </dd>
+            </dl>
+            <dl>
+                <dt>选择支付方式</dt>
+                <dd class="no-padding" id="paytype">
+                    <div class="paytype-option active" data-type="wechat">
+                        <span><i class="icon-wechat"></i>微信支付</span>
+                        <span class="icon-checkbox"></span>
+                    </div>
+                    <div class="paytype-option" data-type="alipay">
+                        <span><i class="icon-alipay"></i>支付宝支付</span>
+                        <span class="icon-checkbox"></span>
+                    </div>
+                </dd>
+            </dl>
+        </div>
+    </div>
+    <div id="pay"></div>
+    <button class="button fixed-button" id="submit">确认支付</button>
+<script type="text/javascript" src="js/global.js?v=099b487e"></script><script type="text/javascript" src="js/pay.js?v=099b487e"></script></body>
+<script>
+function pay(url,mobile,type)
+{
+    $.get(url, {mobile:mobile,type:type}, function(t) {
+        $("#pay").html(t);
+    })
+}
+    $(function(){
+        var oPackage = {
+            price: 100,
+            package: 1,
+            url:''
+        },oPayType = "wechat";
+        $('#package').on('click','[data-package]',function(){
+            $(this).addClass('active').siblings().removeClass('active');
+            oPackage.price = $(this).data('price');
+            oPackage.package = $(this).data('package');
+            oPackage.url = $(this).data('url');
+            $('#submit').html('确认支付¥' + oPackage.price);
+        })
+        $('#paytype').on('click','[data-type]',function(){
+            $(this).addClass('active').siblings().removeClass('active');
+            oPayType = $(this).data('type')
+        })
+        $('#submit').click(function(){
+            var mobile = $("#mobile").val();
+            if(!/1\d{10}/.test(mobile)){
+                alert("手机号码不正确");
+                return;
+            }
+            //console.log(mobile,oPackage,oPayType)
+            pay(oPackage.url, mobile, oPayType);
+        })
+        
+        $('.active').click();
+    })
+</script>
+
+</html>

+ 22 - 0
vip/assets/mobile/success.html

@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+    <title>精美时尚</title>
+<link href="css/global.css?v=099b487e" rel="stylesheet"><link href="css/success.css?v=099b487e" rel="stylesheet"></head>
+
+<body>
+    <div class="success">购买成功!</div>
+    <p class="download"><a href="#">点击下载“JSTYLE精美”APP查看电子刊</a></p>
+    <div class="code">
+        <img src="images/code.png"/>
+        <p>
+            或长按扫描二维码下载App
+            <br>享受专属会员特权
+        </p>
+    </div>
+<script type="text/javascript" src="js/global.js?v=099b487e"></script><script type="text/javascript" src="js/success.js?v=099b487e"></script></body>
+
+</html>

+ 137 - 0
vip/database/config.php

@@ -0,0 +1,137 @@
+<?php
+
+$ios_pay = array
+(
+	1 => '关闭小程序支付',
+	2 => '开启公众号支付',
+	3 => '开启小程序支付',
+);
+
+$video = array
+(
+	1 => '显示',
+	2 => '不显示',
+);
+
+return array
+(
+	# 表名
+	'name' => 'config',
+	# 显示给用户看的名称
+	'lang' => '基本配置',
+	'order' => 1,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '系统ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'hr1'		=> array
+		(
+			'name' 		=> '通用设置',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '会员设置',
+			'default' 	=> '',
+			'desc' 		=> '会员设置',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'pic1'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '第一张图片',
+			'default' 	=> '',
+			'desc' 		=> '第一张图片',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'pic2'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '第二张图片',
+			'default' 	=> '',
+			'desc' 		=> '第二张图片',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'pic3'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '第三张图片',
+			'default' 	=> '',
+			'desc' 		=> '第三张图片',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'pic4'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '第四张图片',
+			'default' 	=> '',
+			'desc' 		=> '第四张图片',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	'default' => array
+	(
+		'col' => 'name',
+		'value' => array
+		(
+			'"会员设置"',
+		),
+	),
+
+	/*
+	'alter' => array
+	(
+		2 => array
+		(
+			array('update', 'task_id', 'task_id', 'varchar-800  软装任务链接'),
+			//array('add', 'config', 'config', 'int-11 1 配置'),
+		),
+		'version' => 2,
+	),
+	*/
+
+	'manage' => array
+	(
+		# 后台管理不要列表页
+		'list' => 'update',
+	),
+);

+ 110 - 0
vip/database/member.php

@@ -0,0 +1,110 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'member',
+    # 显示给用户看的名称
+    'lang' => '会员管理',
+    # 后台菜单排序
+    'order' => 20,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买者用户名',
+            'default'   => '',
+            'desc'      => '购买者用户名',
+            'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'update'    => 'text',
+        ),
+        
+        'mobile'        => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'option',
+            //'show'        => 'status=5'
+            'search'    => 'fulltext',
+            'list'		=> true,
+        ),
+        
+        'start'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '开始时间',
+            'match'     => 'is_numeric',
+            'desc'      => '开始时间',
+            'update'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {start})',
+            'callback'  => 'maketime',
+        ),
+
+        'end'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '结束时间',
+            'match'     => 'is_numeric',
+            'desc'      => '结束时间',
+            'update'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {end})',
+            'callback'  => 'maketime',
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 320 - 0
vip/database/order.php

@@ -0,0 +1,320 @@
+<?php
+
+$type = array
+(
+    1 => '购买会员',
+);
+
+# 系统
+$system = array
+(
+    1 => '小程序',
+    1 => 'H5',
+    3 => 'ios',
+    4 => '安卓',
+);
+
+# 渠道
+$source = function()
+{
+    return Dever::db('source/info')->state();
+};
+
+$status = array
+(
+    1 => '待支付',
+    2 => '已支付',
+    3 => '支付失败',
+    //4 => '申请退款',
+    5 => '已退款',
+);
+
+$seller = function()
+{
+    return Dever::db('code/seller')->state();
+};
+
+return array
+(
+    # 表名
+    'name' => 'order',
+    # 显示给用户看的名称
+    'lang' => '订单管理',
+    'order' => 1,
+
+    'end' => array
+    (
+        //'update' => 'journal/lib/manage.order',
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单id',
+            'default'   => '',
+            'desc'      => '付款订单id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'        => true,
+            //'list'        => '"{order_id}" ? "{order_id}" : "{code}"',
+        ), 
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '订单名称',
+            'default'   => '',
+            'desc'      => '订单名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name' => '订单信息',
+            'list'      => 'Dever::load("journal/lib/manage.showOrderUser", "{id}")',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名',
+            'default'   => '',
+            'desc'      => '用户id',
+            'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'update'    => 'text',
+        ),
+
+        'mobile'        => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'option',
+            //'show'        => 'status=5'
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '支付方式',
+            'default'   => '1',
+            'desc'      => '支付方式',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'search'    => 'select',
+            'update'    => 'radio',
+            //'list'        => true,
+            'control'   => 'type',
+        ),
+
+        'system'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '系统',
+            'default'   => '1',
+            'desc'      => '系统',
+            'match'     => 'is_numeric',
+            'option'    => $system,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'        => true,
+        ),
+
+        'source'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '渠道来源',
+            'default'   => '1',
+            'desc'      => '支付方式',
+            'match'     => 'is_numeric',
+            'option'    => $source,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'        => true,
+        ),
+
+        'seller_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '1',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $seller,
+            'search'    => 'select',
+            //'list'      => true,
+        ),
+
+        'notice'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '模板消息提醒次数',
+            'default'   => '0',
+            'desc'      => '模板消息提醒次数',
+            'match'     => 'is_numeric',
+        ),
+
+        'start'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '开始时间',
+            'match'     => 'is_string',
+            'desc'      => '开始时间',
+            'update'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {start})',
+            'callback'  => 'maketime',
+        ),
+
+        'end'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '结束时间',
+            'match'     => 'is_string',
+            'desc'      => '结束时间',
+            'update'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {end})',
+            'callback'  => 'maketime',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=1',
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '使用的兑换码',
+            'default'   => '',
+            'desc'      => '使用的兑换码',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=2',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '请选择订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'      => 'Dever::load("journal/lib/manage.showOrderStatus", "{id}")',
+            'control'   => 'status',
+        ),
+
+        'tk_time'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款时间',
+            'default'   => '',
+            'desc'      => '退款时间',
+            'match'     => 'option',
+            //'list'        => true,
+            'show'      => 'status=5',
+        ),
+
+        'tk_admin'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款审核人',
+            'default'   => '1',
+            'desc'      => '退款审核人',
+            'match'     => 'option',
+            //'list'        => true,
+            'show'      => 'status=5',
+        ),
+
+        'tk_desc'       => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '退款备注',
+            'default'   => '',
+            'desc'      => '退款备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            //'show'        => 'status=5',
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '下单时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'date',
+            'list'        => 'date("Y-m-d H:i:s", {cdate})',
+            //'list'      => 'Dever::load("service/lib/manage.showOrderTime", "{id}")',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+
+        'button' => array
+        (
+            //'导出订单' => array('location', 'journal/lib/manage.out'),
+        ),
+
+        'list_button' => array(
+            //'edit' => array('退款', 'tk_time,tk_desc,tk_admin', '{status} > 1'),
+            //'delete' => array('删除', '', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 144 - 0
vip/database/time.php

@@ -0,0 +1,144 @@
+<?php
+
+$type = array
+(
+    1 => '普通价格',
+    2 => '超值价格',
+);
+
+return array
+(
+    # 表名
+    'name' => 'time',
+    # 显示给用户看的名称
+    'lang' => '时长设置',
+    # 后台菜单排序
+    'order' => 19,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'name'        => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '时长名称-如1年',
+            'default'   => '',
+            'desc'      => '时长名称',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+        
+        'time'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '时长设置-以天为单位,直接填写数字即可,如1年则填写365',
+            'match'     => 'is_numeric',
+            'desc'      => '时长设置',
+            'update'    => 'text',
+        ),
+
+        'cash'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '当前价格',
+            'match'     => 'is_numeric',
+            'desc'      => '当前价格',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'price'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '原价格设置',
+            'match'     => 'is_numeric',
+            'desc'      => '原价格设置',
+            'update'    => 'text',
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '时长价格类型',
+            'default'   => '1',
+            'desc'      => '时长价格类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'search'    => 'select',
+            'update'    => 'radio',
+            //'list'        => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        //'insert' => false,
+        //'edit' => false,
+        //'delete' => false,
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 8 - 0
vip/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'vip');
+define('DEVER_APP_LANG', '会员管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 191);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-rmb');
+include(DEVER_APP_PATH . '../boot.php');

+ 32 - 0
vip/lib/Member.php

@@ -0,0 +1,32 @@
+<?php
+namespace Vip\Lib;
+
+use Dever;
+
+class Member
+{
+	public function get($uid)
+	{
+		if (is_array($uid)) {
+			$user = $uid;
+		} else {
+			$user = Dever::db('passport/user')->one($uid);
+		}
+
+		if ($user['mobile']) {
+			$member = Dever::db('vip/member')->one(array('mobile' => $user['mobile']));
+
+			if ($member) {
+				if (time() > $member['end']) {
+					# 已过期
+					return -2; 
+				} else {
+					return $member['end'];
+				}
+			}
+		}
+
+		# 未开通
+		return -1;
+	}
+}

+ 80 - 0
vip/lib/Pay.php

@@ -0,0 +1,80 @@
+<?php
+namespace Vip\Lib;
+
+use Dever;
+
+class Pay
+{
+	/**
+	 * 支付成功后,调取的接口
+	 *
+	 * @return mixed
+	 */
+	public function act_api($param = array())
+	{
+        $send = Dever::preInput('pay_');
+        $key = md5('vip_buy');
+        ksort($send);
+        $send['signature'] = md5($key . '&' . http_build_query($send));
+        $signature = Dever::input('signature');
+        if ($send['signature'] == $signature) {
+            $product_id = $send['pay_product_id'];
+            $uid = $send['pay_uid'];
+            $cash = $send['pay_cash'];
+            $order_id = $send['pay_order_id'];
+            $status = $send['pay_status'];
+            $msg = $send['pay_msg'];
+
+            $order = Dever::db('vip/order')->one(array('order_id' => $order_id, 'uid' => $uid));
+
+            if ($send['pay_status'] == 2 && $order) {
+                
+                $update = array();
+                $update['where_id'] = $order['id'];
+                $update['status'] = 2;
+
+                Dever::db('journal/order')->update($update);
+
+                if ($order['type'] != 1) {
+                    return;
+                }
+
+                if ($order['buy_id'] > 0) {
+                    $buy = Dever::db('vip/time')->one($order['buy_id']);
+                    if ($buy) {
+
+                        $member = Dever::db('vip/member')->one(array('mobile' => $order['mobile']));
+
+                        $insert['mobile'] = $order['mobile'];
+                        $insert['uid'] = $order['uid'];
+                        $insert['end'] = $order['end'] + ($buy['time'] * 86400);
+
+                        if ($member) {
+                            $insert['where_id'] = $member['id'];
+                            Dever::db('vip/member')->update($insert);
+                        } else {
+                            $insert['start'] = time();
+                            Dever::db('vip/member')->insert($insert);
+                        }
+
+                        # 发消息
+                        /*
+                        if (Dever::project('message')) {
+                            Dever::load('message/lib/data')->push(-1, $uid, '购买提醒', '购买成功,您获得了 '.$buy['name'].' 的会员资格!', 11);
+                        }
+
+                        # 发短信
+                        if (Dever::project('sms')) {
+                            $send = array();
+                            $send['name'] = $buy['name'];
+                            Dever::load('sms/api.send', 'buy_member', $order['mobile'], $send);
+                        }
+                        */
+                    }
+                }
+            } else {
+                Dever::db('vip/order')->update(array('where_id' => $order['id'], 'status' => 3));
+            }
+        }
+	}
+}

+ 39 - 0
vip/src/Base.php

@@ -0,0 +1,39 @@
+<?php namespace Vip\Src;
+
+use Dever;
+use Service\Src\Base as P;
+
+class Base extends P
+{
+    # 获取基本配置
+    public function config()
+    {
+        $config = Dever::db('main/config')->one();
+
+        $config['buy'] = $this->url('pay', array(), 'vip');
+        $config['login'] = 'location.href=\'' . Dever::url('request.auth?account='.$this->account.'&source='.$this->source.'&refer=' . urlencode($config['buy']), 'oauth') . '\'';
+
+        $vip = Dever::db('vip/config')->one();
+
+        $config['title'] = $vip['name'];
+        $config['pic1'] = $vip['pic1'];
+        $config['pic2'] = $vip['pic2'];
+        $config['pic3'] = $vip['pic3'];
+        $config['pic4'] = $vip['pic4'];
+
+        return $config;
+    }
+
+    protected function createOrder($prefix = 'HY')
+    {
+        $order = Dever::order($prefix);
+
+        $info = Dever::db('vip/order')->one(array('order_id' => $order));
+
+        if ($info) {
+            return $this->createOrder($prefix);
+        }
+
+        return $order;
+    }
+}

+ 146 - 0
vip/src/Buy.php

@@ -0,0 +1,146 @@
+<?php namespace Vip\Src;
+
+use Dever;
+
+# 必须登录才能购买小刊
+class Buy extends Base
+{
+	public function __construct()
+    {
+    	parent::__construct();
+
+    	if (!$this->user) {
+    		//return $this->location('auth', array(), 'vip');
+    	}
+    }
+
+    # 详细信息
+    public function info()
+    {
+        $info = array();
+
+        if ($this->user) {
+            $info['mobile'] = $this->user['mobile'];
+        } else {
+            $info['mobile'] = '';
+        }
+
+        # 下载地址
+        $info['download'] = 'http://t.cn/ELf3Waq';
+        # 下载二维码
+        $info['download_code'] = '';
+        
+        return $info;
+    }
+
+    # 购买页
+    public function buy()
+    {
+        $data = Dever::db('vip/time')->state();
+
+        if ($data) {
+            $i = 0;
+            foreach ($data as $k => $v) {
+
+                $data[$k]['price'] = '<i>¥</i><b>'.$v['cash'].'</b>¥' . $v['price'];
+
+                if ($v['type'] == 2) {
+                    $data[$k]['name'] .= '<i></i>';
+                }
+                if ($i == 0) {
+                    $data[$k]['active'] = 'active';
+                } else {
+                    $data[$k]['active'] = '';
+                }
+                
+                $data[$k]['pay_url'] = $this->url('buy.pay', array('buy_id' => $v['id']), 'vip');
+
+                $i++;
+            }
+        }
+        return $data;
+    }
+
+    # 购买
+    public function pay()
+    {
+        $uid = $this->user['id'];
+
+        $buy_id = Dever::input('buy_id');
+        $mobile = Dever::input('mobile');
+        $type = Dever::input('type');
+
+        if (!$buy_id) {
+            Dever::alert('请传入正确的支付ID');
+        }
+        if (!$mobile) {
+            Dever::alert('请传入正确的手机号');
+        }
+
+        $user = Dever::db('passport/user')->one(array('mobile' => $mobile));
+        $buy = Dever::db('vip/time')->one($buy_id);
+
+        if (!$buy || !$user) {
+            Dever::alert('请传入正确的信息');
+        }
+
+        $user = Dever::db('passport/user')->one($uid);
+
+        if ($type == 'wechat') {
+            $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid, 'type' => 2));
+        } elseif ($type != 'alipay') {
+            Dever::alert('请传入正确的信息');
+        }
+        
+
+        $order_id = $this->createOrder();
+        $order_data['order_id'] = $order_id;
+        $order_data['buy_id'] = $buy_id;
+        $order_data['uid'] = $uid;
+        $order_data['mobile'] = $mobile;
+        $order_data['type'] = 1;
+        $order_data['status'] = 1;
+
+        $order_data['name'] = $buy['name'];
+        $order_data['cash'] = $buy['cash'];
+
+        $order_data['system'] = 2;
+        if ($this->source) {
+        	$order_data['source'] = $this->source;
+        }
+
+        if ($this->seller) {
+            $order_data['seller_id'] = $this->seller;
+        }
+
+        $id = Dever::db('vip/order')->insert($order_data);
+
+        if (!$id) {
+            Dever::alert('支付失败');
+        }
+
+        //$param参数
+        $refer = $this->url('success', array('buy' => $buy_id, 'order_id' => $id), 'vip');
+        $param = array
+        (
+            'project_id' => 2,
+            'uid' => $uid,
+            'username' => $user['username'],
+            'name' => $order_data['name'],
+            'cash' => $order_data['cash'],
+            //'cash' => '0.01',
+            'product_id' => $buy_id,
+            'order_id' => $order_id,
+            'refer' => $refer
+        );
+
+        if (isset($wechat) && $wechat) {
+            $param['account_id'] = 2;
+            $param['openid'] = $wechat['openid'];
+        } elseif ($type == 'alipay') {
+            $param['account_id'] = 6;
+        }
+
+        return Dever::load('pay/api.page', $param);
+    }
+}

+ 20 - 0
vip/src/Data.php

@@ -0,0 +1,20 @@
+<?php namespace Vip\Src;
+
+use Dever;
+
+# 未登录
+class Data extends Base
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function checkLogin()
+    {
+        //return $this->location('list');
+        if ($this->user) {
+            return $this->location('pay');
+        }
+    }
+}

+ 17 - 0
vip/template/mobile/auth.php

@@ -0,0 +1,17 @@
+<?php
+
+$view
+
+->set('name', 'auth')
+
+->import('inc/head')
+
+->fetch('.logo@src',    'vip/base.config#logo')
+
+->fetch('.tip@check', 'vip/data.checkLogin')
+
+->fetch('.button@onclick', 'vip/base.config#login')
+
+->import('inc/foot')
+
+->display();

+ 18 - 0
vip/template/mobile/home.php

@@ -0,0 +1,18 @@
+<?php
+
+$view
+
+->set('name', 'index')
+
+->import('inc/head')
+
+->fetch(array('img@src', 0),    'vip/base.config#pic1')
+->fetch(array('img@src', 1),    'vip/base.config#pic2')
+->fetch(array('img@src', 2),    'vip/base.config#pic3')
+->fetch(array('img@src', 3),    'vip/base.config#pic4')
+
+->fetch('.paybtn@href', 'vip/base.config#buy')
+
+->import('inc/foot')
+
+->display();

+ 14 - 0
vip/template/mobile/inc/foot.php

@@ -0,0 +1,14 @@
+<?php
+
+$view
+
+->fetch(array('script@src', 0),     Dever::assets('global.js'))
+->fetch(array('script@src', 1),     Dever::assets('<{(isset($name) ? $name : "index")}>.js', 'js'))
+
+
+->append('body',    '<script src="'.Dever::assets('lib/jquery/jquery.min.js', 'script').'"></script>')
+->append('body',    '<script src="'.Dever::assets('dever/core.js', 'script').'"></script>')
+->append('body',    '<script src="'.Dever::assets('config.js').'"></script>')
+->append('body',    '<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>')
+
+;

+ 10 - 0
vip/template/mobile/inc/head.php

@@ -0,0 +1,10 @@
+<?php
+
+$view
+->fetch('title',                    '<{isset($title) ? $title . "_" . Dever::load("vip/base.config#title") : Dever::load("vip/base.config#title")}>')
+
+->fetch(array('link@href', 0),      Dever::assets("global.css"))
+->fetch(array('link@href', 1),      Dever::assets('<{(isset($name) ? $name : "index")}>.css', "css"))
+
+
+->append('head',    '<script><{Dever::script()}>config.uid=<{Dever::load("passport/user.data") ? Dever::load("passport/user.data#id") : -1}></script>');

+ 33 - 0
vip/template/mobile/pay.php

@@ -0,0 +1,33 @@
+<?php
+
+$view
+
+->set('name', 'pay')
+
+->import('inc/head')
+
+->fetch('#mobile', 'vip/buy.info#mobile')
+
+# 循环
+->loop
+(
+    '#package .time-option',
+    'vip/buy.buy',
+    array
+    (
+        'span|0' => '$v.name',
+        'span|1' => '$v.price',
+
+        'self' => array
+        (
+            'class' => 'time-option <{$v.active}>',
+            'data-price' => '$v.cash',
+            'data-package' => '$v.id',
+            'data-url' => '$v.pay_url',
+        ),
+    )
+)
+
+->import('inc/foot')
+
+->display();

+ 15 - 0
vip/template/mobile/success.php

@@ -0,0 +1,15 @@
+<?php
+
+$view
+
+->set('name', 'success')
+
+->import('inc/head')
+
+->fetch('.download a@href',    'vip/buy.info#download')
+
+->fetch('.code img@src',    'vip/buy.info#download_code')
+
+->import('inc/foot')
+
+->display();

Some files were not shown because too many files changed in this diff