means that when the user enters the program we developed on the official account (web page, not Mini Program), we need to judge whether the user has followed the official account, and if not, a pop-up window will pop up. I have found a lot on the Internet, but there are no examples. I don"t quite know how to call that interface. I ask all of you to answer your doubts. Thank you very much. The following is the code and error report. Ps (I heard that there are two interfaces for obtaining user information. I have tried one and reported an error. Please post an error message picture below.)
data() {
return {
show: false
}
},
mounted() {
this.tanchu()
},
methods: {
tanchu() {
let openid = window.sessionStorage.getItem("openid")
let access_token = window.sessionStorage.getItem("access_token")
// let url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid +
// "&lang=zh_CN"
let url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + access_token + "&openid=" + openid +
"&lang=zh_CN"
const res = this.$http.get(url)
console.log(res);
if (res.subscribe == 0) {
setTimeout(() => {
this.show = true
}, 3000);
} else {
this.show = false
}
},
close() {
this.show = false
}
},
< hr >