123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <view class="user-content">
- <!-- 头部 -->
- <view class="user-head" >
- <view>
- <open-data type="userAvatarUrl" class="user-photo"></open-data>
- </view>
- <view class="user-info">
- <view>
- <view v-if="hasLogin" class="user-info-item">{{userData.name ? userData.name :''}}</view>
- <open-data type="userNickName" class="user-info-item" v-if="!userData.name && hasLogin"></open-data>
- <view v-if="hasLogin" class="user-info-item">{{userData.mobile? userData.mobile:''}}</view>
- <u-button v-else="!hasLogin" plain size="mini" shape="circle" @click="toLoginPage">立即登录</u-button>
- </view>
- <view>
- <u-tag v-if="hasLogin" :text="userData?userData.reserveUserHistoryAccount+'元' :0+'元'" bg-color="#ff2c5c30" color="#FF2C5C" shape="circleLeft" mode="dark" class="tagPrice"/>
- </view>
- </view>
- </view>
- <!-- 列表 -->
- <view class="list-container">
- <!-- <view v-if="hasLogin" @click="toZY" class="list-item flex align_center justify_between">
- <view class="flex align_center">
- <u-image src="/static/personal_icon_flag.png" width="48" height="48"></u-image>
- <text>回收指引</text>
- </view>
- <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
- </view> -->
- <view @click="checkUpdate" class="list-item flex align_center justify_between">
- <view class="flex align_center">
- <u-image src="/static/personal_icon_version.png" width="48" height="48"></u-image>
- <text>版本检查</text>
- </view>
- <view>
- <text>{{version}}</text>
- <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
- </view>
- </view>
- <view v-if="hasLogin" @click="quitSys" class="list-item flex align_center justify_between">
- <view class="flex align_center">
- <u-image src="/static/personal_icon_out.png" width="48" height="48"></u-image>
- <text>退出登录</text>
- </view>
- <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { checkLogin, getUserInfo, logout } from '@/api/login.js'
- export default {
- data() {
- return {
- hasLogin: false,
- // name:'',
- // mobile:
- userData: {},
- price:'', // 交易金额
- version: '1.0.2' // 小程序版本
- };
- },
- onShow() {
- checkLogin().then(res => {
- this.hasLogin = res.status == 200
- console.log(this.hasLogin,res,'this.hasLogin')
- if(this.hasLogin){
- this.getUserInfo()
- }else{
- // uni.navigateTo({
- // url:"/pages/login/login"
- // })
- }
- })
- },
- computed: {
- // user() {
- // return this.userData
- // },
- name(){
- return this.$store.state.vuex_userInfoData.contactName
- },
- mobile(){
- return this.$store.state.vuex_userInfoData.contactMobile
- }
- },
- onLoad() {
- console.log(this.$store.state.vuex_userInfoData,this.$store.state.vuex_userInfoData.contactName,this.$store.state.vuex_userInfoData.contactMobile,'-------------用户信息')
- // this.getVersion()
- // 开启分享
- uni.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage', 'shareTimeline']
- })
- },
- methods:{
- // 回收指引
- // toZY(){
- // uni.navigateTo({
- // url: '/pages/index/zhiyin'
- // })
- // },
- // 获取当前小程序版本
- getVersion(){
- const accountInfo = uni.getAccountInfoSync();
- this.version = accountInfo.miniProgram.version
- console.log(accountInfo,accountInfo.miniProgram.appId,'ppppppppp'); // 小程序 appId
- },
- // 检查更新
- checkUpdate(){
- if (uni.canIUse('getUpdateManager')) {
- const updateManager = uni.getUpdateManager()
- updateManager.onCheckForUpdate(function (res) {
- console.log('onCheckForUpdate====', res)
- // 请求完新版本信息的回调
- if (res.hasUpdate) {
- console.log('res.hasUpdate====')
- updateManager.onUpdateReady(function () {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success: function (res) {
- console.log('success====', res)
- // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
- updateManager.onUpdateFailed(function () {
- // 新的版本下载失败
- uni.showModal({
- title: '已经有新版本了哟~',
- content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
- })
- })
- } else {
- uni.showToast({
- title: '已是最新版本',
- icon: 'none'
- })
- }
- })
- }
- },
- // 获取用户信息
- getUserInfo(){
- getUserInfo().then(res => {
- console.log(res,'getUserInfo')
- if(res.status == 200){
- this.$u.vuex("vuex_userData",res.data)
- this.userData = res.data
- console.log(this.userData,'-----用户信息')
- }
- })
- },
- // 退出登录
- quitSys(){
- let _this = this
- uni.showModal({
- title: '提示',
- content: '您确定要退出登录吗?',
- success(res) {
- if (res.confirm) {
- logout().then(res => {
- console.log(res,'logout')
- getApp().globalData.token = ''
- _this.$u.vuex('vuex_token','')
- // 关闭socket
- uni.reLaunch({
- url: '/pages/login/login'
- })
- })
- }
- }
- })
- },
-
- toLoginPage(){
- uni.navigateTo({
- url: '/pages/login/login'
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .user-content{
- width: 100%;
- background: #fff;
- .user-head{
- display: flex;
- align-items: center;
- padding: 35rpx 0rpx 35rpx 55rpx;
- .user-info{
- display: flex;
- justify-content: space-between;
- align-items: center;
- flex-grow: 1;
- padding-left: 20rpx;
- .user-info-item{
- margin: 10rpx 0;
- :first-child{
- font-size: 34upx;
- }
- }
- .tagPrice{
- width: 200rpx;
- }
- }
- .user-photo{
- display: block;
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- overflow: hidden;
- }
- }
- .list-container{
- width: 100%;
- .icon{
- width: 48rpx;
- height: 48rpx;
- margin-right: 30rpx;
- }
- .list-item{
- padding: 32rpx 36rpx;
- background-color: #fff;
- text{
- display: inline-block;
- margin-left: 28upx;
- font-size: 34rpx;
- color: #191919;
- }
- }
- .margin-bot{
- margin-bottom: 20rpx;
- }
- }
- }
- </style>
|