ReedawFoodApp/pages/my/me.vue

329 lines
7.3 KiB
Vue
Raw Permalink Normal View History

2025-05-30 11:14:38 +08:00
<template>
<view class="content">
<!-- 头部 -->
2026-03-27 10:04:26 +08:00
<view class="top" v-if="token" @click="navTo('/body/setting/setting')">
2025-05-30 11:14:38 +08:00
<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>
2026-03-27 10:04:26 +08:00
<view class="top top2" v-else @click="handleLogin">
2026-03-31 16:04:41 +08:00
{{$t('msgLoginTips')}}
2026-03-23 09:50:49 +08:00
</view>
2025-05-30 11:14:38 +08:00
<!-- -->
<view class="wxlist borderRadius">
2026-03-23 09:50:49 +08:00
<view class="list" @click="navTo('/body/my/manage')">
2025-05-30 11:14:38 +08:00
<view class="item border-bottom">
<view class="left">
2026-03-31 16:04:41 +08:00
<view class="name">{{$t('titleManage')}}</view>
2025-05-30 11:14:38 +08:00
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
2026-03-23 09:50:49 +08:00
<view class="list" @click="navTo('/body/history/history')">
<view class="item border-bottom">
<view class="left">
2026-03-31 16:04:41 +08:00
<view class="name">{{$t('measuringRecord')}}</view>
2026-03-23 09:50:49 +08:00
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
<view class="list" @click="navTo('/Food/me/mymenu?pageName=我的收藏')">
2025-05-30 11:14:38 +08:00
<view class="item border-bottom">
<view class="left">
2026-03-31 16:04:41 +08:00
<view class="name">{{$t('infoMyCollection')}}</view>
2025-05-30 11:14:38 +08:00
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
2026-03-23 09:50:49 +08:00
<view class="list" @click="navTo('/Food/me/record')">
2025-05-30 11:14:38 +08:00
<view class="item border-bottom">
<view class="left">
2026-03-31 16:04:41 +08:00
<view class="name">{{$t('titleHistory')}}</view>
2025-05-30 11:14:38 +08:00
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
2026-03-23 09:50:49 +08:00
<view class="list" @click="navTo('/body/my/about')">
2025-05-30 11:14:38 +08:00
<view class="item border-bottom">
<view class="left">
2026-03-31 16:04:41 +08:00
<view class="name">{{$t('titleAboutUs')}}</view>
2025-05-30 11:14:38 +08:00
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
2026-03-31 16:04:41 +08:00
<view class="list">
<view class="item border-bottom">
<view class="left">
<view class="name">{{$t('titleLanguage')}}</view>
</view>
<view class="right">
<picker mode="selector" @change="changeClickLanguage" :range="languageList" range-key="name"
:value="levelInd">
<view>
{{languageList[levelInd].name}}
<uni-icons type="right"></uni-icons>
</view>
</picker>
</view>
</view>
</view>
2025-05-30 11:14:38 +08:00
<view class="list" v-for="(ite,ind) in CooperationUrl" :key="ind">
2026-03-23 09:50:49 +08:00
<view class="item border-bottom" @click="navTo('/body/webview/webview?url=' + ite.url)">
2025-05-30 11:14:38 +08:00
<view class="left">
<view class="name">{{ite.title}}</view>
</view>
<view class="right">
<uni-icons type="right"></uni-icons>
</view>
</view>
</view>
</view>
2026-03-31 16:04:41 +08:00
<view class="btn mb-15" v-if="token" @click="handleOutLogin">{{$t('btnLogOut')}}</view>
2025-05-30 11:14:38 +08:00
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
token: "",
2026-03-31 16:04:41 +08:00
user: {},
levelInd: 0,
2025-05-30 11:14:38 +08:00
}
},
computed: {
2026-03-31 16:04:41 +08:00
...mapState(["accountNumber", "familayList", "CooperationUrl", "setLocale", "configInfo"]),
2025-05-30 11:14:38 +08:00
nickname() {
return this.accountNumber.nickname
},
userList() {
return this.familayList
2026-03-31 16:04:41 +08:00
},
languageList() {
let that = this
let languageList = this.configInfo.language_arr
that.levelInd = languageList.findIndex(ite => ite.key == that.setLocale)
return this.configInfo.language_arr
2025-05-30 11:14:38 +08:00
}
},
watch: {
nickname() {
this.user = {}
this.user = this.accountNumber
}
},
2026-03-31 16:04:41 +08:00
onLoad() {
let that = this
that.token = uni.getStorageSync('token')
that.handleAccountNumber()
},
onShow() {
let that = this
that.token = uni.getStorageSync('token')
},
2025-05-30 11:14:38 +08:00
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({
2026-03-31 16:04:41 +08:00
title: that.$t('msgTitle'),
content: that.$t('verifyOutLogin'),
cancelText: that.$t('btnSancellation'),
confirmText: that.$t('btnConfirm'),
2025-05-30 11:14:38 +08:00
success: function(res) {
if (res.confirm) {
that.$model.getloginOut({}).then((res) => {
if (res.code != 0) return
console.log('确定退出', res)
2026-03-31 13:51:12 +08:00
that.token = ""
uni.setStorageSync('token', "")
2025-05-30 11:14:38 +08:00
uni.setStorageSync('aan_id', null)
uni.clearStorageSync()
2026-03-31 13:51:12 +08:00
uni.redirectTo({
2026-03-23 09:50:49 +08:00
url: "/body/login/login"
2025-05-30 11:14:38 +08:00
})
})
} else if (res.cancel) {
2026-03-31 16:04:41 +08:00
that.$tools.msg($t('msgCancel'));
2025-05-30 11:14:38 +08:00
}
},
})
},
2026-03-31 16:04:41 +08:00
// 语言切换
changeClickLanguage(e) {
let that = this
let key = that.languageList[e.target.value].key
let val = that.languageList[e.target.value].val
that.levelInd = e.target.value
that.$model.getSetLanguage({
language: val,
}).then(res => {
that.$i18n.locale = key
uni.setStorageSync('language', key)
that.$store.commit('changeLocale', key)
that.$store.dispatch("getHomeConfig")
that.$tools.handleUserList()
that.handleTabBarItem()
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
})
}, 500)
})
},
handleTabBarItem() {
let that = this
uni.setTabBarItem({
index: 0,
text: that.$t('titleHome')
})
uni.setTabBarItem({
index: 1,
text: that.$t('titleCount')
})
uni.setTabBarItem({
index: 2,
text: that.$t('titleMe')
})
},
2026-03-23 09:50:49 +08:00
handleLogin() {
2026-03-31 13:51:12 +08:00
uni.navigateTo({
2026-03-23 09:50:49 +08:00
url: "/body/login/login"
})
},
2025-05-30 11:14:38 +08:00
navTo(url) {
2026-03-23 09:50:49 +08:00
let that = this
if (!that.token) {
2026-03-31 16:04:41 +08:00
that.$tools.msg(that.$t('msgLoginTips'))
2026-03-23 09:50:49 +08:00
return
}
2025-05-30 11:14:38 +08:00
uni.navigateTo({
url
})
},
}
}
</script>
<style scoped lang="scss">
.content {
background-color: #F3F4F6;
padding: 15px;
min-height: 100vh;
}
.top {
2026-03-23 09:50:49 +08:00
width: calc(100% - 20px);
2025-05-30 11:14:38 +08:00
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;
}
}
2026-03-27 10:04:26 +08:00
.top2 {
color: #fff;
text-align: center;
justify-content: center;
background: $maincolor;
}
2025-05-30 11:14:38 +08:00
.wxlist {
2026-03-23 09:50:49 +08:00
width: 100%;
2025-05-30 11:14:38 +08:00
height: auto;
overflow: hidden;
position: relative;
2026-03-23 09:50:49 +08:00
margin-top: 15px;
background: #fff;
border-radius: 10px;
2025-05-30 11:14:38 +08:00
.item {
width: auto;
font-size: 32rpx;
2026-03-23 09:50:49 +08:00
line-height: 50px;
height: 50px;
2025-05-30 11:14:38 +08:00
display: flex;
2026-03-23 09:50:49 +08:00
2025-05-30 11:14:38 +08:00
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 {
2026-03-23 09:50:49 +08:00
width: 100%;
2025-05-30 11:14:38 +08:00
background: $btncolor;
2026-03-23 09:50:49 +08:00
margin: 50px 0px 0;
2025-05-30 11:14:38 +08:00
}
</style>