多语言后台控制

This commit is contained in:
gongfuxiang 2023-03-22 18:59:53 +08:00
parent dbffca022d
commit 5929e209b3
14 changed files with 139 additions and 25 deletions

View File

@ -55,12 +55,17 @@ class AppConfig extends Base
*/
public function Save()
{
// 空字段处理
$field_list = [
'common_user_onekey_bind_mobile_list',
'common_user_address_platform_import_list',
];
return ApiService::ApiDataReturn(ConfigService::ConfigSave(ConfigService::FieldsEmptyDataHandle($_POST, $field_list)));
$params = $_POST;
if(isset($this->ress['nav_type']) && $ssss['nav_type'] == 'app')
{
// 空字段处理
$field_list = [
'common_user_onekey_bind_mobile_list',
'common_user_address_platform_import_list',
];
$params = ConfigService::FieldsEmptyDataHandle($params, $field_list);
}
return ApiService::ApiDataReturn(ConfigService::ConfigSave($params));
}
}
?>

View File

@ -398,7 +398,7 @@ class Common extends BaseController
// 多语言
$assign['multilingual_default_code'] = MultilingualService::GetUserMultilingualValue();
$assign['multilingual_data'] = MultilingualService::MultilingualData();
$assign['multilingual_data'] = (MyC('admin_use_multilingual_status') == 1) ? MultilingualService::MultilingualData() : [];
// 模板赋值
MyViewAssign($assign);

View File

@ -191,6 +191,8 @@ class Site extends Base
'second_nav_list' => MyLang('site.second_nav_list'),
// 网站设置导航
'siteset_nav_list' => MyLang('site.siteset_nav_list'),
// 多语言
'common_multilingual_list' => MyLang('common_multilingual_list'),
];
return $assign;
}
@ -283,6 +285,11 @@ class Site extends Base
case 'order' :
$params['common_default_payment'] = empty($params['common_default_payment']) ? '' : json_encode($params['common_default_payment'], JSON_UNESCAPED_UNICODE);
break;
// 扩展
case 'extends' :
$field_list[] = 'common_multilingual_choose_list';
break;
}
break;

View File

@ -178,6 +178,7 @@ return [
'base_item_crontab_config_title' => 'Timing Script Config',
'base_item_quick_nav_title' => 'Quick Navigation',
'base_item_user_address_title' => 'User Address',
'base_item_multilingual_title' => 'Multilingual',
'base_item_site_auto_mode_title' => 'Automatic Mode',
'base_item_site_manual_mode_title' => 'Manual Mode',
'base_item_default_payment_title' => 'Default Payment Method',

View File

@ -178,6 +178,7 @@ return [
'base_item_crontab_config_title' => '定时脚本配置',
'base_item_quick_nav_title' => '快捷导航',
'base_item_user_address_title' => '用户地址',
'base_item_multilingual_title' => '多语言',
'base_item_site_auto_mode_title' => '自动模式',
'base_item_site_manual_mode_title' => '手动模式',
'base_item_default_payment_title' => '默认支付方式',

View File

@ -8,7 +8,7 @@
<div class="content">
<!-- form start -->
<form class="am-form form-validation" action="{{:MyUrl('admin/appconfig/save')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('admin/appconfig/index', ['nav_type'=>'app'])}}" enctype="multipart/form-data">
<form class="am-form form-validation" action="{{:MyUrl('admin/appconfig/save', ['nav_type'=>$nav_type])}}" method="POST" request-type="ajax-reload">
<div class="am-form-group">
<label>{{$data.common_app_is_use_mobile_detail.name}}<span class="am-form-group-label-tips">{{$data.common_app_is_use_mobile_detail.describe}}</span></label>
<select name="{{$data.common_app_is_use_mobile_detail.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.common_app_is_use_mobile_detail.error_tips}}" required>

View File

@ -8,7 +8,7 @@
<div class="content">
<!-- form start -->
<form class="am-form form-validation" action="{{:MyUrl('admin/appconfig/save')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('admin/appconfig/index')}}">
<form class="am-form form-validation" action="{{:MyUrl('admin/appconfig/save', ['nav_type'=>$nav_type])}}" method="POST" request-type="ajax-reload">
<div class="am-form-group">
<label>{{$data.common_app_h5_url.name}}<span class="am-form-group-label-tips">{{$data.common_app_h5_url.describe}}</span></label>
<input type="text" name="{{$data.common_app_h5_url.only_tag}}" placeholder="{{$data.common_app_h5_url.name}}" data-validation-message="{{$data.common_app_h5_url.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_app_h5_url.value}}"{{/if}} />

View File

@ -135,6 +135,41 @@
</div>
</div>
<!-- 多语言 -->
<div class="am-panel am-panel-default am-margin-top-sm">
<div class="am-panel-hd">
<h3 class="am-panel-title">{{:MyLang('site.base_item_multilingual_title')}}</h3>
</div>
<div class="am-panel-bd am-padding-vertical-xs">
<div class="am-form-group">
<label>{{$data.common_multilingual_choose_list.name}}<span class="am-form-group-label-tips">{{$data.common_multilingual_choose_list.describe}}</span></label>
<div>
{{foreach $common_multilingual_list as $k=>$v}}
<label class="am-checkbox-inline">
<input type="checkbox" name="{{$data.common_multilingual_choose_list.only_tag}}" value="{{$k}}" data-am-ucheck {{if !empty($data['common_multilingual_choose_list']['value']) and is_array($data['common_multilingual_choose_list']['value']) and in_array($k, $data['common_multilingual_choose_list']['value'])}}checked{{/if}} /> {{$v}}
</label>
{{/foreach}}
</div>
</div>
<div class="am-form-group">
<label>{{$data.admin_use_multilingual_status.name}}<span class="am-form-group-label-tips">{{$data.admin_use_multilingual_status.describe}}</span></label>
<select name="{{$data.admin_use_multilingual_status.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.admin_use_multilingual_status.error_tips}}" required>
{{foreach $common_close_open_list as $v}}
<option value="{{$v.value}}" {{if isset($data['admin_use_multilingual_status']['value']) and $data['admin_use_multilingual_status']['value'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</div>
<div class="am-form-group">
<label>{{$data.home_use_multilingual_status.name}}<span class="am-form-group-label-tips">{{$data.home_use_multilingual_status.describe}}</span></label>
<select name="{{$data.home_use_multilingual_status.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.home_use_multilingual_status.error_tips}}" required>
{{foreach $common_close_open_list as $v}}
<option value="{{$v.value}}" {{if isset($data['home_use_multilingual_status']['value']) and $data['home_use_multilingual_status']['value'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</div>
</div>
</div>
<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">
<input type="hidden" name="nav_type" value="{{$nav_type}}" />
<input type="hidden" name="view_type" value="{{$view_type}}" />

View File

@ -3580,6 +3580,21 @@ return [
'desc' => 'Default on',
'tips' => 'Please select the bottom footer content status',
],
'admin_use_multilingual_status' => [
'name' => 'Backend uses multiple languages',
'desc' => 'Default on',
'tips' => 'Please select a backend that uses multiple languages',
],
'home_use_multilingual_status' => [
'name' => 'Multilingual front-end',
'desc' => 'Default on',
'tips' => 'Please select multiple languages for the front end',
],
'common_multilingual_choose_list' => [
'name' => 'Available in multiple languages',
'desc' => 'Check to use',
'tips' => 'Please tick the language you want to use',
],
],
];
?>

View File

@ -3541,6 +3541,21 @@ return [
'desc' => '默认开启',
'tips' => '请选择底部页脚内容状态',
],
'admin_use_multilingual_status' => [
'name' => '后端使用多语言',
'desc' => '默认关闭',
'tips' => '请选择后端使用多语言',
],
'home_use_multilingual_status' => [
'name' => '前端用多语言',
'desc' => '默认关闭',
'tips' => '请选择前端用多语言',
],
'common_multilingual_choose_list' => [
'name' => '可用多语言',
'desc' => '勾选则使用',
'tips' => '请勾选需要使用的语言',
],
],
];
?>

View File

@ -76,6 +76,7 @@ class ConfigService
'home_search_params_type',
'common_user_onekey_bind_mobile_list',
'common_user_address_platform_import_list',
'common_multilingual_choose_list',
];
// json数组字段
@ -124,6 +125,9 @@ class ConfigService
// cookie有效域名
'common_cookie_domain',
// 多语言可选列表
'common_multilingual_choose_list',
];
/**

View File

@ -41,7 +41,7 @@ class MultilingualService
$default = [];
$select = [];
$allow_lang_list = MyConfig('lang.allow_lang_list');
$multilingual_list = MyLang('common_multilingual_list');
$multilingual_list = self::MultilingualCanChooseList();
if(!empty($multilingual_list) && is_array($multilingual_list) && !empty($allow_lang_list) && is_array($allow_lang_list))
{
$allow_lang_list = array_column($allow_lang_list, null, 'code');
@ -87,6 +87,32 @@ class MultilingualService
return $user_multilingual_result;
}
/**
* 语言列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2023-03-22
* @desc description
*/
public static function MultilingualCanChooseList()
{
$result = [];
$data = MyLang('common_multilingual_list');
if(!empty($data) && is_array($data))
{
$choose_list = MyC('common_multilingual_choose_list');
foreach($data as $k=>$v)
{
if(!empty($choose_list) && is_array($choose_list) && in_array($k, $choose_list))
{
$result[$k] = $v;
}
}
}
return $result;
}
/**
* 当前页面url地址
* @author Devil

View File

@ -670,17 +670,20 @@ class NavigationService
];
// 追加多语言
$multilingual_data = MultilingualService::MultilingualData();
if(!empty($multilingual_data) && !empty($multilingual_data['data']) && !empty($multilingual_data['default']))
if(MyC('home_use_multilingual_status') == 1)
{
$data[] = [
'name' => MyLang('lang_title').'['.$multilingual_data['default']['name'].']',
'is_login' => 0,
'badge' => null,
'icon' => 'am-icon-language',
'url' => '',
'items' => $multilingual_data['data'],
];
$multilingual_data = MultilingualService::MultilingualData();
if(!empty($multilingual_data) && !empty($multilingual_data['data']) && !empty($multilingual_data['default']))
{
$data[] = [
'name' => MyLang('lang_title').'['.$multilingual_data['default']['name'].']',
'is_login' => 0,
'badge' => null,
'icon' => 'am-icon-language',
'url' => '',
'items' => $multilingual_data['data'],
];
}
}
// 顶部小导航右侧钩子
@ -1098,7 +1101,9 @@ class NavigationService
$user_order_count = OrderService::OrderTotal($where);
// 商品收藏/我的足迹总数
$where = ['user_id'=>$params['user']['id']];
$where = [
['user_id', '=', $params['user']['id']],
];
$user_goods_favor_count = GoodsFavorService::GoodsFavorTotal($where);
$user_goods_browse_count = GoodsBrowseService::GoodsBrowseTotal($where);

View File

@ -43,14 +43,14 @@ class OrderAftersaleService
public static function OrdferGoodsRow($order_id, $order_detail_id, $user_id)
{
// 获取列表
$data_params = array(
$data_params = [
'm' => 0,
'n' => 1,
'where' => [
'id' => intval($order_id),
'user_id' => intval($user_id),
['id', '=', intval($order_id)],
['user_id', '=', intval($user_id)],
],
);
];
$ret = OrderService::OrderList($data_params);
if($ret['code'] == 0 && !empty($ret['data'][0]))
{