diff --git a/application/admin/form/Appcenternav.php b/application/admin/form/Appcenternav.php index 56e65a9ff..5449552bb 100644 --- a/application/admin/form/Appcenternav.php +++ b/application/admin/form/Appcenternav.php @@ -18,7 +18,7 @@ namespace app\admin\form; * @date 2020-06-20 * @desc description */ -class Appcenternav +class AppCenterNav { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Apphomenav.php b/application/admin/form/Apphomenav.php index c73f8473f..c53ceb9de 100644 --- a/application/admin/form/Apphomenav.php +++ b/application/admin/form/Apphomenav.php @@ -18,7 +18,7 @@ namespace app\admin\form; * @date 2020-06-20 * @desc description */ -class Apphomenav +class AppHomeNav { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Customview.php b/application/admin/form/Customview.php index 95a9b4a0f..3b239edca 100644 --- a/application/admin/form/Customview.php +++ b/application/admin/form/Customview.php @@ -18,7 +18,7 @@ namespace app\admin\form; * @date 2020-06-16 * @desc description */ -class Customview +class CustomView { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Goodsbrowse.php b/application/admin/form/Goodsbrowse.php index 8a6a7a116..c64b020e7 100644 --- a/application/admin/form/Goodsbrowse.php +++ b/application/admin/form/Goodsbrowse.php @@ -20,7 +20,7 @@ use think\Db; * @date 2020-06-30 * @desc description */ -class Goodsbrowse +class GoodsBrowse { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Goodscomments.php b/application/admin/form/Goodscomments.php index 76194e1b3..f9f294b54 100644 --- a/application/admin/form/Goodscomments.php +++ b/application/admin/form/Goodscomments.php @@ -20,7 +20,7 @@ use think\Db; * @date 2020-06-08 * @desc description */ -class Goodscomments +class GoodsComments { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Goodsfavor.php b/application/admin/form/Goodsfavor.php index 49f77afc5..568bd55d3 100644 --- a/application/admin/form/Goodsfavor.php +++ b/application/admin/form/Goodsfavor.php @@ -20,7 +20,7 @@ use think\Db; * @date 2020-06-30 * @desc description */ -class Goodsfavor +class GoodsFavor { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Integrallog.php b/application/admin/form/Integrallog.php index cd0b2f5e5..cfb191242 100644 --- a/application/admin/form/Integrallog.php +++ b/application/admin/form/Integrallog.php @@ -20,7 +20,7 @@ use think\Db; * @date 2020-06-27 * @desc description */ -class Integrallog +class IntegralLog { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Orderaftersale.php b/application/admin/form/Orderaftersale.php index 9899a7185..eb5143724 100644 --- a/application/admin/form/Orderaftersale.php +++ b/application/admin/form/Orderaftersale.php @@ -20,7 +20,7 @@ use think\Db; * @date 2020-06-08 * @desc description */ -class Orderaftersale +class OrderAftersale { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Paylog.php b/application/admin/form/Paylog.php index b2ce6775f..d34a3d903 100644 --- a/application/admin/form/Paylog.php +++ b/application/admin/form/Paylog.php @@ -21,7 +21,7 @@ use app\service\PayLogService; * @date 2020-06-26 * @desc description */ -class Paylog +class PayLog { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Quicknav.php b/application/admin/form/Quicknav.php index eb24d0b39..23f6f999d 100644 --- a/application/admin/form/Quicknav.php +++ b/application/admin/form/Quicknav.php @@ -18,7 +18,7 @@ namespace app\admin\form; * @date 2020-06-20 * @desc description */ -class Quicknav +class QuickNav { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Refundlog.php b/application/admin/form/Refundlog.php index 308b44ed2..1dbd3dec8 100644 --- a/application/admin/form/Refundlog.php +++ b/application/admin/form/Refundlog.php @@ -21,7 +21,7 @@ use app\service\RefundLogService; * @date 2020-06-27 * @desc description */ -class Refundlog +class RefundLog { // 基础条件 public $condition_base = []; diff --git a/application/admin/form/Warehousegoods.php b/application/admin/form/Warehousegoods.php index 3018e090a..e4490e507 100644 --- a/application/admin/form/Warehousegoods.php +++ b/application/admin/form/Warehousegoods.php @@ -22,7 +22,7 @@ use app\service\RegionService; * @date 2020-07-12 * @desc description */ -class Warehousegoods +class WarehouseGoods { // 基础条件 public $condition_base = []; diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index 919b80ac3..b6d6ea03d 100755 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -64,7 +64,7 @@ return array( 'Asia/Kolkata' => '(标准时+5:00) 叶卡捷琳堡、伊斯兰堡、卡拉奇', 'Asia/Dhaka' => '(标准时+6:00) 阿拉木图、 达卡、新亚伯利亚', 'Indian/Christmas' => '(标准时+7:00) 曼谷、河内、雅加达', - 'Australia/Eucla' => '(标准时+8:00)北京、重庆、香港、新加坡', + 'Asia/Shanghai' => '(标准时+8:00)北京、重庆、香港、新加坡', 'Australia/Darwin' => '(标准时+9:00) 东京、汉城、大阪、雅库茨克', 'Australia/Adelaide' => '(标准时+10:00) 悉尼、关岛', 'Australia/Currie' => '(标准时+11:00) 马加丹、索罗门群岛', diff --git a/application/common.php b/application/common.php index f74601a64..286a116a3 100755 --- a/application/common.php +++ b/application/common.php @@ -11,6 +11,67 @@ // 应用公共文件 +/** + * 文件配置数据读写 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-11-13 + * @desc description + * @param [string] $key [数据缓存可以] + * @param [mixed] $value [数据值(空字符串:读, null:删除, 其他:写)] + * @param [mixed] $default [默认值] + * @param [boolean] $mandatory[是否强制判断数据值(空字符串|null|0)视为空] + * @return [mixed] [缓存不存在:null, 则缓存数据] + */ +function MyFileConfig($key, $value = '', $default = null, $mandatory = false) +{ + // 目录不存在则创建 + $config_dir = ROOT.'runtime'.DS.'data'.DS.'config_data'.DS; + \base\FileUtil::CreateDir($config_dir); + + // 数据文件 + $file = $config_dir.md5($key).'.php'; + + // 删除 + if($value === null) + { + return \base\FileUtil::UnlinkFile($aim_url); + } else { + // 读内容 + if($value === '') + { + $value = file_exists($file) ? require $file : $default; + if($mandatory === true) + { + if(empty($value)) + { + $value = $default; + } + } + return $value; + + // 写内容 + } else { + // 目录是否有可写权限 + if(!is_writable($config_dir)) + { + return false; + } + + // 存在则校验写权限 + if(file_exists($file) && !is_writable($file)) + { + return false; + } + + // 存储内容 + $content = ""; + return (file_put_contents($file, $content) !== false); + } + } +} + /** * 获取参数数据 * @author Devil diff --git a/application/index/config/app.php b/application/index/config/app.php index 5f4e8e28c..3d47ec3ab 100755 --- a/application/index/config/app.php +++ b/application/index/config/app.php @@ -27,6 +27,6 @@ return [ 'default_jsonp_handler' => 'jsonpReturn', // 伪静态后缀 - 'url_html_suffix' => MyC('home_seo_url_html_suffix', 'html', true), + 'url_html_suffix' => MyFileConfig('home_seo_url_html_suffix', '', 'html', true), ]; ?> \ No newline at end of file diff --git a/application/index/config/template.php b/application/index/config/template.php index 990801819..9c1ce172c 100755 --- a/application/index/config/template.php +++ b/application/index/config/template.php @@ -22,7 +22,7 @@ return [ // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 'auto_rule' => 1, // 模板路径 - 'view_path' => APP_PATH.'index'.DS.'view'.DS.strtolower(MyC('common_default_theme', 'default', true)).DS, + 'view_path' => APP_PATH.'index'.DS.'view'.DS.strtolower(MyFileConfig('common_default_theme', '', 'default', true)).DS, // 模板后缀 'view_suffix' => 'html', // 模板文件名分隔符 diff --git a/application/index/controller/Goods.php b/application/index/controller/Goods.php index 87ae9185b..49a77dda4 100755 --- a/application/index/controller/Goods.php +++ b/application/index/controller/Goods.php @@ -207,6 +207,46 @@ class Goods extends Common 'goods' => &$goods, ])); + // 商品页面规格顶部钩子 + $hook_name = 'plugins_view_goods_detail_base_sku_top'; + $this->assign($hook_name.'_data', Hook::listen($hook_name, + [ + 'hook_name' => $hook_name, + 'is_backend' => false, + 'goods_id' => $goods_id, + 'goods' => &$goods, + ])); + + // 商品页面库存数量顶部钩子 + $hook_name = 'plugins_view_goods_detail_base_inventory_top'; + $this->assign($hook_name.'_data', Hook::listen($hook_name, + [ + 'hook_name' => $hook_name, + 'is_backend' => false, + 'goods_id' => $goods_id, + 'goods' => &$goods, + ])); + + // 商品页面库存数量底部钩子 + $hook_name = 'plugins_view_goods_detail_base_inventory_bottom'; + $this->assign($hook_name.'_data', Hook::listen($hook_name, + [ + 'hook_name' => $hook_name, + 'is_backend' => false, + 'goods_id' => $goods_id, + 'goods' => &$goods, + ])); + + // 商品页面购买导航顶部钩子 + $hook_name = 'plugins_view_goods_detail_buy_nav_top'; + $this->assign($hook_name.'_data', Hook::listen($hook_name, + [ + 'hook_name' => $hook_name, + 'is_backend' => false, + 'goods_id' => $goods_id, + 'goods' => &$goods, + ])); + // 商品页面基础信息面板底部钩子 $hook_name = 'plugins_view_goods_detail_base_bottom'; $this->assign($hook_name.'_data', Hook::listen($hook_name, diff --git a/application/index/form/Orderaftersale.php b/application/index/form/Orderaftersale.php index 2f12d4a23..db8c9cad5 100644 --- a/application/index/form/Orderaftersale.php +++ b/application/index/form/Orderaftersale.php @@ -20,7 +20,7 @@ use think\Db; * @date 2020-06-30 * @desc description */ -class Orderaftersale +class OrderAftersale { // 基础条件 public $condition_base = []; diff --git a/application/index/form/Userintegral.php b/application/index/form/Userintegral.php index d16069e5a..ed6e3c948 100644 --- a/application/index/form/Userintegral.php +++ b/application/index/form/Userintegral.php @@ -20,7 +20,7 @@ use think\Db; * @date 2020-06-28 * @desc description */ -class Userintegral +class UserIntegral { // 基础条件 public $condition_base = []; diff --git a/application/index/view/default/goods/index.html b/application/index/view/default/goods/index.html index 2088cde32..13bca43de 100755 --- a/application/index/view/default/goods/index.html +++ b/application/index/view/default/goods/index.html @@ -271,6 +271,19 @@
@@ -323,6 +366,20 @@ {{/if}}
+ + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ plugins_view_goods_detail_buy_nav_top +
+ {{/if}} + {{if !empty($plugins_view_goods_detail_buy_nav_top_data) and is_array($plugins_view_goods_detail_buy_nav_top_data)}} + {{foreach $plugins_view_goods_detail_buy_nav_top_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} + {{/if}} +
{{if !empty($goods.is_shelves)}} @@ -367,7 +424,7 @@ {{if $common_site_type eq 1}}
-
+
@@ -385,7 +442,7 @@ {{if isset($is_goods_site_type_consistent) and $is_goods_site_type_consistent eq 1}}
- @@ -399,6 +456,14 @@ + + +
+ + + + +
{{/if}} {{else /}}

商品卖光了

diff --git a/application/service/BaseService.php b/application/service/BaseService.php index b47071952..cc18581de 100644 --- a/application/service/BaseService.php +++ b/application/service/BaseService.php @@ -25,10 +25,6 @@ use app\service\QuickNavService; */ class BaseService { - public static function sss() - { - return MyC('common_timezone', 'Asia/Shanghai', true); - } /** * 公共配置信息 * @author Devil diff --git a/application/service/ConfigService.php b/application/service/ConfigService.php index f13edc43e..c822c4c4b 100755 --- a/application/service/ConfigService.php +++ b/application/service/ConfigService.php @@ -213,8 +213,11 @@ class ConfigService $v = ResourcesService::ContentStaticReplace($v, 'get'); } - // 单个缓存 + // 公共内置数据缓存 cache($k, $v); + + // 数据文件缓存 + MyFileConfig($k, $v); } // 所有配置缓存集合 diff --git a/application/tags.php b/application/tags.php index 4db0d4a35..660ce5272 100755 --- a/application/tags.php +++ b/application/tags.php @@ -34,7 +34,18 @@ return array ( ), 'plugins_css' => array ( - 0 => 'app\\plugins\\membershiplevelvip\\Hook', + 0 => 'app\\plugins\\ordergoodsform\\Hook', + 1 => 'app\\plugins\\membershiplevelvip\\Hook', + 2 => 'app\\plugins\\multilingual\\Hook', + ), + 'plugins_js' => + array ( + 0 => 'app\\plugins\\ordergoodsform\\Hook', + 1 => 'app\\plugins\\multilingual\\Hook', + ), + 'plugins_view_goods_detail_base_inventory_top' => + array ( + 0 => 'app\\plugins\\ordergoodsform\\Hook', ), 'plugins_service_navigation_header_handle' => array ( @@ -95,6 +106,27 @@ return array ( 'plugins_service_header_navigation_top_right_handle' => array ( 0 => 'app\\plugins\\membershiplevelvip\\Hook', + 1 => 'app\\plugins\\multilingual\\Hook', + ), + 'plugins_common_page_bottom' => + array ( + 0 => 'app\\plugins\\multilingual\\Hook', + ), + 'plugins_service_quick_navigation_pc' => + array ( + 0 => 'app\\plugins\\multilingual\\Hook', + ), + 'plugins_service_quick_navigation_h5' => + array ( + 0 => 'app\\plugins\\multilingual\\Hook', + ), + 'plugins_view_common_top' => + array ( + 0 => 'app\\plugins\\multilingual\\Hook', + ), + 'plugins_view_common_bottom' => + array ( + 0 => 'app\\plugins\\multilingual\\Hook', ), ); ?> \ No newline at end of file diff --git a/config/app.php b/config/app.php index 5ddc1ee84..e4e91ae0f 100755 --- a/config/app.php +++ b/config/app.php @@ -37,7 +37,7 @@ return [ // 默认JSONP处理方法 'var_jsonp_handler' => 'callback', // 默认时区 - 'default_timezone' => MyC('common_timezone', 'Asia/Shanghai', true), + 'default_timezone' => MyFileConfig('common_timezone', '', 'Asia/Shanghai', true), // 是否开启多语言 'lang_switch_on' => false, // 默认全局过滤方法 用逗号分隔多个 diff --git a/config/shopxo.php b/config/shopxo.php index 89d56ed7e..de68d024d 100755 --- a/config/shopxo.php +++ b/config/shopxo.php @@ -14,8 +14,8 @@ // +---------------------------------------------------------------------- // cdn地址 -$cdn_attachment_host = MyC('common_cdn_attachment_host', __MY_PUBLIC_URL__, true); -$cdn_public_host = MyC('common_cdn_public_host', __MY_PUBLIC_URL__, true); +$cdn_attachment_host = MyFileConfig('common_cdn_attachment_host', '', __MY_PUBLIC_URL__, true); +$cdn_public_host = MyFileConfig('common_cdn_public_host', '', __MY_PUBLIC_URL__, true); if(substr($cdn_attachment_host, -1) == DS) { $cdn_attachment_host = substr($cdn_attachment_host, 0, -1); diff --git a/config/ueditor.php b/config/ueditor.php index efc7f61fd..487e98e52 100644 --- a/config/ueditor.php +++ b/config/ueditor.php @@ -27,7 +27,7 @@ return [ 'imageFieldName' => 'upfile', // 上传大小限制,单位B - 'imageMaxSize' => MyC('home_max_limit_image', 2048000, true), + 'imageMaxSize' => MyFileConfig('home_max_limit_image', '', 2048000, true), // 上传图片格式显示 'imageAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], @@ -59,7 +59,7 @@ return [ 'scrawlPathFormat' => __MY_ROOT_PUBLIC__.'static/upload/images/'.$upload_path.'/{yyyy}/{mm}/{dd}/{time}{rand:6}', // 上传大小限制,单位B - 'scrawlMaxSize' => MyC('home_max_limit_image', 2048000, true), + 'scrawlMaxSize' => MyFileConfig('home_max_limit_image', '', 2048000, true), // 上传图片格式显示 'scrawlAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], @@ -102,7 +102,7 @@ return [ 'catcherUrlPrefix' => '', // 上传大小限制,单位B - 'catcherMaxSize' => MyC('home_max_limit_image', 2048000, true), + 'catcherMaxSize' => MyFileConfig('home_max_limit_image', '', 2048000, true), // 抓取图片格式显示 'catcherAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], @@ -122,7 +122,7 @@ return [ 'videoUrlPrefix' => '', // 上传大小限制,单位B,默认100MB - 'videoMaxSize' => MyC('home_max_limit_video', 102400000, true), + 'videoMaxSize' => MyFileConfig('home_max_limit_video', '', 102400000, true), // 上传视频格式显示 'videoAllowFiles' => ['.swf', '.ogg', '.ogv', '.mp4', '.webm', '.mp3'], @@ -142,7 +142,7 @@ return [ 'fileUrlPrefix' => '', // 上传大小限制,单位B,默认50MB - 'fileMaxSize' => MyC('home_max_limit_file', 51200000, true), + 'fileMaxSize' => MyFileConfig('home_max_limit_file', '', 51200000, true), // 上传文件格式显示 'fileAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid','.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml'], diff --git a/public/core.php b/public/core.php index 8c4b81efe..84844301d 100755 --- a/public/core.php +++ b/public/core.php @@ -37,6 +37,11 @@ define('__MY_PUBLIC_URL__', empty($_SERVER['HTTP_HOST']) ? '' : __MY_HTTP__.':/ // 当前页面url地址 $request_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; +if(!empty($request_url) && !empty($my_root)) +{ + // 去除多余的子目录路径 + $request_url = str_replace($my_root, '', $request_url); +} define('__MY_VIEW_URL__', substr(__MY_URL__, 0, -1).$request_url); // 系统根目录,强制转换win反斜杠 diff --git a/public/static/common/js/common.js b/public/static/common/js/common.js index 5d7ac0456..eef279efc 100755 --- a/public/static/common/js/common.js +++ b/public/static/common/js/common.js @@ -369,15 +369,10 @@ function FromInit(form_name) // ajax-reload 请求完成后刷新页面 // ajax-url 请求完成后调整到指定的请求值 // ajax-fun 请求完成后调用指定方法 + // ajax-view 请求完成后仅提示文本信息 // sync 不发起请求、直接同步调用指定的方法 // jump 不发起请求、拼接数据参数跳转到指定 url 地址 - var request_handle = ['ajax-reload', 'ajax-url', 'ajax-fun', 'sync', 'jump']; - - // 是form表单直接通过 - if(request_type == 'form') - { - return true; - } + var request_handle = ['ajax-reload', 'ajax-url', 'ajax-fun', 'ajax-view', 'sync', 'jump', 'form']; // 参数校验 if(request_handle.indexOf(request_type) == -1) @@ -387,37 +382,46 @@ function FromInit(form_name) return false; } - // 类型不等于刷新的时候,类型值必须填写 - if(request_type != 'ajax-reload' && request_value == null) + // 类型值必须配置校验 + var request_type_value = ['ajax-url', 'ajax-fun', 'sync', 'jump'] + if(request_type_value.indexOf(request_type) != -1 && request_value == null) { $button.button('reset'); Prompt('表单[类型值]参数配置有误'); return false; } - // 同步调用方法 - if(request_type == 'sync') + // 请求类型 + switch(request_type) { - $button.button('reset'); - if(IsExitsFunction(request_value)) - { - window[request_value](GetFormVal(form_name, true)); - } else { - Prompt('['+request_value+']表单定义的方法未定义'); - } - return false; - } + // 是form表单直接通过 + case 'form' : + return true; + break; + + // 同步调用方法 + case 'sync' : + $button.button('reset'); + if(IsExitsFunction(request_value)) + { + window[request_value](GetFormVal(form_name, true)); + } else { + Prompt('['+request_value+']表单定义的方法未定义'); + } + return false; + break; + + // 拼接参数跳转 + case 'jump' : + var params = GetFormVal(form_name, true); + for(var i in params) + { + request_value = UrlFieldReplace(i, encodeURIComponent(params[i]), request_value) + } + window.location.href = request_value; + return false; + break; - // 拼接参数跳转 - if(request_type == 'jump') - { - var params = GetFormVal(form_name, true); - for(var i in params) - { - request_value = UrlFieldReplace(i, encodeURIComponent(params[i]), request_value) - } - window.location.href = request_value; - return false; } // 请求 url http类型 @@ -433,15 +437,16 @@ function FromInit(form_name) // ajax请求 $.ajax({ - url:action, - type:method, - dataType:"json", - timeout:$form.attr('timeout') || 30000, - data:GetFormVal(form_name), - processData:false, - contentType:false, - success:function(result) + url: action, + type: method, + dataType: "json", + timeout: $form.attr('timeout') || 30000, + data: GetFormVal(form_name), + processData: false, + contentType: false, + success: function(result) { + $.AMUI.progress.done(); // 调用自定义回调方法 if(request_type == 'ajax-fun') { @@ -449,40 +454,45 @@ function FromInit(form_name) { window[request_value](result); } else { - $.AMUI.progress.done(); $button.button('reset'); Prompt('['+request_value+']表单定义的方法未定义'); } - } else if(request_type == 'ajax-url' || request_type == 'ajax-reload') - { - $.AMUI.progress.done(); + } else { + // 统一处理 if(result.code == 0) { - // url跳转 - if(request_type == 'ajax-url') + switch(request_type) { - Prompt(result.msg, 'success'); - setTimeout(function() - { - window.location.href = request_value; - }, 1500); + // url跳转 + case 'ajax-url' : + Prompt(result.msg, 'success'); + setTimeout(function() + { + window.location.href = request_value; + }, 1500); + break; - // 页面刷新 - } else if(request_type == 'ajax-reload') - { - Prompt(result.msg, 'success'); - setTimeout(function() - { - window.location.reload(); - }, 1500); - } + // 页面刷新 + case 'ajax-reload' : + Prompt(result.msg, 'success'); + setTimeout(function() + { + window.location.reload(); + }, 1500); + break; + + // 默认仅提示 + default : + $button.button('reset'); + Prompt(result.msg, 'success'); + } } else { Prompt(result.msg); $button.button('reset'); } } }, - error:function(xhr, type) + error: function(xhr, type) { $.AMUI.progress.done(); $button.button('reset'); diff --git a/public/static/index/default/css/goods.css b/public/static/index/default/css/goods.css index ab16eeac4..666430f67 100755 --- a/public/static/index/default/css/goods.css +++ b/public/static/index/default/css/goods.css @@ -221,6 +221,9 @@ flex: 1 1 0%;line-height: 16px;cursor: pointer;} #min, #add{ width: 35px; height: 25px; outline:none; line-height: 23px; padding: 0; cursor: pointer; } #text_box { width: 60px; height: 25px; text-align: center; font-size: 12px !important; } .theme-popover .am-input-group { display: inline-flex; } +@media only screen and (min-width: 641px) { + .theme-popover .am-input-group { margin-left: 5px; } +} /*购物车*/ diff --git a/public/static/index/default/js/goods.js b/public/static/index/default/js/goods.js index 7acf48b45..f7743211b 100755 --- a/public/static/index/default/js/goods.js +++ b/public/static/index/default/js/goods.js @@ -66,7 +66,7 @@ function GoodsCommentsHtml(page) } /** - * 购买/加入购物车 + * 购买/加入购物车校验 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 @@ -74,10 +74,9 @@ function GoodsCommentsHtml(page) * @desc description * @param {[object]} e [当前标签对象] */ -function CartAdd(e) +function BuyCartCheck(e) { // 参数 - var type = e.attr('data-type'); var stock = parseInt($('#text_box').val()) || 1; var inventory = parseInt($('.stock-tips .stock').text()); var min = $('.stock-tips .stock').data('min-limit') || 1; @@ -124,55 +123,48 @@ function CartAdd(e) }); } } + return { + "stock": stock, + "spec": spec, + "type": e.attr('data-type') + }; +} + +/** + * 购买/加入购物车处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-13 + * @desc description + * @param {[object]} e [当前标签对象] + */ +function BuyCartHandle(e) +{ + // 参数 + var params = BuyCartCheck(e); + if(params === false) + { + return false; + } // 操作类型 - switch(type) + switch(params.type) { // 立即购买 case 'buy' : - var $form_buy = $('form.buy-form'); - $form_buy.find('input[name="spec"]').val(JSON.stringify(spec)); - $form_buy.find('input[name="stock"]').val(stock); - $form_buy.find('button[type="submit"]').trigger('click'); + var $form = $('form.buy-form'); + $form.find('input[name="spec"]').val(JSON.stringify(params.spec)); + $form.find('input[name="stock"]').val(params.stock); + $form.find('button[type="submit"]').trigger('click'); break; // 加入购物车 case 'cart' : - // 开启进度条 - $.AMUI.progress.start(); - - var $button = e; - $button.attr('disabled', true); - - // ajax请求 - $.ajax({ - url: e.data('ajax-url'), - type: 'post', - dataType: "json", - timeout: 10000, - data: {"goods_id": $('.goods-detail').data('id'), "stock": stock, "spec": spec}, - success: function(result) - { - PoptitClose(); - $.AMUI.progress.done(); - $button.attr('disabled', false); - - if(result.code == 0) - { - HomeCartNumberTotalUpdate(parseInt(result.data)); - Prompt(result.msg, 'success'); - } else { - Prompt(result.msg); - } - }, - error: function(xhr, type) - { - PoptitClose(); - $.AMUI.progress.done(); - $button.attr('disabled', false); - Prompt('服务器错误'); - } - }); + var $form = $('form.cart-form'); + $form.find('input[name="spec"]').val(JSON.stringify(params.spec)); + $form.find('input[name="stock"]').val(params.stock); + $form.find('button[type="submit"]').trigger('click'); break; // 默认 @@ -385,6 +377,9 @@ function SpecPopupShow(e) } $(function() { + // 购物车表单初始化 + FromInit('form.cart-form'); + // 商品规格选择 $('.theme-options').each(function() { @@ -498,7 +493,7 @@ $(function() { { if($(window).width() >= 1025) { - CartAdd($(this)); + BuyCartHandle($(this)); } } }); @@ -509,7 +504,7 @@ $(function() { { if($(window).width() < 1025) { - CartAdd($(this)); + BuyCartHandle($(this)); } } });