个人中心修改昵称设置头像显示区块链信息健康档案完善可修改

This commit is contained in:
2022-01-25 09:37:16 +08:00
parent 33b4fb304d
commit 6135fa2fca
10 changed files with 1003 additions and 500 deletions

View File

@@ -42,13 +42,16 @@ const editHealthBefore = (id) => {
* @Date: 2022-01-12 13:49:29
*/
const editHealth = (record_id, data) => {
console.log(data,'data............')
return request({
url: `health/records/${record_id}`,
method: "PUT",
date: data
data: data
})
}
export {
recordsHealth
recordsHealth,
editHealthBefore,
editHealth
}

View File

@@ -0,0 +1,34 @@
/**
* Web-zdx
* moduleName:修改头像和昵称
*/
import {
request
} from '../index'
// 获取用户设置中心的信息
const getUserSettingInfo = () => {
return request({
url: 'user/setting'
})
}
// 修改用户头像或昵称
const resetUserInfo = (data) => {
return request({
url: 'user/' + data.key,
method: 'PUT',
data: {
value: data.value
}
})
}
export {
getUserSettingInfo,
resetUserInfo,
}

View File

@@ -140,6 +140,15 @@
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/setting/setting",
"name": "Setting",
"style": {
"navigationBarTitleText": "设置中心",
"navigationBarBackgroundColor": "#34CE98",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/store/index",
"name": "Store",
@@ -574,8 +583,9 @@
"path": "pages/user/files",
"name": "UserFiles",
"style": {
"navigationBarTitleText": "健康档案",
"navigationBarBackgroundColor": "#FFFFFF"
"navigationBarTitleText": "健康档案管理",
"navigationBarBackgroundColor": "#34CE98",
"navigationBarTextStyle": "white"
}
}
],

View File

@@ -306,16 +306,9 @@ export default {
},
//年龄------------- 过滤出生年月日
formatter(type, value) {
if (type === 'year') {
return `${value}`;
}
if (type === 'month') {
return `${value}`;
}
if (type === 'day') {
return `${value}`;
}
console.log(value);
if (type === 'year') {return `${value}`;}
if (type === 'month') {return `${value}`;}
if (type === 'day') {return `${value}`;}
return value;
},
// 体重---------标尺滚动

211
pages/setting/setting.vue Normal file
View File

@@ -0,0 +1,211 @@
<template>
<view class="setting">
<!-- 更多管理 -->
<view class="list">
<view class="list-item" @click="updImgs">
<view class="list-item-left">
<span>修改头像</span>
</view>
<view class="avatar" >
<image :src="avatar.showPath || require('@/static/user/cover.png')" mode="aspectFill" />
<u-icon name="arrow-right" color="#999" size="20"></u-icon>
</view>
</view>
<view class="list-item">
<view class="list-item-left">
<span>修改昵称</span>
</view>
<view class="input">
<input type="text" :value="nickname" @blur='blur' placeholder="请输入用户的昵称" maxlength="12" />
<u-icon name="arrow-right" color="#999" size="20"></u-icon>
</view>
</view>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
import {
getUserSettingInfo,
resetUserInfo
} from '@/apis/interfaces/setting.js'
import {
uploads
} from '@/apis/interfaces/uploading'
export default {
data() {
return {
canLogin: true,
nickname: '',
avatar: {
path: '',
showPath: ''
},
is_bind: true
}
},
onShow() {
this.getUserInfo()
},
onPullDownRefresh() {
this.getUserInfo()
},
methods: {
// 获取当前用户得基本信息
getUserInfo() {
getUserSettingInfo().then(res => {
this.avatar.showPath = res.avatar
this.nickname = res.nickname
this.is_bind = res.is_bind
uni.stopPullDownRefresh()
}).catch(err => {
this.$refs.uToast.show({
title: err.message,
type: 'primary',
duration: 3000
})
})
},
// 上传头像
updImgs(type) {
uni.chooseImage({
crop: {
width: 80,
height: 80
},
success: res => {
let path = res.tempFiles.map((val, index) => {
return {
name: 'uploads' + index,
uri: val.path
}
})
uploads(path).then(pathRes => {
this.avatar.path = pathRes.path[0]
this.avatar.showPath = pathRes.url[0]
this.resetUserInfo('avatar',pathRes.url[0])
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
}
})
},
// 修改姓名
blur(e){
let value = e.detail.value
if(value !== this.nickname){
this.resetUserInfo('nickname',value)
}
},
// 修改头像或昵称
resetUserInfo(key, value) {
let data ={
key:key,
value:value
}
resetUserInfo(data).then(res=>{
uni.showToast({
title: res,
icon: 'none'
})
this.getUserInfo()
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
}
}
}
</script>
<style lang="scss" scoped>
page {
background-color: #F8F8F8;
}
.setting {
position: relative;
background-color: #fff;
// 更多管理
.list {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
box-sizing: border-box;
position: relative;
top: -10rpx;
border-radius: 20rpx;
margin: 0 $margin;
padding: 30rpx 0;
width: calc(100% - 80rpx);
.list-item {
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 40rpx 0;
border-bottom: solid 1rpx #f9f9f9;
box-sizing: border-box;
font-size: $title-size;
.avatar {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
image {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
margin-right: 20rpx;
}
}
.input {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
text-align: right;
flex: 1;
input {
padding-right: $padding - 10;
width: 100%;
}
}
.list-item-left {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
image {
width: 40rpx;
}
span {
margin-left: 20rpx;
}
}
}
}
}
</style>

View File

@@ -1,70 +1,282 @@
<template>
<view class="content">
<view class="files">
<view class="name">
性别
</view>
<view class="text">
{{ recordsData.sex == 1 ? '男' : '女' }}
</view>
</view>
<view class="files">
<view class="name">
年龄
</view>
<view class="text">
{{ recordsData.age }}
</view>
</view>
<view class="files">
<view class="name">
身高
</view>
<view class="text">
{{ recordsData.height }}cm
</view>
</view>
<view class="files">
<view class="name">
体重
</view>
<view class="text">
{{ recordsData.weight }}kg
</view>
</view>
</view>
<view class="content">
<!-- 性别start -->
<view class="files" @click="sexShow = true">
<view class="name">性别</view>
<view class="text">
<u-icon
class="target-icon"
:label="recordsData.sex == 1 ? '男士' : '女士'"
name="arrow-right"
color="#999"
size="14"
labelSize="14"
labelColor="#666"
labelPos="left"
space="10"
/>
</view>
</view>
<u-action-sheet
:actions="sexList"
title="你的性别是?"
:show="sexShow"
cancelText="暂不修改"
@select=" e => { (this.recordsData.sex = e.id), (this.sexShow = false); } "
@close="sexShow = false"
/>
<!-- 性别 end -->
<!-- 生日 start -->
<view class="files" @click="birthdayShow = true">
<view class="name">生日</view>
<view class="text">
<u-icon class="target-icon" :label="showBirthday" name="arrow-right" color="#999" size="14" labelSize="14" labelColor="#666" labelPos="left" space="10" />
</view>
</view>
<u-datetime-picker
confirmColor="#34ce98"
v-model="recordsData.birthday"
mode="date"
:show="birthdayShow"
:formatter="formatter"
:minDate="-302688000"
:maxDate="maxDate"
@confirm=" e => { this.recordsData.birthday = e.value, this.birthdayShow = false } "
@cancel=" () => { this.birthdayShow = false; } "
/>
<!-- 生日 end -->
<!-- 身高 start-->
<view class="files" @click="heightShow = true">
<view class="name">身高</view>
<view class="text">
<u-icon class="target-icon" :label="recordsData.height + ` CM`" name="arrow-right" color="#999" size="14" labelSize="14" labelColor="#666" labelPos="left" space="10" />
</view>
</view>
<u-popup :show="heightShow" @close="() => { heightShow = false }">
<view class="v-scale">
<view class="title"> 你的身高为?</view>
<view class="total"> {{recordsData.height}} CM </view>
<vue-scale :min="10" :max="100" :int="false" :single="10" :h="80" :styles="styles" @scroll="scrollAll('height',$event)" :scrollLeft="Number(recordsData.height)" />
</view>
</u-popup>
<!-- 身高 end -->
<!-- 最新体重 start -->
<view class="files bt30" @click="weightShow = true">
<view class="name">最新体重</view>
<view class="text">
<u-icon class="target-icon" :label="recordsData.weight + ` KG`" name="arrow-right" color="#999" size="14" labelSize="14" labelColor="#666" labelPos="left" space="10" />
</view>
</view>
<u-popup :show="weightShow" @close="() => { weightShow = false }">
<view class="v-scale">
<view class="title"> 你的当前体重为?</view>
<view class="total"> {{recordsData.weight}} KG </view>
<vue-scale :min="10" :max="100" :int="false" :single="10" :h="80" :styles="styles" @scroll="scrollAll('weight',$event)" :scrollLeft="Number(recordsData.weight)" />
</view>
</u-popup>
<!-- 生日 end -->
<!-- 目标 start -->
<view class="files" @click="targetShow = true">
<view class="name">目标</view>
<view class="text">
<u-icon class="target-icon" :label="targetList[selectedTargetIndex].name" name="arrow-right" color="#999" size="14" labelSize="14" labelColor="#666" labelPos="left" space="10" />
</view>
</view>
<u-action-sheet
:actions="targetList"
title="你的目标是?"
:show="targetShow"
cancelText="暂不修改"
@select=" e => { (this.selectedTargetIndex = this.targetList.findIndex(item => e.id === item.id)), (this.targetShow = false); } "
@close="targetShow = false"
/>
<!-- 目标 end -->
<!-- 目标体重 start-->
<view class="files" @click="targetWeightShow = true">
<view class="name">目标体重</view>
<view class="text"><u-icon class="target-icon" :label="recordsData.goal_weight + ` KG`" name="arrow-right" color="#999" size="14" labelSize="14" labelColor="#666" labelPos="left" space="10" /></view>
</view>
<u-popup :show="targetWeightShow" @close="() => { targetWeightShow = false }">
<view class="v-scale">
<view class="title"> 你的目标体重为?</view>
<view class="total"> {{recordsData.goal_weight}} KG </view>
<vue-scale :min="10" :max="100" :int="false" :single="10" :h="80" :styles="styles" @scroll="scrollAll('goalweight',$event)" :scrollLeft="Number(recordsData.goal_weight)" />
</view>
</u-popup>
<!-- 目标体重 end -->
<!-- 运动量 start -->
<view class="files" @click="exerciseShow = true">
<view class="name">运动量</view>
<view class="text">
<u-icon class="target-icon" :label="exerciseList[selectExerciseIndex].name" name="arrow-right" color="#999" size="14" labelSize="14" labelColor="#666" labelPos="left" space="10" />
</view>
</view>
<u-action-sheet
:actions="exerciseList"
title="你的运动量是?"
:show="exerciseShow"
cancelText="暂不修改"
@select=" e => { (this.selectExerciseIndex = this.exerciseList.findIndex(item => e.id === item.id)), (this.exerciseShow = false); } "
@close="exerciseShow = false"
/>
<!-- 运动量 end -->
<view class="sureBtn" @click="sureBtn"> 确认修改 </view>
<view class="des">修改资料后可更新并查看最新方案预算热量可能会发生变化</view>
</view>
</template>
<script>
import { records } from '@/apis/interfaces/user'
export default {
data() {
return {
recordsData: ''
};
},
mounted() {
records().then(res => {
this.recordsData = res
})
}
};
import { editHealthBefore,editHealth } from '@/apis/interfaces/essentialInfo.js';
import moment from 'moment';
import vueScale from '@/components/vueScale'; // 体重标尺
export default {
components:{
vueScale
},
data() {
return {
recordsData: {},
birthdayShow: false, // 出生日期展示
maxDate: new Date().getTime(),
sexShow: false, // 性别弹窗是否显示
sexList: [{name: '男士',id: 1},{name: '女士',id: 2}],
targetShow: false, // 目标弹窗是否显示
targetList: [{name: '减脂',id: 1},{name: '保持体重',id: 2},{name: '增肌',id: 3}],
selectedTargetIndex: 0,// 默认选择了那个target
exerciseShow:false,// 运动量弹窗是否显示
exerciseList:[{name:'久坐不动',id:1},{name:'少量运动',id:2},{name:'中等运动量',id:3},{name:'超强度运动',id:4}],
selectExerciseIndex:0,//默认选择运动量是久坐不懂得
heightShow:false,
weightShow:false,
targetWeightShow:false,
styles: {
line: '#dbdbdb',
bginner: '#fbfbfb',
bgoutside: '#ffffff',
font: '#404040',
fontColor: '#404040',
fontSize: 16
},
};
},
computed: {
showBirthday() {
return moment(this.recordsData.birthday).format('YYYY年MM月DD日');
}
},
onShow() {
let id = this.$Route.query.id;
editHealthBefore(id)
.then(res => {
this.recordsData = res;
this.recordsData.birthday = moment(res.birthday).format('YYYY-MM-DD');
this.selectExerciseIndex = this.exerciseList.findIndex(item => item.id === res.exercise)
})
.catch(err => {
conso.log(err);
});
},
methods: {
// 身高 体重 目标体重 滚动
scrollAll(type,value) {
if(type === 'height'){
return this.recordsData.height = value;
}
if(type === 'weight'){
return this.recordsData.weight = value;
}
if(type === 'goalweight'){
return this.recordsData.goal_weight = value;
}
},
// 年龄 - 过滤 - 自定义 - 出生年月日
formatter(type, value) {
if (type === 'year') {return `${value}`;}
if (type === 'month') {return `${value}`;}
if (type === 'day') {return `${value}`;}
return value;
},
// 提交按钮
sureBtn(){
let params = {
record_id:this.recordsData.record_id,
birthday:moment(this.recordsData.birthday).format('YYYY-MM-DD'),
sex:this.recordsData.sex,
height:this.recordsData.height,
weight:this.recordsData.weight,
exercise:this.exerciseList[this.selectExerciseIndex].id,
goal_weight:this.recordsData.goal_weight,
days:1
}
editHealth(params.record_id,params).then(res=>{
this.$Router.back()
}).catch(err=>{
this.$Router.back()
})
}
}
};
</script>
<style lang="scss" scoped>
.files {
display: flex;
padding: $padding;
box-sizing: border-box;
border-bottom: $border-color 2rpx solid;
&:last-child {
border: none;
}
.name {
flex: 1;
}
.text {
color: $text-gray;
}
}
.content {
padding: $padding;
}
.files {
display: flex;
padding: $padding + 10 $padding - 20;
box-sizing: border-box;
border-bottom: #f9f9f9 2rpx solid;
font-size: $title-size;
&:last-child {
border: none;
}
.name {
flex: 1;
}
.text {
color: $text-gray;
}
}
.v-scale{
padding: $padding * 2 0;
font-size: $title-size;
.title{
text-align: center;
font-size: $title-size + 10;
margin-bottom: $margin;
}
.total{
font-size: $title-size;
color: $main-color;
text-align: center;
}
}
.des {
color: $text-gray-m;
font-size: $title-size-m - 4;
margin-top: $margin * 2;
text-align: center;
}
.sureBtn{
background-color: $main-color;
color: #fff;
font-size: $title-size;
text-align: center;
padding: $padding;
border-radius: $radius;
margin-top: $margin * 2;
}
.bt30 {
border-bottom: #f9f9f9 20rpx solid;
}
</style>

View File

@@ -1,432 +1,472 @@
<template>
<view class="content">
<!-- 用户信息 -->
<view class="info-box">
<image src="@/static/user/user_back.png" mode="aspectFill"></image>
<view class="user-flex">
<image class="cover" :src="userInfo.avatar || require('@/static/user/cover.png')" mode="aspectFill"></image>
<view class="user-content">
<block v-if="$store.state.token != ''">
<view class="name">{{userInfo.nickname}}</view>
<view class="tabs" v-if="userInfo.identity.length != 0">
<view class="tabs-item"><image src="@/static/user/icon_07.png"></image>会员</view>
</view>
</block>
<block v-else>
<view class="name" @click="isLogin()">未登录</view>
</block>
</view>
</view>
</view>
<!-- 会员卡 -->
<view class="vip-card">
<view class="title">
<image src="@/static/user/icon_06.png" mode="widthFix"></image>
ZH会员
</view>
<view class="subtitle">
<u-notice-bar
:text="cardText"
icon=""
bgColor=""
duration="3000"
color="#fcc692"
direction="column"
></u-notice-bar>
</view>
<view class="btn" @click="openVip" v-if="userInfo.identity.length === 0">开通</view>
</view>
<!-- 健康数据 -->
<view class="health-flex" v-if="userInfo.has_record">
<view class="health-flex-item">
<view class="title">
体脂率
<image class="icon" src="@/static/user/icon_04.png" mode="widthFix"></image>
</view>
<view class="num">
{{userInfo.record.fat.fat}}<text>%</text>
</view>
<view class="hith">{{userInfo.record.fat.text}}</view>
</view>
<view class="health-flex-item">
<view class="title">
体重
<image class="icon" src="@/static/user/icon_05.png" mode="widthFix"></image>
</view>
<view class="num">
{{userInfo.record.weight.weight}}<text>KG</text>
</view>
<view class="hith">{{userInfo.record.weight.text}}</view>
</view>
</view>
<!-- 订单 -->
<view class="order-box">
<view class="order-box-item" @click="onBtn('Order', {index: 0})">
<image class="icon" src="@/static/user/order_icon_00.png" mode="widthFix"></image>
<view class="title">全部订单</view>
</view>
<view class="order-box-item" @click="onBtn('Order', {index: 1})">
<image class="icon" src="@/static/user/order_icon_01.png" mode="widthFix"></image>
<view class="title">待付款</view>
</view>
<view class="order-box-item" @click="onBtn('Order', {index: 2})">
<image class="icon" src="@/static/user/order_icon_02.png" mode="widthFix"></image>
<view class="title">待发货</view>
</view>
<view class="order-box-item" @click="onBtn('Order', {index: 3})">
<image class="icon" src="@/static/user/order_icon_03.png" mode="widthFix"></image>
<view class="title">待收货</view>
</view>
<view class="order-box-item" @click="onBtn('Order', {index: 4})">
<image class="icon" src="@/static/user/order_icon_04.png" mode="widthFix"></image>
<view class="title">已完成</view>
</view>
</view>
<!-- 功能块 -->
<view class="btns-box">
<view class="btns-box-item" @click="onWallet">
<image class="icon" src="@/static/user/userIcon_00.png" mode="widthFix"></image>
ZH钱包
<uni-icons class="forward" type="forward" color="#999"></uni-icons>
</view>
<view class="btns-box-item" @click="onFiles">
<image class="icon" src="@/static/user/userIcon_02.png" mode="widthFix"></image>
健康档案
<uni-icons class="forward" type="forward" color="#999"></uni-icons>
</view>
<view class="btns-box-item" @click="onBtn('Address', {type: 'edit'})">
<image class="icon" src="@/static/user/userIcon_03.png" mode="widthFix"></image>
地址管理
<uni-icons class="forward" type="forward" color="#999"></uni-icons>
</view>
</view>
<view class="btns-box" v-if="$store.state.token != ''">
<view class="btns-box-item" @click="logOut">
<image class="icon" src="@/static/user/userIcon_05.png" mode="widthFix"></image>
退出登录
<uni-icons class="forward" type="forward" color="#999"></uni-icons>
</view>
</view>
<view class="footer-text">
<view>ZH生态俱乐部</view>
<view>All Rights Reserved. ZH Eco Club</view>
</view>
</view>
<view class="content">
<!-- 用户信息 -->
<view class="info-box">
<image src="@/static/user/user_back.png" mode="aspectFill" />
<view class="user-flex">
<image class="cover" @click="$Router.push({ name: 'Setting' })" :src="userInfo.avatar || require('@/static/user/cover.png')" mode="aspectFill" />
<view class="user-content">
<block v-if="$store.state.token != ''">
<view class="name">{{ userInfo.nickname }}</view>
<view class="tabs" v-if="userInfo.identity.length !== 0">
<view class="tabs-item">
<image src="@/static/user/icon_07.png" />
VIP会员
</view>
</view>
<view class="tabs" v-else>
<view class="tabs-item">
<image src="@/static/user/icon_07.png" />
普通用户
</view>
</view>
<view class="chainAddress" v-if="userInfo.chain_address">
<u-icon labelPos="left" @click="copy(userInfo.chain_address)" labelSize="14" labelColor="#fff" :label="userInfo.chain_address.substr(0, 20)+'...'" space="10" :name="require('@/static/imgs/copy.png')" size="16" />
</view>
</block>
<block v-else><view class="name" @click="isLogin()">未登录</view></block>
</view>
</view>
</view>
<!-- 会员卡 -->
<view class="vip-card">
<view class="title">
<image src="@/static/user/icon_06.png" mode="widthFix" />
ZH会员
</view>
<view class="subtitle"><u-notice-bar :text="cardText" icon="" bgColor="" duration="3000" color="#fcc692" direction="column"></u-notice-bar></view>
<view class="btn" @click="openVip" v-if="userInfo.identity.length === 0">开通</view>
</view>
<!-- 健康数据 -->
<view class="health-flex" v-if="userInfo.has_record">
<view class="health-flex-item">
<view class="title">
体脂率
<image class="icon" src="@/static/user/icon_04.png" mode="widthFix" />
</view>
<view class="num">
{{ userInfo.record.fat.fat }}
<text>%</text>
</view>
<view class="hith">{{ userInfo.record.fat.text }}</view>
</view>
<view class="health-flex-item">
<view class="title">
体重
<image class="icon" src="@/static/user/icon_05.png" mode="widthFix" />
</view>
<view class="num">
{{ userInfo.record.weight.weight }}
<text>KG</text>
</view>
<view class="hith">{{ userInfo.record.weight.text }}</view>
</view>
</view>
<!-- 订单 -->
<view class="order-box">
<view class="order-box-item" @click="onBtn('Order', { index: 0 })">
<image class="icon" src="@/static/user/order_icon_00.png" mode="widthFix" />
<view class="title">全部订单</view>
</view>
<view class="order-box-item" @click="onBtn('Order', { index: 1 })">
<image class="icon" src="@/static/user/order_icon_01.png" mode="widthFix" />
<view class="title">待付款</view>
</view>
<view class="order-box-item" @click="onBtn('Order', { index: 2 })">
<image class="icon" src="@/static/user/order_icon_02.png" mode="widthFix" />
<view class="title">待发货</view>
</view>
<view class="order-box-item" @click="onBtn('Order', { index: 3 })">
<image class="icon" src="@/static/user/order_icon_03.png" mode="widthFix" />
<view class="title">待收货</view>
</view>
<view class="order-box-item" @click="onBtn('Order', { index: 4 })">
<image class="icon" src="@/static/user/order_icon_04.png" mode="widthFix" />
<view class="title">已完成</view>
</view>
</view>
<!-- 功能块 -->
<view class="btns-box">
<view class="btns-box-item" @click="onWallet">
<image class="icon" src="@/static/user/userIcon_00.png" mode="widthFix" />
ZH钱包
<uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="onFiles">
<image class="icon" src="@/static/user/userIcon_02.png" mode="widthFix" />
健康档案
<uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="onBtn('Address', { type: 'edit' })">
<image class="icon" src="@/static/user/userIcon_03.png" mode="widthFix" />
地址管理
<uni-icons class="forward" type="forward" color="#999" />
</view>
</view>
<view class="btns-box" v-if="$store.state.token != ''">
<view class="btns-box-item" @click="logOut">
<image class="icon" src="@/static/user/userIcon_05.png" mode="widthFix" />
退出登录
<uni-icons class="forward" type="forward" color="#999" />
</view>
</view>
<view class="footer-text">
<view>ZH生态俱乐部</view>
<view>All Rights Reserved. ZH Eco Club</view>
</view>
</view>
</template>
<script>
import { info } from '@/apis/interfaces/user'
import userAuth from '@/public/userAuth'
export default {
data() {
return {
cardText: ['新用户首单即赠会员', '老用户专属验证开通会员'],
userInfo: {
nickname: "",
avatar : "",
identity: []
}
};
},
onShow() {
this.getInfo()
},
methods:{
// 用户信息
getInfo(){
if(this.$store.state.token === '') return
info().then(res => {
uni.setNavigationBarTitle({
title: res.nickname
})
this.userInfo = res
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
},
// 开通会员
openVip(){
if(this.isLogin()){
uni.showActionSheet({
itemList: ["我是新用户", "我是老用户"],
success: res=> {
switch (res.tapIndex){
case 0:
uni.showModal({
title: '开通提示',
content: '平台新用户完成首笔订单即可获赠ZH健康会员',
showCancel:false,
cancelText: '去完成',
success: res => {
console.log(res)
this.$Router.pushTab({name: 'Store'})
}
})
break;
case 1:
uni.showToast({
title: '老用户渠道暂未开放',
icon : 'none'
})
break;
}
}
})
}
},
// 开通钱包
onWallet(){
if(this.isLogin()){
if(this.userInfo.is_wallet) this.$Router.push({name: 'WalletProperty'})
else this.$Router.push({name: 'WalletAdd'})
}
},
// 个人档案
onFiles(){
if(this.isLogin()){
if(!this.userInfo.has_record){
this.$Router.push({name: 'EssentialInfo'})
return
}
this.$Router.push({name: 'UserFiles'})
}
},
// 按钮导航
onBtn(name, params){
if(this.isLogin()){
this.$Router.push({name, params})
}
},
// 检查登录
isLogin(){
if(this.$store.state.token === ''){
const Auth = new userAuth()
Auth.Login()
return false
}
return true
},
// 退出登录
logOut(){
this.userInfo = {
nickname: "",
avatar : "",
identity: []
}
this.$store.commit('setToken', '')
}
}
}
import { info } from '@/apis/interfaces/user';
import userAuth from '@/public/userAuth';
export default {
data() {
return {
cardText: ['新用户首单即赠会员', '老用户专属验证开通会员'],
userInfo: {
nickname: '',
avatar: '',
identity: []
}
};
},
onShow() {
this.getInfo();
},
methods: {
// 用户信息
getInfo() {
if (this.$store.state.token === '') return;
info()
.then(res => {
console.log(res);
uni.setNavigationBarTitle({
title: res.nickname
});
this.userInfo = res;
console.log(res);
})
.catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
});
});
},
// 开通会员
openVip() {
if (this.isLogin()) {
uni.showActionSheet({
itemList: ['我是新用户', '我是老用户'],
success: res => {
switch (res.tapIndex) {
case 0:
uni.showModal({
title: '开通提示',
content: '平台新用户完成首笔订单即可获赠ZH健康会员',
showCancel: false,
cancelText: '去完成',
success: res => {
console.log(res);
this.$Router.pushTab({ name: 'Store' });
}
});
break;
case 1:
uni.showToast({
title: '老用户渠道暂未开放',
icon: 'none'
});
break;
}
}
});
}
},
// 开通钱包
onWallet() {
if (this.isLogin()) {
if (this.userInfo.is_wallet) this.$Router.push({ name: 'WalletProperty' });
else this.$Router.push({ name: 'WalletAdd' });
}
},
// 个人档案
onFiles() {
if (this.isLogin()) {
if (!this.userInfo.has_record) {
this.$Router.push({ name: 'EssentialInfo' });
return;
}
// this.$Router.push({ name: 'UserFiles',params:{id:this.userInfo.record_id} });
uni.navigateTo({
url: `/pages/user/files?id=${this.userInfo.record.record_id}`
});
}
},
// 按钮导航
onBtn(name, params) {
if (this.isLogin()) {
this.$Router.push({ name, params });
}
},
// 检查登录
isLogin() {
if (this.$store.state.token === '') {
const Auth = new userAuth();
Auth.Login();
return false;
}
return true;
},
// 退出登录
logOut() {
this.userInfo = {
nickname: '',
avatar: '',
identity: []
};
this.$store.commit('setToken', '');
},
copy(data){
uni.setClipboardData({
data: data,
success: function () {
uni.showToast({
title:'复制成功',
icon:'none'
})
}
});
}
}
};
</script>
<style lang="scss" scoped>
.content{
background: $window-color;
min-height: 100vh;
}
// 版权信息
.footer-text{
text-align: center;
font-size: $title-size-sm;
padding: $padding $padding $padding*2;
color: $text-gray-m;
}
// 用户信息
.info-box{
position: relative;
background: linear-gradient(to right, #34ce98, #22aa98);
color: white;
@extend .ios-top;
&>image{
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
}
.user-flex{
position: relative;
padding: $padding*2 $padding ($padding*2 + 60);
height: 128rpx;
.cover{
position: absolute;
width: 128rpx;
height: 128rpx;
border-radius: 50%;
border:solid 6rpx white;
box-sizing: border-box;
}
.user-content{
padding-left: 158rpx;
height: 128rpx;
display: flex;
flex-direction: column;
justify-content: center;
.name{
line-height: 40rpx;
font-weight: bold;
font-size: $title-size + 8;
@extend .nowrap;
}
.tabs{
padding-top: 10rpx;
&-item{
background: rgba($color: #000000, $alpha: .3);
font-size: $title-size-sm - 4;
display: inline-block;
line-height: 36rpx;
padding: 0 20rpx;
border-radius: 20rpx;
image{
width: 26rpx;
height: 26rpx;
vertical-align: middle;
margin-bottom: 2rpx;
margin-right: 8rpx;
}
}
}
}
}
}
// 会员卡
.vip-card{
position: relative;
margin: -60rpx $margin $margin;
background: linear-gradient(to right bottom, #3e5364, #31364a);
border-radius: $radius;
box-sizing: border-box;
color: #fcc692;
padding: $padding ($padding + 170) $padding $padding;
.title{
font-weight: bold;
font-size: $title-size-lg;
line-height: 40rpx;
image{
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
vertical-align: middle;
margin-bottom: 4rpx;
}
}
.subtitle{
font-size: $title-size-sm;
margin-top: 10rpx;
.u-notice-bar{
padding: 0;
}
}
.btn{
position: absolute;
right: $margin;
margin-top: -30rpx;
top: 50%;
height: 60rpx;
line-height: 60rpx;
background: linear-gradient(to right, #fce3c5, #fcc590);
color: #31364a;
font-weight: bold;
width: 150rpx;
text-align: center;
font-size: $title-size-m;
border-radius: 30rpx;
}
}
// 订单信息
.order-box{
margin: $margin;
background: white;
border-radius: $radius;
display: flex;
justify-content: space-between;
&-item{
width: 25%;
padding: $padding $padding/2;
text-align: center;
.icon{
width: 48rpx;
height: 48rpx;
vertical-align: top;
}
.title{
font-size: $title-size-sm;
margin-top: $margin/3;
}
}
}
// 健康数据
.health-flex{
display: flex;
margin: $margin ($margin - 10);
&-item{
margin: 0 10rpx;
background: white;
width: calc(50% - 20rpx);
border-radius: $radius;
padding: $padding;
box-sizing: border-box;
.title{
font-size: $title-size-lg;
.icon{
width: 32rpx;
height: 32rpx;
vertical-align: middle;
margin-left: 10rpx;
margin-bottom: 2rpx;
}
}
.num{
font-weight: bold;
font-size: $title-size + 10;
padding: $padding/3 0;
text{
font-size: 70%;
padding-left: 10rpx;
}
}
.hith{
font-size: $title-size-sm;
color: $text-gray;
}
}
}
// 模块
.btns-box{
background: white;
margin: $margin;
border-radius: $radius;
&-item{
position: relative;
line-height: 90rpx;
padding: 0 $padding;
font-size: $title-size-lg;
&::after{
position: absolute;
height: 1rpx;
content: " ";
left: $margin;
right: $margin;
bottom: 0;
background-color: $border-color;
}
&:last-child::after{
display: none;
}
.forward{
position: absolute;
right: $margin;
}
.icon{
width: 44rpx;
height: 44rpx;
vertical-align: middle;
margin-right: $margin/2;
margin-bottom: 8rpx;
}
}
}
.content {
background: $window-color;
min-height: 100vh;
}
// 版权信息
.footer-text {
text-align: center;
font-size: $title-size-sm;
padding: $padding $padding $padding * 2;
color: $text-gray-m;
}
// 用户信息
.info-box {
position: relative;
background: linear-gradient(to right, #34ce98, #22aa98);
color: white;
@extend .ios-top;
& > image {
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
// z-index: 100;
}
.user-flex {
position: relative;
padding: $padding * 2 $padding ($padding * 2 + 60);
height: 128rpx;
.cover {
position: absolute;
width: 128rpx;
height: 128rpx;
border-radius: 50%;
border: solid 6rpx white;
box-sizing: border-box;
z-index: 100;
}
.user-content {
padding-left: 158rpx;
height: 128rpx;
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
.chainAddress {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: $title-size-m;
padding-top: 10rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
position: relative;
z-index: 200;
}
.name {
line-height: 40rpx;
font-weight: bold;
font-size: $title-size + 8;
@extend .nowrap;
}
.tabs {
padding-top: 10rpx;
&-item {
background: rgba($color: #000000, $alpha: 0.3);
font-size: $title-size-sm - 4;
display: inline-block;
line-height: 36rpx;
padding: 0 20rpx;
border-radius: 20rpx;
image {
width: 26rpx;
height: 26rpx;
vertical-align: middle;
margin-bottom: 2rpx;
margin-right: 8rpx;
}
}
}
}
}
}
// 会员卡
.vip-card {
position: relative;
margin: -60rpx $margin $margin;
background: linear-gradient(to right bottom, #3e5364, #31364a);
border-radius: $radius;
box-sizing: border-box;
color: #fcc692;
padding: $padding ($padding + 170) $padding $padding;
.title {
font-weight: bold;
font-size: $title-size-lg;
line-height: 40rpx;
image {
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
vertical-align: middle;
margin-bottom: 4rpx;
}
}
.subtitle {
font-size: $title-size-sm;
margin-top: 10rpx;
.u-notice-bar {
padding: 0;
}
}
.btn {
position: absolute;
right: $margin;
margin-top: -30rpx;
top: 50%;
height: 60rpx;
line-height: 60rpx;
background: linear-gradient(to right, #fce3c5, #fcc590);
color: #31364a;
font-weight: bold;
width: 150rpx;
text-align: center;
font-size: $title-size-m;
border-radius: 30rpx;
}
}
// 订单信息
.order-box {
margin: $margin;
background: white;
border-radius: $radius;
display: flex;
justify-content: space-between;
&-item {
width: 25%;
padding: $padding $padding/2;
text-align: center;
.icon {
width: 48rpx;
height: 48rpx;
vertical-align: top;
}
.title {
font-size: $title-size-sm;
margin-top: $margin/3;
}
}
}
// 健康数据
.health-flex {
display: flex;
margin: $margin ($margin - 10);
&-item {
margin: 0 10rpx;
background: white;
width: calc(50% - 20rpx);
border-radius: $radius;
padding: $padding;
box-sizing: border-box;
.title {
font-size: $title-size-lg;
.icon {
width: 32rpx;
height: 32rpx;
vertical-align: middle;
margin-left: 10rpx;
margin-bottom: 2rpx;
}
}
.num {
font-weight: bold;
font-size: $title-size + 10;
padding: $padding/3 0;
text {
font-size: 70%;
padding-left: 10rpx;
}
}
.hith {
font-size: $title-size-sm;
color: $text-gray;
}
}
}
// 模块
.btns-box {
background: white;
margin: $margin;
border-radius: $radius;
&-item {
position: relative;
line-height: 90rpx;
padding: $padding * 0.6 $padding;
font-size: $title-size-lg;
&::after {
position: absolute;
height: 1rpx;
content: ' ';
left: $margin;
right: $margin;
bottom: 0;
background-color: #f9f9f9;
}
&:last-child::after {
display: none;
}
.forward {
position: absolute;
right: $margin;
}
.icon {
width: 44rpx;
height: 44rpx;
vertical-align: middle;
margin-right: $margin/2;
margin-bottom: 8rpx;
}
}
}
</style>

BIN
static/imgs/copy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
static/user/user-avatar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 B