Browse Source

欢迎进入页面去掉用户授权弹框

master
FightingN 6 years ago
parent
commit
54e75e7d96
  1. 89
      pages/formid/formid.js
  2. 3
      pages/formid/formid.wxml

89
pages/formid/formid.js

@ -63,49 +63,52 @@ Page({
})
},
bindGetUserInfo: function (e) {
if (e.detail.userInfo) {
// let wxHeadImg = e.detail.userInfo.avatarUrl
// let wxNickName = e.detail.userInfo.nickName
console.log(e)
let that = this
wx.login({
success: function (response) {
let code = response.code;
wx.getUserInfo({
success: function (res) {
console.log(res.encryptedData)
console.log(res.iv)
let encryptedData = res.encryptedData
let iv = res.iv
api.updateWxInfo(code, encryptedData, iv).then(function (res) {
// 跳转到首页
console.log('跳转到首页')
wx.setStorageSync('isFirst', 'noFirst')
wx.reLaunch({
url: '/pages/index/index'
})
})
}
})
}
})
// if (e.detail.userInfo) {
// // let wxHeadImg = e.detail.userInfo.avatarUrl
// // let wxNickName = e.detail.userInfo.nickName
// console.log(e)
// let that = this
// wx.login({
// success: function (response) {
// let code = response.code;
// wx.getUserInfo({
// success: function (res) {
// console.log(res.encryptedData)
// console.log(res.iv)
// let encryptedData = res.encryptedData
// let iv = res.iv
// api.updateWxInfo(code, encryptedData, iv).then(function (res) {
// // 跳转到首页
// console.log('跳转到首页')
// wx.setStorageSync('isFirst', 'noFirst')
// wx.reLaunch({
// url: '/pages/index/index'
// })
// })
// }
// })
// }
// })
} else {
console.log('拒绝授权')
wx.redirectTo({
url: '/pages/index/index'
})
// wx.showModal({
// title: '提示',
// content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!',
// showCancel: false,
// confirmText: '返回授权',
// success: function (res) {
// if (res.confirm) {
// console.log('用户点击了“返回授权”')
// }
// }
// })
}
// } else {
// console.log('拒绝授权')
// wx.redirectTo({
// url: '/pages/index/index'
// })
// // wx.showModal({
// // title: '提示',
// // content: '您点击了拒绝授权,将无法进入小程序,请授权之后再进入!',
// // showCancel: false,
// // confirmText: '返回授权',
// // success: function (res) {
// // if (res.confirm) {
// // console.log('用户点击了“返回授权”')
// // }
// // }
// // })
// }
wx.reLaunch({
url: '/pages/index/index'
})
}
})

3
pages/formid/formid.wxml

@ -11,6 +11,7 @@
 </view>
</view>
<view class="buttons fixed">
<button hover-class="hover-class" class="btn2" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">进入首页</button>
<!-- <button hover-class="hover-class" class="btn2" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">进入首页</button> -->
<button hover-class="hover-class" class="btn2" bind:tap="bindGetUserInfo">进入首页</button>
</view>
</view>
Loading…
Cancel
Save