Ejemplo n.º 1
0
 /**
  * 数据收集
  */
 public function getData(Request $request, $productid, $layerid, $id = null)
 {
     //名称处理
     if ($id) {
         $attrModel = ProductAttrModel::find($id);
         $name = $attrModel->name;
     } else {
         $name = $request->name;
     }
     //内边距处理
     if (!$request->padType) {
         $padding = '';
     } elseif ($request->padType == 1) {
         if (!$request->pad1) {
             echo "<script>alert('边距必填!');history.go(-1);</script>";
             exit;
         }
         $padding = $request->pad1;
     } elseif ($request->padType == 2) {
         if ($request->pad2 == '' || $request->pad3 == '') {
             echo "<script>alert('边距必填!');history.go(-1);</script>";
             exit;
         }
         $padding = $request->pad2 . ',' . $request->pad3;
     } elseif ($request->padType == 3) {
         if ($request->pad4 == '' || $request->pad5 == '' || $request->pad6 == '' || $request->pad7 == '') {
             echo "<script>alert('边距必填!');history.go(-1);</script>";
             exit;
         }
         $padding = $request->pad4 . ',' . $request->pad5 . ',' . $request->pad6 . ',' . $request->pad7;
     }
     //处理透明度
     if ($request->isopacity && $request->opacity == '') {
         echo "<script>alert('透明度不能空!');history.go(-1);</script>";
         exit;
     }
     //处理边框
     if ($request->isborder) {
         if (!$request->borderText || !$request->borderType || !$request->borderColor) {
             echo "<script>alert('边框信息未填满!');history.go(-1);</script>";
             exit;
         }
     }
     $data = ['name' => $name, 'productid' => $productid, 'layerid' => $layerid, 'padding' => $padding, 'size' => $request->width . ',' . $request->height, 'pos' => $request->posType . ',' . $request->left . ',' . $request->top, 'float' => $request->float, 'opacity' => $request->isopacity . ',' . $request->opacity, 'border' => $request->isborder . ',' . $request->borderText . ',' . $request->borderType . ',' . $request->borderColor];
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * 获取父级属性
  */
 public function getParent()
 {
     return ProductAttrModel::find($this->parent);
 }
Ejemplo n.º 3
0
 /**
  * 属性样式修改
  */
 public function updateAttr(Request $request, $productid, $attrid)
 {
     //样式名称
     $attrModel = ProductAttrModel::find($attrid);
     if ($request->genre == 1 && !$request->name) {
         echo "<script>alert('样式名称必填!');history.go(-1);</script>";
         exit;
     } elseif ($request->genre != 1) {
         $request->name = $attrModel->name;
     }
     //宽高
     if (!$request->width || !$request->height) {
         echo "<script>alert('宽高必填!');history.go(-1);</script>";
         exit;
     }
     $size = $request->width . ',' . $request->height;
     //内边距
     if ($request->padType == 0) {
         $padding = '';
     } elseif ($request->padType == 1) {
         $padding = $request->pad1;
     } elseif ($request->padType == 2) {
         $padding = $request->pad2 . ',' . $request->pad3;
     } elseif ($request->padType == 3) {
         $padding = $request->pad4 . ',' . $request->pad5 . ',' . $request->pad6 . ',' . $request->pad7;
     }
     //边框
     if ($request->isborder == 0) {
         $border = '0,,1,1';
     } else {
         if (!$request->borderText) {
             echo "<script>alert('边框宽度必填!');history.go(-1);</script>";
             exit;
         }
         $border = '1,' . $request->borderText . ',' . $request->borderType . ',' . $request->borderColor;
     }
     //定位方式
     if ($request->posType && !$request->left && !$request->top) {
         echo "<script>alert('宽高未填!');history.go(-1);</script>";
         exit;
     }
     $pos = $request->posType . ',' . $request->left . ',' . $request->top;
     //透明度
     if ($request->isopacity && $request->opacity == '') {
         echo "<script>alert('透明度必填!');history.go(-1);</script>";
         exit;
     }
     $opacity = $request->isopacity . ',' . $request->opacity;
     //判断更新数据
     $record['size'] = $attrModel->size == $size ? 1 : 0;
     $record['padding'] = $attrModel->padding == $padding ? 1 : 0;
     $record['border'] = $attrModel->border == $border ? 1 : 0;
     $record['pos'] = $attrModel->pos == $pos ? 1 : 0;
     $record['float'] = $attrModel->float;
     $record['opacity'] = $attrModel->opacity == $opacity ? 1 : 0;
     $data = ['name' => $request->name, 'size' => $size, 'padding' => $padding, 'border' => $border, 'pos' => $pos, 'float' => $request->float, 'opacity' => $opacity, 'updated_at' => time(), 'record' => serialize($record)];
     ProductAttrModel::where('id', $attrid)->update($data);
     return redirect(DOMAIN . 'online/u/' . $productid . '/frame/' . $request->layerid . '/' . $request->con_id . '/' . $request->attrGenre);
 }
Ejemplo n.º 4
0
 /**
  * 属性修改,这里id是attrid
  */
 public function updateAttr(Request $request, $productid, $id)
 {
     //处理名称
     if ($request->genre == 1) {
         $attrName = $request->name;
     } else {
         $attrModel = ProductAttrModel::find($id);
         $attrName = $attrModel->name;
     }
     //内边距处理
     if (!$request->padType) {
         $padding = '';
     } elseif ($request->padType == 1) {
         if (!$request->pad1) {
             echo "<script>alert('边距必填!');history.go(-1);</script>";
             exit;
         }
         $padding = $request->pad1;
     } elseif ($request->padType == 2) {
         if ($request->pad2 == '' || $request->pad3 == '') {
             echo "<script>alert('边距必填!');history.go(-1);</script>";
             exit;
         }
         $padding = $request->pad2 . ',' . $request->pad3;
     } elseif ($request->padType == 3) {
         if ($request->pad4 == '' || $request->pad5 == '' || $request->pad6 == '' || $request->pad7 == '') {
             echo "<script>alert('边距必填!');history.go(-1);</script>";
             exit;
         }
         $padding = $request->pad4 . ',' . $request->pad5 . ',' . $request->pad6 . ',' . $request->pad7;
     }
     $data = ['name' => $attrName, 'size' => $request->width . ',' . $request->height, 'padding' => $padding, 'border' => $request->isborder . ',' . $request->borderWidth . ',' . $request->borderType . ',' . $request->borderColor, 'pos' => $request->posType . ',' . $request->left . ',' . $request->top, 'float' => $request->float, 'opacity' => $request->isopacity . ',' . $request->opacity, 'updated_at' => time()];
     ProductAttrModel::where('id', $id)->update($data);
     return redirect(DOMAIN . 'admin/' . $productid . '/creation/edit/' . $request->layerid . '/' . $request->con_id . '/' . $request->genre);
 }