作者 开飞机的舒克

大屏接口优化

@@ -171,44 +171,13 @@ class Study extends Backend @@ -171,44 +171,13 @@ class Study extends Backend
171 } 171 }
172 } 172 }
173 173
174 - public function qiniu($filePath = '', $fileName = '') 174 + public function chang_down()
175 { 175 {
176 -// $filePath=ROOT_PATH.'public'.DS.'uploads'.DS.'20200224'.DS.'img1.jpg';//文件路径  
177 -// $fileName='public'.DS.'uploads'.DS.'20200224'.DS.'img1.jpg'; //七牛云上的名字  
178 -// $filePath = ROOT_PATH . 'public' . DS . 'uploads' . DS . '20200224' . DS . 'img2.jpg';//文件路径  
179 -// $fileName = 'public' . DS . 'uploads' . DS . '20200224' . DS . 'img2.jpg'; //七牛云上的名字,头部不带杠  
180 -  
181 - $config = get_addon_config('qiniu');  
182 - $policy = array(  
183 - 'saveKey' => $fileName,  
184 - );  
185 - $auth = new \Qiniu\Auth($config['accessKey'], $config['secretKey']);  
186 - $token = $auth->uploadToken($config['bucket'], null, $config['expire'], $policy);  
187 - $multipart = [  
188 - ['name' => 'token', 'contents' => $token],  
189 - [  
190 - 'name' => 'file',  
191 - 'contents' => fopen($filePath, 'r'),  
192 - 'filename' => $fileName,  
193 - ]  
194 - ];  
195 -  
196 - try {  
197 - $client = new Client();  
198 - $res = $client->request('POST', $config['uploadurl'], [  
199 - 'multipart' => $multipart  
200 - ]);  
201 - $code = $res->getStatusCode();  
202 - //成功不做任何操作  
203 - } catch (\GuzzleHttp\Exception\ClientException $e) {  
204 - // unlink($filePath);  
205 - $this->error("上传失败"); 176 + $id = input('id');
  177 + $res = \app\admin\model\Study::where('id', $id)->update(['grade_id' => 1]);
  178 + if ($res !== false) {
  179 + $this->success('');
206 } 180 }
207 -// dump($code);  
208 -// $url = '/';  
209 -  
210 - //上传成功后将存储变更为qiniu  
211 -// $this->success("上传成功", ['url' => cdnurl($url), 'save_path' => $url]);  
212 } 181 }
213 182
214 /** 183 /**
@@ -109,13 +109,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -109,13 +109,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
109 icon: 'fa fa-leaf', 109 icon: 'fa fa-leaf',
110 // dropdown: '更多',//如果包含dropdown,将会以下拉列表的形式展示 110 // dropdown: '更多',//如果包含dropdown,将会以下拉列表的形式展示
111 click: function (e, data) { 111 click: function (e, data) {
  112 +
112 $.ajax({ 113 $.ajax({
113 type: 'get', 114 type: 'get',
  115 + url: 'study/chang_down',
114 data: {id: data.id}, 116 data: {id: data.id},
115 success: function (res) { 117 success: function (res) {
116 if (res.code === 1) { 118 if (res.code === 1) {
117 - var domain = 'http://campus.cn/';  
118 - var url = domain + data.barcode_images; 119 + var domain = window.location.href.split(':')[0] + '://' + document.domain;
  120 + var url = domain + data.barcode;
  121 + alert(url);
119 var link = document.createElement('a'); 122 var link = document.createElement('a');
120 link.setAttribute("download", ""); 123 link.setAttribute("download", "");
121 link.href = url; 124 link.href = url;