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)
}
})
}
})
}
},
typeof cb == "function" && cb(that.globalData.userInfo)
X console.log("info"+info);
console.log("info");
console.log(info);
person: {
name: "jafir",
age: "11",
}
var name = person["name"];
var age = person["age"];
info: {persons:[{name:"123",age:11},{name:"jafir1",age:12}]}
//如果有数组 通过这种方法获取
console.log(that.data.info["persons"][1].name)
console.log(that.data.info["persons"][1].age)
if (this.data.isSccess) {
console.log("true")
} else {
console.log("false")
}
//上下文对象
var that;
page({
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
that = this;
}
...
that.setData({
xxx: xxx,
})
})
onLoad: function (options) {
var value= options.key
}
<image src="{{logoUrl?logoUrl:'../../img/paihao.png'}}"></image>
style="visibility:{{isShow?'visible':'hidden'}}"
requestWithGet: function(paramsData) {
data.method = 'GET'
this.requestInternal(paramsData)
},
requestWithPost: function(paramsData) {
data.method = 'POST'
this.requestInternal(paramsData)
},
requestInternal: function (paramsData) {
var that = this;
console.log('requestInternal: 开始请求接口[' + paramsData.url + ']');
//开始网络请求
wx.request({
url: paramsData.url,
data: paramsData.data,
method: paramsData.method,
success: function (res) {
console.log('requestInternal: 接口请求成功[' + paramsData.url + ']');
paramsData.success(res);
},
fail: function (res) {
console.log('requestInternal: 接口请求失败[' + paramsData.url + ']');
console.log(res);
////在这里做请求失败的统一处理
wx.showToast({
title: '网络访问失败',
duration: 1500
})
typeof paramsData.fail == "function" && paramsData.fail(res);
},
complete: function (res) {
//在这里做完成的统一处理
typeof paramsData.complete == "function" && paramsData.complete(res);
}
})
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有