Commit d684c0f0 by 张天炜

小程序登录功能更新

parent f4f8bf07
...@@ -35,17 +35,26 @@ Page({ ...@@ -35,17 +35,26 @@ Page({
}, },
handleWxAuth: function(event) { handleWxAuth: function() {
var _this = this
Wx.login().then(res => { Wx.login().then(res => {
//获取登录的临时凭证
_this.wxLoginCode = res.code
})
wx.getUserProfile({
desc: '用于完善个人资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中
success: (e) => {
api.login({ api.login({
code: res.code, code: _this.wxLoginCode,
signature: event.detail.signature, signature: e.signature,
rawData: event.detail.rawData, rawData: e.rawData,
encryptedData: event.detail.encryptedData, encryptedData: e.encryptedData,
iv: event.detail.iv, iv: e.iv,
scene: app.options.query && app.options.query.scene ? decodeURIComponent(app.options.query.scene) : '' scene: app.options.query && app.options.query.scene ? decodeURIComponent(app.options.query.scene) : ''
}).then(res => { }).then(res => {
if (!res.code) { console.log(res)
if (!_this.wxLoginCode) {
app.globalData.userInfo = res.user app.globalData.userInfo = res.user
wx.setStorageSync('token', res.token) wx.setStorageSync('token', res.token)
$Toast({ $Toast({
...@@ -64,7 +73,12 @@ Page({ ...@@ -64,7 +73,12 @@ Page({
}); });
} }
}) })
},
fail: (e) => {
console.log(e)
}
}) })
}, },
handlePhoneAuth: function(event) { handlePhoneAuth: function(event) {
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
<view>美好的教育,行走在路上</view> <view>美好的教育,行走在路上</view>
</view> </view>
<view class='action-wrapper'> <view class='action-wrapper'>
<i-button bindgetuserinfo="handleWxAuth" type="success" shape="circle" open-type='getUserInfo'>微信授权</i-button> <!-- <i-button bindgetuserinfo="handleWxAuth" type="success" shape="circle" open-type='getUserInfo'>微信授权</i-button> -->
<i-button bindtap="handleWxAuth" type="success" shape="circle">微信授权</i-button>
<!-- <i-button bindgetphonenumber="handlePhoneAuth" type="info" shape="circle" open-type="getPhoneNumber">手机号授权</i-button> --> <!-- <i-button bindgetphonenumber="handlePhoneAuth" type="info" shape="circle" open-type="getPhoneNumber">手机号授权</i-button> -->
<!-- <view class="text-small text-hint tip">请完成微信授权</view> --> <!-- <view class="text-small text-hint tip">请完成微信授权</view> -->
<i-button bindtap="gotoHome" type="default" shape="circle">暂不登录</i-button> <i-button bindtap="gotoHome" type="default" shape="circle">暂不登录</i-button>
......
{ {
"description": "项目配置文件", "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"packOptions": { "packOptions": {
"ignore": [] "ignore": [],
"include": []
}, },
"setting": { "setting": {
"urlCheck": false, "urlCheck": false,
...@@ -10,90 +11,86 @@ ...@@ -10,90 +11,86 @@
"minified": true, "minified": true,
"newFeature": true, "newFeature": true,
"nodeModules": false, "nodeModules": false,
"autoAudits": false "autoAudits": false,
"coverView": true,
"lazyloadPlaceholderEnable": false,
"preloadBackgroundData": false,
"uglifyFileName": false,
"uploadWithSourceMap": true,
"enhance": true,
"useMultiFrameRuntime": true,
"showShadowRootInWxmlPanel": true,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"useStaticServer": true,
"showES6CompileOption": false,
"checkInvalidKey": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"disableUseStrict": false,
"useCompilerPlugins": false,
"minifyWXML": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.10.2", "libVersion": "2.10.2",
"appid": "wx1b834552a7d49bb3", "appid": "wx1b834552a7d49bb3",
"projectname": "%E7%BE%8E%E8%A1%8C%E8%80%85%E4%BA%B2%E5%AD%90%E6%B8%B8", "projectname": "%E7%BE%8E%E8%A1%8C%E8%80%85%E4%BA%B2%E5%AD%90%E6%B8%B8",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"simulatorType": "wechat", "simulatorType": "wechat",
"simulatorPluginLibVersion": {}, "simulatorPluginLibVersion": {},
"condition": { "condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"list": []
},
"gamePlugin": {
"current": -1,
"list": []
},
"miniprogram": { "miniprogram": {
"current": 16,
"list": [ "list": [
{ {
"id": 16,
"name": "活动详情(水梨)", "name": "活动详情(水梨)",
"pathName": "pages/detail/index", "pathName": "pages/detail/index",
"query": "id=662", "query": "id=662",
"scene": null "scene": null
}, },
{ {
"id": -1,
"name": "直播页面", "name": "直播页面",
"pathName": "pages/live/live", "pathName": "pages/live/live",
"query": "", "query": "",
"scene": null "scene": null
}, },
{ {
"id": -1,
"name": "个人中心", "name": "个人中心",
"pathName": "pages/me/index", "pathName": "pages/me/index",
"query": "", "query": "",
"scene": null "scene": null
}, },
{ {
"id": -1,
"name": "我的地址", "name": "我的地址",
"pathName": "pages/address/index", "pathName": "pages/address/index",
"query": "", "query": "",
"scene": null "scene": null
}, },
{ {
"id": -1,
"name": "添加地址", "name": "添加地址",
"pathName": "pages/address/create", "pathName": "pages/address/create",
"query": "", "query": "",
"scene": null "scene": null
}, },
{ {
"id": -1,
"name": "活动-下单购买", "name": "活动-下单购买",
"pathName": "pages/detail/enroll/index", "pathName": "pages/detail/enroll/index",
"query": "id=662", "query": "id=662",
"scene": null "scene": null
}, },
{ {
"id": -1,
"name": "我的订单", "name": "我的订单",
"pathName": "pages/me/order/index", "pathName": "pages/me/order/index",
"query": "",
"scene": null "scene": null
} }
] ]
} }
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
} }
} }
\ No newline at end of file
{
"projectname": "%E7%BE%8E%E8%A1%8C%E8%80%85%E4%BA%B2%E5%AD%90%E6%B8%B8",
"setting": {
"compileHotReLoad": true
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "2.24.7"
}
\ No newline at end of file
...@@ -27,7 +27,7 @@ export default { ...@@ -27,7 +27,7 @@ export default {
login: obj => f(wx.login, obj), login: obj => f(wx.login, obj),
checkSession: obj => f(wx.checkSession, obj), checkSession: obj => f(wx.checkSession, obj),
authorize: obj => f(wx.authorize, obj), authorize: obj => f(wx.authorize, obj),
getUserInfo: obj => f(wx.getUserInfo, obj), // getUserInfo: obj => f(wx.getUserInfo, obj),
// 支付 // 支付
requestPayment: obj => f(wx.requestPayment, obj), requestPayment: obj => f(wx.requestPayment, obj),
...@@ -72,7 +72,8 @@ export default { ...@@ -72,7 +72,8 @@ export default {
removeStorage: obj => f(wx.removeStorage, obj), removeStorage: obj => f(wx.removeStorage, obj),
// 位置 // 位置
getLocation: obj => f(wx.getLocation, obj), //getLocation已注释,暂无具体业务调用该功能
// getLocation: obj => f(wx.getLocation, obj),
chooseLocation: obj => f(wx.chooseLocation, obj), chooseLocation: obj => f(wx.chooseLocation, obj),
openLocation: obj => f(wx.openLocation, obj), openLocation: obj => f(wx.openLocation, obj),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment