bug
This commit is contained in:
@@ -104,7 +104,9 @@
|
||||
onLoad (query) {
|
||||
this.id = query.id
|
||||
this.qqmapsdk = new QQMapWX({
|
||||
key: '3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY'
|
||||
key: process.env.NODE_ENV == "production" ?
|
||||
"RWWBZ-64BEJ-MVLFJ-FTHLQ-JTR6J-SAB2S" :
|
||||
"3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY"
|
||||
})
|
||||
|
||||
this.$loading()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="my">
|
||||
<div class="user">
|
||||
<div class="user" @click="toSetting">
|
||||
<image src="https://jisheng-xiaochengxu.oss-cn-hangzhou.aliyuncs.com/admin/5bad9165-fa6e-4c81-894d-2beae426260b.png" />
|
||||
<div class="right" v-if="isLogin">
|
||||
<h2>张三</h2>
|
||||
@@ -63,48 +63,28 @@
|
||||
onLoad () {
|
||||
console.log(this.user)
|
||||
console.log(this.token)
|
||||
if (this.token) {
|
||||
this.getUserInfo()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions(['autoLogin', 'getUserInfo', 'getToken', 'getCode']),
|
||||
...mapActions(['autoLogin', 'getUserInfo']),
|
||||
|
||||
login () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
uni.login({
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
resolve(res)
|
||||
} else {
|
||||
reject(res)
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
reject(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
toSetting () {
|
||||
if (!this.token) {
|
||||
this.autoLogin()
|
||||
} else {
|
||||
this.$linkTo('./UserInfo')
|
||||
}
|
||||
},
|
||||
|
||||
toLogin () {
|
||||
wx.getUserProfile({
|
||||
desc: '用于完善会员资料',
|
||||
lang: 'zh_CN',
|
||||
success: data => {
|
||||
this.$loading()
|
||||
this.getCode().then(res => {
|
||||
this.getToken({
|
||||
...data.userInfo,
|
||||
code: res
|
||||
}).then(e => {
|
||||
console.log(e)
|
||||
|
||||
this.$hideLoading()
|
||||
}).catch(() => {
|
||||
this.$hideLoading()
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
if (!this.token) {
|
||||
this.autoLogin()
|
||||
} else {
|
||||
this.getUserInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
174
src/project/tianfuxing/AppMy/UserInfo.vue
Normal file
174
src/project/tianfuxing/AppMy/UserInfo.vue
Normal file
@@ -0,0 +1,174 @@
|
||||
<template>
|
||||
<div class="userinfo">
|
||||
<div class="section">
|
||||
<div class="form">
|
||||
<div class="form-item avatar">
|
||||
<h2>头像</h2>
|
||||
<div class="form-item__right" @click="uploadImg">
|
||||
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
|
||||
<image class="avatar" :src="userInfo.avatar"></image>
|
||||
</button>
|
||||
<image class="right" src="/static/images/next.png" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<h2>昵称</h2>
|
||||
<div class="form-item__right">
|
||||
<input placeholder="请输入昵称" type="nickname" v-model="userInfo.nickname" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn" @click="save">保存</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
appName: '设置',
|
||||
name: 'UserInfo',
|
||||
data () {
|
||||
return {
|
||||
userInfo: {}
|
||||
}
|
||||
},
|
||||
|
||||
onLoad () {
|
||||
if (uni.getStorageSync('token')) {
|
||||
this.userInfo = uni.getStorageSync('userInfo')
|
||||
console.log(this.userInfo)
|
||||
}
|
||||
|
||||
uni.$on('updateUserInfo', () => {
|
||||
this.getUserInfo()
|
||||
})
|
||||
},
|
||||
|
||||
methods: {
|
||||
getUserInfo () {
|
||||
this.$http.post(`/app/getUserInfo`).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.isLogin = true
|
||||
this.userInfo = res.data
|
||||
uni.setStorageSync('userInfo', res.data)
|
||||
uni.setStorageSync('token', res.data.id)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
uploadImg () {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: res => {
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
save () {
|
||||
this.$loading()
|
||||
this.$http.post('/app/editUserInfo', null, {
|
||||
params: {
|
||||
...this.userInfo
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$toast('保存成功')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.userinfo {
|
||||
.btn {
|
||||
margin-top: 180rpx;
|
||||
}
|
||||
|
||||
.section {
|
||||
background: #fff;
|
||||
|
||||
&:first-child {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
& > h2 {
|
||||
position: relative;
|
||||
height: 98rpx;
|
||||
line-height: 98rpx;
|
||||
padding: 0 50rpx;
|
||||
color: #363636;
|
||||
border-bottom: 1rpx solid #e9e9e9;
|
||||
font-size: 34rpx;
|
||||
|
||||
&:after {
|
||||
position: absolute;
|
||||
left: 30rpx;
|
||||
top: 50%;
|
||||
z-index: 1;
|
||||
width: 5rpx;
|
||||
height: 50rpx;
|
||||
background: #fd2c21;
|
||||
content: ' ';
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
}
|
||||
|
||||
.form {
|
||||
.form-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 88rpx;
|
||||
padding: 0 30rpx;
|
||||
border-bottom: 1rpx solid #e9e9e9;
|
||||
|
||||
&:last-child {
|
||||
border: none;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #4e4e4e;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
&.avatar {
|
||||
height: 160rpx;
|
||||
|
||||
.avatar-img {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.form-item__right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
input {
|
||||
width: 500rpx;
|
||||
text-align: right;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
span {
|
||||
color: #4e4e4e;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.right {
|
||||
width: 13rpx;
|
||||
height: 21rpx;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user