Commit 46d148d8 authored by ZhuChunYang's avatar ZhuChunYang

添加H5icon

parent d6adb350
......@@ -50,7 +50,7 @@ class ApplicationController extends BaseController
if(Yii::$app->request->isPost){
Yii::$app->response->format = 'json';
$category_id = Yii::$app->request->get('category_id');
$fields = ['category_id','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type'];
$fields = ['category_id','h5_icon','official_url','introduce_image','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type'];
$params = array_merge(Yii::$app->request->post(),['category_id' => $category_id]);
$params = $this->initParams($params, $fields);
$coin_applicateion_form = new CoinApplicationForm();
......@@ -70,7 +70,7 @@ class ApplicationController extends BaseController
{
if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$fields = ['category_id','id','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type'];
$fields = ['category_id','id','h5_icon','official_url','introduce_image','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type'];
$params = $this->initParams(Yii::$app->request->post(), $fields);
$coin_applicateion_form = new CoinApplicationForm();
$coin_applicateion_form->setScenario(CoinApplicationForm::SCENARIO_EDIT);
......@@ -81,13 +81,44 @@ class ApplicationController extends BaseController
$category_id = Yii::$app->request->get('category_id', null);
if ($id) {
$applicate = CoinApplication::getApplicateById($id);
$coin_ids = [];
if($applicate['icon']){
$coin_ids[] = $applicate['icon'];
}
if($applicate['h5_icon']){
$coin_ids[] = $applicate['h5_icon'];
}
if($applicate['introduce_image']){
$coin_ids[] = $applicate['introduce_image'];
}
if($coin_ids){
$coin_items = CoinImage::getItemsByIds($coin_ids);
}
$app_cate = CoinAppCate::getAppCate($category_id,$id);
if($applicate['icon']){
$icon_info = CoinImage::getItemById($applicate['icon']);
$icon_info = $coin_items[$applicate['icon']];
$applicate['icon_url'] =$icon_info['base_url'].$icon_info['file_url'];
}else{
$applicate['icon_url'] ="";
}
if($applicate['icon']){
$icon_info = $coin_items[$applicate['icon']];
$applicate['icon_url'] =$icon_info['base_url'].$icon_info['file_url'];
}else{
$applicate['icon_url'] ="";
}
if($applicate['h5_icon']){
$icon_info = $coin_items[$applicate['h5_icon']];
$applicate['h5_icon_url'] =$icon_info['base_url'].$icon_info['file_url'];
}else{
$applicate['h5_icon_url'] ="";
}
if($applicate['introduce_image']){
$icon_info = $coin_items[$applicate['introduce_image']];
$applicate['introduce_image_url'] =$icon_info['base_url'].$icon_info['file_url'];
}else{
$applicate['introduce_image_url'] ="";
}
$applicate['sort'] = $app_cate->sort;
$this->layout = false;
return $this->render('edit', ['item' => $applicate,'category_id' => $category_id]);
......
......@@ -18,7 +18,10 @@ class UploadForm extends BaseForm
const IMAGE_SAVE_DIR = [
1 => "/coin/", //存放logo
2 => "/banner/", //存放banner
3 => "/application/" //存放应用详情图片
3 => "/application/", //存放应用详情图片,
4 => "/h5_icon/", //存放h5_logo ,
5 => "/h5_banner/", //存放h5_banner,
6 => "/h5_application/" //存放h5_application
];
......
......@@ -21,6 +21,9 @@ class CoinApplicationForm extends BaseForm
public $category_id;
public $name;
public $icon;
public $h5_icon;
public $official_url;
public $introduce_image;
public $sort;
public $type;
public $native_url;
......@@ -37,8 +40,8 @@ class CoinApplicationForm extends BaseForm
public function scenarios()
{
return [
self::SCENARIO_ADD => ['category_id','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type'],
self::SCENARIO_EDIT => ['category_id','id','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type'],
self::SCENARIO_ADD => ['category_id','name','h5_icon','official_url','introduce_image','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type'],
self::SCENARIO_EDIT => ['category_id','id','h5_icon','official_url','introduce_image','name','sort','icon','type','native_url','native_login_url','h5_url','android_url','ios_url','app_store_url','advertise','description','redirect_type'],
];
}
......@@ -50,6 +53,9 @@ class CoinApplicationForm extends BaseForm
'category_id' => '分类ID',
'name' => '名称',
'icon' => '图标',
'h5_icon' => 'h5图标',
'official_url' => '官方链接',
'introduce_image' => '介绍图',
'sort' => '排序',
'type' => '类型',
'native_url' => '原生链接',
......
......@@ -26,6 +26,21 @@
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">H5图标</label>
<div class="layui-input-block">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon2">
</div>
<input type="hidden" name="h5_icon" value="">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload2" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">应用名称</label>
<div class="layui-input-block">
<input class="layui-input" name="name" value="" lay-verify="required">
......@@ -53,6 +68,12 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">官方链接</label>
<div class="layui-input-block">
<input class="layui-input" name="official_url" value="" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">原生登录链接</label>
<div class="layui-input-block">
<input class="layui-input" name="native_login_url" value="">
......@@ -83,6 +104,21 @@
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">介绍图</label>
<div class="layui-input-block">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon3">
</div>
<input type="hidden" name="introduce_image" value="">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload3" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">宣传语</label>
<div class="layui-input-block">
<input type="text" class="layui-input" name="advertise" value="">
......@@ -135,4 +171,33 @@
}
});
uploader.render({
elem: "#upload2",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:4},
done: function (res) {
if(res.code == 0){
$("input[name='h5_icon']").val(res.data.image_id);
$("#icon2").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
uploader.render({
elem: "#upload3",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:4},
done: function (res) {
if(res.code == 0){
$("input[name='introduce_image']").val(res.data.image_id);
$("#icon3").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
</script>
\ No newline at end of file
......@@ -28,6 +28,21 @@
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">H5图标</label>
<div class="layui-input-block">
<img src="<?= $item['h5_icon_url'] ?>" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon2">
</div>
<input type="hidden" name="h5_icon" value="<?= $item['h5_icon'] ?>">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload2" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">应用名称</label>
<div class="layui-input-block">
<input class="layui-input" name="name" value="<?= $item['name'] ?>" lay-verify="required">
......@@ -55,6 +70,12 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">官方链接</label>
<div class="layui-input-block">
<input class="layui-input" name="official_url" value="<?= $item['official_url'] ?>" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">原生登录链接</label>
<div class="layui-input-block">
<input class="layui-input" name="native_login_url" value="<?= $item['native_login_url'] ?>">
......@@ -85,6 +106,21 @@
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">介绍图</label>
<div class="layui-input-block">
<img src="<?= $item['introduce_image_url'] ?>" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon3">
</div>
<input type="hidden" name="introduce_image" value="<?= $item['introduce_image'] ?>">
</div>
<div class="layui-inline" style="margin-left: 50px;">
<button type="button" class="layui-btn" id="upload3" style="">
<i class="layui-icon">&#xe67c;</i>上传新图片
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">宣传语</label>
<div class="layui-input-block">
<input type="text" class="layui-input" name="advertise" value="<?= $item['advertise'] ?>">
......@@ -131,4 +167,34 @@
}
});
uploader.render({
elem: "#upload2",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:4},
done: function (res) {
if(res.code == 0){
$("input[name='h5_icon']").val(res.data.image_id);
$("#icon2").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
uploader.render({
elem: "#upload3",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:4},
done: function (res) {
if(res.code == 0){
$("input[name='introduce_image']").val(res.data.image_id);
$("#icon3").attr('src', res.data.image_src);
}
},
error: function (res) {
}
});
</script>
\ No newline at end of file
......@@ -40,8 +40,12 @@ class CoinImage extends BaseActiveRecord
public static function getItemsByImageIds($image_ids)
{
if($image_ids){
if($image_ids) {
if(is_array($image_ids)){
$idItems = $image_ids;
}else {
$idItems = explode(',',$image_ids);
}
$data = self::find()->where(['in','id',$idItems])->asArray()->all();
foreach ($data as &$value){
$value['image_url'] = $value['base_url'].$value['file_url'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment