Commit d684c0f0 by 张天炜

小程序登录功能更新

parent f4f8bf07
......@@ -35,17 +35,26 @@ Page({
},
handleWxAuth: function(event) {
handleWxAuth: function() {
var _this = this
Wx.login().then(res => {
//获取登录的临时凭证
_this.wxLoginCode = res.code
})
wx.getUserProfile({
desc: '用于完善个人资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中
success: (e) => {
api.login({
code: res.code,
signature: event.detail.signature,
rawData: event.detail.rawData,
encryptedData: event.detail.encryptedData,
iv: event.detail.iv,
code: _this.wxLoginCode,
signature: e.signature,
rawData: e.rawData,
encryptedData: e.encryptedData,
iv: e.iv,
scene: app.options.query && app.options.query.scene ? decodeURIComponent(app.options.query.scene) : ''
}).then(res => {
if (!res.code) {
console.log(res)
if (!_this.wxLoginCode) {
app.globalData.userInfo = res.user
wx.setStorageSync('token', res.token)
$Toast({
......@@ -64,7 +73,12 @@ Page({
});
}
})
},
fail: (e) => {
console.log(e)
}
})
},
handlePhoneAuth: function(event) {
......
......@@ -8,7 +8,8 @@
<view>美好的教育,行走在路上</view>
</view>
<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> -->
<!-- <view class="text-small text-hint tip">请完成微信授权</view> -->
<i-button bindtap="gotoHome" type="default" shape="circle">暂不登录</i-button>
......
{
"description": "项目配置文件",
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"packOptions": {
"ignore": []
"ignore": [],
"include": []
},
"setting": {
"urlCheck": false,
......@@ -10,90 +11,86 @@
"minified": true,
"newFeature": true,
"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",
"libVersion": "2.10.2",
"appid": "wx1b834552a7d49bb3",
"projectname": "%E7%BE%8E%E8%A1%8C%E8%80%85%E4%BA%B2%E5%AD%90%E6%B8%B8",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"list": []
},
"gamePlugin": {
"current": -1,
"list": []
},
"miniprogram": {
"current": 16,
"list": [
{
"id": 16,
"name": "活动详情(水梨)",
"pathName": "pages/detail/index",
"query": "id=662",
"scene": null
},
{
"id": -1,
"name": "直播页面",
"pathName": "pages/live/live",
"query": "",
"scene": null
},
{
"id": -1,
"name": "个人中心",
"pathName": "pages/me/index",
"query": "",
"scene": null
},
{
"id": -1,
"name": "我的地址",
"pathName": "pages/address/index",
"query": "",
"scene": null
},
{
"id": -1,
"name": "添加地址",
"pathName": "pages/address/create",
"query": "",
"scene": null
},
{
"id": -1,
"name": "活动-下单购买",
"pathName": "pages/detail/enroll/index",
"query": "id=662",
"scene": null
},
{
"id": -1,
"name": "我的订单",
"pathName": "pages/me/order/index",
"query": "",
"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 {
login: obj => f(wx.login, obj),
checkSession: obj => f(wx.checkSession, 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),
......@@ -72,7 +72,8 @@ export default {
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),
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