请问wx.login没有被触发是怎么回事,急!!!
发布于 5 年前 作者 xiuyingwu 6173 次浏览 来自 问答

//index.js

//获取应用实例

const app = getApp()

let Decryptor = require(’…/…/utils/Decryptor.js’)

let moment = require(’…/…/utils/moment.js’)

Page({

/**

  * 页面的初始数据

  */

data: {

stepInfoList: [],

today: {},

isClockIn: false,

openGId: “”,

images: [

‘/pages/images/index/index01.jpg’,

‘/pages/images/index/index02.jpg’

],

tab: {

list: [{

id: 0,

title: ‘昨天’

}, {

id: 1,

title: ‘今天’

}]

},

selectedId: 0

},

onShareAppMessage: function(result) {

var that = this

wx.showShareMenu({

withShareTicket: true

})

return {

title: “转发测试”,

path: ‘/pages/index/index’,

}

},

/**

  * 生命周期函数–监听页面加载

  */

onLoad: function() {

// 登录

let that = this

let isLogin = false

wx.login({

success: res => {

if (res.code) {

//发起网络请求

isLogin = true;

}

wx.showLoading({

title: ‘登陆中’,

})

wx.getUserInfo({

success: function(user) {

wx.request({

url: http://10.215.21.110:8080/WALKCRM/login.htm,

data: {

code: res.code,

wechatName: user.userInfo.nickName

},

header: {

‘content-type’: ‘application/x-www-form-urlencoded;charset=utf-8’

},

success: function(result) {

if(result.data.data.status != null){

that.setData({ disableButton: true})

that.setData({ disableButton1: true })

wx.setStorageSync(‘disableButton’, true);

wx.setStorageSync(‘disableButton1’, true);

}

console.log(result);

wx.setStorage({

key: ‘sid’,

data: result.data.data.sid,

success: res => {

wx.showToast({

title: ‘登陆成功’,

duration:3000,

})

}

})

wx.setStorage({

key: ‘nickName’,

data: result.data.data.nickName

})

that.fetchRunData(result.data.data.sid);

},

fail: function(res) {

wx.showToast({

title: ‘登陆失败’,

duration: 3000,

})

},

complete: function() {

wx.hideLoading()

}

})

},

fail: () => {

wx.navigateTo({

url: ‘/pages/login/login’,

})

}

})

}

})

},

transformData: function(data) {

return data.map(e => ({

time: moment(e.timestamp * 1000).format(“YYYY-MM-DD”),

step: e.step

}))

},

clockin: function() {

let that = this

wx.showLoading({

title: ‘打卡中’,

})

wx.getStorage({

key: ‘sid’,

success: function(res) {

wx.getWeRunData({

success: function(runData) {

wx.getStorage({

key: ‘shareTicket’,

success: function(shareTicket) {

wx.getShareInfo({

shareTicket: shareTicket.data,

success: function(groupdata) {

that.pushclock({

sid: res.data,

rundata: runData.encryptedData,

runiv: runData.iv,

groupdata: groupdata.encryptedData,

groupiv: groupdata.iv

})

},

fail: function() {

console.log(213)

that.pushclock({

sid: res.data,

rundata: runData.encryptedData,

runiv: runData.iv

})

}

})

},

})

}

})

},

})

},

pushclock: function(params = {}) {

wx.request({

url: http://10.215.21.110:8080/WALKCRM/clock.htm,

method: ‘post’,

header: {

‘content-type’: ‘application/x-www-form-urlencoded;charset=utf-8’

},

data: {

…params

},

success: (result) => {

console.log(result);

if (result.data.status == ‘0’) {

wx.showToast({

title: result.data.msg,

icon: ‘none’

})

}

console.log(result.data.status==‘0’)

if (result.data.status == ‘1’){

this.fetchRunData(params.sid)

wx.showToast({

title: ‘打卡成功’,

icon: ‘success’

})

}

this.setData({disableButton:true});

this.setData({ disableButton1:true});

wx.setStorageSync(‘disableButton’, true);

wx.setStorageSync(‘disableButton1’, true);

},

fail: function() {

wx.showToast({

title: ‘打卡失败’,

duration: 2000

})

},

complete: function() {

wx.hideLoading()

}

})

},

handleTabChange: function(data) {

this.setData({

selectedId: data.detail

}, () => {

wx.getStorage({

key: ‘sid’,

success: (res) => {

this.fetchRunData(res.data)

},

})

})

},

fetchRunData: function(sid) {

wx.showLoading({

title: ‘加载数据中’,

})

wx.request({

url: http://10.215.21.110:8080/WALKCRM/getCardRecord.htm,

data: {

sid,

type: this.data.selectedId

},

header: {

‘content-type’: ‘application/x-www-form-urlencoded;charset=utf-8’

},

success: (resultData) => {

console.log(resultData)

this.setData({

stepInfoList: resultData.data.data.recordList

})

},

fail: function() {

wx.showToast({

title: ‘加载失败’,

icon: ‘none’,

duration: 2000

})

},

complete: function() {

wx.hideLoading()

}

})

},

leave: function() {

wx.navigateTo({

url: ‘/pages/leave/leave’,

})

},

/**

  * 生命周期函数–监听页面初次渲染完成

  */

onReady: function() {

},

/**

  * 生命周期函数–监听页面显示

  */

onShow: function() {

var disableButton= wx.getStorageSync(‘disableButton’);

var disableButton1 = wx.getStorageSync(‘disableButton1’);

console.log(disableButton);

this.setData({

disableButton: disableButton,

disableButton1: disableButton1

})

},

/**

  * 生命周期函数–监听页面隐藏

  */

onHide: function() {

},

/**

  * 生命周期函数–监听页面卸载

  */

onUnload: function() {

},

/**

  * 页面相关事件处理函数–监听用户下拉动作

  */

onPullDownRefresh: function() {

},

/**

  * 页面上拉触底事件的处理函数

  */

onReachBottom: function() {

},

})

上述代码中,wx.login没有被执行

3 回复

你好,问一下只是调用一下wx.login没有响应,怎么处理

你把工具关了再打开试试

回到顶部