From 5c1b205e530a0384739a2d7199c972e991b6878e Mon Sep 17 00:00:00 2001 From: devil_gong Date: Fri, 14 Sep 2018 18:06:53 +0800 Subject: [PATCH] category --- .../Home/Controller/CartController.class.php | 59 +++++ .../Controller/CategoryController.class.php | 43 ++++ .../Controller/CommonController.class.php | 16 +- .../Home/Controller/EmptyController.class.php | 1 - .../Home/Controller/GoodsController.class.php | 69 ++--- .../Home/View/Default/Cart/Index.html | 243 +++++++----------- .../Home/View/Default/Category/Index.html | 54 ++++ .../Home/View/Default/Goods/Index.html | 162 ++++++------ .../Home/View/Default/Index/Index.html | 6 +- .../Home/View/Default/Public/Error.html | 24 +- .../Home/View/Default/Public/Footer.html | 1 + .../View/Default/Public/GoodsCategory.html | 6 +- .../Home/View/Default/Public/Header.html | 1 + .../View/Default/Public/HeaderTopNav.html | 27 +- .../Home/View/Default/Public/TipsError.html | 6 +- .../Application/Service/BuyService.class.php | 143 +++++++++++ service/Public/Common/Js/Common.js | 95 ++++--- service/Public/Home/Default/Css/Cart.css | 23 +- service/Public/Home/Default/Css/Category.css | 13 + service/Public/Home/Default/Css/Common.css | 53 ++-- service/Public/Home/Default/Css/Goods.css | 32 +-- service/Public/Home/Default/Css/Index.css | 4 +- service/Public/Home/Default/Css/Search.css | 1 - service/Public/Home/Default/Js/Cart.js | 143 +++++++++++ service/Public/Home/Default/Js/Common.js | 12 + service/Public/Home/Default/Js/Goods.js | 108 ++++---- 26 files changed, 924 insertions(+), 421 deletions(-) create mode 100644 service/Application/Home/Controller/CategoryController.class.php create mode 100644 service/Application/Home/View/Default/Category/Index.html create mode 100644 service/Public/Home/Default/Css/Category.css create mode 100644 service/Public/Home/Default/Js/Cart.js diff --git a/service/Application/Home/Controller/CartController.class.php b/service/Application/Home/Controller/CartController.class.php index 27d93bf96..e49abd168 100644 --- a/service/Application/Home/Controller/CartController.class.php +++ b/service/Application/Home/Controller/CartController.class.php @@ -38,6 +38,15 @@ class CartController extends CommonController */ public function Index() { + $cart_list = BuyService::CartList(['user'=>$this->user]); + $this->assign('cart_list', $cart_list['data']); + + $base = [ + 'total_price' => empty($cart_list['data']) ? 0 : array_sum(array_column($cart_list['data'], 'total_price')), + 'total_stock' => empty($cart_list['data']) ? 0 : array_sum(array_column($cart_list['data'], 'stock')), + 'ids' => empty($cart_list['data']) ? '' : implode(',', array_column($cart_list['data'], 'id')), + ]; + $this->assign('base', $base); $this->display('Index'); } @@ -51,10 +60,60 @@ class CartController extends CommonController */ public function Save() { + // 是否ajax请求 + if(!IS_AJAX) + { + $this->error(L('common_unauthorized_access')); + } + $params = $_POST; $params['user'] = $this->user; $ret = BuyService::CartAdd($params); $this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']); } + + /** + * 购物车删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-14 + * @desc description + */ + public function Delete() + { + // 是否ajax请求 + if(!IS_AJAX) + { + $this->error(L('common_unauthorized_access')); + } + + $params = $_POST; + $params['user'] = $this->user; + $ret = BuyService::CartDelete($params); + $this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']); + } + + /** + * 数量保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-14 + * @desc description + */ + public function Stock() + { + // 是否ajax请求 + if(!IS_AJAX) + { + $this->error(L('common_unauthorized_access')); + } + + $params = $_POST; + $params['user'] = $this->user; + $ret = BuyService::CartStock($params); + $this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']); + } } ?> \ No newline at end of file diff --git a/service/Application/Home/Controller/CategoryController.class.php b/service/Application/Home/Controller/CategoryController.class.php new file mode 100644 index 000000000..8e24020df --- /dev/null +++ b/service/Application/Home/Controller/CategoryController.class.php @@ -0,0 +1,43 @@ +display('Index'); + } +} +?> \ No newline at end of file diff --git a/service/Application/Home/Controller/CommonController.class.php b/service/Application/Home/Controller/CommonController.class.php index 9c6ce66ec..a2620b386 100755 --- a/service/Application/Home/Controller/CommonController.class.php +++ b/service/Application/Home/Controller/CommonController.class.php @@ -234,7 +234,6 @@ class CommonController extends Controller protected function _empty($name) { $this->assign('msg', L('common_unauthorized_access')); - $this->assign('is_footer', 0); $this->display('/Public/Error'); } @@ -249,10 +248,17 @@ class CommonController extends Controller { if(MyC('home_site_state') == 0) { - $this->assign('msg', MyC('home_site_close_reason', L('common_site_maintenance_tips'), true)); - $this->assign('is_footer', 0); - $this->display('/Public/Error'); - exit; + // 是否ajax请求 + if(IS_AJAX) + { + $this->error(MyC('home_site_close_reason', L('common_site_maintenance_tips'))); + } else { + $this->assign('msg', MyC('home_site_close_reason', L('common_site_maintenance_tips'), true)); + $this->assign('is_header', 0); + $this->assign('is_footer', 0); + $this->display('/Public/Error'); + exit; + } } } diff --git a/service/Application/Home/Controller/EmptyController.class.php b/service/Application/Home/Controller/EmptyController.class.php index b6e60c766..fff4e44e1 100755 --- a/service/Application/Home/Controller/EmptyController.class.php +++ b/service/Application/Home/Controller/EmptyController.class.php @@ -21,7 +21,6 @@ class EmptyController extends CommonController public function Index() { $this->assign('msg', L('common_unauthorized_access')); - $this->assign('is_footer', 0); $this->display('/Public/Error'); } } diff --git a/service/Application/Home/Controller/GoodsController.class.php b/service/Application/Home/Controller/GoodsController.class.php index 47a7bf55d..be88fae25 100755 --- a/service/Application/Home/Controller/GoodsController.class.php +++ b/service/Application/Home/Controller/GoodsController.class.php @@ -45,43 +45,48 @@ class GoodsController extends CommonController 'is_attribute' => true, ]; $goods = GoodsService::GoodsList($params); + if(empty($goods[0]) || $goods[0]['is_delete_time'] != 0) + { + $this->assign('msg', L('common_data_no_exist_error')); + $this->display('/Public/TipsError'); + } else { + // 当前登录用户是否已收藏 + $ret_favor = GoodsService::IsUserGoodsFavor(['goods_id'=>$id, 'user'=>$this->user]); + $goods[0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0; - // 当前登录用户是否已收藏 - $ret_favor = GoodsService::IsUserGoodsFavor(['goods_id'=>$id, 'user'=>$this->user]); - $goods[0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0; + $this->assign('goods', $goods[0]); + $this->assign('home_seo_site_title', $goods[0]['title']); - $this->assign('goods', $goods[0]); - $this->assign('home_seo_site_title', $goods[0]['title']); + // 商品访问统计 + M('Goods')->where(array('id'=>$id))->setInc('access_count'); - // 商品访问统计 - M('Goods')->where(array('id'=>$id))->setInc('access_count'); + // 左侧商品 看了又看 + $params = [ + 'where' => [ + 'g.is_delete_time'=>0, + 'g.is_shelves'=>1 + ], + 'order_by' => 'access_count desc', + 'field' => 'g.id,g.title,g.title_color,g.price,g.images', + 'n' => 10, + ]; + $this->assign('left_goods', GoodsService::GoodsList($params)); - // 左侧商品 看了又看 - $params = [ - 'where' => [ - 'g.is_delete_time'=>0, - 'g.is_shelves'=>1 - ], - 'order_by' => 'access_count desc', - 'field' => 'g.id,g.title,g.title_color,g.price,g.images', - 'n' => 10, - ]; - $this->assign('left_goods', GoodsService::GoodsList($params)); - - // 详情tab商品 猜你喜欢 - $params = [ - 'where' => [ - 'g.is_delete_time'=>0, - 'g.is_shelves'=>1, - 'is_home_recommended'=>1, - ], - 'order_by' => 'sales_count desc', - 'field' => 'g.id,g.title,g.title_color,g.price,g.images,g.home_recommended_images', - 'n' => 16, - ]; - $this->assign('detail_like_goods', GoodsService::GoodsList($params)); + // 详情tab商品 猜你喜欢 + $params = [ + 'where' => [ + 'g.is_delete_time'=>0, + 'g.is_shelves'=>1, + 'is_home_recommended'=>1, + ], + 'order_by' => 'sales_count desc', + 'field' => 'g.id,g.title,g.title_color,g.price,g.images,g.home_recommended_images', + 'n' => 16, + ]; + $this->assign('detail_like_goods', GoodsService::GoodsList($params)); - $this->display('Index'); + $this->display('Index'); + } } /** diff --git a/service/Application/Home/View/Default/Cart/Index.html b/service/Application/Home/View/Default/Cart/Index.html index 5a0794518..6735c63c8 100644 --- a/service/Application/Home/View/Default/Cart/Index.html +++ b/service/Application/Home/View/Default/Cart/Index.html @@ -14,155 +14,106 @@
- - - - - - - - - - - - - - - - - - - + + +
商品信息单价数量金额操作
- - -
- ¥3964.00 - ¥2378.00 - x10 -
-
-

¥3964.00

-

¥2378.00

-
-
- - - - + -
-
- ¥2378.00 - - 删除 -
+ + + + + + + + + + + + am-warningam-danger"> + + + + + + + + +
商品信息单价数量金额操作
+ disabled /> +
+ + + +
+ {{$cart.title}} + +
    + +
  • {{$attr.attr_type_name}}:{{$attr.attr_name}}
  • +
    +
+
+
+
+
+ ¥{{$cart.original_price}} + ¥{{$cart.price}} + x{{$cart.stock}} +
+
+

¥{{$cart.original_price}}

+

¥{{$cart.price}}

+
+
+ stock-submit" data-type="min">- + disabled /> + stock-submit" data-type="add">+ +
+ +

商品已下架

+
+ +

商品已作废

+
+
+ ¥{{$cart.total_price}} + + 删除 +
- - - - -
- ¥3964.00 - ¥2378.00 - x10 -
- - -

¥3964.00

-

¥2378.00

- - -
- - - - + -
- - - ¥2378.00 - - - 删除 - - - - - - - -
- ¥3964.00 - ¥2378.00 - x10 -
- - -

¥3964.00

-

¥2378.00

- - -
- - - - + -
- - - ¥2378.00 - - - 删除 - - - - - - -
-
- - 删除 + +
+
+ + 清空 +
+
+ 已选商品 0 + 合计: + ¥0.00 + +
-
- 已选商品 0 - 合计: - ¥2131234 - + +
+ +
+

您的购物车还是空的,赶紧行动吧!您可以

+ +
-
+
diff --git a/service/Application/Home/View/Default/Category/Index.html b/service/Application/Home/View/Default/Category/Index.html new file mode 100644 index 000000000..75d9ea9c6 --- /dev/null +++ b/service/Application/Home/View/Default/Category/Index.html @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + +
+ +
+ +
+
+ {{$v.name}} +
+
+ +
+
+
+
+ +
{{:L('common_not_data_tips')}}
+
+
+ + + + \ No newline at end of file diff --git a/service/Application/Home/View/Default/Goods/Index.html b/service/Application/Home/View/Default/Goods/Index.html index 6ad8c3150..014fc568c 100755 --- a/service/Application/Home/View/Default/Goods/Index.html +++ b/service/Application/Home/View/Default/Goods/Index.html @@ -12,7 +12,7 @@ -
+
@@ -95,92 +95,98 @@ -
- -
- -
-
-
-
- -
-
-
- -
-
- - +
+ + +
-
- - 首页 - - - 已收藏 - - 收藏 - -
-
  • -
  • -
  • -
  • + +

    商品已下架

    +
    diff --git a/service/Application/Home/View/Default/Index/Index.html b/service/Application/Home/View/Default/Index/Index.html index 0d7529847..6aff6a758 100755 --- a/service/Application/Home/View/Default/Index/Index.html +++ b/service/Application/Home/View/Default/Index/Index.html @@ -19,7 +19,7 @@
    - {{:U('Home/User/LoginInfo')}}{{:U('Home/User/Index')}}"> + href="javascript:;" class="login-event" href="{{:U('Home/User/Index')}}"> diff --git a/service/Application/Home/View/Default/Public/Error.html b/service/Application/Home/View/Default/Public/Error.html index fd3c40d68..390723260 100755 --- a/service/Application/Home/View/Default/Public/Error.html +++ b/service/Application/Home/View/Default/Public/Error.html @@ -1,10 +1,26 @@ + + + + + + + + + + + + + + -
    style="{{$max_width_style}}"> -
    -
    {{$msg}}
    -
    +
    +
    +
    +
    {{$msg}}
    +
    +
    diff --git a/service/Application/Home/View/Default/Public/Footer.html b/service/Application/Home/View/Default/Public/Footer.html index 25789e12a..be97ad26d 100755 --- a/service/Application/Home/View/Default/Public/Footer.html +++ b/service/Application/Home/View/Default/Public/Footer.html @@ -16,6 +16,7 @@ + diff --git a/service/Application/Home/View/Default/Public/GoodsCategory.html b/service/Application/Home/View/Default/Public/GoodsCategory.html index 912fc7906..4c79b24e3 100755 --- a/service/Application/Home/View/Default/Public/GoodsCategory.html +++ b/service/Application/Home/View/Default/Public/GoodsCategory.html @@ -1,7 +1,7 @@
    diff --git a/service/Application/Home/View/Default/Public/TipsError.html b/service/Application/Home/View/Default/Public/TipsError.html index b8e06065a..5d8f06f8d 100755 --- a/service/Application/Home/View/Default/Public/TipsError.html +++ b/service/Application/Home/View/Default/Public/TipsError.html @@ -13,7 +13,7 @@ -
    style="{{$max_width_style}}"> +
    {{$msg}}
    @@ -22,10 +22,6 @@
    - - - - \ No newline at end of file diff --git a/service/Application/Service/BuyService.class.php b/service/Application/Service/BuyService.class.php index eb725857b..1865d715b 100644 --- a/service/Application/Service/BuyService.class.php +++ b/service/Application/Service/BuyService.class.php @@ -108,5 +108,148 @@ class BuyService return DataReturn(L('common_join_error'), -100); } + + /** + * 获取购物车列表 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-08-29 + * @desc description + * @param [array] $params [输入参数] + */ + public static function CartList($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'user', + 'error_msg' => '用户信息有误', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + $where = [ + 'c.user_id'=>$params['user']['id'], + ]; + $field = 'c.*, g.title, g.images, g.original_price, g.price, g.inventory, g.is_shelves, g.is_delete_time'; + $data = M('Cart')->alias('c')->join(' __GOODS__ AS g ON g.id=c.goods_id')->where($where)->field($field)->select(); + if(!empty($data) && is_array($data)) + { + $images_host = C('IMAGE_HOST'); + foreach($data as &$v) + { + $v['goods_url'] = HomeUrl('Goods', 'Index', ['id'=>$v['goods_id']]); + $v['images'] = empty($v['images']) ? null : $images_host.$v['images']; + $v['attribute'] = empty($v['attribute']) ? null : json_decode($v['attribute'], true); + $v['total_price'] = $v['stock']*$v['price']; + } + } + return DataReturn(L('common_operation_success'), 0, $data); + } + + /** + * 购物车删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-14 + * @desc description + * @param [array] $params [输入参数] + */ + public static function CartDelete($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '删除数据id有误', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'user', + 'error_msg' => '用户信息有误', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 删除 + $where = [ + 'id' => ['in', explode(',', $params['id'])], + 'user_id' => $params['user']['id'] + ]; + if(M('Cart')->where($where)->delete()) + { + return DataReturn(L('common_operation_delete_success'), 0); + } + return DataReturn(L('common_operation_delete_error'), -100); + } + + /** + * 购物车数量保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-14 + * @desc description + * @param [array] $params [输入参数] + */ + public static function CartStock($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '数据id有误', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'goods_id', + 'error_msg' => '商品id有误', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'stock', + 'error_msg' => '购买数量有误', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'user', + 'error_msg' => '用户信息有误', + ], + ]; + $ret = params_checked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 更新 + $where = [ + 'id' => intval($params['id']), + 'goods_id' => intval($params['goods_id']), + 'user_id' => intval($params['user']['id']), + ]; + $data = [ + 'stock' => intval($params['stock']), + 'upd_time' => time(), + ]; + if(M('Cart')->where($where)->save($data)) + { + return DataReturn(L('common_operation_update_success'), 0); + } + return DataReturn(L('common_operation_update_error'), -100); + } } ?> \ No newline at end of file diff --git a/service/Public/Common/Js/Common.js b/service/Public/Common/Js/Common.js index 69b3034d1..7eb4d4808 100755 --- a/service/Public/Common/Js/Common.js +++ b/service/Public/Common/Js/Common.js @@ -586,6 +586,35 @@ function ModalLoad(url, title, tag) $('#'+tag).modal(); } +/** + * 价格四舍五入,并且指定保留小数位数 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-14 + * @desc description + * @param {[float]} value [金额] + * @param {[int]} pos [位数 默认2] + */ +function FomatFloat(value, pos) +{ + pos = pos || 2; + var f_x = Math.round(value*Math.pow(10, pos))/Math.pow(10, pos); + + var s_x = f_x.toString(); + var pos_decimal = s_x.indexOf('.'); + if(pos_decimal < 0) + { + pos_decimal = s_x.length; + s_x += '.'; + } + while (s_x.length <= pos_decimal + 2) + { + s_x += '0'; + } + return s_x; +} + // 公共数据操作 $(function() @@ -619,45 +648,45 @@ $(function() */ $(document).on('click', '.submit-delete', function() { - $('#common-confirm-delete').modal({ - relatedTarget: this, + var id = $(this).data('id'); + var url = $(this).data('url'); + var title = $(this).data('title') || '温馨提示'; + var msg = $(this).data('msg') || '删除后不可恢复、确认操作吗?'; + + AMUI.dialog.confirm({ + title: title, + content: msg, onConfirm: function(options) { - // 获取参数 - var $tag = $(this.relatedTarget); - var id = $tag.data('id'); - var url = $tag.data('url'); - var list_tag = $tag.data('list-tag') || '#data-list-'+id; - if(id == undefined || url == undefined) + if((id || null) == null || (url || null) == null) { Prompt('参数配置有误'); - return false; - } - - // 请求删除数据 - $.ajax({ - url:url, - type:'POST', - dataType:"json", - timeout:10000, - data:{"id":id}, - success:function(result) - { - if(result.code == 0) + } else { + // 请求删除数据 + $.ajax({ + url:url, + type:'POST', + dataType:"json", + timeout:10000, + data:{"id":id}, + success:function(result) { - Prompt(result.msg, 'success'); + if(result.code == 0) + { + Prompt(result.msg, 'success'); - // 成功则删除数据列表 - $(list_tag).remove(); - } else { - Prompt(result.msg); + // 成功则删除数据列表 + $('#data-list-'+id).remove(); + } else { + Prompt(result.msg); + } + }, + error:function(xhr, type) + { + Prompt('网络异常出错'); } - }, - error:function(xhr, type) - { - Prompt('网络异常出错'); - } - }); + }); + } }, onCancel: function(){} }); @@ -983,7 +1012,7 @@ $(function() }); }, onCancel: function(){} - }); + }); }); // 地区联动 diff --git a/service/Public/Home/Default/Css/Cart.css b/service/Public/Home/Default/Css/Cart.css index 40678eac2..12c4f99db 100644 --- a/service/Public/Home/Default/Css/Cart.css +++ b/service/Public/Home/Default/Css/Cart.css @@ -1,7 +1,6 @@ .goods-detail img { width: 80px; height: 80px; } -.goods-detail { position: relative; margin-left: 15px; } +.goods-detail { position: relative; margin-left: 20px; } .goods-title { display: block; max-height: 36px; overflow: hidden; text-overflow: ellipsis; } -.goods-title, .goods-attr li, .original-price, .operation a, .wap-number, .selected-tips, .cart-nav a, .total-price-tips, .cart-nav label { font-size: 12px; } .goods-title:hover { text-decoration: underline; } .goods-base { position: absolute; top: 0; left: 85px; } .goods-attr { margin-top: 5px; } @@ -10,21 +9,22 @@ .original-price { color: #9c9c9c; text-decoration: line-through; } .line-price { color: #3c3c3c; } .line-price, strong.total-price-content, .nav-total-price { font-weight: 700; } -.number-tag { width: 100px; } -.number-tag .am-form-field { padding: 3px; height: 25px; text-align: center; font-size: 16px !important; } -.number-tag .am-input-group-label { line-height: 23px; height: 25px; font-size: 14px !important; padding: 0 10px; } -.number-tag .am-input-group-label, .cart-nav label { cursor: pointer; } +.stock-tag { width: 100px; } +.stock-tag .am-form-field { padding: 3px; height: 25px; text-align: center; font-size: 16px !important; } +.stock-tag .am-input-group-label { line-height: 23px; height: 25px; font-size: 14px !important; padding: 0 10px; } +.stock-tag .am-input-group-label, .cart-nav label { cursor: pointer; } strong.total-price-content, .selected-tips strong, .nav-total-price { color: #d2364c; font-size: 16px; } -.operation a { display: block; } +.am-table { margin-bottom: 10px; } .am-table > tbody > tr > td { border-top: 1px solid #F5F5F5; } .cart-content table td.base input[type="checkbox"] { float: left; } -.cart-nav { background: #eee; height: 50px; line-height: 50px; padding: 0 0 0 5px; } -.cart-nav .separate-submit { height: 50px; width: 100px; font-size: 20px; } +.cart-nav { background: #eee; height: 50px; line-height: 46px; } +.cart-nav .separate-submit { height: 50px; width: 100px; font-size: 20px; font-weight: 500; } .selected-tips { margin-right: 15px; } -.cart-nav label { font-weight: 100; } +.cart-nav label { font-weight: 500; margin: 0; } .cart-nav input[type="checkbox"] { vertical-align: inherit; } -.cart-nav .delete-submit-all { margin-left: 10px; } +.cart-nav .am-fl { margin-left: 5px; } +.cart-nav .am-fl a { margin-left: 10px; } @media only screen and (min-width:640px) { .cart-content table tr .base { width: 30%; } @@ -38,4 +38,5 @@ strong.total-price-content, .selected-tips strong, .nav-total-price { color: #d2 @media only screen and (max-width:640px) { .cart-content table tr .base { width: 80%; } .selected-tips { display: none; } + .am-footer { margin-top: 10px; } } \ No newline at end of file diff --git a/service/Public/Home/Default/Css/Category.css b/service/Public/Home/Default/Css/Category.css new file mode 100644 index 000000000..00b9a90f8 --- /dev/null +++ b/service/Public/Home/Default/Css/Category.css @@ -0,0 +1,13 @@ +.category-list ul { overflow: hidden; border-bottom: 1px solid #dedede; margin-bottom: 20px; } +.category-list ul:last-child { border-bottom: 0; margin-bottom: 0; } +.category-list .title { font-weight: 500; } +.category-list ul li { margin-right: 10px; line-height: 38px; font-size: 14px; } +.category-list ul li a { color: #888; border-left: 1px solid #dedede; padding-left: 10px; } +.category-list ul li a.first { border-left: 0; padding-left: 0; } +.am-accordion-gapped .am-accordion-title { font-size: 16px; font-weight: 500; } +@media only screen and (min-width:640px) { + .am-accordion-gapped { margin: 0; } +} +@media only screen and (max-width:1025px) { + .am-accordion-gapped { margin: 0 5px; } +} \ No newline at end of file diff --git a/service/Public/Home/Default/Css/Common.css b/service/Public/Home/Default/Css/Common.css index c582da979..f49265a1e 100755 --- a/service/Public/Home/Default/Css/Common.css +++ b/service/Public/Home/Default/Css/Common.css @@ -30,8 +30,6 @@ footer, header, hgroup, menu, nav, section, main { ul,li,ol{ list-style:none;} dl,dd{ margin:auto;} -.am-btn {font-size:12px ;} - html{width:100%; height:100%; -ms-text-size-adjust:none; @@ -41,11 +39,11 @@ html{width:100%; } /*text-size-adjust不管屏幕怎么变文字大小不变*/ -* { font-size: 14px; } +*, body, html, .am-btn { font-size: 12px; } body{margin:0; padding:0; width:100%; - font-family: arial,"Lantinghei SC","Microsoft Yahei"; + font-family: arial,"Lantinghei SC","Microsoft Yahei"; } .am-form select, .am-form textarea, .am-form input[type="text"], .am-form input[type="password"], .am-form input[type="datetime"], .am-form input[type="datetime-local"], .am-form input[type="date"], .am-form input[type="month"], .am-form input[type="time"], .am-form input[type="week"], .am-form input[type="number"], .am-form input[type="email"], .am-form input[type="url"], .am-form input[type="search"], .am-form input[type="tel"], .am-form input[type="color"], .am-form-field { @@ -55,9 +53,6 @@ body{margin:0; height: 32px; font-size: 14px !important; } - -a:link,a:visited,a:hover{text-decoration:none; outline:none;} -a:hover, a:focus { color: #d2364c; } /*所有超链接不要下划线*/ *, *:after, *:before{ @@ -75,6 +70,8 @@ a { color: #333; text-decoration: none; } +a:link,a:visited,a:hover{ outline:none;} +a:hover, a:focus { color: #d2364c !important; text-decoration: underline; } .spatic{width:100%; height:16px;} h5{float: right;color: #666;padding-right:20px;} @@ -122,7 +119,7 @@ color: #F5F5F2;font-size: 14px;cursor:pointer;border-radius:0px 0px ;} /* 顶部小导航 */ .header-top { background-color: #fafafa; border-bottom: solid 1px #f0f0f0; } -.header-top a, .header-top span { color: #333; font-size: 12px; } +.header-top a, .header-top span { color: #333; } .header{ display:none; max-width:1000px; margin:0px auto; font-size:12px;} .am-footer { border-top: 2px solid #d2364c; } @@ -145,23 +142,6 @@ color: #F5F5F2;font-size: 14px;cursor:pointer;border-radius:0px 0px ;} @media only screen and (min-width: 640px) { - /*公共*/ - html, body, div, span, applet, object, iframe, - h1, h2, h3, h4, h5, h6, p, blockquote, pre, - a, abbr, acronym, address, big, cite, code, - del, dfn, em, img, ins, kbd, q, s, samp, - small, strike, strong, sub, sup, tt, var, - b, u, i, center, - dl, dt, dd, ol, ul, li, - fieldset, form, label, legend, - table, caption, tbody, tfoot, thead, tr, th, td, - article, aside, canvas, details, embed, - figure, figcaption, footer, header, hgroup, - menu, nav, output, ruby, section, summary, - time, mark, audio, video { - font-size: 14px; - } - .am-container {padding-left:0px;padding-right:0px ;} .shop-nav {position: relative;} @@ -218,7 +198,7 @@ color: #F5F5F2;font-size: 14px;cursor:pointer;border-radius:0px 0px ;} .nav-table{max-width:1000px;margin: 0px auto;height: 45px;position: relative;overflow: hidden;} .all-goods{font-size: 16px;} .goods-category-title{background:#d2364c;color:#fff ;height: 45px;line-height: 45px;display:block;position: absolute;width:150px ;text-align: center;font-size:16px ;top:0px;z-index: 6;cursor: pointer;} - .nav-cont{position: absolute;padding-left:150px;display:block;width:100% ;top:0px} + .nav-cont{position: absolute;padding-left:150px;display:block;width:100% ;top:4px} .nav-cont li{float: left;height: 45px;line-height: 45px;} .nav-cont li::before{content: '\20';display: inline-block;height: 16px;border-right: 1px solid #d9d9d9;width: 0;vertical-align: middle;margin-left: -1px;} .nav-cont li a {font-size: 16px;color: #333;line-height: 36px;margin-left: -1px;padding: 0 25px;text-decoration: none;font-weight: 700;display: inline-block;vertical-align: middle;} @@ -363,7 +343,7 @@ background: url(../Images/ibar_sprites.png) no-repeat; .item:hover,.quick_toggle li:hover{ background:#ed145b;} -.item p {font-size: 12px;width:16px;margin:0px auto;padding-bottom:10px;} +.item p {width:16px;margin:0px auto;padding-bottom:10px;} .item,.nav-content{ font-size:12px;} .ibar_login_box {width: 267px;height: 185px;padding: 10px;background: #fff;box-shadow: 0 0 5px rgba(0,0,0,.4);border-radius: 5px 0 0 5px;border-left: 1px solid #ccc\0;border-top: 1px solid #ccc\0;border-bottom: 1px solid #ccc\0;z-index: 3;position: absolute;top: 0px;left: -270px;display: none;} @@ -466,6 +446,16 @@ background:url(../Images/ibar_sprites.png) no-repeat;background-position:0px -23 /* 页面加载数据 */ .loding-view { text-align: center; color: #888; padding: 10px 0; } +/** + * 混合提示 + */ +.mixed-tips { width: 360px; overflow: hidden; margin:0 auto; margin-top: 5%; margin-bottom: 10%; } +.mixed-tips .icon { font-size: 68px; color: #ccc; margin-right: 20px; } +.mixed-tips-content { margin-top: 10px; } +.mixed-tips-content h1 { font-size: 14px; font-weight: 500; } +.mixed-tips-content ul { margin-top: 5px; } +.mixed-tips-content ul li a { color: #d13b49; } + /** * 底部 */ @@ -547,6 +537,10 @@ background:url(../Images/ibar_sprites.png) no-repeat;background-position:0px -23 background-color: #e86175; border-color: #e86175; } +.am-btn-secondary:active, .am-btn-secondary.am-active, .am-dropdown.am-active .am-btn-secondary.am-dropdown-toggle { + background-image: none; + background-color: #d13b49; +} .am-btn-primary { color: #fff; @@ -560,10 +554,13 @@ background:url(../Images/ibar_sprites.png) no-repeat;background-position:0px -23 color: #fff; border-color: #d31e37; } - .am-btn-primary.am-disabled, .am-btn-primary[disabled], fieldset[disabled] .am-btn-primary, .am-btn-primary.am-disabled:hover, .am-btn-primary[disabled]:hover, fieldset[disabled] .am-btn-primary:hover, .am-btn-primary.am-disabled:focus, .am-btn-primary[disabled]:focus, fieldset[disabled] .am-btn-primary:focus, .am-btn-primary.am-disabled:active, .am-btn-primary[disabled]:active, fieldset[disabled] .am-btn-primary:active, .am-btn-primary.am-disabled.am-active, .am-btn-primary[disabled].am-active, fieldset[disabled] .am-btn-primary.am-active { background-color: #d31e37; border-color: #d31e37; } +.am-btn-primary:active, .am-btn-primary.am-active, .am-dropdown.am-active .am-btn-primary.am-dropdown-toggle { + background-image: none; + background-color: #d13b49; +} .am-popup-hd .am-popup-title { font-size: 18px; } \ No newline at end of file diff --git a/service/Public/Home/Default/Css/Goods.css b/service/Public/Home/Default/Css/Goods.css index 26787e9d5..ea6461694 100755 --- a/service/Public/Home/Default/Css/Goods.css +++ b/service/Public/Home/Default/Css/Goods.css @@ -8,7 +8,7 @@ a{text-decoration:none;cursor:pointer} input{font-size:12px;font-size:100%;outline:none;line-height:normal;color:#444;} .ipt{border:solid 1px #d2d2d2;border-left-color:#ccc;border-top-color:#ccc;border-radius:2px;box-shadow:inset 0 1px 0 #f8f8f8;background-color:#fff;padding:4px 6px;height:21px;line-height:21px;color:#555;width:180px;vertical-align:baseline;} .ipt:focus{border-color:#95C8F1;box-shadow:0 0 4px #95C8F1;} -.theme-login,.item-props-can{cursor: pointer;} +.buy-event,.item-props-can{cursor: pointer;} .theme-popover-mask{z-index:1000;position:fixed;left:0;top:0;width:100%;height:100%;background:#333;opacity:0.5;filter:alpha(opacity=50);-moz-opacity:0.5;display:none;} .theme-popover{z-index:10000009;position:fixed;bottom:0;left:0;width:100%;display:none;} @@ -21,7 +21,7 @@ input{font-size:12px;font-size:100%;outline:none;line-height:normal;color:#444;} .scoll { margin-bottom: 10px; } /*内容布局*/ -.theme-popover .theme-poptit h3,.btn.close,i.theme-login{display:none} +.theme-popover .theme-poptit h3,.btn.close,i.buy-event{display:none} .theme-span{width:100%;background:transparent;height: 15px;} .theme-popbod.dform{background:#fff;} /*商品信息*/ @@ -43,7 +43,7 @@ input{font-size:12px;font-size:100%;outline:none;line-height:normal;color:#444;} .theme-signin .btn{width:100%;font-size: 16px;padding:5px ;} .btn-op{position:fixed;left:0;bottom: 0;width:100% ;} -.iteminfo_parameter dt.theme-login {text-align: left;width:100% ;} +.iteminfo_parameter dt.buy-event {text-align: left;width:100% ;} .theme-options dd{margin:10px 0px ;} .introduce-main .am-sticky-placeholder { margin: 0px !important; } @@ -87,7 +87,7 @@ input{font-size:12px;font-size:100%;outline:none;line-height:normal;color:#444;} .btn-op{overflow: hidden;padding:10px 20%; position: static;} .theme-signin .btn {width:auto; font-size:12px ;padding:5px 15px ;border-radius:0;} .btn.close {display:block;float: left;position: static;} - i.theme-login{display: inline-block;} + i.buy-event{display: inline-block;} .btn.confirm { float: right; } .buy-nav .buy-nav-opt { position: absolute; margin-left: 283px; display: block; } @@ -97,7 +97,7 @@ input{font-size:12px;font-size:100%;outline:none;line-height:normal;color:#444;} @media only screen and (min-width:1025px) { - i.theme-login{display: none;} + i.buy-event{display: none;} .theme-signin-left{padding-top:15px ;float: left;max-width:none;padding-bottom:0px ;} .theme-signin-right{float: left;display:block;overflow: hidden;padding: 10px;} .theme-signin-right .img-info,.theme-signin-right .text-info{position: static;} @@ -170,8 +170,8 @@ flex: 1 1 0%;line-height: 16px;cursor: pointer;} /*规格*/ .theme-signin .btn-op.act{display: none;} .theme-signin .btn-op.act .btn{width:50%;float: left;} -.theme-login .cart-title{ width:100%;padding:5px;} -.theme-login .cart-title .am-icon-angle-right{float: right;} +.buy-event .cart-title{ width:100%;padding:5px;} +.buy-event .cart-title .am-icon-angle-right{float: right;} /*数量*/ .iteminfo_parameter.munber,.iteminfo_parameter.freight{display:none ;} .iteminfo_parameter.munber dd{margin-left:5px ;} @@ -181,14 +181,14 @@ flex: 1 1 0%;line-height: 16px;cursor: pointer;} /*购物车*/ -.tb-btn button, .buy-nav li,.buy-nav .buy-nav-opt, .buy-nav span { height: 35px; line-height: 35px; } +.tb-btn button, .buy-nav div.submit,.buy-nav .buy-nav-opt, .buy-nav span { height: 35px; line-height: 35px; } .tb-btn button {margin-right: 0px;float: left;overflow: hidden; position: relative;width:100%; background-color: #FFEDED; color:#F03726;font-size: 14px;text-align: center;border: 0;} .tb-btn-basket button {background-color:#F03726;color: #FFF;} -.buy-nav .buy-nav-opt, .buy-nav li { float:left; } +.buy-nav .buy-nav-opt, .buy-nav div.submit { float:left; } .buy-nav .buy-nav-opt { width: 40%; } -.buy-nav li { width: 30%; } +.buy-nav div.submit { width: 30%; } .buy-nav span{display:inline-block;width: 50%;float: left; ;cursor: pointer; border-top: 1px solid #f5f5f5; border-left: 1px solid #f5f5f5;} .tb-detail-hd h1 {padding-bottom:0.4em; line-height: 1;font-size: 14px;font-weight: 600;color: #333; line-height: 20px;} @@ -276,7 +276,8 @@ li.am-comment{ width:100%} .buy-nav{ position:fixed; bottom:0px;right:0px; z-index:1000;width:100% ;background:#fff ;} .nav.white,.tip{z-index:999} - +/* 文字提示 */ +.shelves-tips { color: #FF5722; margin: 5px 0; font-size: 14px; } @media only screen and (min-width:640px) { @@ -291,8 +292,8 @@ li.am-comment{ width:100%} ul.detail-attr li {display: inline;float: left;width: 33.33%;} /*可选规格*/ - .theme-login .cart-title{border:none ;margin-left: -60px;position: relative;padding:10px 0px 5px 10px ;} - .theme-login .cart-title .am-icon-angle-right {position: absolute;right: -50px;} + .buy-event .cart-title{border:none ;margin-left: -60px;position: relative;padding:10px 0px 5px 10px ;} + .buy-event .cart-title .am-icon-angle-right {position: absolute;right: -50px;} /*销量*/ .tm-ind-panel {border-width:1px 0px;margin: -1px 0px 0px 0px;padding: 10px 0px; @@ -319,7 +320,7 @@ li.am-comment{ width:100%} /*购物车*/ .tb-btn-buy{margin-left:50px; margin-right:20px;} .tb-btn button{width:98px ;border: 1px solid #F03726;} - .buy-nav li{width: auto;} + .buy-nav div.submit{width: auto;} /*印象*/ .p-bfc {padding: 0px ; } @@ -368,7 +369,7 @@ li.am-comment{ width:100%} /*规格*/ .theme-popover {display: block;position: static;border:none ;box-shadow: none;} - .theme-poptit,.theme-signin-right,.iteminfo_parameter dt.theme-login,.btn-op{display: none;} + .theme-poptit,.theme-signin-right,.iteminfo_parameter dt.buy-event,.btn-op{display: none;} .theme-options{overflow: visible;padding:0px 0px;} .theme-options ul{overflow: hidden;float: none;} @@ -442,4 +443,5 @@ li.am-comment{ width:100%} /* 推荐商品 */ .like li:not(:nth-of-type(2n)) { border-right: 1px solid #eee; } .like li:nth-child(1), .like li:nth-child(2) { border-top: 0px; } + .shelves-tips { text-align: center; } } \ No newline at end of file diff --git a/service/Public/Home/Default/Css/Index.css b/service/Public/Home/Default/Css/Index.css index 6895ccb96..4e0d38ab0 100755 --- a/service/Public/Home/Default/Css/Index.css +++ b/service/Public/Home/Default/Css/Index.css @@ -201,7 +201,7 @@ text-align: center;float:none} /*楼层*/ .flood {border: 1px solid #eee;border-top: none;} .outer-con .describe ,.recommendation .info h3{font-size: 14px;font-weight: 600;} - + .goods-title, .outer-con .price { font-size: 14px; } /*楼层*/ .flood .text-one img{width:90%;margin:37% 5% 0% 5%;} @@ -292,7 +292,7 @@ text-align: center;float:none} .list .word{display: block;padding:20px 0 30px 10px;} .word .outer {margin: 0 10px 10px 0;float: left;width: 50px;height: 50px;text-align: center;color: #2f2f2f;background-color: #fff;border-radius: 50px;} .word .outer .inner {display: table-cell;vertical-align: middle;width:50px;height:50px;} - .word .outer .text {font-weight: 400;display: inline-block; max-width:40px;margin: 0 auto;} + .word .outer .text {font-weight: 400;display: inline-block; max-width:35px;margin: 0 auto;} /*楼层*/ .flood .text-one,.flood .text-two,.flood .text-three{width:20%;text-align: center;margin: 0px 0px;height:200px ;} diff --git a/service/Public/Home/Default/Css/Search.css b/service/Public/Home/Default/Css/Search.css index 8037d2425..914e42ee6 100755 --- a/service/Public/Home/Default/Css/Search.css +++ b/service/Public/Home/Default/Css/Search.css @@ -8,7 +8,6 @@ /*任何标签、包括它前面、后面生成的内容都不要影响盒子的边框*/ ul, li, ol {list-style: none;} dl,dt,dd{ margin:0px auto; padding:0px;} -p {margin: 0 0 .3rem 0; font-size:14px; } [class*="am-u-"] {padding-left:0rem;padding-right:0rem;} .am-thumbnails {margin-left: 0rem;margin-right: 0rem;} .am-thumbnail {margin-bottom:0;} diff --git a/service/Public/Home/Default/Js/Cart.js b/service/Public/Home/Default/Js/Cart.js new file mode 100644 index 000000000..a46aa2485 --- /dev/null +++ b/service/Public/Home/Default/Js/Cart.js @@ -0,0 +1,143 @@ +$(function() +{ + // 计算选择的商品总数和总价 + function cart_base_total() + { + var total_stock = 0; + var total_price = 0.00; + $('.am-table input[type="checkbox"]').each(function(k, v) + { + if($(this).prop('checked')) + { + var stock = parseInt($(this).parents('tr').find('.stock-tag input').val()); + var price = parseFloat($(this).parents('tr').find('.stock-tag').data('price')); + total_stock += stock; + total_price += stock*price; + } + }); + $('.cart-nav .selected-tips strong').text(total_stock); + $('.cart-nav .nav-total-price').text('¥'+FomatFloat(total_price)); + console.log(total_stock, total_price) + } + + // 购物车数量操作 + $('.stock-tag .stock-submit').on('click', function() + { + var id = parseInt($(this).parents('tr').data('id')); + var goods_id = parseInt($(this).parents('tr').data('goods-id')); + var inventory = parseInt($(this).parent().data('inventory')); + var price = parseFloat($(this).parent().data('price')); + var stock = parseInt($(this).parent().find('input').val()); + var type = $(this).data('type'); + + var temp_stock = (type == 'add') ? stock+1 : stock-1; + if(temp_stock > inventory) + { + temp_stock = inventory; + } + if(temp_stock <= 0) + { + temp_stock = 1; + } + $(this).parent().find('input').val(temp_stock); + + var temp_price = FomatFloat(temp_stock*price, 2); + $(this).parents('tr').find('.total-price-content').text('¥'+temp_price); + + // 数量不一样则更新 + if(stock != temp_stock) + { + // 开启进度条 + $.AMUI.progress.start(); + + // ajax请求 + $.ajax({ + url: $(this).parent().data('ajax-url'), + type: 'post', + dataType: "json", + timeout: 10000, + data: {"id": id, "goods_id": goods_id, "stock": temp_stock}, + success: function(result) + { + $.AMUI.progress.done(); + if(result.code == 0) + { + Prompt(result.msg, 'success'); + + // 计算选择的商品总数和总价 + cart_base_total(); + } else { + Prompt(result.msg); + } + }, + error: function(xhr, type) + { + $.AMUI.progress.done(); + Prompt('网络异常错误'); + } + }); + } + }); + + // 全选/反选 + $('.select-all-event').on('click', function() + { + if($(this).prop('checked')) + { + $(this).next().text('取消'); + $('.am-table input[type="checkbox"]').each(function(k, v) + { + if(!$(this).prop('disabled')) + { + this.checked = true; + } + }); + } else { + $(this).next().text('全选'); + $('.am-table input[type="checkbox"]').each(function(k, v) + { + if(!$(this).prop('disabled')) + { + this.checked = false; + } + }); + } + + // 计算选择的商品总数和总价 + cart_base_total(); + }); + + // 选择 + $('.am-table input[type="checkbox"]').on('click', function() + { + // 计算选择的商品总数和总价 + cart_base_total(); + }); + + // 导航固定 + var nav_top = $('.cart-nav').length > 0 ? $('.cart-nav').offset().top : 0; + function cart_nav_pop() + { + var scroll = $(document).scrollTop(); + var location = scroll+$(window).height(); + if(location < nav_top) + { + $('.cart-nav').css({"position":"fixed", "bottom":0, "width":$('.cart-content').width()+"px", "z-index":1000}); + } else { + $('.cart-nav').css({"position":"relative", "bottom":0, "z-index":0}); + } + } + cart_nav_pop(); + $(window).scroll(function() + { + cart_nav_pop(); + }); + + // 浏览器窗口实时事件 + $(window).resize(function() + { + // 导航固定初始化 + cart_nav_pop(); + }); + +}); \ No newline at end of file diff --git a/service/Public/Home/Default/Js/Common.js b/service/Public/Home/Default/Js/Common.js index 682edca86..a8bb7aa37 100755 --- a/service/Public/Home/Default/Js/Common.js +++ b/service/Public/Home/Default/Js/Common.js @@ -87,5 +87,17 @@ $(function() $('.nav-search').css('position','relative'); } }); + + // 登录事件 + $('.login-event').on('click', function() + { + // 是否登录 + if(__user_id__ == 0) + { + ModalLoad(__modal_login_url__, '登录'); + return false; + } + }); + }); \ No newline at end of file diff --git a/service/Public/Home/Default/Js/Goods.js b/service/Public/Home/Default/Js/Goods.js index 08b617103..0bdb1d0a6 100755 --- a/service/Public/Home/Default/Js/Goods.js +++ b/service/Public/Home/Default/Js/Goods.js @@ -136,16 +136,22 @@ $(function() { }); //弹出规格选择 - $('.theme-login').on('click', function() { - if ($(window).width() < 1010) { - $(document.body).css("position", "fixed"); - $('.theme-popover-mask').show(); - $('.theme-popover').slideDown(200); + $('.buy-event').on('click', function() { + if($(window).width() < 1010) { + // 是否登录 + if(__user_id__ != 0) + { + $(document.body).css("position", "fixed"); + $('.theme-popover-mask').show(); + $('.theme-popover').slideDown(200); + + $('.theme-popover .confirm').attr('data-type', $(this).data('type')); + } } else { poptit_pc_show(); } }); - $('.theme-poptit .close,.btn-op .close').on('click', function() { + $('.theme-poptit .close, .btn-op .close').on('click', function() { poptit_close(); }); @@ -153,68 +159,70 @@ $(function() { $('.buy-submit, .cart-submit').on('click', function() { // 是否登录 - if(__user_id__ == 0) + if(__user_id__ != 0) { - ModalLoad($('.goods-detail').data('login-url'), '登录'); - return false; - } - - if($(window).width() >= 1010) - { - CartAdd($(this)); - } else { - $('.theme-popover .confirm').attr('data-type', $(this).data('type')); + if($(window).width() >= 1010) + { + CartAdd($(this)); + } } }); - // 购买 确认 $('.theme-popover .confirm').on('click', function() { - if($(window).width() < 1010) + // 是否登录 + if(__user_id__ != 0) { - CartAdd($(this)); + if($(window).width() < 1010) + { + CartAdd($(this)); + } } }); // 收藏 $('.favor-submit').on('click', function() { - var $this = $(this); - // 开启进度条 - $.AMUI.progress.start(); - - // ajax请求 - $.ajax({ - url: $(this).data('ajax-url'), - type: 'post', - dataType: "json", - timeout: 10000, - data: {"goods_id": $('.goods-detail').data('id')}, - success: function(result) - { - poptit_close(); - $.AMUI.progress.done(); + // 是否登录 + if(__user_id__ != 0) + { + var $this = $(this); + // 开启进度条 + $.AMUI.progress.start(); - if(result.code == 0) + // ajax请求 + $.ajax({ + url: $(this).data('ajax-url'), + type: 'post', + dataType: "json", + timeout: 10000, + data: {"goods_id": $('.goods-detail').data('id')}, + success: function(result) { - $this.text(' '+result.data.text); - if(result.data.status == 1) + poptit_close(); + $.AMUI.progress.done(); + + if(result.code == 0) { - $this.addClass('text-active'); + $this.text(' '+result.data.text); + if(result.data.status == 1) + { + $this.addClass('text-active'); + } else { + $this.removeClass('text-active'); + } + Prompt(result.msg, 'success'); } else { - $this.removeClass('text-active'); + Prompt(result.msg); } - Prompt(result.msg, 'success'); - } else { - Prompt(result.msg); + }, + error: function(xhr, type) + { + poptit_close(); + $.AMUI.progress.done(); + Prompt('网络异常错误'); } - }, - error: function(xhr, type) - { - poptit_close(); - $.AMUI.progress.done(); - Prompt('网络异常错误'); - } - }); + }); + } }); }); -- GitLab