Browse Source

更新bug

sugar1569 7 years ago
parent
commit
e94419f01c

+ 5 - 6
application/admin/controller/widget/Images.php

@@ -1,7 +1,6 @@
 <?php
 
 namespace app\admin\controller\widget;
-use function Sodium\add;
 use think\Request;
 use think\Url;
 use app\admin\model\system\SystemAttachment as SystemAttachmentModel;
@@ -26,8 +25,8 @@ class Images extends AuthController
      */
    public function index()
    {
-       $pid = input('pid')!=''?input('pid'):0;
-       if(!empty($pid))session('pid',$pid);
+       $pid = input('pid') != NULL ?input('pid'):session('pid');
+       if($pid != NULL)session('pid',$pid);
        if(!empty(session('pid')))$pid = session('pid');
        $this->assign('pid',$pid);
        //分类标题
@@ -39,14 +38,14 @@ class Images extends AuthController
        return $this->fetch('widget/images');
    }
     /**
-     * 编辑器上传图片
+     * 图片管理上传图片
      * @return \think\response\Json
      */
     public function upload()
     {
-        $pid = input('pid')!=''?input('pid'):0;
+        $pid = input('pid')!= NULL ?input('pid'):session('pid');
 
-        $res = Upload::image('file',$pid.'/'.date('Ymd'));
+        $res = Upload::image('file','attach'.DS.date('Y').DS.date('m').DS.date('d'));
         $thumbPath = Upload::thumb($res->dir);
         //产品图片上传记录
         $fileInfo = $res->fileInfo->getinfo();

+ 3 - 3
application/routine/common.php

@@ -69,7 +69,7 @@ function createPoster($product = array()){
                 'text'=>substr(iconv_substr($product['store_name'],0,mb_strlen($product['store_name']),'utf-8'),0,24).'...',
                 'left'=>50,
                 'top'=>500,
-                'fontPath'=>ROOT_PATH.'public/uploads/poster/simsunb.ttf',     //字体文件
+                'fontPath'=>ROOT_PATH.'public/static/font/simsunb.ttf',     //字体文件
                 'fontSize'=>16,             //字号
                 'fontColor'=>'40,40,40',       //字体颜色
                 'angle'=>0,
@@ -78,7 +78,7 @@ function createPoster($product = array()){
                 'text'=>'¥'.$product['price'],
                 'left'=>50,
                 'top'=>580,
-                'fontPath'=>ROOT_PATH.'public/uploads/poster/simsunb.ttf',     //字体文件
+                'fontPath'=>ROOT_PATH.'public/static/font/simsunb.ttf',     //字体文件
                 'fontSize'=>16,             //字号
                 'fontColor'=>'40,40,40',       //字体颜色
                 'angle'=>0,
@@ -108,7 +108,7 @@ function createPoster($product = array()){
                 'opacity'=>100,
             ),
         ),
-        'background'=>ROOT_PATH.'public/uploads/poster/background.jpg'          //背景图
+        'background'=>ROOT_PATH.UPLOAD_PATH.'/poster/background.jpg'          //背景图
     );
     $imageDefault = array(
         'left'=>0,

+ 31 - 12
application/routine/controller/AuthApi.php

@@ -1432,19 +1432,18 @@ class AuthApi extends AuthController{
     public  function get_code(){
         header('content-type:image/jpg');
         if(!$this->userInfo['uid']) return JsonService::fail('授权失败,请重新授权');
-        $path = 'public/uploads/routine/'.$this->userInfo['uid'].'.jpg';
+        $path = makePathToUrl('routine/code');
+        if($path == '')
+            return JsonService::fail('生成上传目录失败,请检查权限!');
+        $picname = $path.DS.$this->userInfo['uid'].'.jpg';
         $domain = SystemConfigService::get('site_url').'/';
         $domainTop = substr($domain,0,5);
         if($domainTop != 'https') $domain = 'https:'.substr($domain,5,strlen($domain));
-        if(file_exists($path)) return JsonService::successful($domain.$path);
+        if(file_exists($picname)) return JsonService::successful($domain.$picname);
         else{
-            if(!file_exists('public/uploads/routine')){
-                $dir = iconv("UTF-8", "GBK", "public/uploads/routine");
-                mkdir ($dir,0775,true);
-            }
-            file_put_contents($path,RoutineCode::getCode($this->userInfo['uid']));
+            file_put_contents($picname,RoutineCode::getCode($this->userInfo['uid']));
         }
-        return JsonService::successful($domain.$path);
+        return JsonService::successful($domain.$picname);
     }
 
     /**
@@ -1954,11 +1953,12 @@ class AuthApi extends AuthController{
         if(!$id) return JsonService::fail('参数错误');
         $productInfo = StoreProduct::getValidProduct($id,'store_name,id,price,image,code_path');
         if(empty($productInfo)) return JsonService::fail('参数错误');
-        if($productInfo['code_path'] == '') {
-            $codePath = 'public/uploads/codepath/product/'.$productInfo['id'].'.jpg';
+        if(strlen($productInfo['code_path'])< 10) {
+            $path = 'public'.DS.'uploads'.DS.'codepath'.DS.'product';
+            $codePath = $path.DS.$productInfo['id'].'.jpg';
             if(!file_exists($codePath)){
-                $dir = iconv("UTF-8", "GBK", "public/uploads/codepath/product");
-                mkdir($dir,0775,true);
+                if(!is_dir($path))
+                    mkdir($path,0777,true);
                 file_put_contents($codePath,RoutineCode::getPages('pages/product-con/index?id='.$productInfo['id']));
             }
             $res = StoreProduct::edit(['code_path'=>$codePath],$id);
@@ -1967,6 +1967,25 @@ class AuthApi extends AuthController{
         }
         $posterPath = createPoster($productInfo);
         return JsonService::successful($posterPath);
+
+//        if(!$id) return JsonService::fail('参数错误');
+//        $productInfo = StoreProduct::getValidProduct($id,'store_name,id,price,image,code_path');
+//        if(empty($productInfo)) return JsonService::fail('参数错误');
+//        if($productInfo['code_path'] == '') {
+//            $path = 'public'.DS.'uploads'.DS.'codepath'.DS.'product';
+//            $codePath = $path.DS.$productInfo['id'].'.jpg';
+//            if(!file_exists($codePath)){
+//                //$dir = iconv("UTF-8", "GBK", "public".DS."uploads".DS."codepath".DS."product");
+//                if(!is_dir($path))
+//                    mkdir($path,0777,true);
+//                file_put_contents($codePath,RoutineCode::getPages('pages/product-con/index?id='.$productInfo['id']));
+//            }
+//            $res = StoreProduct::edit(['code_path'=>$codePath],$id);
+//            if($res) $productInfo['code_path'] = $codePath;
+//            else return JsonService::fail('没有查看权限');
+//        }
+//        $posterPath = createPoster($productInfo);
+//        return JsonService::successful($posterPath);
     }
 
 

BIN
public/static/font/simsunb.ttf


+ 4 - 4
public/system/module/widget/images.js

@@ -40,8 +40,8 @@ layui.use(['layer','upload'], function() {
             var images = Array.from(self.document.getElementsByTagName('img'));
             images.forEach(function (image) {
                 if(Array.from(image.parentNode.classList).indexOf('on') !== -1 && value.indexOf(image.src) == -1){
-                    // list.push(image.src);
-                    list.push(image.getAttribute("src"));
+                    list.push(image.src);
+                    // list.push(image.getAttribute("src"));
                 }
             });
             parent.$f.changeField(parentinputname,list);
@@ -51,8 +51,8 @@ layui.use(['layer','upload'], function() {
             var images = Array.from(self.document.getElementsByTagName('img'));
             images.forEach(function (image) {
                 if(Array.from(image.parentNode.classList).indexOf('on') !== -1 ){
-                    // parent.changeIMG(parentinputname,image.src);
-                    parent.changeIMG(parentinputname,image.getAttribute("src"));
+                    parent.changeIMG(parentinputname,image.src);
+                    // parent.changeIMG(parentinputname,image.getAttribute("src"));
                 }
             });
             var index = parent.layer.getFrameIndex(window.name);

File diff suppressed because it is too large
+ 113 - 0
update.sql


+ 4 - 2
view/crmebN/pages/productSort/productSort.js

@@ -158,7 +158,7 @@ Page({
                 hiddendown: true
             })
         }
-        var SoerErId = 0;
+      var SoerErId = 0; 
         if ($taber >= 0) {
             for (var indexSoerEr in that.data.sorter){
                 if (that.data.sorter[indexSoerEr].id == $taber){
@@ -167,6 +167,7 @@ Page({
                     })
                     SoerErId = that.data.sorter[indexSoerEr].id;
                 }
+              //console.log(that.data.sorter[indexSoerEr].id);
             }
         }else that.setData({total: '全部'})
         that.setData({sid: SoerErId})
@@ -191,6 +192,7 @@ Page({
             }
         }
         that.setData({ hiddendown: true })
+        that.setData({ sid: 0 })
         that.getProductList();
     },
     getCartCount: function () {
@@ -235,7 +237,7 @@ Page({
         var n=t+1;
         if (n%2>0) priceOrder ='asc';
         else priceOrder='desc';
-        var sid = that.data.sid;
+      var sid = that.data.sid; 
         that.setData({ price: priceOrder, t: n, })
         that.getProductList();
     },