为什么说我的start界面找不到?原来好好的然后我加了不知道什么东西就一直报错。后来把新加的代码也删除了,无法获取用户头像和姓名信息,第一个界面也报错。
start界面变这样了,红框部分应该要头像,黄框的字应该是清楚的。
按钮也无法点击,提示是这样的:
但我设置了handler
求帮助!
APP.JS的代码如下:
let wechat = require(’./utils/wechat.js’);
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync(‘logs’) || []
logs.unshift(Date.now())
wx.setStorageSync(‘logs’, logs)
/* 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting[‘scope.userInfo’]) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})*/
},
//reminder里的
getUserInfo: function (cb) {
var that = this
if (this.globalData.userInfo) {
typeof cb == “function” && cb(this.globalData.userInfo)
}
else {
// 登录
wx.login({
success: function () {
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
typeof cb == “function” && cb(that.globalData.userInfo)
}
})
}
})
}
// 发送 res.code 到后台换取 openId, sessionKey, unionId
},//getUserInfo结束
bindGoBack: function (type) {
if (type == 0) {
wx.navigateBack()
}
else {
wx.navigateBack({
delta: type
})
}
},
//页面内部导航跳转
bindNavigateTo: function (action, params = “”) {
var linkurl
switch (action) {
case ‘business_card’:
linkurl = this.globalData.basePath + this.globalData.routePath.business_card + params
break
case ‘business_card_add’:
linkurl = this.globalData.basePath + this.globalData.routePath.business_card_add + params
break
case ‘business_card_view’:
linkurl = this.globalData.basePath + this.globalData.routePath.business_card_view + params
break
case ‘business_card_edit’:
linkurl = this.globalData.basePath + this.globalData.routePath.business_card_edit + params
break
}
console.log(linkurl)
wx.navigateTo({
url: linkurl
})
},
globalData: {
userInfo: null,
/*api: {
api_login: “/api/xcx/login”,
api_userinfo: “/api/xcx/userinfo”,
api_del: “/api/xcx/deleteapi”,
api_proxy: “/api/xcx/proxy”,
api_get_location: “/api/xcx/getlocation”,
api_district: “/api/xcx/district”,
api_is_check_in: “/api/xcx/is_check_in”,
api_check_in: “/api/xcx/check_in”,
api_businesscard_add: “/api/xcx/businesscard/add”,
api_businesscard_info: “/api/xcx/businesscard/info”,
api_businesscard_edit: “/api/xcx/businesscard/edit”,
api_businesscard: “/api/xcx/businesscard”,
},*/
routePath: {
business_card_add: “/card/add/add”,
business_card_view: “/card/view/view”,
business_card_edit: “/card/edit/edit”,
business_card: “/card/list/list”,
},
basePath: “/pages”,
},
func: {
http_request_action: http.http_request_action,
showToast_success: show.showToast_success,
showToast_default: show.showToast_default,
showModal: show.showModal,
makePhoneCall: common.makePhoneCall,
WxParse: WxParse,
Operation_add: common.Operation_add,
Operation_sub: common.Operation_sub,
Operation_mul: common.Operation_mul,
Operation_div: common.Operation_div,
},
})