我的/登录
commit
bdbe8c443e
14
main.js
14
main.js
|
|
@ -14,11 +14,25 @@ $http.beforeRequest = function (options) {
|
||||||
title: '数据加载中'
|
title: '数据加载中'
|
||||||
})
|
})
|
||||||
if (options.url.indexOf('/my/') !== -1) {
|
if (options.url.indexOf('/my/') !== -1) {
|
||||||
|
if (options.url.indexOf('/getByUserId') !== -1){
|
||||||
|
options.header = {
|
||||||
|
'gs-token': uni.getStorageSync('Gs-Token')
|
||||||
|
}
|
||||||
|
} else if (options.url.indexOf('/info/update') !== -1){
|
||||||
|
options.header = {
|
||||||
|
'gs-token': uni.getStorageSync('Gs-Token')
|
||||||
|
}
|
||||||
|
}else if (options.url.indexOf('info/recover') !== -1){
|
||||||
|
options.header = {
|
||||||
|
'gs-token': uni.getStorageSync('Gs-Token')
|
||||||
|
}
|
||||||
|
}else {
|
||||||
options.header = {
|
options.header = {
|
||||||
Authorization: store.state.address.token
|
Authorization: store.state.address.token
|
||||||
}
|
}
|
||||||
console.log(options.header)
|
console.log(options.header)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (options.url.indexOf('/getLoginInfo') !== -1) {
|
if (options.url.indexOf('/getLoginInfo') !== -1) {
|
||||||
options.header = {
|
options.header = {
|
||||||
'gs-token': uni.getStorageSync('Gs-Token')
|
'gs-token': uni.getStorageSync('Gs-Token')
|
||||||
|
|
|
||||||
|
|
@ -75,11 +75,28 @@
|
||||||
uni.showLoading({title:'努力登录中...', mask:true});
|
uni.showLoading({title:'努力登录中...', mask:true});
|
||||||
|
|
||||||
if (res.data.code === 200) {
|
if (res.data.code === 200) {
|
||||||
|
|
||||||
//localStorage保存token
|
//localStorage保存token
|
||||||
if (res.data.data){
|
if (res.data.data){
|
||||||
uni.setStorageSync('Gs-Token', res.data.data)
|
uni.setStorageSync('Gs-Token', res.data.data)
|
||||||
uni.$http.get('/gunshiApp/xfflood/getLoginInfo').then(res=>{
|
uni.$http.get('/gunshiApp/xfflood/getLoginInfo').then(res=>{
|
||||||
uni.setStorageSync('value', res.data.data)
|
uni.setStorageSync('value', res.data.data)
|
||||||
|
console.log('-----value------',res.data.data);
|
||||||
|
})
|
||||||
|
|
||||||
|
//获取userId并获取头像
|
||||||
|
uni.$http.get('/gunshiApp/xfflood/my/info/getByUserId').then(res=>{
|
||||||
|
console.log('-----avatar1------',res.data);
|
||||||
|
if (res.data.data) {
|
||||||
|
let url = '/gunshiApp/xfflood/bzProjectManipulationRecord/file/get/'
|
||||||
|
url = url + res.data.data.fileId
|
||||||
|
uni.$http.get(url).then(res=>{
|
||||||
|
uni.setStorageSync('avatar','http://223.75.53.141:9102/test.by-lyf.tmp'+res.data.data.filePath)
|
||||||
|
console.log('-----avatar------',uni.getStorageSync('avatar'));
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.setStorageSync('avatar','../../static/tabs/头像_icon@2x.png')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,10 @@
|
||||||
<view class="userInfo">
|
<view class="userInfo">
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<image
|
<image
|
||||||
|
class="image-left"
|
||||||
style="width: 100%; height: 100%"
|
style="width: 100%; height: 100%"
|
||||||
src="../../static/tabs/头像_icon@2x.png"
|
:src="default_src"
|
||||||
mode="aspectFit"
|
mode="aspectFill"
|
||||||
></image>
|
></image>
|
||||||
</div>
|
</div>
|
||||||
<div class="user">
|
<div class="user">
|
||||||
|
|
@ -51,7 +52,6 @@
|
||||||
]
|
]
|
||||||
|
|
||||||
const userList = uni.getStorageSync('value')
|
const userList = uni.getStorageSync('value')
|
||||||
console.log(userList);
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
|
|
@ -62,8 +62,13 @@
|
||||||
userresponse:'防汛办',
|
userresponse:'防汛办',
|
||||||
version:'011.14.23',
|
version:'011.14.23',
|
||||||
func: func,
|
func: func,
|
||||||
|
default_src: uni.getStorageSync('avatar'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.default_src = uni.getStorageSync('avatar')
|
||||||
|
console.log('----mypageAvatar',this.default_src);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
navigateToSubPage(index){
|
navigateToSubPage(index){
|
||||||
|
|
||||||
|
|
@ -117,6 +122,11 @@
|
||||||
color: #007afd;
|
color: #007afd;
|
||||||
line-height: 50px;
|
line-height: 50px;
|
||||||
}
|
}
|
||||||
|
.image-left{
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
.user{
|
.user{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@
|
||||||
show-arrow="true"
|
show-arrow="true"
|
||||||
clickable
|
clickable
|
||||||
class="listContainer"
|
class="listContainer"
|
||||||
@click="showActionSheet()"
|
@click="showActionSheet(default_src)"
|
||||||
>
|
>
|
||||||
<template v-slot:footer >
|
<template v-slot:footer >
|
||||||
<image class="slot-image" src='../../static/tabs/头像_icon@2x.png' mode="aspectFit"></image>
|
<image class="slot-image" :src="default_src" mode="aspectFill"></image>
|
||||||
</template>
|
</template>
|
||||||
</uni-list-item>
|
</uni-list-item>
|
||||||
<uni-list-item
|
<uni-list-item
|
||||||
|
|
@ -27,16 +27,19 @@
|
||||||
clickable
|
clickable
|
||||||
:title="item.name"
|
:title="item.name"
|
||||||
class="listContainer"
|
class="listContainer"
|
||||||
|
@click="modifyValue(item)"
|
||||||
>
|
>
|
||||||
<template v-slot:footer >
|
<template v-slot:footer >
|
||||||
<div @click="modifyValue(item)" @click.stop="over(item)">
|
<div class="item" @click.stop="changeItemInfo(item,index)">
|
||||||
<text >{{item.info}}</text>
|
<text >{{item.info}}</text>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</uni-list-item>
|
</uni-list-item>
|
||||||
</uni-list>
|
</uni-list>
|
||||||
<button type="primary" class="button">保存</button>
|
<button type="primary" class="button" @click="save">保存</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -45,33 +48,60 @@
|
||||||
|
|
||||||
//访问数据
|
//访问数据
|
||||||
const userList = uni.getStorageSync('value')
|
const userList = uni.getStorageSync('value')
|
||||||
const userListShow = [
|
let userListShow = [
|
||||||
{name: '手机号码', info: userList.phone},
|
{name: '手机号码', info: userList.phone},
|
||||||
]
|
]
|
||||||
|
|
||||||
const default_src = '../../static/tabs/头像_icon@2x.png'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
userList: userList,
|
userList: userList,
|
||||||
userListShow:userListShow,
|
userListShow:userListShow,
|
||||||
modify: modify
|
modify: modify,
|
||||||
|
default_src: uni.getStorageSync('avatar'),
|
||||||
|
fileId: '',
|
||||||
|
phone: userList.phone,
|
||||||
|
reset: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() { //挂载时重新获取一次Storage数据
|
||||||
|
this.userList = uni.getStorageSync('value')
|
||||||
|
this.userListShow[0].info = this.userList.phone
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goBack(){
|
goBack(){
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
},
|
},
|
||||||
showActionSheet(){
|
showActionSheet(default_src){ //修改头像
|
||||||
uni.showActionSheet({
|
uni.showActionSheet({
|
||||||
itemList: ['拍照/上传照片', '恢复默认头像'],
|
itemList: ['拍照/上传照片', '恢复默认头像'],
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log('选择了第' + (res.tapIndex + 1) + '个选项');
|
console.log('选择了第' + (res.tapIndex + 1) + '个选项');
|
||||||
if (res.tapIndex === 0) { //拍照上传照片
|
if (res.tapIndex === 0) { //拍照上传照片
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sizeType: ['origin','compressed'],
|
||||||
|
sourceType: ['camera', 'album'],
|
||||||
|
success: (res) => {
|
||||||
|
const tempFilePaths = res.tempFilePaths;
|
||||||
|
console.log('--------拍照上传照片--------',res);
|
||||||
|
this.default_src = tempFilePaths[0]
|
||||||
|
uni.uploadFile({
|
||||||
|
url: uni.$http.baseUrl+'/gunshiApp/xfflood/my/info/file/upload/singleSimple',
|
||||||
|
fileType: 'image',
|
||||||
|
filePath: tempFilePaths[0],
|
||||||
|
name: 'file',
|
||||||
|
success: (res) => {
|
||||||
|
this.fileId = JSON.parse(res.data).data.fileId
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
} else if(res.tapIndex === 1) { //恢复默认头像
|
} else if(res.tapIndex === 1) { //恢复默认头像
|
||||||
|
console.log('click');
|
||||||
|
this.reset = true
|
||||||
|
this.default_src = '../../static/tabs/头像_icon@2x.png'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
|
@ -82,6 +112,90 @@
|
||||||
modifyValue(item){
|
modifyValue(item){
|
||||||
console.log(item);
|
console.log(item);
|
||||||
|
|
||||||
|
},
|
||||||
|
changeItemInfo(item,index){ //修改电话
|
||||||
|
uni.showModal({
|
||||||
|
title:"修改"+item.name,
|
||||||
|
editable:true,
|
||||||
|
placeholderText:item.info,
|
||||||
|
confirmText:"确认",
|
||||||
|
cancelText:"取消",
|
||||||
|
success: (res) => {
|
||||||
|
const phoneReg = /^[1][3-9]\d{9}$/;
|
||||||
|
if (res.confirm){
|
||||||
|
if (phoneReg.test(res.content) ){
|
||||||
|
this.userListShow[index].info = res.content
|
||||||
|
this.phone = res.content
|
||||||
|
uni.showToast({
|
||||||
|
title:"修改成功,请保存",
|
||||||
|
icon: "none",
|
||||||
|
duration: 1000,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title:"请输入正确手机号码",
|
||||||
|
icon: "none",
|
||||||
|
duration: 1000,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.log('取消');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
save(){
|
||||||
|
if (this.fileId == ''){ //图片无修改或重置时
|
||||||
|
if (this.reset) { //重置头像
|
||||||
|
//调接口清空返回图片路径的data
|
||||||
|
uni.$http.get('/gunshiApp/xfflood/my/info/recover').then(res=>{
|
||||||
|
uni.setStorageSync('avatar','../../static/tabs/头像_icon@2x.png')
|
||||||
|
})
|
||||||
|
console.log('重置头像');
|
||||||
|
}
|
||||||
|
|
||||||
|
let params = {
|
||||||
|
"phone": this.phone,
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.$http.post('/gunshiApp/xfflood/my/info/update',params).then(res=>{
|
||||||
|
console.log('-----修改图片1-----',res);
|
||||||
|
let new_userList = uni.getStorageSync('value')
|
||||||
|
new_userList.phone = this.phone
|
||||||
|
uni.setStorageSync('value', new_userList)
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pages/mypage/mypage'
|
||||||
|
})
|
||||||
|
},err=>{
|
||||||
|
console.log('----err----',err);
|
||||||
|
})
|
||||||
|
|
||||||
|
} else { //修改图片后
|
||||||
|
let params = {
|
||||||
|
"phone": this.phone,
|
||||||
|
"attach": {
|
||||||
|
"fileId": this.fileId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
uni.$http.post('/gunshiApp/xfflood/my/info/update',params).then(res=>{
|
||||||
|
console.log('-----修改图片2-----',res);
|
||||||
|
if (res.data.code == 200){
|
||||||
|
console.log('---修改图片3---',res);
|
||||||
|
let url = '/gunshiApp/xfflood/bzProjectManipulationRecord/file/get/'+this.fileId
|
||||||
|
uni.$http.get(url).then(res=>{
|
||||||
|
uni.setStorageSync('avatar','http://223.75.53.141:9102/test.by-lyf.tmp'+res.data.data.filePath)
|
||||||
|
console.log('-----modifiedAvatar------',uni.getStorageSync('avatar'));
|
||||||
|
})
|
||||||
|
uni.reLaunch({
|
||||||
|
url:'/pages/mypage/mypage'
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -135,7 +249,9 @@
|
||||||
background-color: #007afd;
|
background-color: #007afd;
|
||||||
}
|
}
|
||||||
.slot-image{
|
.slot-image{
|
||||||
width: 8vw;
|
margin-top: 12px;
|
||||||
height: 8vh;
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue