解决体验版弹出登录框

This commit is contained in:
dengjie
2023-01-28 22:33:37 +08:00
parent 5678815237
commit 1f6d21a1a0
14 changed files with 213 additions and 83 deletions

View File

@@ -11,14 +11,23 @@
placeholderStyle="color: #CCCCCC;font-size: 24rpx;"></u--input>
</u-form-item>
</u--form>
<u-button type="success" text="确定" color="#0EBB5B"></u-button>
<view style="height: 230rpx;"></view>
<u-button type="success" text="确定" color="#0EBB5B" @click="handleSubmit()"></u-button>
</view>
<view style="margin:0 20rpx;">
<u-overlay :show="!isLoad">
<login @success="reOnLoad()" @fail="failToLoad()"></login>
</u-overlay>
</view>
</view>
</template>
<script>
import login from 'pages/my/login/login'
export default {
components: {
login
},
data() {
return {
avatar: 'https://cdn.uviewui.com/uview/album/2.jpg',
@@ -27,8 +36,19 @@
name: ''
},
},
isLoad: true,
}
},
onLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
methods: {
//修改头像
changeAvatar() {
@@ -38,13 +58,14 @@
success: (res) => {
console.log(res.tempFilePaths[0]); //成功则返回图片的本地文件路径列表 tempFilePaths
this.avatar = res.tempFilePaths[0] //更新本地浏览头像图片
// this.update(res.tempFilePaths[0]) //上传图片
}
});
},
update(filePath) {
const _this = this
const token = uni.getStorageSync('token')
const token = uni.getStorageSync('loginToken')
const res = uni.uploadFile({
url: _this.action, //仅为示例,非真实的接口地址
filePath: filePath,
@@ -61,6 +82,32 @@
}
});
},
//提交头像和昵称
handleSubmit() {
this.$apiServe.updateUser({
nickname: this.model.userInfo.name,
avatar: this.avatar
}).then(res => {
console.log('修改头像昵称==', res);
}).finally(_ => {})
},
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.$toast.warn('登录失败请重试')
this.isLoad = false
// uni.navigateTo({
// url: '../../pages/my/login/login'
// })
return
}
this.isLoad = true
},
failToLoad() {
// uni.navigateBack({
// url: '/pages/my/my'
// })
this.$toast.warn('登录失败请重试')
}
}
}
</script>
@@ -78,6 +125,5 @@
height: 86rpx !important;
background: #0EBB5B;
border-radius: 20rpx !important;
margin-top: 230rpx;
}
</style>