Browse Source

商品和店铺详情

master
liangyuyan 6 years ago
parent
commit
4890543436
  1. 24
      app/Admin/Controllers/v3/GoodsController.php
  2. 87
      app/Admin/Controllers/v3/StoreController.php
  3. 18
      app/Models/v3/Store.php
  4. 2
      resources/lang/zh-CN/store.php

24
app/Admin/Controllers/v3/GoodsController.php

@ -92,8 +92,28 @@ class GoodsController extends AdminController
$show->width(6)->tags->as(function ($value){ $show->width(6)->tags->as(function ($value){
return $value; return $value;
}); });
// $show->width(6)->spec;
// $show->details_imgs;
$show->width(6)->spec->as(function ($value){
$text = '';
foreach ($value as $v){
$text .= '【'.$v['spec_key'] .':'.$v['spec_value'].'】 ';
}
return $text;
});
$goodsModel = new GoodsModel();
$show->html(function () use($goodsModel){
if(empty($this->details_imgs)){
return '';
}else{
// 还需要优化
$value = $this->details_imgs;
$text = '';
foreach ($value as $v){
$img = $goodsModel->imageUrl($v);
$text .= "<img src='$img' />";
}
return $text;
}
});
// $show->created_at; // $show->created_at;
// $show->updated_at; // $show->updated_at;

87
app/Admin/Controllers/v3/StoreController.php

@ -67,44 +67,55 @@ class StoreController extends AdminController
return Show::make($id, new Store(), function (Show $show) { return Show::make($id, new Store(), function (Show $show) {
$show->row(function (Show\Row $show) { $show->row(function (Show\Row $show) {
$show->width(6)->id;
$show->width(6)->mm_user_id->as(function ($mmUserId){
$item = MminfoModel::getMmInfo($mmUserId,'name');
return empty($item) ? '' : $item->name;
});
$show->width(6)->market_id->as(function ($marketId){
$item = MarketModel::getMarketInfo($marketId,'name');
return empty($item) ? '' : $item->name;
});
$show->width(6)->category_id->as(function ($categoryId){
$item = CategoryModel::getCategoryInfo($categoryId,'title');
return empty($item) ? '' : $item->title;
});
$show->width(6)->name;
$show->width(6)->logo->image();
$show->width(6)->user_id->as(function ($userId){
$item = UserModel::getUserInfo($userId,'nick_name');
return empty($item) ? '' : $item->nick_name;
});
$show->width(6)->admin_id->as(function ($userId){
$item = UserModel::getUserInfo($userId,'nick_name');
return empty($item) ? '' : $item->nick_name;
});
$show->width(6)->business_license->image();
$show->width(6)->zm_img->image();
$show->width(6)->fm_img->image();
$show->width(6)->tel;
$show->width(6)->link_name;
$show->width(6)->link_tel;
$show->width(6)->time;
$show->width(6)->time2;
$show->width(6)->time3;
$show->width(6)->time4;
}); });
$show->row(function (Show\Row $show) { $show->row(function (Show\Row $show) {
$show->width(6)->announcement;
$show->width(6)->address;
$show->width(6)->coordinates;
$show->width(6)->is_rest_text;
$show->width(6)->is_open_text;
$show->width(6)->sort;
// $show->width(6)->environment;
$show->width(6)->expire_time;
$show->width(6)->loudspeaker_imei;
}); });
$show->id;
$show->mm_user_id;
$show->market_id;
$show->name;
$show->address;
$show->tel;
$show->announcement;
$show->is_rest;
$show->logo;
$show->details;
$show->coordinates;
$show->business_license;
$show->store_type_id;
$show->is_open;
$show->sort;
$show->user_id;
$show->environment;
$show->expire_time;
$show->zm_img;
$show->fm_img;
$show->link_name;
$show->link_tel;
$show->admin_id;
$show->loudspeaker_imei;
$show->time;
$show->time2;
$show->time3;
$show->time4;
$show->created_at;
$show->updated_at;
// $show->created_at;
// $show->updated_at;
}); });
} }
@ -152,12 +163,12 @@ class StoreController extends AdminController
})->default(1); })->default(1);
$form->text('address'); $form->text('address');
}); });
$form->column(6, function (Form $form) {
$form->column(6, function (Form $form) use($userList){
$form->image('business_license')->required(); $form->image('business_license')->required();
$form->image('zm_img')->required(); $form->image('zm_img')->required();
$form->image('fm_img')->required(); $form->image('fm_img')->required();
$form->text('admin_id')->required();/*需要优化 一个用户只能绑定一家店铺*/
$form->text('user_id')->required();/*需要优化 一个用户只能绑定一家店铺*/
$form->select('admin_id')->options($userList)->required();/*需要优化 一个用户只能绑定一家店铺*/
$form->select('user_id')->options($userList)->required();/*需要优化 一个用户只能绑定一家店铺*/
$form->timeRange('time1','time2','营业时间段一')->required(); $form->timeRange('time1','time2','营业时间段一')->required();
$form->timeRange('time3','time4','营业时间段二'); $form->timeRange('time3','time4','营业时间段二');
}); });

18
app/Models/v3/Store.php

@ -16,14 +16,30 @@ class Store extends Model
protected $appends = [ protected $appends = [
'logo_url', 'logo_url',
'is_rest_text',
'is_open_text'
]; ];
public static $_isRest= ['否','是'];
public static $_isOpen = ['关闭','开启'];
public function getLogoUrlAttribute($value) public function getLogoUrlAttribute($value)
{ {
$value = $value ? $value : $this->logo; $value = $value ? $value : $this->logo;
return $this->imageUrl($value); return $this->imageUrl($value);
} }
public function getIsRestTextAttribute($value)
{
$value = $value ? $value : $this->is_rest;
return isset(self::$_onRest[$value]) ? self::$_onRest[$value] : '';
}
public function getIsOpenTextAttribute($value)
{
$value = $value ? $value : $this->is_iopen;
return isset(self::$_isOpen[$value]) ? self::$_isOpen[$value] : '';
}
/** /**
* 获取商家环境图片 * 获取商家环境图片
* @param $value $this->environment * @param $value $this->environment

2
resources/lang/zh-CN/store.php

@ -16,6 +16,7 @@ return [
'tel' => '电话(座机)', 'tel' => '电话(座机)',
'announcement' => '公告', 'announcement' => '公告',
'is_rest' => '是否休息', 'is_rest' => '是否休息',
'is_rest_text' => '是否休息',
'logo' => 'logo', 'logo' => 'logo',
'logo_url' => 'logo', 'logo_url' => 'logo',
'introduction' => '商家简介', 'introduction' => '商家简介',
@ -24,6 +25,7 @@ return [
'category_id' => '店铺所属分类', 'category_id' => '店铺所属分类',
'category_name' => '店铺分类', 'category_name' => '店铺分类',
'is_open' => '开启门店', 'is_open' => '开启门店',
'is_open_text' => '开启门店',
'sort' => '排序', 'sort' => '排序',
'user_id' => '提现用户', 'user_id' => '提现用户',
'environment' => '商家环境', 'environment' => '商家环境',

Loading…
Cancel
Save