From e6fef74ea3867d282dff1bc26dccf46a0518b837 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 16 Jun 2021 19:54:53 +0800
Subject: [PATCH] 1.新增点击头像上传 2.新增用户昵称,手机号,邮箱,生日可修改
---
pages/myself/myself.vue | 69 +++++++++++++++++++++++++++++++++-
1 files changed, 66 insertions(+), 3 deletions(-)
diff --git a/pages/myself/myself.vue b/pages/myself/myself.vue
index 40bd3ba..4dc7b3c 100644
--- a/pages/myself/myself.vue
+++ b/pages/myself/myself.vue
@@ -4,7 +4,7 @@
<view class="m-top">
<view class="m-t-left">
<view class="userImg">
- <img class="img" :src="useimg" alt="">
+ <img class="img" :src="useimg" @click="ChooseImage">
</view>
<view class="usermsg">
<view>{{userName}}</view>
@@ -102,10 +102,11 @@
butTitle() {
return this.$store.state.loging == true ? '登出' : '登入'
}
-
},
onLoad() {
-
+ if(this.$store.state.avatar!=null && this.$store.state.avatar!=''){
+ this.useimg = this.$store.state.avatar;
+ }
},
methods: {
openThere(fn) {
@@ -165,6 +166,68 @@
that.showTextmsg = false;
}
},
+ //图片上传
+ ChooseImage() {
+ var that = this;
+ uni.chooseImage({
+ count: 1, //可选择数量,默认9
+ sizeType: ['compressed','original'], //上传压缩图,原图
+ sourceType: ['album','camera'], //从相册选择或从使用相机
+ success: async (res) => {
+ for (var i = 0; i < res.tempFiles.length; i++) {
+ if(res.tempFiles[i].size > 10 * 1024 * 1000){ //上传图片大小限制
+ uni.showToast({
+ title: "照片大小不能10MB",
+ icon: "none"
+ })
+ return
+ }
+ }
+ var tempFilePath = res.tempFilePaths;
+ try{
+ uni.showLoading({
+ title:"上传中...",
+ mask:true
+ })
+ var that = this;
+ // 文件上传
+ uni.uploadFile({
+ // url: 'https://web.byisf.com/api/blade-jfpts/depl/put-depl', //仅为示例,非真实的接口地址
+ url: 'http://web.byisf.com:82/blade-jfpts/depl/put-depl',
+ filePath: tempFilePath[0],
+ name: 'file',
+ formData: {
+ 'user': 'test' // 上传附带参数
+ },
+ success: (data) => {
+ that.useimg = JSON.parse(data.data).data;
+ //修改用户头像信息
+ uni.request({
+ url:"http://s16s652780.51mypc.cn/api/blade-user/updateUserInfo",
+ method:"POST",
+ data:{
+ id: this.$store.state.puserID,
+ avatar:that.useimg
+ },
+ success:(res)=> {
+ if(res.data.code==200){
+ uni.showToast({
+ title: '上传成功!',
+ duration: 2000
+ });
+ }
+ }
+ })
+ }
+ });
+ }catch(e){
+ console.log(e);
+ }finally{
+ uni.hideLoading();
+ }
+ }
+ });
+ }
// geton() {
// wx.navigateTo({
// url: '../poput/workbench/policeDetails/policeDetails?id=111'
--
Gitblit v1.9.3