mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-06-06 03:56:57 +08:00
1.后台、前端登录支持帐号密码,邮箱验证码,手机验证码。2.微信小程序登录新规适配。3.api新增帐号密码登录验证码登录接口。4.部分细节优化+bug修复
This commit is contained in:
@ -73,7 +73,7 @@ App({
|
||||
|
||||
// 请求地址
|
||||
request_url: "{{request_url}}",
|
||||
// request_url: 'http://shopxo.com/',
|
||||
request_url: 'http://shopxo.com/',
|
||||
// request_url: 'https://dev.shopxo.net/',
|
||||
|
||||
// 基础信息
|
||||
@ -231,12 +231,12 @@ App({
|
||||
var self = this;
|
||||
wx.checkSession({
|
||||
success: function () {
|
||||
var openid = wx.getStorageSync(self.data.cache_user_login_key) || null;
|
||||
if (openid == null)
|
||||
var login_data = wx.getStorageSync(self.data.cache_user_login_key) || null;
|
||||
if (login_data == null)
|
||||
{
|
||||
self.user_login(object, method);
|
||||
} else {
|
||||
self.get_user_login_info(object, method, openid, auth_data);
|
||||
self.get_user_login_info(object, method, login_data, auth_data);
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
@ -253,8 +253,8 @@ App({
|
||||
* auth_data 授权数据
|
||||
*/
|
||||
user_login(object, method) {
|
||||
var openid = wx.getStorageSync(this.data.cache_user_login_key) || null;
|
||||
if (openid == null)
|
||||
var login_data = wx.getStorageSync(this.data.cache_user_login_key) || null;
|
||||
if (login_data == null)
|
||||
{
|
||||
var self = this;
|
||||
// 加载loding
|
||||
@ -270,6 +270,7 @@ App({
|
||||
dataType: 'json',
|
||||
header: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
success: (res) => {
|
||||
console.log(res.data);
|
||||
wx.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
var data = res.data.data;
|
||||
@ -289,7 +290,7 @@ App({
|
||||
} else {
|
||||
wx.setStorage({
|
||||
key: self.data.cache_user_login_key,
|
||||
data: data.openid
|
||||
data: data
|
||||
});
|
||||
self.login_to_auth();
|
||||
}
|
||||
@ -338,24 +339,24 @@ App({
|
||||
* 获取用户授权信息
|
||||
* object 回调操作对象
|
||||
* method 回调操作对象的函数
|
||||
* openid 用户openid
|
||||
* login_data 登录信息
|
||||
* auth_data 授权数据
|
||||
*/
|
||||
get_user_login_info(object, method, openid, auth_data) {
|
||||
get_user_login_info(object, method, login_data, auth_data) {
|
||||
// 邀请人参数
|
||||
var params = wx.getStorageSync(this.data.cache_launch_info_key) || null;
|
||||
var referrer = (params == null) ? 0 : (params.referrer || 0);
|
||||
|
||||
// 远程解密数据
|
||||
// 用户信息处理
|
||||
wx.showLoading({ title: "授权中..." });
|
||||
var self = this;
|
||||
wx.request({
|
||||
url: self.get_request_url('wechatuserinfo', 'user'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
"encrypted_data": auth_data.encryptedData,
|
||||
"iv": auth_data.iv,
|
||||
"openid": openid,
|
||||
"auth_data": JSON.stringify(auth_data),
|
||||
"openid": login_data.openid,
|
||||
"unionid": login_data.unionid,
|
||||
"referrer": referrer
|
||||
},
|
||||
dataType: 'json',
|
||||
|
||||
@ -48,7 +48,12 @@ Page({
|
||||
* 登录授权事件
|
||||
*/
|
||||
get_user_info_event(e) {
|
||||
this.user_auth_code(e.detail);
|
||||
wx.getUserProfile({
|
||||
desc: '注册使用',
|
||||
success: (res) => {
|
||||
this.user_auth_code(res.userInfo);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -56,7 +61,7 @@ Page({
|
||||
* auth_data 授权数据
|
||||
*/
|
||||
user_auth_code(auth_data) {
|
||||
if ((auth_data.encryptedData || null) != null && (auth_data.iv || null) != null) {
|
||||
if ((auth_data || null) != null) {
|
||||
app.user_auth_login(this, 'user_auth_back_event', auth_data);
|
||||
} else {
|
||||
app.showToast("授权失败");
|
||||
|
||||
@ -23,5 +23,5 @@
|
||||
<!-- 获取用户信息授权 -->
|
||||
<view wx:else class="user-login tc">
|
||||
<view class="cr-888 fs-12">确认登录授权,为您提供更优质的服务</view>
|
||||
<button type="primary" size="mini" open-type="getUserInfo" bindgetuserinfo="get_user_info_event">授权登录</button>
|
||||
<button type="primary" size="mini" bindtap="get_user_info_event">授权登录</button>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user