Kirin 2 years ago
parent
commit
6b161534f7

+ 2 - 0
addons/qiniu/bootstrap.js

@@ -49,6 +49,7 @@ require(['upload'], function (Upload) {
                 ret = typeof response === 'string' ? JSON.parse(response) : response;
                 if (file.xhr.status === 200) {
                     if (typeof ret.key !== 'undefined') {
+                        console.log(Config.upload,1111)
                         ret = {code: 1, msg: "", data: {url: '/' + ret.key, hash: ret.hash}};
                     }
                     Fast.api.ajax({
@@ -63,6 +64,7 @@ require(['upload'], function (Upload) {
             } catch (e) {
                 console.error(e);
             }
+            ret.data.url= Config.upload.cdnurl + ret.data.url
             _success.call(this, file, ret);
         });
 

+ 2 - 2
addons/qiniu/controller/Index.php

@@ -136,7 +136,7 @@ class Index extends Controller
                 $this->error("上传失败");
             }
 
-            $this->success("上传成功", '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
+            $this->success("上传成功", '', ['url' => cdnurl($attachment->url, true), 'fullurl' => cdnurl($attachment->url, true)]);
         }
     }
 
@@ -170,7 +170,7 @@ class Index extends Controller
                 'imagetype'   => $suffix,
                 'imageframes' => 0,
                 'mimetype'    => $type,
-                'url'         => $url,
+                'url'         => cdnurl($url,true),
                 'uploadtime'  => time(),
                 'storage'     => 'qiniu',
                 'sha1'        => $hash,

+ 1 - 1
application/admin/controller/Ajax.php

@@ -112,7 +112,7 @@ class Ajax extends Backend
                 $this->error($e->getMessage());
             }
 
-            $this->success(__('Uploaded successful'), '', ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]);
+            $this->success(__('Uploaded successful'), '', ['url' => cdnurl($attachment->url, true), 'fullurl' => cdnurl($attachment->url, true)]);
         }
     }
 

+ 1 - 1
application/admin/controller/general/Attachment.php

@@ -60,7 +60,7 @@ class Attachment extends Backend
 
             $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root());
             foreach ($list as $k => &$v) {
-                $v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
+                $v['fullurl'] = ($v['storage'] == 'local'||$v['storage'] == 'qiniu' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
             }
             unset($v);
             $result = array("total" => $list->total(), "rows" => $list->items());

+ 2 - 2
application/api/controller/Index.php

@@ -100,11 +100,11 @@ class Index extends Api
             ->limit(20)
             ->select();
         foreach ($list as &$item) {
-            $images = explode(',', $item['good_images']);
+            $images = explode(',', $item['goods_image']);
             foreach ($images as $k => $vv) {
                 $images[$k] = cdnurl($vv, true);
             }
-            $item['good_images'] = implode(',', $images);
+            $item['goods_image'] = implode(',', $images);
         }
 
         $this->success('查询成功', $list);