yingzi 2 years ago
parent
commit
3d13560056
2 changed files with 8 additions and 4 deletions
  1. 3 1
      app/api/controller/Pub.php
  2. 5 3
      app/system/controller/ShowTemplate.php

+ 3 - 1
app/api/controller/Pub.php

@@ -69,13 +69,15 @@ class Pub extends BaseController
         $data=null;
         if($totalCount>0){
             $data = (new ShowTemplate)
-                ->field("id,title,price,old_price,status,img,is_hot,is_recommend,code")
+                ->field("id,title,price,old_price,status,imgs,is_hot,is_recommend,code")
                 ->where($where)
                 ->order("id", "desc")
                 ->page((int)$page, $post["pageSize"])
                 ->select();
             foreach($data as $k=>$v){
                 $data[$k]["is_use"] = 0;//是否已经购买或者可以使用
+                $data[$k]["imgs"]   = getImageAr($v["imgs"]);
+                $data[$k]["img"]    = getImageAr($v["imgs"],0);
             }
         }
         $data = empty($data)?[]:$data;

+ 5 - 3
app/system/controller/ShowTemplate.php

@@ -55,6 +55,8 @@ class ShowTemplate extends  BaseController{
                 ->select();
             foreach($data as $k=>$v){
                 $data[$k]["time"] = date("Y-m-d H:i:s",$v["time"]);
+                $data[$k]["imgs"]   = getImageAr($v["imgs"]);
+                $data[$k]["img"]    = getImageAr($v["imgs"],0);
             }
         }
         $data = empty($data)?[]:$data;
@@ -73,7 +75,7 @@ class ShowTemplate extends  BaseController{
             ['title','','empty','请填写模板标题'],
             ['price','0','is_numeric','请输入正确的模板售价'],
             ['old_price','0','is_numeric','请输入正确的模板原价'],
-            ['img','','empty','请上传模板展示图'],
+            ['imgs',[],'empty','请上传商品主图'],
             ['is_hot','0'],
             ['is_recommend','0'],
             ['code','','empty','请输入CODE'],
@@ -85,9 +87,9 @@ class ShowTemplate extends  BaseController{
         $save["price"]        = floatval($post["price"]);
         $save["old_price"]    = floatval($post["old_price"]);
         $save["status"]       = (int)$post["status"]==1?1:0;
-        $save["img"]          = empty($post["img"]) ? "" : $post["img"];
+        $save["imgs"]         = empty($post["imgs"]) ? "" : implode(",", $post["imgs"]);
         $save["is_hot"]       = (int)$post["is_hot"]==1?1:0;
-        $save["is_recommend"] = (int)$post["is_ip"]==1?1:0;
+        $save["is_recommend"] = (int)$post["is_recommend"]==1?1:0;
         $save["code"]         = $post["code"];
         $save["unreal_sales"] = (int)$post["unreal_sales"];
         $save["admin_time"]   = time();