demingshangjia/pages/user/index.vue

205 lines
5.5 KiB
Vue
Raw Normal View History

2020-06-12 15:08:37 +08:00
<template>
<view class="user">
2020-06-13 17:36:24 +08:00
<view class="head" @click="toOthersPage('info')">
2020-08-10 11:27:06 +08:00
<view class="info" :key="num">
2020-08-10 12:04:09 +08:00
<image :src="info.member_avatar+'?'+new Date().getTime()"></image>
2020-06-12 15:08:37 +08:00
<view class="name">
2020-07-29 20:35:33 +08:00
<text>{{info.member_nickname==null?"新用户":info.member_nickname}}</text>
<text>账号{{info.member_name}}</text>
2020-09-18 14:22:31 +08:00
<text class="u-line-2">个性签名{{info.signature==""?"该用户很懒没有签名!":info.signature}}</text>
2020-06-12 15:08:37 +08:00
</view>
</view>
2020-06-12 18:05:39 +08:00
<image src="/static/image/user/1.png"></image>
2020-06-12 15:08:37 +08:00
</view>
2020-06-12 18:05:39 +08:00
<view class="nav" @click="toOthersPage('fans')">
<text>我的粉丝</text>
2020-09-18 14:22:31 +08:00
<image src="/static/image/user/1.png"></image>
2020-06-12 18:05:39 +08:00
</view>
2020-09-18 14:22:31 +08:00
<view class="nav" @click="toOthersPage('content')">
2020-06-12 18:05:39 +08:00
<text>内容管理</text>
<image src="/static/image/user/1.png"></image>
</view>
<view class="nav" @click="toOthersPage('complaint')">
<text>骑手投诉</text>
<image src="/static/image/user/1.png"></image>
</view>
2020-09-01 20:32:15 +08:00
<view class="nav" @click="clearCache">
<text>清除缓存</text>
<text>{{ fileSizeString }}</text>
</view>
<view class="nav" @click="isLoginOut = true">
2020-08-10 11:31:03 +08:00
<text>退出登录</text>
<image src="/static/image/user/1.png"></image>
</view>
2020-09-01 20:32:15 +08:00
<u-modal v-model="isLoginOut" show-confirm-button show-cancel-button :content="content" @confirm="loginOut"></u-modal>
2020-07-30 10:12:27 +08:00
<u-toast ref="uToast" />
2020-06-12 15:08:37 +08:00
</view>
</template>
<script>
export default {
2020-06-12 18:05:39 +08:00
name:"user",
2020-07-29 20:35:33 +08:00
data() {
return {
2020-08-10 11:27:06 +08:00
info:{},
2020-09-01 20:32:15 +08:00
isLoginOut: false,
2020-08-28 14:17:51 +08:00
content: "是否退出登录?",
2020-09-01 20:32:15 +08:00
num:0,
fileSizeString: "", // 缓存大小
2020-07-29 20:35:33 +08:00
}
},
2020-09-01 20:32:15 +08:00
watch: {
isLoginOut() {
// console.log(this.isLoginOut);
2020-09-19 20:02:43 +08:00
// if (this.isLoginOut) {
// uni.hideTabBar();
// } else {
// setTimeout(function() {
// uni.showTabBar();
// },200)
// }
2020-09-01 20:32:15 +08:00
}
},
2020-07-29 20:35:33 +08:00
onLoad() {
2020-09-01 20:32:15 +08:00
this.getCache();
2020-08-06 17:02:11 +08:00
},
onShow() {
2020-07-29 20:35:33 +08:00
this.getmyinfo()
},
2020-06-12 18:05:39 +08:00
methods: {
2020-09-01 20:32:15 +08:00
// 获取缓存
getCache() {
let _this = this;
// #ifdef APP-PLUS
plus.cache.calculate(function(size) {
console.log(size);
let sizeCache = size;
if (sizeCache == 0) {
_this.fileSizeString = "0B";
} else if (sizeCache < 1024) {
_this.fileSizeString = sizeCache + "B";
} else if (sizeCache < 1048576) {
_this.fileSizeString = (sizeCache / 1024).toFixed(2) + "KB";
} else if (sizeCache < 1073741824) {
_this.fileSizeString = (sizeCache / 1048576).toFixed(2) + "MB";
} else {
_this.fileSizeString = (sizeCache / 1073741824).toFixed(2) + "GB";
}
});
// #endif
},
// 清除缓存
clearCache() {
// #ifdef APP-PLUS
uni.showModal({
title: "确定要清理缓存吗?",
cancelColor: "#999",
confirmColor: "#f00",
success: (res) => {
// console.log(res);
if (res.confirm) {
plus.cache.clear(function(e) {
console.log(e);
})
2020-09-19 20:02:43 +08:00
this.getCache();
2020-09-01 20:32:15 +08:00
}
}
})
// #endif
},
2020-08-10 11:31:03 +08:00
// 退出登陆
2020-08-28 14:17:51 +08:00
loginOut(){
2020-08-10 11:31:03 +08:00
uni.clearStorage();
2020-08-28 14:17:51 +08:00
this.imService.disconnect();
2020-08-10 11:31:03 +08:00
this.$refs.uToast.show({
title: "退出登陆成功!",
type: 'success'
});
uni.reLaunch({
url:"../login/login"
})
},
2020-07-29 20:35:33 +08:00
// 获取个人信息
getmyinfo(){
let that = this;
2020-07-30 19:49:12 +08:00
this.$u.api.getshopinfo({}).then(res => {
2020-07-29 20:35:33 +08:00
console.log(res);
if (res.errCode != 0) {
this.$refs.uToast.show({
title: res.message,
type: 'error'
});
} else {
this.info = res.data.memberInfo
2020-08-10 11:27:06 +08:00
this.num++
2020-07-29 20:35:33 +08:00
}
});
},
2020-06-12 18:05:39 +08:00
toOthersPage(url) {
uni.navigateTo({
url: '/pages/user/' + url
});
}
},
2020-06-12 15:08:37 +08:00
}
</script>
<style lang="scss" scoped>
.user{
2020-06-12 18:05:39 +08:00
min-height: calc(100vh - var(--window-top));
background: #ececec;
2020-06-12 15:08:37 +08:00
.head{
width: 100%;
height: 220rpx;
background-color: #FF780F;
padding: 0 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
.info{
display: flex;
align-items: center;
>image{
2020-09-18 14:22:31 +08:00
flex-shrink: 0;
2020-06-12 15:08:37 +08:00
width: 110rpx;
height: 110rpx;
border-radius: 50%;
}
.name{
font-size: 24rpx;
color: #fff;
display: flex;
flex-direction: column;
margin-left: 26rpx;
>text{
margin-top: 14rpx;
}
>text:first-child{
font-size: 28rpx;
margin-top: 0;
}
}
}
>image{
width: 12rpx;
height: 20rpx;
}
}
2020-06-12 18:05:39 +08:00
.nav{
width: 100%;
height: 100rpx;
display: flex;
padding: 30rpx;
align-items: center;
justify-content: space-between;
font-size: 30rpx;
margin-bottom: 2rpx;
color:#333;
background-color: #fff;
>image{
width: 13rpx;
height: 25rpx;
}
}
2020-06-12 15:08:37 +08:00
}
</style>