ReedawFoodApp/pages/my/me.vue

264 lines
5.5 KiB
Vue

<template>
<view class="content">
<!-- 头部 -->
<view class="top" v-if="token" @click="navTo('/body/setting/setting')">
<view class="headimg">
<image :src="user.head_pic" class="image"></image>
<view class="size20 bold">{{user.nickname}}</view>
</view>
<text class="t-icon t-icon-arrow-right-bold"></text>
</view>
<view class="top top2" v-else @click="handleLogin">
登录后查看更多
</view>
<!-- -->
<view class="wxlist borderRadius">
<view class="list" @click="navTo('/body/my/manage')">
<view class="item border-bottom">
<view class="left">
<view class="name">成员管理</view>
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
<view class="list" @click="navTo('/body/history/history')">
<view class="item border-bottom">
<view class="left">
<view class="name">测量记录</view>
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
<view class="list" @click="navTo('/Food/me/mymenu?pageName=我的收藏')">
<view class="item border-bottom">
<view class="left">
<view class="name">我的收藏</view>
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
<view class="list" @click="navTo('/Food/me/record')">
<view class="item border-bottom">
<view class="left">
<view class="name">饮食记录</view>
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
<!-- #ifdef APP-PLUS -->
<view class="list" @click="navTo('/body/my/about')">
<view class="item border-bottom">
<view class="left">
<view class="name">关于我们</view>
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
<!-- #endif -->
<view class="list" v-for="(ite,ind) in CooperationUrl" :key="ind">
<view class="item border-bottom" @click="navTo('/body/webview/webview?url=' + ite.url)">
<view class="left">
<view class="name">{{ite.title}}</view>
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
</view>
<view class="btn mb-15" v-if="token" @click="handleOutLogin">退出登录</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
token: "",
user: {}
}
},
computed: {
...mapState(["accountNumber", "familayList", "CooperationUrl", ]),
nickname() {
return this.accountNumber.nickname
},
userList() {
return this.familayList
}
},
onLoad() {
let that = this
that.token = uni.getStorageSync('token')
that.handleAccountNumber()
},
watch: {
nickname() {
this.user = {}
this.user = this.accountNumber
}
},
onPullDownRefresh() {
let that = this
that.token = uni.getStorageSync('token')
that.handleAccountNumber()
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1000);
},
methods: {
handleAccountNumber() {
let that = this
that.$model.getAccountNumber({}).then(res => {
console.log("账号信息", res)
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
that.user = res.data
that.$store.commit('changeAccountNumber', res.data)
}).catch(err => {})
},
handleOutLogin() {
let that = this
uni.showModal({
title: '友情提示',
content: '是否退出登录?',
success: function(res) {
if (res.confirm) {
that.$model.getloginOut({}).then((res) => {
if (res.code != 0) return
console.log('确定退出', res)
uni.setStorageSync('token', null)
uni.setStorageSync('aan_id', null)
uni.clearStorageSync()
uni.reLaunch({
url: "/body/login/login"
})
})
} else if (res.cancel) {
that.$tools.msg("您已取消操作!");
}
},
})
},
handleLogin() {
uni.redirectTo({
url: "/body/login/login"
})
},
navTo(url) {
let that = this
if (!that.token) {
that.$tools.msg("登录后查看更多!")
return
}
uni.navigateTo({
url
})
},
}
}
</script>
<style scoped lang="scss">
.content {
background-color: #F3F4F6;
padding: 15px;
min-height: 100vh;
}
.top {
width: calc(100% - 20px);
height: auto;
background: #fff;
border-radius: 10px;
display: flex;
padding: 10px;
align-items: center;
justify-content: space-between;
.headimg {
width: 80%;
display: flex;
align-items: center;
view {
width: calc(100% - 70px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
image {
width: 60px;
height: 60px;
border-radius: 50%;
margin-right: 10px;
}
}
.top2 {
color: #fff;
text-align: center;
justify-content: center;
background: $maincolor;
}
.wxlist {
width: 100%;
height: auto;
overflow: hidden;
position: relative;
margin-top: 15px;
background: #fff;
border-radius: 10px;
.item {
width: auto;
font-size: 32rpx;
line-height: 50px;
height: 50px;
display: flex;
padding: 0 10px;
justify-content: space-between;
align-items: center;
.left {
display: flex;
align-items: center;
}
}
}
.href {
display: flex;
width: 100%;
color: #000;
text-decoration: none;
justify-content: space-between;
}
.btn {
width: 100%;
background: $btncolor;
margin: 50px 0px 0;
}
</style>