From b501abb64da23384a85081c246e9c906c6962efd Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期四, 23 三月 2023 15:59:04 +0800
Subject: [PATCH] 用户头像修改

---
 miniprogram/pages/user/myself/detail/index.ts |   61 ++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/miniprogram/pages/user/myself/detail/index.ts b/miniprogram/pages/user/myself/detail/index.ts
index 05e6288..2944ca7 100644
--- a/miniprogram/pages/user/myself/detail/index.ts
+++ b/miniprogram/pages/user/myself/detail/index.ts
@@ -4,11 +4,67 @@
 
 Page({
   data: {
+    isShowImg:false,
+      pic:'',
+      picUrl:'',
       reportList:{},
   },
 face(){
+    console.log(this.data.reportList.pic);
+    
  wx.previewMedia({
         sources:[{url:this.data.reportList.pic}]
+    })
+},
+subImg(){
+    wx.request(  
+        {
+          url:userDetailMyself.globalData.url+  "/wx/user/add",
+          method:"POST",
+          data:{
+              id:wx.getStorageSync('id'),
+              pic:this.data.pic
+          },
+          header:{'token':wx.getStorageSync('token')},
+          success:(res)=>{
+              console.log(res)
+              this.data.reportList.pic= this.data.picUrl
+                   this.setData({
+                    isShowImg:false
+                   })
+                    }
+              })
+},
+faces(){
+    wx.chooseMedia({
+        count:1,
+        mediaType:['image'],
+        sourceType:['camera'],
+        camera:"front",
+        success:(res)=>{
+            wx.uploadFile({
+                url: userDetailMyself.globalData.url+"/minio/upload",
+                filePath: res.tempFiles[0].tempFilePath,
+                name: "file",
+                header: {
+                    // 'token': wx.getStorageSync('token'),
+                    'content-type': 'application/json'
+                },
+                success:(res)=>{
+                    // // 鎴愬姛閫氱煡
+                    // Notify({ type: 'primary', message: '閲囬泦鎴愬姛' });
+                    const result = JSON.parse(res.data)
+                    this.setData({
+                        pic:result.data,
+                        picUrl:userDetailMyself.globalData.imageUrl+'/img/'+result.data,
+                        isShowImg:true
+                    })
+                        this.subImg()
+                    console.log(this.data.pic,this.data.picUrl);
+                    
+                }
+            })
+        }
     })
 },
   onLoad() {
@@ -26,8 +82,11 @@
                 res.data.data.pic=userDetailMyself.globalData.imageUrl+"/img/"+res.data.data.pic
               }
               this.setData({
-                reportList:res.data.data
+                reportList:res.data.data,
+                picUrl:res.data.data.pic
               })
+              console.log(this.data.picUrl);
+              
           }
               })
     }

--
Gitblit v1.8.0