diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php
index 35fd32a8e163c3111f0bea6658068d5aa6156edf..ead7fd8af400dce104f112733a4469c47391e218 100755
--- a/application/api/controller/Goods.php
+++ b/application/api/controller/Goods.php
@@ -79,12 +79,16 @@ class Goods extends Common
$search = [
'
',
];
$replace = [
'
![]()
',
+ '
',
+ '
',
];
$ret['data'][0]['content_web'] = str_replace($search, $replace, $ret['data'][0]['content_web']);
}
diff --git a/application/api/controller/User.php b/application/api/controller/User.php
index b6527da98d9b3df3ed52ebb100f8aea1982813cc..e56a8d8a97053d9ea5c7c9a895953083c526e590 100755
--- a/application/api/controller/User.php
+++ b/application/api/controller/User.php
@@ -76,7 +76,7 @@ class User extends Common
}
/**
- * [GetAlipayUserInfo 获取支付宝用户信息]
+ * [GetAlipayUserInfo 支付宝用户授权]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
@@ -87,21 +87,82 @@ class User extends Common
// 参数
if(empty($this->data_post['authcode']))
{
- return DataReturn('授权码不能为空', -1);
+ return DataReturn('授权码为空', -1);
}
// 授权
- $ret = (new \base\AlipayAuth())->GetAlipayUserInfo($this->data_post['authcode'], MyC('common_app_mini_alipay_appid'));
- if($ret['status'] != 0)
+ $result = (new \base\AlipayAuth())->GetAuthCode(MyC('common_app_mini_alipay_appid'), $this->data_post['authcode']);
+ if($result['status'] == 0)
+ {
+ return DataReturn('授权登录成功', 0, $result['data']['user_id']);
+ }
+ return DataReturn($result['msg'], -100);
+
+
+
+
+ // // 参数
+ // if(empty($this->data_post['authcode']))
+ // {
+ // return DataReturn('授权码不能为空', -1);
+ // }
+
+ // // 授权
+ // $ret = (new \base\AlipayAuth())->GetAuthCode($this->data_post['authcode'], MyC('common_app_mini_alipay_appid'));
+ // if($ret['status'] != 0)
+ // {
+ // return DataReturn($ret['msg'], -10);
+ // } else {
+ // $data = $ret['data'];
+ // $data['gender'] = empty($data['gender']) ? 0 : ($data['gender'] == 'm') ? 2 : 1;
+ // $data['openid'] = $data['user_id'];
+ // $data['referrer']= isset($this->data_post['referrer']) ? $this->data_post['referrer'] : 0;
+ // return UserService::AuthUserProgram($data, 'alipay_openid');
+ // }
+ }
+
+ /**
+ * 支付宝小程序获取用户信息
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2018-11-06
+ * @desc description
+ */
+ public function AlipayUserInfo()
+ {
+ // 参数校验
+ $p = [
+ [
+ 'checked_type' => 'empty',
+ 'key_name' => 'openid',
+ 'error_msg' => 'openid为空',
+ ],
+ [
+ 'checked_type' => 'empty',
+ 'key_name' => 'userinfo',
+ 'error_msg' => '用户数据为空',
+ ],
+ ];
+ $ret = ParamsChecked($this->data_post, $p);
+ if($ret !== true)
{
- return DataReturn($ret['msg'], -10);
+ return DataReturn($ret, -1);
+ }
+
+ // 先从数据库获取用户信息
+ $user = UserService::UserInfo('alipay_openid', $this->data_post['openid']);
+ if(empty($user))
+ {
+ $result = $this->data_post;
+ $result['nick_name'] = isset($result['nickName']) ? $result['nickName'] : '';
+ $result['gender'] = empty($result['gender']) ? 0 : ($result['gender'] == 'f') ? 1 : 2;
+ return UserService::AuthUserProgram($result, 'alipay_openid');
} else {
- $data = $ret['data'];
- $data['gender'] = empty($data['gender']) ? 0 : ($data['gender'] == 'm') ? 2 : 1;
- $data['openid'] = $data['user_id'];
- $data['referrer']= isset($this->data_post['referrer']) ? intval($this->data_post['referrer']) : 0;
- return UserService::AuthUserProgram($data, 'alipay_openid');
+ $user['is_mandatory_bind_mobile'] = intval(MyC('common_user_is_mandatory_bind_mobile'));
+ return DataReturn('授权成功', 0, $user);
}
+ return DataReturn(empty($result) ? '获取用户信息失败' : $result, -100);
}
/**
@@ -179,6 +240,7 @@ class User extends Common
return UserService::AuthUserProgram($result, 'weixin_openid');
}
} else {
+ $user['is_mandatory_bind_mobile'] = intval(MyC('common_user_is_mandatory_bind_mobile'));
return DataReturn('授权成功', 0, $user);
}
return DataReturn(empty($result) ? '获取用户信息失败' : $result, -100);
@@ -200,7 +262,7 @@ class User extends Common
$result = (new \Library\BaiduAuth())->GetAuthUserInfo($_POST);
if($result['status'] == 0)
{
- return UserService::AuthUserProgram($result, 'alipay_openid');
+ return UserService::AuthUserProgram($result, 'baidu_openid');
}
return DataReturn($result['msg'], -10);
}
diff --git a/application/service/UserService.php b/application/service/UserService.php
index 09e8f728a4c2dae4d40ccefedbc1f93ca2be3d5c..676293138042cdaddec5206b980a7475567a7e5e 100755
--- a/application/service/UserService.php
+++ b/application/service/UserService.php
@@ -1587,21 +1587,39 @@ class UserService
*/
public static function AuthUserProgram($params, $field)
{
+ // 是否强制绑定手机号码
+ $is_mandatory_bind_mobile = intval(MyC('common_user_is_mandatory_bind_mobile'));
+
+ // 用户信息
$data = [
$field => $params['openid'],
'nickname' => empty($params['nick_name']) ? '' : $params['nick_name'],
'avatar' => empty($params['avatar']) ? '' : $params['avatar'],
- 'gender' => empty($params['gender']) ? 0 : ($params['gender'] == 'm') ? 2 : 1,
+ 'gender' => empty($params['gender']) ? 0 : intval($params['gender']),
'province' => empty($params['province']) ? '' : $params['province'],
'city' => empty($params['city']) ? '' : $params['city'],
- 'referrer' => isset($params['referrer']) ? intval($params['referrer']) : 0,
+ 'referrer' => isset($params['referrer']) ? $params['referrer'] : 0,
];
$user = self::UserInfo($field, $params['openid']);
if(!empty($user))
{
$data = $user;
+ } else {
+ if($is_mandatory_bind_mobile != 1)
+ {
+ $ret = self::UserInsert($data, $params);
+ if($ret['code'] == 0)
+ {
+ $data = self::UserInfo('id', $ret['data']['user_id']);
+ } else {
+ return $ret;
+ }
+ }
}
+ // 是否强制绑定手机号码
+ $data['is_mandatory_bind_mobile'] = $is_mandatory_bind_mobile;
+
// 返回成功
return DataReturn('授权成功', 0, $data);
}
diff --git a/extend/base/AlipayAuth.php b/extend/base/AlipayAuth.php
index 359283c759b8141eb8b17e13b2cd687b91f8b8f5..a45a4a7d323f39dd61e6b60d7f257e316dece9f5 100755
--- a/extend/base/AlipayAuth.php
+++ b/extend/base/AlipayAuth.php
@@ -93,7 +93,6 @@ class AlipayAuth
// 执行请求
$result = $this->HttpRequest('https://openapi.alipay.com/gateway.do', $param);
-
if(!empty($result['alipay_user_info_share_response']['code']) && $result['alipay_user_info_share_response']['code'] == 10000)
{
// 验证签名正确则存储缓存返回数据
@@ -110,6 +109,10 @@ class AlipayAuth
}
$msg = empty($result['error_response']['sub_msg']) ? '授权失败' : $result['error_response']['sub_msg'];
+ if(!empty($result['alipay_user_info_share_response']['sub_msg']))
+ {
+ $msg = $result['alipay_user_info_share_response']['sub_msg'];
+ }
return ['status'=>-1, 'msg'=>$msg];
} else {
return $auth;
@@ -152,14 +155,12 @@ class AlipayAuth
* @version 1.0.0
* @datetime 2017-09-24T21:55:45+0800
* @param [string] $app_id [应用appid]
- * @param [string] $key [缓存key]
* @param [string] $authcode [用户授权码]
- * @param [string] $refresh_token [刷新授权token]
* @return [array|boolean] [失败false, 用户授权信息]
*/
- private function GetAuthCode($app_id, $key, $authcode = '', $refresh_token = '')
+ public function GetAuthCode($app_id, $authcode = '')
{
- if(empty($app_id) || empty($key) || (empty($authcode) && empty($refresh_token)))
+ if(empty($app_id) || empty($authcode))
{
return ['status'=>-1, 'msg'=>'参数有误'];
}
@@ -173,18 +174,10 @@ class AlipayAuth
'sign_type' => 'RSA2',
'timestamp' => date('Y-m-d H:i:s'),
'version' => '1.0',
+ 'code' => $authcode,
+ 'grant_type' => 'authorization_code',
'biz_content' => 'mini-authcode',
];
- if(!empty($authcode))
- {
- $param['code'] = $authcode;
- $param['grant_type'] = 'authorization_code';
- }
- if(!empty($refresh_token))
- {
- $param['refresh_token'] = $refresh_token;
- $param['grant_type'] = 'refresh_token';
- }
// 生成签名参数+签名
$p = $this->GetParamSign($param);
@@ -202,8 +195,6 @@ class AlipayAuth
return ['status'=>-1, 'msg'=>'签名验证失败'];
}
- // 存储缓存
- SS($key, $result['alipay_system_oauth_token_response']);
return ['status'=>0, 'msg'=>'success', 'data'=>$result['alipay_system_oauth_token_response']];
}
$msg = empty($result['error_response']['sub_msg']) ? '授权失败' : $result['error_response']['sub_msg'];
diff --git a/public/appmini/old/alipay/app.js b/public/appmini/old/alipay/app.js
index 5055a68b0ef3261facc37af974c88c44a9f0618f..b5da04cbeb7ff2ac728482d6ac9acd97ad56c5e4 100644
--- a/public/appmini/old/alipay/app.js
+++ b/public/appmini/old/alipay/app.js
@@ -1,5 +1,8 @@
App({
data: {
+ // 用户登录缓存key
+ cache_user_login_key: "cache_user_login_key",
+
// 用户信息缓存key
cache_user_info_key: "cache_shop_user_info_key",
@@ -167,7 +170,7 @@ App({
if (params != "" && params.substr(0, 1) != "&") {
params = "&" + params;
}
- var user = this.GetUserCacheInfo();
+ var user = this.get_user_cache_info();
var app_client_user_id = user == false ? "" : user.alipay_openid;
var user_id = user == false ? 0 : user.id;
return (
@@ -188,11 +191,11 @@ App({
* method 回调操作对象的函数
* return 有用户数据直接返回, 则回调调用者
*/
- GetUserInfo(object, method) {
- var user = this.GetUserCacheInfo();
+ get_user_info(object, method) {
+ var user = this.get_user_cache_info();
if (user == false) {
// 唤醒用户授权
- this.UserAuthCode(object, method);
+ this.user_login(object, method);
return false;
} else {
@@ -203,7 +206,7 @@ App({
/**
* 从缓存获取用户信息
*/
- GetUserCacheInfo() {
+ get_user_cache_info() {
var user = my.getStorageSync({ key: this.data.cache_user_info_key });
if ((user.data || null) == null) {
return false;
@@ -215,8 +218,9 @@ App({
* 用户授权
* object 回调操作对象
* method 回调操作对象的函数
+ * auth_data 授权数据
*/
- UserAuthCode(object, method) {
+ user_login(object, method, auth_data) {
// 邀请人参数
var params = my.getStorageSync({key: this.data.cache_launch_info_key});
var referrer = (params.data == null) ? 0 : (params.data.referrer || 0);
@@ -241,13 +245,13 @@ App({
my.hideLoading();
if (res.data.code == 0) {
my.setStorage({
- key: this.data.cache_user_info_key,
+ key: this.data.cache_user_login_key,
data: res.data.data
});
-
- if (typeof object === "object" && (method || null) != null) {
- object[method]();
- }
+
+ my.navigateTo({
+ url: "/pages/login/login"
+ });
} else {
my.showToast({
type: "fail",
@@ -280,6 +284,77 @@ App({
});
},
+ /**
+ * 用户登录
+ * object 回调操作对象
+ * method 回调操作对象的函数
+ * auth_data 授权数据
+ */
+ user_auth_login(object, method, auth_data) {
+ my.showLoading({ content: "授权中..." });
+ var openid = my.getStorageSync({key: this.data.cache_user_login_key});
+ if ((openid || null) == null)
+ {
+ this.user_login(object, method, auth_data);
+ } else {
+ this.get_user_login_info(object, method, openid, auth_data);
+ }
+ },
+
+ /**
+ * 获取用户授权信息
+ * object 回调操作对象
+ * method 回调操作对象的函数
+ * openid 用户openid
+ * auth_data 授权数据
+ */
+ get_user_login_info(object, method, openid, userinfo) {
+ // 远程解密数据
+ var $this = this;
+ my.request({
+ url: $this.get_request_url('alipayuserinfo', 'user'),
+ method: 'POST',
+ data: { userinfo: userinfo, openid: openid },
+ dataType: 'json',
+ header: { 'content-type': 'application/x-www-form-urlencoded' },
+ success: (res) => {
+ my.hideLoading();
+ if (res.data.code == 0) {
+ my.setStorage({
+ key: $this.data.cache_user_info_key,
+ data: res.data.data,
+ success: (res) => {
+ if (typeof object === 'object' && (method || null) != null) {
+ object[method]();
+ }
+ },
+ fail: () => {
+ my.showToast({
+ type: "fail",
+ content: "用户信息缓存失败",
+ duration: 3000
+ });
+ }
+ });
+ } else {
+ my.showToast({
+ type: "fail",
+ content: res.data.msg,
+ duration: 3000
+ });
+ }
+ },
+ fail: () => {
+ wx.hideLoading();
+ my.showToast({
+ type: "fail",
+ content: "服务器请求出错",
+ duration: 3000
+ });
+ },
+ });
+ },
+
/**
* 获取位置权限
* object 回调操作对象
@@ -512,4 +587,20 @@ App({
}
}
},
+
+ /**
+ * 是否需要绑定手机号码
+ */
+ user_is_need_login(user) {
+ // 是否需要绑定手机号码
+ if ((user.is_mandatory_bind_mobile || 0) == 1)
+ {
+ if ((user.mobile || null) == null)
+ {
+ return true;
+ }
+ }
+ return false;
+ },
+
});
diff --git a/public/appmini/old/alipay/pages/answer-form/answer-form.js b/public/appmini/old/alipay/pages/answer-form/answer-form.js
index 104b7944ea70d44db783cadf79d49fa2ebd2e93e..6ffcb9c811ef7cfa8a959624c43d6d7e5e4ce872 100755
--- a/public/appmini/old/alipay/pages/answer-form/answer-form.js
+++ b/public/appmini/old/alipay/pages/answer-form/answer-form.js
@@ -16,10 +16,10 @@ Page({
// 初始化
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/cart/cart.js b/public/appmini/old/alipay/pages/cart/cart.js
index db01cd66c3f668d21dd742096fb6a3728bd99749..c75838809a2ae31b2544b9318b8ddd5ee09e660a 100755
--- a/public/appmini/old/alipay/pages/cart/cart.js
+++ b/public/appmini/old/alipay/pages/cart/cart.js
@@ -17,11 +17,11 @@ Page({
},
init(e) {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
var msg = (user == false) ? '授权用户信息' : '绑定手机号码';
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.confirm({
title: '温馨提示',
content: msg,
diff --git a/public/appmini/old/alipay/pages/goods-detail/goods-detail.js b/public/appmini/old/alipay/pages/goods-detail/goods-detail.js
index ba9f98cbbf829259146cba47ec9baf89f84a58fb..cfc37254d736ab372a6dfde2e8c8a4ed16886ee7 100644
--- a/public/appmini/old/alipay/pages/goods-detail/goods-detail.js
+++ b/public/appmini/old/alipay/pages/goods-detail/goods-detail.js
@@ -103,14 +103,17 @@ Page({
is_use_mobile_detail: data.is_use_mobile_detail || 0,
});
- parse(data.goods.content_web, (err, nodes) => {
- if (!err) {
- this.setData({
- 'goods.content_web': nodes,
- });
- console.log(this.data.goods.content_web);
- }
- })
+ // web内容转化
+ if((data.goods.content_web || null) != null)
+ {
+ parse(data.goods.content_web, (err, nodes) => {
+ if (!err) {
+ this.setData({
+ 'goods.content_web': nodes,
+ });
+ }
+ });
+ }
// 不能选择规格处理
this.goods_specifications_choose_handle_dont(0);
@@ -223,10 +226,10 @@ Page({
// 收藏事件
goods_favor_event(e)
{
- var user = app.GetUserInfo(this, 'goods_favor_event');
+ var user = app.get_user_info(this, 'goods_favor_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.navigateTo({
url: "/pages/login/login?event_callback=init"
});
@@ -275,10 +278,10 @@ Page({
// 加入购物车事件
goods_cart_event(e, spec) {
- var user = app.GetUserInfo(this, 'goods_cart_event');
+ var user = app.get_user_info(this, 'goods_cart_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.navigateTo({
url: "/pages/login/login?event_callback=init"
});
@@ -558,10 +561,10 @@ Page({
// 确认
goods_buy_confirm_event(e) {
- var user = app.GetUserInfo(this, 'goods_buy_confirm_event');
+ var user = app.get_user_info(this, 'goods_buy_confirm_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.navigateTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/login/login.acss b/public/appmini/old/alipay/pages/login/login.acss
index c322498fcd1ca884dcfaf19b6ac9c8f146af26b8..b4630b2a00d8e0e15744a01e1f9052cf1960f4a5 100755
--- a/public/appmini/old/alipay/pages/login/login.acss
+++ b/public/appmini/old/alipay/pages/login/login.acss
@@ -46,4 +46,14 @@ page{
bottom: 34rpx;
height: 90rpx;
line-height: 90rpx;
+}
+
+/**
+ 授权登录
+*/
+.user-login {
+ padding-top: 30%;
+}
+.user-login button {
+ margin-top: 30rpx;
}
\ No newline at end of file
diff --git a/public/appmini/old/alipay/pages/login/login.axml b/public/appmini/old/alipay/pages/login/login.axml
old mode 100755
new mode 100644
index ee9f771a0148a85075afba8f85758d0c70b7a1a6..8cdbfd5ffdf3d3c3ae6e6b098d823e16a03548bc
--- a/public/appmini/old/alipay/pages/login/login.axml
+++ b/public/appmini/old/alipay/pages/login/login.axml
@@ -1,4 +1,4 @@
-
+
-
\ No newline at end of file
+
+
+
+ 确认登录授权,为您提供更优质的服务
+
+
diff --git a/public/appmini/old/alipay/pages/login/login.js b/public/appmini/old/alipay/pages/login/login.js
old mode 100755
new mode 100644
index e962bfc193520f7130272932fdcfd78c07099506..5e2b99f571bf3b8b14754629b18373b9738e0cde
--- a/public/appmini/old/alipay/pages/login/login.js
+++ b/public/appmini/old/alipay/pages/login/login.js
@@ -20,9 +20,44 @@ Page({
my.setNavigationBar({title: '手机绑定'});
// 设置用户信息
- this.setData({params: option, user: app.GetUserCacheInfo()});
+ this.setData({params: option, user: app.get_user_cache_info() || null});
},
+ /**
+ * 登录授权事件
+ */
+ get_user_info_event(e) {
+ this.user_auth_code(null, null, e.detail);
+ },
+
+ /**
+ * 用户授权
+ * object 回调操作对象
+ * method 回调操作对象的函数
+ * auth_data 授权数据
+ */
+ user_auth_code(object, method, auth_data) {
+ my.getOpenUserInfo({
+ success: (userinfo) => {
+ console.log(userinfo)
+ app.user_auth_login($this, 'user_auth_back_event', userinfo);
+ }
+ });
+ },
+
+ /**
+ * 授权返回事件
+ */
+ user_auth_back_event() {
+ var user = app.get_user_cache_info();
+ this.setData({user: user || null});
+ if (app.user_is_need_login(user) == false)
+ {
+ my.navigateBack();
+ }
+ },
+
+
/**
* 输入手机号码事件
*/
diff --git a/public/appmini/old/alipay/pages/message/message.js b/public/appmini/old/alipay/pages/message/message.js
index 2cf5de63c863fe121db899ad41ff6726b6428719..94e8d1ececed5d458cc756aa15be89c8f79d51fb 100755
--- a/public/appmini/old/alipay/pages/message/message.js
+++ b/public/appmini/old/alipay/pages/message/message.js
@@ -14,10 +14,10 @@ Page({
},
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/user-address-save/user-address-save.js b/public/appmini/old/alipay/pages/user-address-save/user-address-save.js
index 383aa067db66a372115200ebfd3de8b42143eed6..3285aae388fbb5903ebd7dc7ffb4e8aaf4854e97 100755
--- a/public/appmini/old/alipay/pages/user-address-save/user-address-save.js
+++ b/public/appmini/old/alipay/pages/user-address-save/user-address-save.js
@@ -36,10 +36,10 @@ Page({
},
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/user-address/user-address.js b/public/appmini/old/alipay/pages/user-address/user-address.js
index b64f104f987fd1a07338500d77f249ee8cbb1a9b..bafa22237f94817f9589b1f2483826c6e8a97876 100755
--- a/public/appmini/old/alipay/pages/user-address/user-address.js
+++ b/public/appmini/old/alipay/pages/user-address/user-address.js
@@ -19,10 +19,10 @@ Page({
// 初始化
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/user-answer-list/user-answer-list.js b/public/appmini/old/alipay/pages/user-answer-list/user-answer-list.js
index 8f178951d82f7f34e56f96e5750cfc9713e80c86..2c31a6c308c785570d1da0f459869b7cba0808b0 100755
--- a/public/appmini/old/alipay/pages/user-answer-list/user-answer-list.js
+++ b/public/appmini/old/alipay/pages/user-answer-list/user-answer-list.js
@@ -16,10 +16,10 @@ Page({
},
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/user-faovr/user-faovr.js b/public/appmini/old/alipay/pages/user-faovr/user-faovr.js
index 324ce4535e26d64faa2aef82b77c0a66b217e1d8..cdbe41145457f74bd5397d3a3c9eef905a13c465 100755
--- a/public/appmini/old/alipay/pages/user-faovr/user-faovr.js
+++ b/public/appmini/old/alipay/pages/user-faovr/user-faovr.js
@@ -14,10 +14,10 @@ Page({
},
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/user-goods-browse/user-goods-browse.js b/public/appmini/old/alipay/pages/user-goods-browse/user-goods-browse.js
index 4d011ba26c8536a8092f5be28dc05108a5f9a7d0..16d6c681287404b86e56b160317c69a68c707fd6 100755
--- a/public/appmini/old/alipay/pages/user-goods-browse/user-goods-browse.js
+++ b/public/appmini/old/alipay/pages/user-goods-browse/user-goods-browse.js
@@ -14,10 +14,10 @@ Page({
},
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/user-integral/user-integral.js b/public/appmini/old/alipay/pages/user-integral/user-integral.js
index b0d42a04785c4cf96a4ffcebe9abb59d1d3f806c..a383f290147cf6a022364f4539b13342a31d8248 100755
--- a/public/appmini/old/alipay/pages/user-integral/user-integral.js
+++ b/public/appmini/old/alipay/pages/user-integral/user-integral.js
@@ -14,10 +14,10 @@ Page({
},
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/user-order/user-order.js b/public/appmini/old/alipay/pages/user-order/user-order.js
index 46e21737a4098704afc2f1a4e9495981e3d6fc2c..c9ca41108706d8bbec37e9cccb7b6e7f1234ee4a 100755
--- a/public/appmini/old/alipay/pages/user-order/user-order.js
+++ b/public/appmini/old/alipay/pages/user-order/user-order.js
@@ -49,10 +49,10 @@ Page({
},
init() {
- var user = app.GetUserInfo(this, "init");
+ var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/alipay/pages/user/user.js b/public/appmini/old/alipay/pages/user/user.js
index 2e7e4292568377c5803b531191023c213bb5f0e0..8356318e1f50d7886b2861ba5cae3f5507b18d3a 100755
--- a/public/appmini/old/alipay/pages/user/user.js
+++ b/public/appmini/old/alipay/pages/user/user.js
@@ -52,12 +52,12 @@ Page({
},
init(e) {
- var user = app.GetUserInfo(this, "init"),
+ var user = app.get_user_info(this, "init"),
self = this;
if (user != false) {
// 用户未绑定用户则转到登录页面
var msg = (user == false) ? '授权用户信息' : '绑定手机号码';
- if ((user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
my.confirm({
title: '温馨提示',
content: msg,
diff --git a/public/appmini/old/weixin/app.js b/public/appmini/old/weixin/app.js
index 16a4c660739d6c2b563d6058475fd2712f63d8be..6bf1c17912ddea48b390f7bbe8f7c7765bc0d088 100755
--- a/public/appmini/old/weixin/app.js
+++ b/public/appmini/old/weixin/app.js
@@ -487,6 +487,29 @@ App({
duration: 3000
});
}
+ },
+
+ /**
+ * 是否需要登录
+ * 是否需要绑定手机号码
+ */
+ user_is_need_login(user) {
+ // 用户信息是否正确
+ if (user == false)
+ {
+ return true;
+ }
+
+ // 是否需要绑定手机号码
+ if ((user.is_mandatory_bind_mobile || 0) == 1)
+ {
+ if ((user.mobile || null) == null)
+ {
+ return true;
+ }
+ }
+
+ return false;
}
});
\ No newline at end of file
diff --git a/public/appmini/old/weixin/pages/answer-form/answer-form.js b/public/appmini/old/weixin/pages/answer-form/answer-form.js
index 6d90971f711b5247819069cafd4cbf2ee22deb32..7e941238f1d05aaeeae16392d94f9a97ca4acb04 100755
--- a/public/appmini/old/weixin/pages/answer-form/answer-form.js
+++ b/public/appmini/old/weixin/pages/answer-form/answer-form.js
@@ -15,7 +15,7 @@ Page({
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/cart/cart.js b/public/appmini/old/weixin/pages/cart/cart.js
index 51e6000b097836c068e8e5f27e75e081fa4ee001..bd4525c0decb87d242b4b35a772c4187867bb7ac 100755
--- a/public/appmini/old/weixin/pages/cart/cart.js
+++ b/public/appmini/old/weixin/pages/cart/cart.js
@@ -20,7 +20,7 @@ Page({
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
var msg = (user == false) ? '授权用户信息' : '绑定手机号码';
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.showModal({
title: '温馨提示',
content: msg,
diff --git a/public/appmini/old/weixin/pages/goods-detail/goods-detail.js b/public/appmini/old/weixin/pages/goods-detail/goods-detail.js
index d24bfeffdb1fa7862fd132063515eebad12c042f..738cc4e60014ed1eee44fa19343f39bcf6f4d07b 100755
--- a/public/appmini/old/weixin/pages/goods-detail/goods-detail.js
+++ b/public/appmini/old/weixin/pages/goods-detail/goods-detail.js
@@ -213,7 +213,7 @@ Page({
{
var user = app.get_user_cache_info(this, 'goods_favor_event');
// 用户未绑定用户则转到登录页面
- if (user == false || (user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
wx.navigateTo({
url: "/pages/login/login?event_callback=init"
});
@@ -254,7 +254,7 @@ Page({
goods_cart_event(e, spec) {
var user = app.get_user_cache_info(this, 'goods_cart_event');
// 用户未绑定用户则转到登录页面
- if (user == false || (user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
wx.navigateTo({
url: "/pages/login/login?event_callback=init"
});
@@ -514,7 +514,7 @@ Page({
goods_buy_confirm_event(e) {
var user = app.get_user_cache_info(this, 'goods_buy_confirm_event');
// 用户未绑定用户则转到登录页面
- if (user == false || (user.mobile || null) == null) {
+ if (app.user_is_need_login(user)) {
wx.navigateTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/login/login.js b/public/appmini/old/weixin/pages/login/login.js
index bd612176f4b9ceffe692b2ecb0883c1a275c5ad3..bc57d9a5be229e89c4316007346a312647c5b1c7 100755
--- a/public/appmini/old/weixin/pages/login/login.js
+++ b/public/appmini/old/weixin/pages/login/login.js
@@ -60,10 +60,9 @@ Page({
* 授权返回事件
*/
user_auth_back_event() {
- this.setData({
- user: app.get_user_cache_info() || null
- });
- if((this.data.user.mobile || null) != null)
+ var user = app.get_user_cache_info();
+ this.setData({user: user || null});
+ if (app.user_is_need_login(user) == false)
{
wx.navigateBack();
}
diff --git a/public/appmini/old/weixin/pages/login/login.wxml b/public/appmini/old/weixin/pages/login/login.wxml
index 0562f949fac496659a382bc75f12b9a61cc6df78..7e1b6537f6c3b057c7878547a42254095a731bf2 100755
--- a/public/appmini/old/weixin/pages/login/login.wxml
+++ b/public/appmini/old/weixin/pages/login/login.wxml
@@ -9,7 +9,7 @@
-
+
确认登录授权,为您提供更优质的服务
diff --git a/public/appmini/old/weixin/pages/login/login.wxss b/public/appmini/old/weixin/pages/login/login.wxss
index dfdeb0a24ecfeff6baafaacb63b79eef2d9ec2dc..c899160a240ffc2fec5e600bd3aaaa876d24c095 100755
--- a/public/appmini/old/weixin/pages/login/login.wxss
+++ b/public/appmini/old/weixin/pages/login/login.wxss
@@ -55,9 +55,9 @@ page{
/**
授权登录
*/
-.wx-login {
+.user-login {
padding-top: 30%;
}
-.wx-login button {
+.user-login button {
margin-top: 30rpx;
}
\ No newline at end of file
diff --git a/public/appmini/old/weixin/pages/message/message.js b/public/appmini/old/weixin/pages/message/message.js
index 2eb54fba9dcec8a11af26d20876760fd75b6d836..250b8d8538e9ffed462ecaa88ace8ab6d059a90d 100755
--- a/public/appmini/old/weixin/pages/message/message.js
+++ b/public/appmini/old/weixin/pages/message/message.js
@@ -16,7 +16,7 @@ Page({
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/user-address-save/user-address-save.js b/public/appmini/old/weixin/pages/user-address-save/user-address-save.js
index 0603dd09963e6983779decc65079bcaff47e2b72..c167aa0c615a30a5f3f6459a2c8e18deb20dea5a 100755
--- a/public/appmini/old/weixin/pages/user-address-save/user-address-save.js
+++ b/public/appmini/old/weixin/pages/user-address-save/user-address-save.js
@@ -39,7 +39,7 @@ Page({
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/user-answer-list/user-answer-list.js b/public/appmini/old/weixin/pages/user-answer-list/user-answer-list.js
index 360d984fc719bd1539eeb0e9900f60f953ae3503..45ca82189c5dd4b56fd9d86681bb6667a443f6e2 100755
--- a/public/appmini/old/weixin/pages/user-answer-list/user-answer-list.js
+++ b/public/appmini/old/weixin/pages/user-answer-list/user-answer-list.js
@@ -18,7 +18,7 @@ Page({
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/user-faovr/user-faovr.js b/public/appmini/old/weixin/pages/user-faovr/user-faovr.js
index 4c4530c7e48e5716b34a05c10c87e733e2203288..49e263d236026c357cc2e5e76b0c68b796c4299e 100755
--- a/public/appmini/old/weixin/pages/user-faovr/user-faovr.js
+++ b/public/appmini/old/weixin/pages/user-faovr/user-faovr.js
@@ -16,7 +16,7 @@ Page({
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/user-goods-browse/user-goods-browse.js b/public/appmini/old/weixin/pages/user-goods-browse/user-goods-browse.js
index f0c21a4a231130d740952a4e58728ef41ac11e6e..c273d9c33c2efce9992389fa94a0aa9c5a0b1147 100755
--- a/public/appmini/old/weixin/pages/user-goods-browse/user-goods-browse.js
+++ b/public/appmini/old/weixin/pages/user-goods-browse/user-goods-browse.js
@@ -16,7 +16,7 @@ Page({
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/user-integral/user-integral.js b/public/appmini/old/weixin/pages/user-integral/user-integral.js
index a8eb09dbd049e164f02201a5beeba44bcb5773ef..f81a47b3ee396a67d3a7ca84f88707db77b68a52 100755
--- a/public/appmini/old/weixin/pages/user-integral/user-integral.js
+++ b/public/appmini/old/weixin/pages/user-integral/user-integral.js
@@ -16,7 +16,7 @@ Page({
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/user-order/user-order.js b/public/appmini/old/weixin/pages/user-order/user-order.js
index 41162acb89f99754c8409bf4340c201428db8dfb..64664acb690056112e403344ee7ed42193c4a6f9 100755
--- a/public/appmini/old/weixin/pages/user-order/user-order.js
+++ b/public/appmini/old/weixin/pages/user-order/user-order.js
@@ -51,7 +51,7 @@ Page({
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.redirectTo({
url: "/pages/login/login?event_callback=init"
});
diff --git a/public/appmini/old/weixin/pages/user/user.js b/public/appmini/old/weixin/pages/user/user.js
index bae550aadfa18356f29581b5efe2a49d1ae9ff29..2d37d9b6a1d7085e94ce086ae92c8c163ca93a49 100755
--- a/public/appmini/old/weixin/pages/user/user.js
+++ b/public/appmini/old/weixin/pages/user/user.js
@@ -56,7 +56,7 @@ Page({
self = this;
// 用户未绑定用户则转到登录页面
var msg = (user == false) ? '授权用户信息' : '绑定手机号码';
- if (user == false || ((user.mobile || null) == null)) {
+ if (app.user_is_need_login(user)) {
wx.showModal({
title: '温馨提示',
content: msg,