<button open-type="getUserInfo" @getuserinfo="bindGetUserInfo"></button>
export default {
methods: {
bindGetUserInfo(e) {
//
this.submitForm()
},
submitForm() {
//
this.login()
},
async login () {
wx.login({
success:async res => {
let code = res.code;
if (code) {
this.submitData["code"] = code
const data = await Api.Login(this.submitData); //ajax
if (data.errcode === 0) {
//
}
The ajax request in the code is defined in the login method. The order of clicking the button call is bindGetUserInfo-> submitForm-> login,await without waiting. I replaced it with
.export default {
methods: {
async bindGetUserInfo(e) {
//
await this.submitForm()
},
async submitForm() {
//
await this.login()
},
async login () {
wx.login({
success:async res => {
let code = res.code;
if (code) {
this.submitData["code"] = code
const data = await Api.Login(this.submitData); //ajax
if (data.errcode === 0) {
//
}
this doesn"t work either. I don"t know why?