Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
092c8af0
Commit
092c8af0
authored
Apr 18, 2021
by
linlinjava
Browse files
chore[litemall-wx, renard-wx]]:登录接口调整
parent
4514653a
Changes
6
Hide whitespace changes
Inline
Side-by-side
litemall-wx/config/api.js
View file @
092c8af0
// 以下是业务服务器API地址
// 本机开发时使用
//
var WxApiRoot = 'http://localhost:8080/wx/';
var
WxApiRoot
=
'
http://localhost:8080/wx/
'
;
// 局域网测试使用
var
WxApiRoot
=
'
http://192.168.1.3:8080/wx/
'
;
//
var WxApiRoot = 'http://192.168.1.3:8080/wx/';
// 云平台部署时使用
// var WxApiRoot = 'http://122.51.199.160:8080/wx/';
// 云平台上线时使用
...
...
litemall-wx/pages/auth/login/login.js
View file @
092c8af0
...
...
@@ -4,10 +4,17 @@ var user = require('../../../utils/user.js');
var
app
=
getApp
();
Page
({
data
:
{
canIUseGetUserProfile
:
false
,
},
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成
if
(
wx
.
getUserProfile
)
{
this
.
setData
({
canIUseGetUserProfile
:
true
})
}
},
onReady
:
function
()
{
...
...
@@ -24,21 +31,38 @@ Page({
},
wxLogin
:
function
(
e
)
{
user
.
checkLogin
().
catch
(()
=>
{
if
(
this
.
data
.
canIUseGetUserProfile
)
{
wx
.
getUserProfile
({
desc
:
'
用于完善会员资料
'
,
desc
:
'
用于完善会员资料
'
,
// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success
:
(
res
)
=>
{
user
.
loginByWeixin
(
res
.
userInfo
).
then
(
res
=>
{
app
.
globalData
.
hasLogin
=
true
;
wx
.
navigateBack
({
delta
:
1
})
}).
catch
((
err
)
=>
{
app
.
globalData
.
hasLogin
=
false
;
util
.
showErrorToast
(
'
微信登录失败
'
);
});
this
.
doLogin
(
res
.
userInfo
)
},
fail
:
()
=>
{
util
.
showErrorToast
(
'
微信登录失败
'
);
}
})
}
else
{
if
(
e
.
detail
.
userInfo
==
undefined
)
{
app
.
globalData
.
hasLogin
=
false
;
util
.
showErrorToast
(
'
微信登录失败
'
);
return
;
}
this
.
doLogin
(
e
.
detail
.
userInfo
)
}
},
doLogin
:
function
(
userInfo
)
{
user
.
checkLogin
().
catch
(()
=>
{
user
.
loginByWeixin
(
userInfo
).
then
(
res
=>
{
app
.
globalData
.
hasLogin
=
true
;
wx
.
navigateBack
({
delta
:
1
})
}).
catch
((
err
)
=>
{
app
.
globalData
.
hasLogin
=
false
;
util
.
showErrorToast
(
'
微信登录失败
'
);
});
});
},
accountLogin
:
function
()
{
...
...
litemall-wx/pages/auth/login/login.wxml
View file @
092c8af0
<view class="container">
<view class="login-box">
<button type="primary" open-type="getUserProfile" class="wx-login-btn" bindtap="wxLogin">微信直接登录</button>
<button wx:if="{{canIUseGetUserProfile}}" type="primary" class="wx-login-btn" bindtap="wxLogin">微信直接登录</button>
<button wx:else type="primary" open-type="getUserProfile" class="wx-login-btn" open-type="getUserInfo" bindgetuserinfo="wxLogin">微信直接登录</button>
<button type="primary" class="account-login-btn" bindtap="accountLogin">账号登录</button>
</view>
</view>
\ No newline at end of file
renard-wx/pages/auth/login/login.js
View file @
092c8af0
...
...
@@ -4,11 +4,17 @@ var user = require('../../../utils/user.js');
var
app
=
getApp
();
Page
({
data
:
{},
data
:
{
canIUseGetUserProfile
:
false
,
},
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成
if
(
wx
.
getUserProfile
)
{
this
.
setData
({
canIUseGetUserProfile
:
true
})
}
},
onReady
:
function
()
{
...
...
@@ -25,17 +31,30 @@ Page({
},
wxLogin
:
function
(
e
)
{
if
(
e
.
detail
.
userInfo
==
undefined
)
{
app
.
globalData
.
hasLogin
=
false
;
util
.
showErrorToast
(
'
微信登录失败
'
);
return
;
if
(
this
.
data
.
canIUseGetUserProfile
)
{
wx
.
getUserProfile
({
desc
:
'
用于完善会员资料
'
,
// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success
:
(
res
)
=>
{
this
.
doLogin
(
res
.
userInfo
)
},
fail
:
()
=>
{
util
.
showErrorToast
(
'
微信登录失败
'
);
}
})
}
else
{
if
(
e
.
detail
.
userInfo
==
undefined
)
{
app
.
globalData
.
hasLogin
=
false
;
util
.
showErrorToast
(
'
微信登录失败
'
);
return
;
}
this
.
doLogin
(
e
.
detail
.
userInfo
)
}
},
doLogin
:
function
(
userInfo
)
{
user
.
checkLogin
().
catch
(()
=>
{
user
.
loginByWeixin
(
e
.
detail
.
userInfo
).
then
(
res
=>
{
user
.
loginByWeixin
(
userInfo
).
then
(
res
=>
{
app
.
globalData
.
hasLogin
=
true
;
wx
.
navigateBack
({
delta
:
1
})
...
...
renard-wx/pages/auth/login/login.wxml
View file @
092c8af0
<view class="container">
<view class="form-box">
<button
type="primary" open-type="getUserInfo
" class="login-btn" bind
getuserinfo
="wxLogin">微信直接登录</button>
<button
wx:if="{{canIUseGetUserProfile}}" type="primary
" class="login-btn" bind
tap
="wxLogin">微信直接登录</button>
<button wx:else type="primary" open-type="getUserInfo" class="login-btn" bindgetuserinfo="wxLogin">微信直接登录</button>
</view>
</view>
\ No newline at end of file
renard-wx/project.config.json
View file @
092c8af0
{
"description"
:
"项目配置文件。"
,
"setting"
:
{
"urlCheck"
:
false
,
"es6"
:
true
,
"postcss"
:
true
,
"minified"
:
true
,
"newFeature"
:
true
,
"uglifyFileName"
:
true
},
"compileType"
:
"miniprogram"
,
"libVersion"
:
"2.4.0"
,
"appid"
:
"wxa5b486c6b918ecfb"
,
"projectname"
:
"Renard"
,
"simulatorType"
:
"wechat"
,
"simulatorPluginLibVersion"
:
{},
"condition"
:
{
"search"
:
{
"current"
:
-1
,
"list"
:
[]
},
"conversation"
:
{
"current"
:
-1
,
"list"
:
[]
},
"plugin"
:
{
"current"
:
-1
,
"list"
:
[]
},
"game"
:
{
"list"
:
[]
},
"miniprogram"
:
{
"current"
:
34
,
"list"
:
[
{
"id"
:
-1
,
"name"
:
"首页"
,
"pathName"
:
"pages/index/index"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"专题"
,
"pathName"
:
"pages/topic/topic"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"专题详情"
,
"pathName"
:
"pages/topicDetail/topicDetail"
,
"query"
:
"id=314"
},
{
"id"
:
-1
,
"name"
:
"品牌"
,
"pathName"
:
"pages/brand/brand"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"品牌详情"
,
"pathName"
:
"pages/brandDetail/brandDetail"
,
"query"
:
"id=1001000"
},
{
"id"
:
-1
,
"name"
:
"人气推荐"
,
"pathName"
:
"pages/hotGoods/hotGoods"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"新品首发"
,
"pathName"
:
"pages/newGoods/newGoods"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"分类"
,
"pathName"
:
"pages/catalog/catalog"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"分类详情"
,
"pathName"
:
"pages/category/category"
,
"query"
:
"id=1008002"
},
{
"id"
:
-1
,
"name"
:
"查找"
,
"pathName"
:
"pages/search/search"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"商品"
,
"pathName"
:
"pages/goods/goods"
,
"query"
:
"id=1181000"
},
{
"id"
:
-1
,
"name"
:
"商品评论列表"
,
"pathName"
:
"pages/comment/comment"
,
"query"
:
"valueId=1181000&type=0"
},
{
"id"
:
-1
,
"name"
:
"购物车"
,
"pathName"
:
"pages/cart/cart"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"下单"
,
"pathName"
:
"pages/shopping/checkout/checkout"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"支付结果"
,
"pathName"
:
"pages/payResult/payResult"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的"
,
"pathName"
:
"pages/ucenter/index/index"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的订单列表"
,
"pathName"
:
"pages/ucenter/order/order"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的订单详情"
,
"pathName"
:
"pages/ucenter/orderDetail/orderDetail"
,
"query"
:
"id=1"
},
{
"id"
:
22
,
"name"
:
"待评价的订单详情"
,
"pathName"
:
"pages/ucenter/orderDetail/orderDetail"
,
"query"
:
"id=1"
},
{
"id"
:
-1
,
"name"
:
"购买商品评价"
,
"pathName"
:
"pages/commentPost/commentPost"
,
"query"
:
"orderId=2&type=0&valueId=1116011"
},
{
"id"
:
-1
,
"name"
:
"我的优惠券"
,
"pathName"
:
"pages/ucenter/coupon/coupon"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的收藏"
,
"pathName"
:
"pages/ucenter/collect/collect"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的地址"
,
"pathName"
:
"pages/ucenter/address/address"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的地址添加"
,
"pathName"
:
"pages/ucenter/addressAdd/addressAdd"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"登录"
,
"pathName"
:
"pages/auth/login/login"
,
"query"
:
""
}
]
}
}
"description"
:
"项目配置文件。"
,
"setting"
:
{
"urlCheck"
:
false
,
"es6"
:
true
,
"postcss"
:
true
,
"minified"
:
true
,
"newFeature"
:
true
,
"uglifyFileName"
:
true
,
"checkInvalidKey"
:
true
,
"checkSiteMap"
:
true
,
"uploadWithSourceMap"
:
true
,
"useMultiFrameRuntime"
:
true
,
"useApiHook"
:
true
,
"useApiHostProcess"
:
true
,
"babelSetting"
:
{
"ignore"
:
[],
"disablePlugins"
:
[],
"outputPath"
:
""
},
"useIsolateContext"
:
true
,
"useCompilerModule"
:
true
,
"userConfirmedUseCompilerModuleSwitch"
:
false
,
"userConfirmedBundleSwitch"
:
false
,
"packNpmManually"
:
false
,
"packNpmRelationList"
:
[],
"minifyWXSS"
:
true
},
"compileType"
:
"miniprogram"
,
"libVersion"
:
"2.4.0"
,
"appid"
:
"wxa5b486c6b918ecfb"
,
"projectname"
:
"Renard"
,
"simulatorType"
:
"wechat"
,
"simulatorPluginLibVersion"
:
{},
"condition"
:
{
"search"
:
{
"list"
:
[]
},
"conversation"
:
{
"list"
:
[]
},
"plugin"
:
{
"list"
:
[]
},
"game"
:
{
"list"
:
[]
},
"miniprogram"
:
{
"list"
:
[
{
"id"
:
-1
,
"name"
:
"首页"
,
"pathName"
:
"pages/index/index"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"专题"
,
"pathName"
:
"pages/topic/topic"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"专题详情"
,
"pathName"
:
"pages/topicDetail/topicDetail"
,
"query"
:
"id=314"
},
{
"id"
:
-1
,
"name"
:
"品牌"
,
"pathName"
:
"pages/brand/brand"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"品牌详情"
,
"pathName"
:
"pages/brandDetail/brandDetail"
,
"query"
:
"id=1001000"
},
{
"id"
:
-1
,
"name"
:
"人气推荐"
,
"pathName"
:
"pages/hotGoods/hotGoods"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"新品首发"
,
"pathName"
:
"pages/newGoods/newGoods"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"分类"
,
"pathName"
:
"pages/catalog/catalog"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"分类详情"
,
"pathName"
:
"pages/category/category"
,
"query"
:
"id=1008002"
},
{
"id"
:
-1
,
"name"
:
"查找"
,
"pathName"
:
"pages/search/search"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"商品"
,
"pathName"
:
"pages/goods/goods"
,
"query"
:
"id=1181000"
},
{
"id"
:
-1
,
"name"
:
"商品评论列表"
,
"pathName"
:
"pages/comment/comment"
,
"query"
:
"valueId=1181000&type=0"
},
{
"id"
:
-1
,
"name"
:
"购物车"
,
"pathName"
:
"pages/cart/cart"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"下单"
,
"pathName"
:
"pages/shopping/checkout/checkout"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"支付结果"
,
"pathName"
:
"pages/payResult/payResult"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的"
,
"pathName"
:
"pages/ucenter/index/index"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的订单列表"
,
"pathName"
:
"pages/ucenter/order/order"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的订单详情"
,
"pathName"
:
"pages/ucenter/orderDetail/orderDetail"
,
"query"
:
"id=1"
},
{
"id"
:
22
,
"name"
:
"待评价的订单详情"
,
"pathName"
:
"pages/ucenter/orderDetail/orderDetail"
,
"query"
:
"id=1"
},
{
"id"
:
-1
,
"name"
:
"购买商品评价"
,
"pathName"
:
"pages/commentPost/commentPost"
,
"query"
:
"orderId=2&type=0&valueId=1116011"
},
{
"id"
:
-1
,
"name"
:
"我的优惠券"
,
"pathName"
:
"pages/ucenter/coupon/coupon"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的收藏"
,
"pathName"
:
"pages/ucenter/collect/collect"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的地址"
,
"pathName"
:
"pages/ucenter/address/address"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"我的地址添加"
,
"pathName"
:
"pages/ucenter/addressAdd/addressAdd"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"登录"
,
"pathName"
:
"pages/auth/login/login"
,
"query"
:
""
}
]
}
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment