You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

463 lines
12 KiB

4 years ago
<template>
<view>
<view class="navBar fixed" style="background-image: none;">
2 months ago
<!-- <uni-nav-bar class="flex_start" :fixed="true" :status-bar="true" color="#000"
4 years ago
background-color="rgba(0,0,0,0)">
<view style="width:95%;text-align: center;" class="map-top-text flex_center">个人中心</view>
2 months ago
</uni-nav-bar> -->
4 years ago
</view>
<view class="mine-top">
4 years ago
<image :src="topimg" class="mine-top-img"></image>
4 years ago
</view>
<view class="mine-box">
<view class="mine-box-user">
2 months ago
<view class="user_avator" @click="showEditForm">
4 years ago
<u-avatar :src="info.headimgurl" size="61"></u-avatar>
4 years ago
</view>
<view class="user_info">
<view class="user_name">
4 years ago
{{info.nickname||"暂未授权"}}
4 years ago
</view>
<view class="user_phone">
4 years ago
{{info.mobile||"暂未设置"}}
4 years ago
</view>
</view>
</view>
<view class="mine-box-nav">
<view class="mine-box-navtitle">
3 years ago
预约记录
4 years ago
</view>
<view class="mine-box-navlist">
<view class="mine-box-navitem" @click="toPage(1)">
<image src="../../static/img/icon_visit.png" class="mine-box-navitemimg"
style="width: 60rpx;height: 54rpx;"></image>
<text class="mine-box-navitemtxt">参观预约</text>
</view>
<view class="mine-box-navitem" @click="toPage(2)">
<image src="../../static/img/icon_activity.png" class="mine-box-navitemimg"
style="width: 51rpx;height: 56rpx;"></image>
<text class="mine-box-navitemtxt">活动预约</text>
</view>
<view class="mine-box-navitem" @click="toPage(3)">
<image src="../../static/img/icon_park.png" style="width: 51rpx;height: 52rpx;"
class="mine-box-navitemimg"></image>
<text class="mine-box-navitemtxt">停车场预约</text>
</view>
</view>
</view>
<view class="mine-box-list">
<view class="list-item" style="position: relative;">
4 years ago
<button open-type="feedback" class="hideBtn"
style="width: 100%;height: 100%;top:0rpx;left: 0rpx;"></button>
4 years ago
<view class="list-item-left">
<text class="iconfont icon-yijianfankui"></text>
<text class="list-item-lefttxt">意见反馈</text>
</view>
<view class="list-item-right">
<u-icon name="arrow-right" color="#ccc"></u-icon>
</view>
</view>
4 years ago
<view class="list-item" @click="toPage(4)">
4 years ago
<view class="list-item-left">
<text class="iconfont icon-fenxiang"></text>
2 months ago
<text class="list-item-lefttxt">推荐预约管理系统</text>
4 years ago
</view>
<view class="list-item-right">
<u-icon name="arrow-right" color="#ccc"></u-icon>
</view>
</view>
</view>
</view>
4 years ago
<!-- H5和小程序环境判断的授权弹窗 -->
4 years ago
<u-popup :show="showAuthorization" mode="bottom" @close="closeInfo" :round="10">
<view class="box">
<view class="box-title" style="text-align: center;padding: 20rpx 0;font-size: 32rpx;">
{{isH5 ? '请完善您的个人信息' : '请授权您的微信头像和昵称'}}
4 years ago
</view>
<view class="box-content" style="padding: 20px;">
<!-- H5环境直接显示编辑表单 -->
<view v-if="isH5">
<u-form labelPosition="top" :model="form">
<u-form-item label="昵称" prop="name" labelWidth="60px" required>
<u-input v-model="form.name" placeholder="请输入昵称"></u-input>
</u-form-item>
<u-form-item label="头像" prop="avatar" labelWidth="60px">
<view class="avatar-upload">
<u-avatar :src="form.avatar" size="80" @click="chooseAvatar"></u-avatar>
<text class="avatar-tip">点击上传头像</text>
</view>
</u-form-item>
</u-form>
<u-button type="primary" @click="tosubmit"></u-button>
</view>
<!-- 小程序环境微信一键授权 -->
<u-button v-else type="primary" @click="getUserProfile"></u-button>
</view>
</view>
</u-popup>
<!-- 小程序环境确认编辑弹窗 -->
<u-popup :show="showform" mode="bottom" @close="closeForm" :round="10" v-if="!isH5">
<view class="box">
<view class="box-title" style="text-align: center;padding: 20rpx 0;font-size: 32rpx;">
请确认编辑您的微信头像和昵称
</view>
<view class="box-content" style="padding: 20px;">
<u-form labelPosition="top" :model="form">
<u-form-item label="昵称" prop="name" labelWidth="60px" required>
<u-input v-model="form.name" placeholder="请输入昵称"></u-input>
</u-form-item>
<u-form-item label="头像" prop="avatar" labelWidth="60px">
<view class="avatar-upload">
<u-avatar :src="form.avatar" size="80" @click="chooseAvatar"></u-avatar>
<text class="avatar-tip">点击上传头像</text>
</view>
</u-form-item>
</u-form>
<u-button type="primary" @click="tosubmit"></u-button>
4 years ago
</view>
</view>
</u-popup>
4 years ago
</view>
</template>
<script>
export default {
data() {
return {
4 years ago
topimg: "",
info: {},
showAuthorization: false,
showform: false,
action: '',
otherData: {
token: ''
},
avatarList: [],
form: {
name: '',
avatar: ''
},
isH5: false
4 years ago
}
4 years ago
},
onReady() {
this.topimg = this.util.HOST + "/top_bg.png";
},
4 years ago
onShow() {
var that = this;
// 检测运行环境
this.isH5 = typeof window !== 'undefined' && window.location
this.action = this.util.HOST + "/api/mobile/upload-file"
this.otherData.token = uni.getStorageSync("userInfo_token").token;
4 years ago
this.loadInfo(function(res) {
if (res.headimgurl || res.nickname) {
4 years ago
that.showAuthorization = false;
} else {
that.showAuthorization = true;
4 years ago
}
});
4 years ago
},
methods: {
2 months ago
// 显示编辑表单
showEditForm() {
// 检测运行环境
const isH5 = typeof window !== 'undefined' && window.location
if (isH5) {
// H5环境直接显示编辑弹窗
this.showAuthorization = true;
// 预填充当前信息
this.form.name = this.info.nickname || '';
this.form.avatar = this.info.headimgurl || '';
} else {
// 小程序环境:显示确认编辑弹窗
this.showform = true;
// 预填充当前信息
this.form.name = this.info.nickname || '';
this.form.avatar = this.info.headimgurl || '';
}
},
4 years ago
closeInfo() {
this.showAuthorization = false;
},
closeForm() {
this.showform = false
4 years ago
},
4 years ago
loadInfo(cb) {
var that = this;
this.util.getOpenidInfo(function(res) {
that.util.getUserInfo(function(r) {
that.info = r;
cb(r);
}, true)
4 years ago
}, true);
},
getUserProfile() {
var that = this;
this.util.getUserProfile((res) => {
console.log("res", res)
that.form.name = res.nickName
that.form.avatar = res.avatarUrl
that.avatarList.push({
type: 0,
url: res.avatarUrl
})
that.showAuthorization = false
// 小程序环境:显示确认编辑弹窗
// H5环境直接提交因为已经在第一个弹窗中编辑了
if (that.isH5) {
that.tosubmit()
} else {
that.showform = true
}
})
},
chooseAvatar() {
var that = this;
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: function(res) {
const tempFilePath = res.tempFilePaths[0];
// 上传图片到服务器
uni.uploadFile({
url: that.action,
filePath: tempFilePath,
name: 'file',
formData: that.otherData,
success: function(uploadRes) {
console.log("upload success", uploadRes)
let data = JSON.parse(uploadRes.data)
that.form.avatar = data.url
uni.showToast({
title: "上传成功",
icon: "success"
})
},
fail: function(err) {
console.log("upload fail", err)
uni.showToast({
title: "上传失败",
icon: "none"
})
}
})
}
})
},
tosubmit() {
if(this.util.isNull(this.form.name)){
uni.showToast({
title: "请填写昵称",
icon: "none"
4 years ago
})
return
}
var that = this
that.util.request({
api: '/api/mobile/user/save',
method: 'POST',
data: {
headimgurl: that.form.avatar,
nickname: that.form.name
},
utilSuccess: function(r) {
that.showform = false;
that.showAuthorization = false;
that.loadInfo(function() {
uni.showToast({
title: "保存成功",
icon: "success"
})
})
}
4 years ago
})
},
4 years ago
toPage(type) {
var url = "";
switch (type) {
case 1:
url = "../order/visitorder"
break;
4 years ago
case 2:
url = "../order/activityorder"
break;
case 3:
url = "../order/parkorder"
break;
case 4:
url = "recommend"
break;
4 years ago
}
uni.navigateTo({
url: url
})
}
}
}
</script>
<style>
.uni-navbar--border {
border-bottom-width: 0 !important;
}
page {
background: #d8ac75;
}
2 months ago
.navBar{
height:80rpx;
}
4 years ago
.mine-box-user {
margin-bottom: 65rpx;
}
.mine-top-img {
width: 100%;
}
.map-top-text {
width: 124px;
font-family: PingFangSC-Medium;
font-size: 32rpx;
color: #FFFFFF;
letter-spacing: 0;
text-align: center;
}
.mine-box {
width: 100%;
border-top-left-radius: 30rpx;
border-top-right-radius: 30rpx;
background-color: #fff;
position: relative;
z-index: 1024;
padding: 55rpx 25rpx;
box-sizing: border-box;
margin-top: -288rpx;
4 years ago
height: calc(100vh);
4 years ago
}
.mine-box-nav {
background: url("../../static/img/nav_bg.png") no-repeat;
background-size: cover;
width: 100%;
height: 273rpx;
}
.mine-box-user {
display: flex;
align-items: center;
}
2 months ago
.user_avator {
cursor: pointer;
position: relative;
transition: transform 0.2s;
}
.user_avator:active {
transform: scale(0.95);
}
4 years ago
.user_info {
margin-left: 33rpx;
}
.user_name {
font-size: 32rpx;
font-family: PingFang SC;
color: #4E4E4E;
}
.user_phone {
font-size: 24rpx;
color: #828282;
line-height: 40rpx;
}
.mine-box-nav {
padding: 39rpx;
box-sizing: border-box;
}
.mine-box-navtitle {
font-size: 32rpx;
font-family: PingFang SC;
color: #4E4E4E;
}
.hideBtn {
width: 170rpx;
height: 170rpx;
opacity: 0;
border-radius: 50%;
position: absolute;
top: 30rpx;
4 years ago
left: 30rpx;
4 years ago
z-index: 9999;
}
.mine-box-navlist {
display: flex;
justify-content: space-around;
margin-top: 40rpx;
}
.mine-box-navitem {
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
align-items: center;
}
.mine-box-navitemtxt {
font-size: 24rpx;
font-family: PingFang SC;
color: #4E4E4E;
margin-top: 30rpx;
}
.mine-box-list {
display: flex;
margin-top: 27rpx;
font-size: 32rpx;
color: #4E4E4E;
flex-direction: column;
}
.list-item {
display: flex;
flex-direction: row;
justify-content: space-between;
padding-top: 32rpx;
padding-bottom: 32rpx;
border-bottom: 2rpx solid #F7F6F4;
}
.list-item-lefttxt {
margin-left: 41rpx;
}
.avatar-upload {
display: flex;
flex-direction: column;
align-items: center;
gap: 10rpx;
}
.avatar-tip {
font-size: 24rpx;
color: #999;
}
</style>