Browse Source

no message

sys 2 years ago
parent
commit
9b974760af
6 changed files with 34 additions and 18 deletions
  1. 1 1
      api/common.js
  2. 1 1
      pages.json
  3. 1 0
      pages/login/model/loginContent.nvue
  4. 10 6
      pages/perfect/cards.vue
  5. 2 2
      service/ajax.js
  6. 19 8
      service/txOssSts.js

+ 1 - 1
api/common.js

@@ -4,5 +4,5 @@ const commonUrl = '/utility/'
 // 发送短信
 export const commonSend = (data) => request(commonUrl + 'send', 'post', { ...data })
 // 获取sts
-export const getTxySts = (data) => request(commonUrl + 'credential', 'post', { ...data })
+export const getTxySts = (data) => request(commonUrl + 'credential', 'get', { ...data })
 

+ 1 - 1
pages.json

@@ -412,7 +412,7 @@
     "list": [
       {
         "name": "列表调试",
-        "path": "pages/login/index",
+        "path": "/pages/perfect/cards",
         "query": ""
       }
     ]

+ 1 - 0
pages/login/model/loginContent.nvue

@@ -55,6 +55,7 @@ export default {
         console.log(res)
         console.log(res.errCode)
         console.log(res.errMsg)
+        that.isPreLogin=false
       }
     })
     //#endif

+ 10 - 6
pages/perfect/cards.vue

@@ -95,18 +95,22 @@ export default {
         sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有
         sourceType: ['album'], //从相册选择
         success:  (res) =>{
-          if(res.tempFilePaths.length>0){
-            console.log(res.tempFilePaths)
-            res.tempFilePaths.forEach((item,key)=>{
+          console.log(res)
+          if(res.tempFiles.length>0){
+            console.log(res.tempFiles)
+            res.tempFiles.forEach((item,key)=>{
+              console.log(item)
               txUploadFile(item,'gallery').then((res)=>{
                 console.log(res)
+                if(key===0){
+                  this.imgBg=res.Location
+                }
+                this.imgList.push(res.Location)
               })
             })
-            this.imgBg=res.tempFilePaths[0]
-            this.imgList=res.tempFilePaths
+            console.log( this.imgList)
             this.isOK=true
           }
-          console.log(JSON.stringify(res.tempFilePaths));
           this.$refs.cardPopup.close()
         }
       });

+ 2 - 2
service/ajax.js

@@ -28,9 +28,9 @@ export const request = (url, method, data, show = false) => {
       method: method || 'post',
       header: {
         'content-type': 'application/json',
-        'apikey': '01ABA77B8BA6F26243D85B5A50FFB88624951C7B3A4078B3F9971983E667D5B8',
         'hversion': '1.0',
-        'Authorization': token
+        'Authorization': 'Bearer cd58ee97-5700-45f3-ae1f-9bebef504fc1'
+        // 'Authorization': 'Bearer '+token
       },
       success: (res) => {
         if (res.statusCode === 200) {

+ 19 - 8
service/txOssSts.js

@@ -12,7 +12,7 @@
  * @param {area} 地区
  * @return {string|boolean} 成功返回文件地址,失败返回false
  */
-import COS from "./cos-wx-sdk-v5.min"
+import COS from "cos-js-sdk-v5"
 
 console.log(COS)
 import tools from "./tools";
@@ -26,17 +26,27 @@ let Region = 'ap-guangzhou';
 
 let cos=null;
 function startCos(){
+    console.log('startCos-----------------')
     cos = new COS({
         getAuthorization: function (options, callback) {
             console.log('---------------获取初始化信息')
+
             getTxySts().then((res)=>{
+                console.log({
+                    TmpSecretId: res.data.credentials.tmpSecretId,
+                    TmpSecretKey: res.data.credentials.tmpSecretKey,
+                    XCosSecurityToken: res.data.credentials.sessionToken,
+                    StartTime: res.data.startTime, // 时间戳,单位秒,如:1580000000,建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
+                    ExpiredTime: res.data.expiredTime, // 时间戳,单位秒,如:1580000900
+                })
+                console.log('---------------获取初始化信息')
                 if(res.code===0){
                     callback({
                         TmpSecretId: res.data.credentials.tmpSecretId,
                         TmpSecretKey: res.data.credentials.tmpSecretKey,
                         XCosSecurityToken: res.data.credentials.sessionToken,
-                        StartTime: res.data.startTime, // 时间戳,单位秒,如:1580000000,建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
-                        ExpiredTime: res.data.expiredTime, // 时间戳,单位秒,如:1580000900
+                        StartTime: res.data.startTime*1, // 时间戳,单位秒,如:1580000000,建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
+                        ExpiredTime: res.data.expiredTime*1, // 时间戳,单位秒,如:1580000900
                     })
                 }
             })
@@ -63,13 +73,13 @@ function txUploadFile(file,folder){
     return new Promise((resolve, reject) => {
         console.log('cos-*-------------------------',cos)
         console.log(file)
-        console.log(folder+'/'+tools.getDate()+tools.getRandFileName(file))
+        console.log(folder+'/'+tools.getDate()+tools.getRandFileName(file.name))
         // 分片上传文件
-        cos.postObject({
+        cos.putObject({
             Bucket: Bucket,
             Region: Region,
-            Key: folder+'/'+tools.getDate()+'/'+tools.getRandFileName(file),
-            FilePath: file,
+            Key: folder+'/'+tools.getDate()+'/'+tools.getRandFileName(file.name),
+            Body: file,
             onHashProgress: function (progressData) {
                 console.log('校验中', JSON.stringify(progressData));
             },
@@ -78,7 +88,8 @@ function txUploadFile(file,folder){
             },
         }, function (err, data) {
             tools.hideLoading()
-            console.log(err, data);
+            console.log(err);
+            console.log(data);
             if(data.Location!==undefined){
                 data.Location='https://'+data.Location;
                 resolve( data)