uni.showLoading({
title: "同步中...",
mask: true
})
uni.login({
provider: 'weixin',
success: function(loginRes) {
let code = loginRes.code;
myRequest({
url: "/wxminiprogram/miniAuth",
method: "POST",
urltype:2,
data: {
code: code
}
})
.then(res => {
console.log(res);
uni.setStorageSync('authToken', {
token: res.data.data.authToken
});
uni.setStorageSync('openid', {
openid: res.data.data.openid
});
uni.setStorageSync('userid', {
userid: res.data.data.id
});
uni.authorize({
scope: 'scope.werun',
success() {
wx.getWeRunData({
success(res) {
console.log(res)
const encryptedData = res.encryptedData
const iv = res.iv
generalRequest({
url: "/wxminiprogram/getWeRunData",
method: "POST",
urltype:"test",
data: {
encryptedData: encryptedData,
iv: iv,
openid: uni.getStorageSync('openid').openid
}
})
.then((res) => {
console.log(res)
let list = res.data.data.stepInfoList
_this.werun_number = list[list.length - 1].step
generalRequest({
url: "/carboncoindetail/save",
method: "POST",
urltype:"test",
data: {
behaviorType: 2,
userId: uni.getStorageSync('userid').userid,
step: list[list.length - 1].step
}
})
.then((res) => {
uni.hideLoading()
console.log("步数获取碳积分", res)
if (res.data.code == 0) {
_this.tanjifen = res.data.data
_this.getBushuInfo()
} else {
uni.showToast({
"title": res.data.msg,
"icon": "none",
"duration": 3000
})
}
})
.catch(err => {
uni.hideLoading()
throw Error(err)
})
})
.catch(err => {
uni.hideLoading()
throw Error(err)
})
},
fail(err) {
uni.hideLoading()
console.log(err.errMsg)
}
})
}
})
})
.catch(err => {
throw Error(err)
})
},
fail: function(err) {
console.log(err)
},
});
到底为啥