public function cate()
 {
     $cateId = $this->_getid('cid', 0);
     //类别
     $myCateid = $this->_getid('cateid', 0);
     //类别
     if (!$cateId) {
         $this->JsonReturn('请先选择类别');
     }
     if ($myCateid) {
         $myCateid = M('ste_goods_cate')->where(array('id' => $myCateid))->getField('pid');
     }
     $cateList = M('ste_goods_cate')->where(array('city_id' => steadmin::$adminInfo['city_id'], 'is_del' => 0))->order('sort DESC')->select('id');
     if (!isset($cateList[$cateId])) {
         $this->JsonReturn('ok', '<option value="' . $cateId . '">一级类目</option>', 1);
     }
     $cates = D('tree')->getSubs($cateList, $cateId, false);
     if (!$cates['list']) {
         $this->JsonReturn('ok', '<option value="' . $cateList[$cateId]['id'] . '">' . $cateList[$cateId]['name'] . '</option>', 1);
     }
     V('tree/catetree');
     $cateStr = '<option value="' . $cateList[$cateId]['id'] . '">一级类目</option>' . D('tree')->genSelectOption(TreeTool::tree($cateList, $cateId), $myCateid, 4);
     $this->JsonReturn('ok', $cateStr, 1);
 }
 /**
  * 编辑
  */
 public function edit()
 {
     parent::_checkLogin();
     parent::_authUser(array(1, 2, 5, 7, 8));
     $id = $this->_getid('id', 0);
     if (!$id) {
         showError('参数丢失');
     }
     $rs = M('ste_goods')->where(array('gid' => $id))->find();
     if (!$rs) {
         showError('商品不存在');
     }
     if (!parent::_checkUser($rs['user_id'], $rs['shop_id']) && (parent::_checkIsPresident() && $rs['service_id'] != steadmin::$adminInfo['service_id'])) {
         showError('没有编辑权限');
     }
     $rs['goods_tips'] = explode(',', trim($rs['goods_tips'], ','));
     if ($rs['goods_parameter']) {
         $rs['goods_parameter'] = json_decode($rs['goods_parameter'], true);
     }
     $cate = M('ste_goods_cate')->where(array('is_del' => 0, 'city_id' => steadmin::$adminInfo['city_id']))->order('`id`')->findAll(false);
     $mainCate = M('ste_goods_cate')->field('id,name')->where(array('is_del' => 0, 'city_id' => steadmin::$adminInfo['city_id'], 'pid' => $this->rootCateId))->order('`id`')->findAll(false);
     if (steadmin::$adminInfo['groupid'] == 8) {
         //店长
         $shop = M('ste_shop')->field('shop_id,shop_name,shop_alt_name')->where(array('shop_id' => steadmin::$adminInfo['shop_id'], 'status' => 1))->findAll();
     } elseif (parent::_checkIsAdmin() || parent::_checkIsPresident()) {
         //管理员
         $shop = M('ste_shop')->field('shop_id,shop_name,shop_alt_name')->where(array('status' => 1))->findAll();
     } else {
         //商家、总店
         $shop = M('ste_shop')->field('shop_id,shop_name,shop_alt_name')->where(array('user_id' => steadmin::$adminInfo['user_id'], 'status' => 1))->findAll();
     }
     V('tree/catetree');
     $ctree = TreeTool::tree($cate, $rs['cate_id'], 'pid', 'id');
     //找到当前项目的父类
     $parentId = 0;
     if ($ctree) {
         foreach ($ctree as $val) {
             if ($val['pid'] == $this->rootCateId) {
                 $parentId = $val['id'];
                 break;
             }
         }
     }
     $this->assign(array('rs' => $rs, 'cate' => $mainCate, 'parentId' => $parentId, 'shop' => $shop, 'setting' => $this->steSetting));
     //        z($this->tVar);
     $this->display();
 }