Пример #1
0
 /**
  * 指定店铺的 商品分类 树
  * @param number $sid		店铺ID
  * @param string $status	状态
  */
 public function tree($sid, $status = null)
 {
     $status_view = array('default' => '所有', 'del' => '已删除', 'forbid' => '禁用', 'allow' => '正常');
     //默认是 所有 未删除
     //店铺id必须有
     $map['store_id'] = (int) $sid;
     if ($map['store_id'] <= 0) {
         $this->error('参数非法');
     }
     $store_M = new Model('Store');
     $store_info = $store_M->find($map['store_id']);
     if (empty($store_info)) {
         $this->error('店铺不存在');
     }
     $this->assign('store_info', $store_info);
     $now_status = $status_view['default'];
     if (isset($status) && key_exists($status, CategoryModel::$mystat)) {
         //指定查询状态
         $map['status'] = CategoryModel::$mystat[$status];
         $now_status = $status_view[$status];
     } else {
         $map['status'] = array('EGT', 0);
         //默认查询状态为未删除的数据
     }
     $model = new CategoryModel();
     $cate_tree = $model->ztreeArr($map);
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //ztree json
     $this->assign('now_status', $now_status);
     //当前页面筛选的状态
     // 记录当前列表页的cookie
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
Пример #2
0
 /**
  * 查看商品
  */
 public function read($id)
 {
     $map['id'] = (int) $id;
     if ($map['id'] <= 0) {
         $this->error('请选择商品');
     }
     $model = new GoodsModel();
     if (false === $model->checkAuth($id)) {
         $this->error('无权限');
     }
     $info = $model->where($map)->find();
     $store_M = new Model('Store');
     $store_info = $store_M->find(STID);
     $this->assign('store_info', $store_info);
     //所属店铺
     $cate_M = new CategoryModel();
     if ($info['cate_id'] > 0) {
         $info['cate_name'] = $cate_M->where('id=' . $info['cate_id'])->getField('cate_name');
     } else {
         $info['cate_name'] = '无分类';
     }
     $map = array('store_id' => STID, 'status' => 1);
     $cate_tree = $cate_M->ztreeArr($map);
     //ztree json
     $tmp = array(array('id' => null, 'pId' => 0, 'name' => '无分类'));
     $cate_tree = array_merge(array(array('id' => 0, 'pId' => 0, 'name' => '无分类', 'open' => true)), $cate_tree);
     //$tmp + $cate_tree;
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //ztree json
     $this->assign('info', $info);
     //商品信息
     //cookie(C('CURRENT_URL_NAME'),$_SERVER['REQUEST_URI']);
     $html = $this->fetch();
     $this->success($html);
 }
Пример #3
0
 /**
  * 新建商品
  * @param number $sid	店铺ID
  */
 public function add($sid)
 {
     //验证店铺是否存在
     $map['store_id'] = (int) $sid;
     if ($map['store_id'] <= 0) {
         $this->error('参数非法');
     }
     $store_M = new Model('Store');
     $store_info = $store_M->find($map['store_id']);
     if (empty($store_info)) {
         $this->error('店铺不存在');
     }
     $this->assign('store_info', $store_info);
     //店铺信息
     $map['status'] = '1';
     //只要状态正常商品分类
     $cate_M = new CategoryModel();
     $cate_tree = $cate_M->ztreeArr($map);
     $cate_tree = array_merge(array(array('id' => 0, 'pId' => 0, 'name' => '无分类', 'open' => true)), $cate_tree);
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //category ztree json
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }