uniapp微信小程序开发 结合提示uniapp 使用uview2实现提示后跳转
<text class="text_22" @click="logout">退出登录</text>
<u-toast ref="uToast"></u-toast>
<script>
import {
logout,
userindex
} from '../../config/api.js'
export default {
data() {
return {};
},
mounted() {
this.userindex()
},
methods: {
showToast(params) {
this.$refs.uToast.show({
...params,
complete() {
params.url && uni.reLaunch({
url: params.url
})
}
})
},
logout() {
var that = this;
logout({}, {
custom: {
auth: true
}
}).then(res => {
if (res.code == 1) {
that.showToast({
type: 'default',
title: '提示',
message: "退出成功",
url: '/pages/login/login',
})
}
}).catch(err => {
})
},
//获取用户信息
userindex() {
userindex({}, {
custom: {
auth: true
}
}).then(res => {
if (res.code == 0) {
}
}).catch(err => {
})
},
}
};
</script>