Esempio n. 1
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);
 }
 public function insert()
 {
     $model = new CategoryModel();
     $data = I('post.');
     if (false === $model->myAdd($data)) {
         $this->error($model->getError());
     }
     $this->success('新建成功', cookie(C('CURRENT_URL_NAME')));
 }
Esempio n. 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();
 }