邹能昇 3 сар өмнө
parent
commit
e9d93d8863

+ 1 - 0
nova-werun/pages/circle/send-circle/index.js

@@ -53,6 +53,7 @@ Page({
         images.push({
             url:options.image
         })
+        console.log('options.image',options.image);
         if(options.image){
             this.setData({
                 fileList:images,

+ 46 - 1
nova-werun/pages/home/share/index.js

@@ -1,4 +1,5 @@
 // nova-werun/pages/home/share/index.js
+const qiniuUploader = require("../../../../utils/qiniuUploader");
 const Parse = getApp().Parse;
 const company = getApp().globalData.company;
 Page({
@@ -25,7 +26,12 @@ Page({
             'https://file-cloud.fmode.cn/qpFbRRSZrO/20250102/j1p6l7125757884.jpg?imageView2/1/w/200/h/200'
         ],
         randomImage: '',
-        saveimage: ''
+        saveimage: '',
+
+        uptokenURL: '',
+        domain: '',
+        uploadURL:''
+
     },
 
     /**
@@ -285,6 +291,7 @@ Page({
                     this.setData({
                         saveimage: res.tempFilePath
                     });
+                    this.getUptoken()
                     console.log(this.data.saveimage);
                 },
                 fail: (err) => {
@@ -294,6 +301,43 @@ Page({
         });
 
 
+    },
+    uploadImageToServer() {
+        const that = this;
+        const tempFilePath = this.data.saveimage; // 获取本地临时文件路径
+    
+        qiniuUploader.upload(
+            tempFilePath, // 本地文件路径
+            (res) => {
+                const imageURL = res.imageURL; // 上传成功后的网络地址
+                console.log('上传成功,网络地址:', imageURL);
+                that.setData({
+                    saveimage: imageURL // 更新 saveimage 为网络地址
+                });
+            },
+            (error) => {
+                console.error('上传失败:', error);
+            },
+            {
+                region: "SCN", // 七牛云区域
+                uploadURL: that.data.uploadURL, // 上传地址
+                domain: that.data.domain, // 域名
+                uptoken: that.data.uptokenURL, // 上传凭证
+            }
+        );
+        console.log('saveimage',this.data.saveimage);
+    },
+    async getUptoken() {
+        let res = await Parse.Cloud.run('qiniu_uptoken', {
+            company: company
+        })
+        this.setData({
+            uptokenURL: res.uptoken,
+            domain: res.domain,
+            uploadURL: res.zoneUrl
+        })
+        this.uploadImageToServer()
+        console.log(this.data.uptokenURL, this.data.domain, this.data.uploadURL);
     },
     //px
     // saveImage() {
@@ -534,6 +578,7 @@ Page({
         });
     },
     sharecircle() {
+        console.log('this.data.saveimage',this.data.saveimage);
         wx.navigateTo({
             url: '../../circle/send-circle/index?image=' + this.data.saveimage // 目标页面的路径
         });