Example #1
0
 public function edit()
 {
     if (IS_POST) {
         if ($this->db->edit()) {
             View::success('操作成功', 'index');
         } else {
             View::error($this->db->getError());
         }
     } else {
         //商品分类
         $cate = new \Admin\Model\ShopCate();
         $cateData = $cate->getAll();
         View::with('cateData', $cateData);
         //商品品牌
         $brand = new \Admin\Model\ShopBrand();
         $brandData = $brand->getAll();
         View::with('brandData', $brandData);
         //获取图集信息
         $pics = new \Admin\Model\Pics();
         $picsData = $pics->getAll();
         View::with('picsData', $picsData);
         //商品类型列表
         $type = new \Admin\Model\ShopType();
         $typeData = $type->getAll();
         View::with('typeData', $typeData);
         //商品属性列表
         $attr = new \Admin\Model\GoodsAttr();
         $attrData = $attr->getAll(Q('goods_id'));
         View::with('attrData', $attrData);
         //读取商品信息
         $field = $this->db->getOne();
         View::with('field', $field)->make();
     }
 }
 public function index()
 {
     //获取商品信息
     $goods = new \Admin\Model\Goods();
     $goodsData = $goods->getOne();
     View::with('goodsData', $goodsData);
     //获取商品属性值
     $goods_attr = new \Admin\Model\GoodsAttr();
     $attrData = $goods_attr->groupAttr($goodsData['goods_id']);
     View::with('attrData', $attrData);
     //获取商品规格标题
     $attrName = $goods_attr->getAttrName($goodsData['goods_id']);
     View::with('attrName', $attrName);
     View::make();
 }
Example #3
0
 public function edit()
 {
     if ($this->create()) {
         $this->uploadPics(Q('goods_id'));
         //商品属性
         $goodsAttr = new \Admin\Model\GoodsAttr();
         $goodsAttr->store(Q('goods_id'));
         return $this->save();
     }
 }
    public function attrList()
    {
        $g_id = Q('goods_id');
        $g_type_id = Q('shop_type_id');
        $g_attr = new \Admin\Model\GoodsAttr();
        $g_attrs = $g_attr->getAllAttr($g_id, $g_type_id);
        $html = '';
        $str = '';
        foreach ($g_attrs as $m => $n) {
            $a = $this->db->one($n['attr_id']);
            switch ($a['show_type']) {
                case '1':
                    # 文本框
                    $str = <<<php
<tr>
    <th>{$a['attr_name']}</th>
    <td>
        <input type="hidden" name="attr_id[]" value="{$a['attr_id']}">
        <input type="hidden" name="goods_attr_id[]" value="{$n['goods_attr_id']}">
        <input type="text" name="goods_attr_value[]" class="common-text" value="{$n['goods_attr_value']}">
    </td>
    <td><input type="hidden" name="goods_add_price[]"></td>
</tr>
php;
                    break;
                case '4':
                    # 下拉选择框
                    $split = preg_split('@\\n@', $a['attr_value']);
                    $option = '';
                    //初始化防止报错
                    foreach ($split as $k => $v) {
                        $v = trim($v);
                        //去除空格
                        $selected = $v == $n['goods_attr_value'] ? 'selected' : '';
                        $option .= "<option value='" . $v . "' " . $selected . " >" . $v . "</option>\n";
                    }
                    $str = <<<php
<tr>
    <th><span onclick="plus_attr(this)"><i class="icon-plus"></i></span> <span onclick="minus_attr(this)"><i class="icon-minus"></i></span> {$a['attr_name']}</th>
    <td>
        <input type="hidden" name="attr_id[]" value="{$a['attr_id']}">
        <input type="hidden" name="goods_attr_id[]" value="{$n['goods_attr_id']}">
        <select name="goods_attr_value[]">
            {$option}
        </select>
    </td>
    <td>加价:<input type="text" name="goods_add_price[]" size="10" class="common-text" value="{$n['goods_add_price']}"> 元</td>
</tr>
php;
                    break;
            }
            $html .= $str;
        }
        echo $html;
    }