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

3
pages/formid/formid.wxml

@ -11,6 +11,7 @@
 </view>  </view>
</view> </view>
<view class="buttons fixed"> <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>
</view> </view>
Loading…
Cancel
Save