diff --git a/admin/controllers/auto/Brand.php b/admin/controllers/auto/Brand.php index 5d513fd4..25d99db0 100644 --- a/admin/controllers/auto/Brand.php +++ b/admin/controllers/auto/Brand.php @@ -137,4 +137,42 @@ class Brand extends HD_Controller{ } + /** + * 获取可选品牌列表 + * @return bool + */ + function json_lists(){ + $keyword = trim($this->input->post('keyword')); + $status = $this->input->post('status'); + $page = $this->input->post('page'); + $size = $this->input->post('size'); + + $where = array(); + $keyword && $where['keyword'] = $keyword; + if(strlen($status) > 0){ + $where['status'] = $status; + } else { + $whre['status > -1'] = null; + } + + $total = $this->auto_brand_model->count($where); + + $lists = array(); + if($total){ + $orderby = 'id desc'; + $select = 'id, name'; + $rows = $this->auto_brand_model->select($where, $orderby, $page, $size, $select); + + foreach($rows as $v){ + $lists[] = array( + 'id' => $v['id'], + 'name' => $v['name'], + ); + } + } + + $this->data = array('total' => $total, 'list' => $lists); + return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); + } + } diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php index bb3647a1..545db0f3 100755 --- a/admin/controllers/biz/store/Store.php +++ b/admin/controllers/biz/store/Store.php @@ -8,12 +8,10 @@ defined('BASEPATH') OR exit('No direct script access allowed'); require_once COMMPATH . 'third_party/pinyin/PinYin.php'; -class Store extends HD_Controller -{ +class Store extends HD_Controller{ private $roles = array('普通', '超级管理'); - public function __construct() - { + public function __construct(){ parent::__construct(); $this->load->helper('image_helper'); $this->load->model("biz/biz_model"); @@ -24,13 +22,11 @@ class Store extends HD_Controller //$this->load->model("user/user_model"); } - public function index() - { + public function index(){ return $this->lists(); } - public function lists() - { + public function lists(){ $page = $this->input->get('page'); $status = $this->input->get('status'); @@ -44,11 +40,11 @@ class Store extends HD_Controller $this->data['article'] = $article = $this->input->get('article'); $status_arr = array('del' => -1, 'off' => 0, 'on' => 1); $this->data['provinces'] = $this->area_model->select(array(), '', 0, 0, 'distinct(province_id), province_name'); - if ($province_id) { + if($province_id){ //获取系统配置的城市 $map_city = $this->city_ary(); $rows_city = array(); - foreach($map_city as $k => $v){ + foreach($map_city as $k => $v){ $rows_city[] = array( 'city_id' => $k, 'city_name' => $v @@ -59,7 +55,7 @@ class Store extends HD_Controller if($city_id){ $this->data['countys'] = $this->area_model->select(array('city_id' => $city_id)); } - if (isset($status_arr[$status])) { + if(isset($status_arr[$status])){ $this->data['status'] = $status; $where['status'] = $status_arr[$status]; } else { @@ -77,18 +73,18 @@ class Store extends HD_Controller $biz_lists = $this->biz_model->select($where, 'id desc', $page, $pagesize); $count = $this->biz_model->count(); $bizlists = []; - foreach ($biz_lists as $v) { - $brand = $this->bizBrand->get(array('id' => $v['brand_id']),'brand_name'); + foreach($biz_lists as $v){ + $brand = $this->bizBrand->get(array('id' => $v['brand_id']), 'brand_name'); $v['brand_name'] = $brand['brand_name']; $bizlists[] = $v; } //获取品牌 - $lists = $this->bizBrand->select(array('status' => 1),'','','','brand_name,id'); + $lists = $this->bizBrand->select(array('status' => 1), '', '', '', 'brand_name,id'); $data = array(); - if ($lists) { - foreach ($lists as $value) { + if($lists){ + foreach($lists as $value){ $data[] = array('name' => $value['brand_name'], 'id' => $value['id']); } } @@ -100,23 +96,22 @@ class Store extends HD_Controller $this->show_view('biz/store/lists', true); } - public function get() - { + public function get(){ $id = intval($this->input->get('id')); $this->data['provinces'] = $this->area_model->select(array(), '', 0, 0, 'distinct(province_id), province_name'); //获取品牌 - $lists = $this->bizBrand->select(array('status' => 1),'','','','brand_name,id'); + $lists = $this->bizBrand->select(array('status' => 1), '', '', '', 'brand_name,id'); $data = array(); - if ($lists) { - foreach ($lists as $value) { + if($lists){ + foreach($lists as $value){ $data[] = array('name' => $value['brand_name'], 'id' => $value['id']); } } $this->data['brand_list'] = $data; - if ($id) { + if($id){ $biz = $this->biz_model->get(array('id' => $id, 'status>-1' => null)); - if (!$biz || empty($biz)) { + if(!$biz || empty($biz)){ return $this->show_json(SYS_CODE_FAIL, '店铺不存在!'); } @@ -128,11 +123,11 @@ class Store extends HD_Controller $this->data['areas'] = $areas; $biz['avatar'] = build_qiniu_image_url($biz['headimg'], 200, 200); //获取品牌名称 - if ($biz && $this->data['brand_list']) { + if($biz && $this->data['brand_list']){ $brand_id = $biz['brand_id']; $brand_name = ''; - foreach ($this->data['brand_list'] as $item) { - if ($brand_id == $item['id']) { + foreach($this->data['brand_list'] as $item){ + if($brand_id == $item['id']){ $brand_name = $item['name']; break; } @@ -141,24 +136,36 @@ class Store extends HD_Controller } //标签 $biz_tags = $this->biz_tagdata_model->select(array('biz_id' => $id, 'type' => 2)); - if ($biz_tags) { - foreach ($biz_tags as $v) { + if($biz_tags){ + foreach($biz_tags as $v){ $biz['biz_tag_more'][] = $v['tag_id']; } } + if($biz['jsondata']){ + $jsondata = json_decode($biz['jsondata'], true); + $biz['auto_brands'] = $jsondata ? $jsondata['auto_brands'] : array(); + } else { + $biz['auto_brands'] = array(); + } + $this->data['biz'] = $biz; } else { $map_city = $this->city_ary(); $rows_city = array(); - foreach($map_city as $k => $v){ + foreach($map_city as $k => $v){ $rows_city[] = array( 'city_id' => $k, 'city_name' => $v ); } $this->data['citys'] = $rows_city; - $biz = array('province_id' => '350', 'type' => 0, 'company_id' => 0);//默认福建城市 + $biz = array( + 'province_id' => '350', + 'type' => 0, + 'company_id' => 0, + 'auto_brands' => array() + );//默认福建城市 $this->data['biz'] = $biz; } @@ -175,11 +182,10 @@ class Store extends HD_Controller $this->show_view('biz/store/edit', true); } - public function add() - { + public function add(){ $biz['biz_name'] = $this->input->post('biz_name', true); - if (!$biz['biz_name']) { + if(!$biz['biz_name']){ return $this->show_json(SYS_CODE_FAIL, '商家名称不能为空'); } //中文转拼音 @@ -188,7 +194,7 @@ class Store extends HD_Controller $biz['firstchar'] = strtoupper($py); $biz['brand_id'] = intval($this->input->post('brand_id', true)); - if (!$biz['brand_id']) { + if(!$biz['brand_id']){ return $this->show_json(SYS_CODE_FAIL, '请选择品牌'); } @@ -202,22 +208,28 @@ class Store extends HD_Controller $biz['type'] = intval($this->input->post('type', true)); $biz['company_id'] = intval($this->input->post('company_id', true)); + $auto_brands = $this->input->post('auto_brands'); + if($auto_brands){ + $jsondata = array('auto_brands' => $auto_brands); + $biz['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); + } + //上传头像 $biz['headimg'] = $this->input->post('headimg'); //商家标签 $tag_more = $this->input->post('tag_more'); - if (!$tag_more || !is_array($tag_more)) { + if(!$tag_more || !is_array($tag_more)){ $tag_more = array(); } $biz['c_time'] = time(); $id = $this->biz_model->add($biz); - if (!$id) { + if(!$id){ return $this->show_json(SYS_CODE_FAIL, '添加失败'); } - foreach ($tag_more as $key => $value) { - if ($value) { + foreach($tag_more as $key => $value){ + if($value){ $biz_tags[$value] = array( 'type' => 2, 'biz_id' => $id, @@ -225,21 +237,20 @@ class Store extends HD_Controller ); } } - if (count($biz_tags)) { + if(count($biz_tags)){ $this->biz_tagdata_model->add_batch($biz_tags); } return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } - public function edit() - { - if (!$this->if_ajax) { + public function edit(){ + if(!$this->if_ajax){ return $this->show_json(SYS_CODE_FAIL, '提交出错!'); } $id = intval($this->input->post('id')); $biz['biz_name'] = $this->input->post('biz_name', true); - if (!$biz['biz_name']) { + if(!$biz['biz_name']){ return $this->show_json(SYS_CODE_FAIL, '商家名称不能为空'); } //中文转拼音 @@ -248,7 +259,7 @@ class Store extends HD_Controller $biz['firstchar'] = strtoupper($py); $biz['brand_id'] = intval($this->input->post('brand_id', true)); - if (!$biz['brand_id']) { + if(!$biz['brand_id']){ return $this->show_json(SYS_CODE_FAIL, '请选择品牌'); } @@ -265,19 +276,30 @@ class Store extends HD_Controller //上传头像 $biz['headimg'] = $this->input->post('headimg'); + //授权品牌 + $auto_brands = $this->input->post('auto_brands'); + $old = $this->biz_model->get(array('id' => $id)); + $jsondata = json_decode($old['jsondata'], true); + if($auto_brands){ + $jsondata['auto_brands'] = $auto_brands; + } else { + unset($jsondata['auto_brands']); + } + $biz['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); + //商家标签 $tag_more = $this->input->post('tag_more'); - if (!$tag_more || !is_array($tag_more)) { + if(!$tag_more || !is_array($tag_more)){ $tag_more = array(); } $res = $this->biz_model->update($biz, array('id' => $id)); - if (!$res) { + if(!$res){ return $this->show_json(SYS_CODE_FAIL, '添加失败'); } - foreach ($tag_more as $key => $value) { - if ($value) { + foreach($tag_more as $key => $value){ + if($value){ $biz_tags[$value] = array( 'type' => 2, 'biz_id' => $id, @@ -286,17 +308,16 @@ class Store extends HD_Controller } } $res = $this->biz_tagdata_model->delete(array('biz_id' => $id, 'type in(2,3)' => null)); - if (count($biz_tags) && $res) { + if(count($biz_tags) && $res){ $this->biz_tagdata_model->add_batch($biz_tags); } return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } - public function del() - { + public function del(){ $id = $this->input->post('id'); - if (!$id) { + if(!$id){ $this->show_json(SYS_CODE_FAIL, '删除出错'); } $stauts = $this->input->post('status'); @@ -306,21 +327,20 @@ class Store extends HD_Controller return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } - public function batch() - { + public function batch(){ $field = $this->input->post('field'); - if ($field === 'ifcheck') { + if($field === 'ifcheck'){ $status = intval($this->input->post('value')); $ids = $this->input->post('id'); $ids = explode(',', $ids); - if (!$ids || count($ids) < 1) { + if(!$ids || count($ids) < 1){ $this->show_json(0, '请选择要操作的选项'); } $where = array('id in(' . implode(',', $ids) . ')' => null); } else { $id = intval($this->input->post('id')); $status = intval($this->input->post('value')); - if (!$id) { + if(!$id){ $this->show_json(0, '参数错误'); } $where['id'] = $id; @@ -330,13 +350,11 @@ class Store extends HD_Controller return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); } - public function export() - { + public function export(){ } - public function lists_bd($where = [], $order = '', $page = 0, $size = 20) - { + public function lists_bd($where = [], $order = '', $page = 0, $size = 20){ $page = $this->input->get('page') ? $this->input->get('page') : '1'; $id = $this->input->get('id'); $biz_name = $this->biz_model->get(['id' => $id], 'biz_name')['biz_name']; @@ -344,7 +362,7 @@ class Store extends HD_Controller $count = $this->bd_biz->count(['biz_id' => $id]); $bd_ids = $this->bd_biz->select(['biz_id' => $id], $order, $page, $size, 'bd_id'); $bd_ids = array_column($bd_ids, 'bd_id'); - foreach ($bd_ids as $key => $value) { + foreach($bd_ids as $key => $value){ $bd = $this->bd->get(['id' => $value], 'uid,title,c_time'); $data[$key]['c_time'] = date('Y-m-d H:i:s', $bd['c_time']); $data[$key]['title'] = $bd['title']; @@ -362,32 +380,31 @@ class Store extends HD_Controller * Created by: dengbw * @return bool */ - public function lists_admin() - { + public function lists_admin(){ $this->load->model('user/user_biz_model', 'mdUserBiz'); $this->load->model('user/user_model', 'mdUser'); $params = $this->input->get(); $params['page'] = $params['page'] ? intval($params['page']) : 1; $params['size'] = $params['size'] ? intval($params['size']) : 20; $biz_id = intval($params['biz_id']); - if (!$biz_id) { + if(!$biz_id){ return $this->show_json(SYS_CODE_FAIL, '非法参数!'); } $biz = $this->biz_model->get(array('id' => $biz_id)); - if (!$biz || empty($biz)) { + if(!$biz || empty($biz)){ return $this->show_json(SYS_CODE_FAIL, '商家不存在!'); } $biz_name = $biz['biz_name']; $where['biz_id'] = $biz_id; - if ($params['mobile']) { + if($params['mobile']){ $user = $this->mdUser->get(array('mobile' => $params['mobile'], 'status' => 1)); $where['uid'] = $user ? $user['uid'] : '0'; } $count = $this->mdUserBiz->count($where); $lists = array(); - if ($count) { + if($count){ $lists = $this->mdUserBiz->select($where, "id desc", $params['page'], $params['size']); - foreach ($lists as $key => &$value) { + foreach($lists as $key => &$value){ $user = $this->mdUser->get(array('uid' => $value['uid'])); $value['uname'] = $user['uname']; $value['mobile'] = $user['mobile']; @@ -406,15 +423,14 @@ class Store extends HD_Controller * Created by: dengbw * @return bool */ - public function get_admin() - { + public function get_admin(){ $id = $this->input->get('id'); $biz_id = $this->input->get('biz_id'); $this->load->model('user/user_biz_model', 'mdUserBiz'); $this->load->model('user/user_model', 'mdUser'); $info = array(); $id && $info = $this->mdUserBiz->get(array('id' => $id)); - if ($info) { + if($info){ $biz_id = $info['biz_id']; $user = $this->mdUser->get(array('uid' => $info['uid'])); $info['mobile'] = $user['mobile']; @@ -424,7 +440,7 @@ class Store extends HD_Controller $info['type'] = 1; $info['role'] = 0; } - if (!$biz_id) { + if(!$biz_id){ return $this->show_json(SYS_CODE_FAIL, '门店不存在!'); } $info['plugins'] = json_decode($info['plugins'], true); @@ -444,8 +460,7 @@ class Store extends HD_Controller * Created by: dengbw * @return bool */ - public function add_admin() - { + public function add_admin(){ $info = $this->input->post('info'); $biz_id = intval($info['biz_id']); // $type = intval($info['type']); @@ -453,25 +468,25 @@ class Store extends HD_Controller $uname = trim($info['uname']); $role = intval($info['role']); $plugins = $info['plugins']; - if (!$biz_id) { + if(!$biz_id){ return $this->show_json(SYS_CODE_FAIL, '门店不存在'); } - if (!$mobile || !$uname) { + if(!$mobile || !$uname){ return $this->show_json(SYS_CODE_FAIL, '手机号或者名称不能为空'); } - if (!mobile_valid($mobile)) { + if(!mobile_valid($mobile)){ return $this->show_json(SYS_CODE_FAIL, '手机号格式不正确'); } $this->load->model('user/user_biz_model', 'mdUserBiz'); $this->load->model('user/user_model', 'mdUser'); //获取用户信息 list($status, $user, $msg) = $this->get_hduser($mobile, $uname); - if (!$status) { + if(!$status){ return $this->show_json(SYS_CODE_FAIL, $msg); } $uid = $user['uid']; $isbiz = $this->mdUserBiz->get(array('uid' => $uid, 'biz_id >' => 0)); - if ($isbiz) { + if($isbiz){ return $this->show_json(0, "该用户已是门店管理员了"); } $biz = $this->biz_model->get(array('id' => $biz_id)); @@ -483,7 +498,7 @@ class Store extends HD_Controller $data['role'] = $role; $plugins && $data['plugins'] = json_encode($plugins, JSON_UNESCAPED_UNICODE); $id = $this->mdUserBiz->add($data); - if (!$id) { + if(!$id){ return $this->show_json(0, "提交失败"); } $this->data = $data; @@ -496,8 +511,7 @@ class Store extends HD_Controller * Created by: dengbw * @return bool */ - public function edit_admin() - { + public function edit_admin(){ $info = $this->input->post('info'); $id = $info['id']; $biz_id = $info['biz_id']; @@ -506,28 +520,28 @@ class Store extends HD_Controller $mobile = trim($info['mobile']); $uname = trim($info['uname']); $plugins = $info['plugins']; - if (!$id) { + if(!$id){ return $this->show_json(SYS_CODE_FAIL, '参数错误'); } - if (!$biz_id) { + if(!$biz_id){ return $this->show_json(SYS_CODE_FAIL, '门店不存在'); } - if (!$mobile || !$uname) { + if(!$mobile || !$uname){ return $this->show_json(SYS_CODE_FAIL, '手机号或者名称不能为空'); } - if (!mobile_valid($mobile)) { + if(!mobile_valid($mobile)){ return $this->show_json(SYS_CODE_FAIL, '手机号格式不正确'); } //获取用户信息 list($status, $user, $msg) = $this->get_hduser($mobile, $uname); - if (!$status) { + if(!$status){ return $this->show_json(SYS_CODE_FAIL, $msg); } $uid = $user['uid']; $this->load->model('user/user_biz_model', 'mdUserBiz'); $this->load->model('user/user_model', 'mdUser'); $isbiz = $this->mdUserBiz->get(array('uid' => $uid, 'biz_id >' => 0, 'id <>' => $id)); - if ($isbiz) { + if($isbiz){ return $this->show_json(0, "该用户已是门店管理员了"); } $biz = $this->biz_model->get(array('id' => $biz_id)); @@ -547,10 +561,9 @@ class Store extends HD_Controller * Created on: 2020/4/7 10:28 * Created by: dengbw */ - public function del_admin() - { + public function del_admin(){ $id = $this->input->post('id'); - if (!$id) { + if(!$id){ $this->show_json(SYS_CODE_FAIL, '非法参数'); } $this->load->model('user/user_biz_model', 'mdUserBiz'); @@ -573,8 +586,7 @@ class Store extends HD_Controller /** * 管理员列表 */ - public function lists_manager() - { + public function lists_manager(){ $this->data['biz_id'] = $biz_id = intval($this->input->get('biz_id', true)); $this->data['mobile'] = $mobile = $this->input->get('mobile', true); $status = $this->input->get('status'); @@ -593,7 +605,7 @@ class Store extends HD_Controller $biz_name = $biz['biz_name']; $where = array('biz_id' => $biz_id); - if ($mobile) { + if($mobile){ $where1 = array('mobile' => $mobile, 'status' => 1); $user = $this->$user_model->get($where1); $where['uid'] = $user ? $user['uid'] : '0'; @@ -602,9 +614,9 @@ class Store extends HD_Controller 'a' != $status && $where['status'] = $status; $count = $this->$ub_model->count($where); $lists = array(); - if ($count) { + if($count){ $lists = $this->$ub_model->select($where, 'id DESC', $page, $size); - foreach ($lists as &$item) { + foreach($lists as &$item){ $user = $this->$user_model->get(array('uid' => $item['uid'])); $item['uname'] = $user['uname']; $item['mobile'] = $user['mobile']; @@ -620,8 +632,7 @@ class Store extends HD_Controller $this->show_view('biz/store/lists_manager', true); } - public function get_manager() - { + public function get_manager(){ $id = $this->input->get('id'); $biz_id = $this->input->get('biz_id'); $user_model = "user_model"; @@ -631,7 +642,7 @@ class Store extends HD_Controller $info = array(); $id && $info = $this->$ub_model->get(array('id' => $id)); - if ($info) { + if($info){ $biz_id = $info['biz_id']; $user = $this->$user_model->get(array('uid' => $info['uid'])); $info['mobile'] = $user['mobile']; @@ -640,7 +651,7 @@ class Store extends HD_Controller $info['biz_id'] = $biz_id; } - if (!$biz_id) { + if(!$biz_id){ return $this->show_json(SYS_CODE_FAIL, '商家不存在!'); } @@ -653,32 +664,31 @@ class Store extends HD_Controller $this->show_view('biz/store/edit_manager'); } - public function add_manager() - { + public function add_manager(){ $biz_id = $this->input->post('biz_id'); $mobile = trim($this->input->post('mobile')); $uname = trim($this->input->post('uname')); - if (!$biz_id) { + if(!$biz_id){ return $this->show_json(SYS_CODE_FAIL, '店铺不存在'); } - if (!$mobile || !$uname) { + if(!$mobile || !$uname){ return $this->show_json(SYS_CODE_FAIL, '手机号或者名称不能为空'); } - if (!mobile_valid($mobile)) { + if(!mobile_valid($mobile)){ return $this->show_json(SYS_CODE_FAIL, '手机号格式不正确'); } //获取用户信息 list($status, $user, $msg) = $this->get_hduser($mobile, $uname); - if (!$status) { + if(!$status){ return $this->show_json(SYS_CODE_FAIL, $msg); } $uid = $user['uid']; $this->load->model('user/user_brand_model'); $isbrand = $this->user_brand_model->get(array('uid' => $uid)); - if ($isbrand) { + if($isbrand){ return $this->show_json(SYS_CODE_FAIL, "该用户已是品牌管理员了"); } @@ -686,7 +696,7 @@ class Store extends HD_Controller $this->load->model('user/user_biz_model'); //是否已经存在该店铺下 $old = $this->$ub_model->get(array('uid' => $uid, 'biz_id' => $biz_id)); - if ($old) { + if($old){ return $this->show_json(SYS_CODE_FAIL, "用户已经绑定该商户"); } //该用户已经正常绑定的信息 @@ -709,7 +719,7 @@ class Store extends HD_Controller $this->load->model('app/zsb/app_zsb_user_model'); $this->load->model('user/user_model', 'user_model'); $res = $this->app_zsb_user_model->get(array('mobile' => $mobile)); - if (!$res) { + if(!$res){ $this->app_zsb_user_model->add(array('mobile' => $mobile, 'uname' => $uname, 'c_time' => time())); $this->user_model->add(array('uname' => $uname, 'mobile' => $mobile, 'c_time' => time())); } @@ -718,29 +728,28 @@ class Store extends HD_Controller } - public function edit_manager() - { + public function edit_manager(){ $id = $this->input->post('id'); $biz_id = $this->input->post('biz_id'); $mobile = trim($this->input->post('mobile')); $uname = trim($this->input->post('uname')); - if (!$id) { + if(!$id){ return $this->show_json(SYS_CODE_FAIL, '参数错误'); } - if (!$biz_id) { + if(!$biz_id){ return $this->show_json(SYS_CODE_FAIL, '店铺不存在'); } - if (!$mobile || !$uname) { + if(!$mobile || !$uname){ return $this->show_json(SYS_CODE_FAIL, '手机号或者名称不能为空'); } - if (!mobile_valid($mobile)) { + if(!mobile_valid($mobile)){ return $this->show_json(SYS_CODE_FAIL, '手机号格式不正确'); } //获取用户信息 list($status, $user, $msg) = $this->get_hduser($mobile, $uname); - if (!$status) { + if(!$status){ return $this->show_json(SYS_CODE_FAIL, $msg); } @@ -748,7 +757,7 @@ class Store extends HD_Controller $this->load->model('user/user_brand_model'); $isbrand = $this->user_brand_model->get(array('uid' => $uid)); - if ($isbrand) { + if($isbrand){ return $this->show_json(SYS_CODE_FAIL, "该用户已是品牌管理员了"); } $this->load->model('app/zsb/app_zsb_user_model'); @@ -756,14 +765,14 @@ class Store extends HD_Controller $this->load->model('user/user_biz_model'); $ubiz = $this->$ub_model->get(array('id' => $id)); //uid不变,不做修改 - if ($ubiz['uid'] == $uid) { + if($ubiz['uid'] == $uid){ //座上宾修改 $this->app_zsb_user_model->update(array('uname' => $uname), array('mobile' => $mobile)); return $this->show_json(SYS_CODE_SUCCESS, '提交成功'); } //是否已经存在该店铺下 $old = $this->$ub_model->get(array('uid' => $uid, 'biz_id' => $biz_id)); - if ($old) { + if($old){ return $this->show_json(SYS_CODE_FAIL, "用户已经绑定该商户"); } //店铺名称 @@ -775,16 +784,15 @@ class Store extends HD_Controller //生成商家关联数据 //座上宾 $res = $this->app_zsb_user_model->get(array('mobile' => $mobile)); - if (!$res) { + if(!$res){ $this->app_zsb_user_model->add(array('mobile' => $mobile, 'uname' => $uname, 'c_time' => time())); } return $this->show_json(SYS_CODE_SUCCESS, '提交成功'); } - public function del_manager() - { + public function del_manager(){ $id = $this->input->post('id'); - if (!$id) { + if(!$id){ $this->show_json(SYS_CODE_FAIL, '操作出错'); } $this->load->model('user/user_biz_model'); @@ -798,13 +806,12 @@ class Store extends HD_Controller * @param $uname * @return array (status, data, msg) */ - private function get_hduser($mobile, $uname) - { + private function get_hduser($mobile, $uname){ $status = 1; $msg = ''; $data = array(); - if (!$mobile || !$uname) { + if(!$mobile || !$uname){ $status = 0; $msg = "手机号或者名称不能为空"; goto end; @@ -816,10 +823,10 @@ class Store extends HD_Controller $info = $this->user_model->get($where); //新增 - if (!$info) { + if(!$info){ $data = array('mobile' => $mobile, 'uname' => $uname, 'c_time' => time(), 'cf_title' => '管理员', 'cf_platform' => '后台添加'); $uid = $this->user_model->add($data); - if (!$uid) { + if(!$uid){ $status = 0; $msg = "用户添加失败"; } else { @@ -829,7 +836,7 @@ class Store extends HD_Controller } //状态异常 - if (1 != $info['status']) { + if(1 != $info['status']){ $status = 0; $msg = "用户存在,但状态异常"; goto end; diff --git a/admin/views/biz/store/edit.php b/admin/views/biz/store/edit.php index 0e8659c3..3b562e34 100755 --- a/admin/views/biz/store/edit.php +++ b/admin/views/biz/store/edit.php @@ -282,14 +282,16 @@ -
@@ -322,9 +324,6 @@ this.point.lat = $('#' + latElemId).val(); this.point.lng = $('#' + lngElemId).val(); - console.log(this.point); - - lngElemId && (this.lngElemId = lngElemId); latElemId && (this.latElemId = latElemId); @@ -434,11 +433,41 @@ }, typeAry:, companyAry:, - info: + info:, + auto_brands:[] + }, + mounted:function(){ + var vm = this; + console.log(vm.info); + vm.init_auto_brands(); }, methods: { + init_auto_brands:function(){ + var vm = this; + $.ajax({ + url: '/auto/brand/json_lists', + type: 'post', + dataType: 'json', + data: {status:1}, + beforeSend: function () {}, + success: function (data) { + if (1 == data.code) { + vm.auto_brands = data.data.list; + } + }, + complete: function () { + loading = 0; + layer.closeAll('loading'); + } + }); + } }, created: function () { + }, + watch:{ + 'info.auto_brands':function(nv, ov){ + console.log(nv); + } } }); /** diff --git a/sql/biz.sql b/sql/biz.sql index a669f502..2d139154 100644 --- a/sql/biz.sql +++ b/sql/biz.sql @@ -3,6 +3,9 @@ -- Author:lcc -- Table:lc_biz -- --------------------------- +-- jsondata:{"auto_brands":[1,2,3]} +-- auto_brands:车型库_品牌ID +-- --------------------------- drop table if exists lc_biz; create table lc_biz ( id int(10) unsigned not null auto_increment comment '自增id', @@ -26,6 +29,7 @@ create table lc_biz ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商家表'; alter table lc_biz add column type tinyint(1) not null default 0 comment '类型:1-合伙店,2-加盟店,3-代理店' after floor; alter table lc_biz add column company_id int not null default 0 comment '公司ID' after type; +alter table lc_biz add column jsondata json null comment '其他数据' after company_id; -- ---------------------------- -- Title:品牌表