mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2026-07-04 21:03:27 +08:00
下订单确认
This commit is contained in:
@ -353,7 +353,7 @@ class CommonController extends Controller
|
||||
{
|
||||
mkdir(ROOT_PATH.$path, 0777, true);
|
||||
}
|
||||
$filename = date('YmdHis').'_logo.'.$suffix;
|
||||
$filename = date('YmdHis').'.'.$suffix;
|
||||
$file = $path.$filename;
|
||||
if(move_uploaded_file($_FILES[$post_name]['tmp_name'], ROOT_PATH.$file))
|
||||
{
|
||||
|
||||
93
service/Application/Home/Controller/BuyController.class.php
Normal file
93
service/Application/Home/Controller/BuyController.class.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Home\Controller;
|
||||
|
||||
use Service\GoodsService;
|
||||
use Service\UserService;
|
||||
use Service\ResourcesService;
|
||||
use Service\BuyService;
|
||||
|
||||
/**
|
||||
* 购买
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class BuyController extends CommonController
|
||||
{
|
||||
/**
|
||||
* [_initialize 前置操作-继承公共前置方法]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-03T12:39:08+0800
|
||||
*/
|
||||
public function _initialize()
|
||||
{
|
||||
// 调用父类前置方法
|
||||
parent::_initialize();
|
||||
|
||||
// 是否登录
|
||||
$this->Is_Login();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Index 首页]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2017-02-22T16:50:32+0800
|
||||
*/
|
||||
public function Index()
|
||||
{
|
||||
if(IS_POST)
|
||||
{
|
||||
$params = $_POST;
|
||||
$params['user'] = $this->user;
|
||||
switch(I('buy_type'))
|
||||
{
|
||||
// 正常购买
|
||||
case 'goods' :
|
||||
$ret = BuyService::BuyGoods($params);
|
||||
break;
|
||||
|
||||
// 购物车
|
||||
case 'cart' :
|
||||
$ret = BuyService::BuyCart($params);
|
||||
break;
|
||||
}
|
||||
|
||||
// 商品校验
|
||||
if(isset($ret['code']) && $ret['code'] == 0 && !empty($ret['data']))
|
||||
{
|
||||
// 用户地址
|
||||
$this->assign('user_address_list', UserService::UserAddressList(['user'=>$this->user])['data']);
|
||||
|
||||
// 快递
|
||||
$this->assign('express_list', ResourcesService::ExpressList());
|
||||
|
||||
// 支付方式
|
||||
$this->assign('payment_list', ResourcesService::PaymentList());
|
||||
|
||||
// 商品/基础信息
|
||||
$base = [
|
||||
'total_price' => empty($ret['data']) ? 0 : array_sum(array_column($ret['data'], 'total_price')),
|
||||
'total_stock' => empty($ret['data']) ? 0 : array_sum(array_column($ret['data'], 'stock')),
|
||||
'address' => UserService::UserDefaultAddress(['user'=>$this->user])['data'],
|
||||
];
|
||||
$this->assign('base', $base);
|
||||
$this->assign('goods_list', $ret['data']);
|
||||
|
||||
$this->display('Index');
|
||||
} else {
|
||||
$this->assign('msg', isset($ret['msg']) ? $ret['msg'] : L('common_param_error'));
|
||||
$this->display('/Public/TipsError');
|
||||
}
|
||||
} else {
|
||||
$this->assign('msg', L('common_unauthorized_access'));
|
||||
$this->display('/Public/TipsError');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -44,7 +44,7 @@ class CartController extends CommonController
|
||||
$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')),
|
||||
'ids' => empty($cart_list['data']) ? '' : implode(',', array_column($cart_list['data'], 'id')),
|
||||
];
|
||||
$this->assign('base', $base);
|
||||
$this->display('Index');
|
||||
|
||||
309
service/Application/Home/View/Default/Buy/Index.html
Normal file
309
service/Application/Home/View/Default/Buy/Index.html
Normal file
@ -0,0 +1,309 @@
|
||||
<include file="Public/Header" />
|
||||
|
||||
<!-- header top nav -->
|
||||
<include file="Public/HeaderTopNav" />
|
||||
|
||||
<!-- search -->
|
||||
<include file="Public/NavSearch" />
|
||||
|
||||
<!-- header nav -->
|
||||
<include file="Public/HeaderNav" />
|
||||
|
||||
<!-- goods category -->
|
||||
<include file="Public/GoodsCategory" />
|
||||
|
||||
<!-- content -->
|
||||
<div class="am-container category-list">
|
||||
|
||||
<!-- 地址 -->
|
||||
<div class="link-list">
|
||||
<div class="address">
|
||||
<div class="control">
|
||||
<h3>确认收货地址</h3>
|
||||
<button class="am-btn am-btn-danger am-btn-xs address-submit" type="button">使用新地址</button>
|
||||
</div>
|
||||
<notempty name="user_address_list">
|
||||
<ul class="address-list">
|
||||
<foreach name="user_address_list" item="address">
|
||||
<li class="<if condition="isset($address['is_default']) and $address['is_default'] eq 1">address-default</if>">
|
||||
<div class="address-left">
|
||||
<div class="user DefaultAddr">
|
||||
<span class="buy-address-detail">
|
||||
<span class="buy-user">{{$address.name}}</span>
|
||||
<span class="buy-phone">{{$address.tel}}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="default-address DefaultAddr">
|
||||
<span class="buy-line-title buy-line-title-type">收货地址:</span>
|
||||
<span class="buy--address-detail">
|
||||
<span class="province">{{$address.province_name}}</span>
|
||||
<span class="city">{{$address.city_name}}</span>
|
||||
<span class="dist">{{$address.county_name}}</span>
|
||||
<span class="street">{{$address.address}}</span>
|
||||
</span>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<if condition="isset($address['is_default']) and $address['is_default'] eq 1">
|
||||
<span class="deftip">默认地址</span>
|
||||
</if>
|
||||
</div>
|
||||
<div class="address-right">
|
||||
<a href="../person/address.html">
|
||||
<span class="am-icon-angle-right am-icon-lg"></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="new-addr-btn">
|
||||
<a href="#" class="hidden">设为默认</a>
|
||||
<span class="new-addr-bar hidden">|</span>
|
||||
<a href="#">编辑</a>
|
||||
<span class="new-addr-bar">|</span>
|
||||
<a href="javascript:void(0);" onclick="delClick(this);">删除</a>
|
||||
</div>
|
||||
</li>
|
||||
</foreach>
|
||||
</ul>
|
||||
</notempty>
|
||||
</div>
|
||||
|
||||
<!-- 物流 -->
|
||||
<div class="business-item logistics">
|
||||
<h3>选择物流方式</h3>
|
||||
<notempty name="express_list">
|
||||
<ul class="logistics-list">
|
||||
<foreach name="express_list" item="express">
|
||||
<li data-value="{{$express.id}}">
|
||||
<notempty name="express.icon">
|
||||
<img src="{{$express.icon}}" />
|
||||
</notempty>
|
||||
<span>{{$express.name}}</span>
|
||||
<i class="icon-active"></i>
|
||||
</li>
|
||||
</foreach>
|
||||
</ul>
|
||||
</notempty>
|
||||
</div>
|
||||
|
||||
<!-- 支付方式 -->
|
||||
<div class="business-item payment">
|
||||
<h3>选择支付方式</h3>
|
||||
<notempty name="payment_list">
|
||||
<ul class="payment-list">
|
||||
<foreach name="payment_list" item="payment">
|
||||
<li data-value="{{$payment.id}}">
|
||||
<notempty name="payment.logo">
|
||||
<img src="{{$payment.logo}}" />
|
||||
</notempty>
|
||||
<span>{{$payment.name}}</span>
|
||||
<i class="icon-active"></i>
|
||||
</li>
|
||||
</foreach>
|
||||
</ul>
|
||||
</notempty>
|
||||
</div>
|
||||
|
||||
<!--订单 -->
|
||||
<div class="concent">
|
||||
<div id="payTable">
|
||||
<h3>确认订单信息</h3>
|
||||
<!-- 商品列表 -->
|
||||
<table class="am-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品信息</th>
|
||||
<th class="am-hide-sm-only">单价</th>
|
||||
<th class="am-hide-sm-only">数量</th>
|
||||
<th class="am-hide-sm-only">金额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<foreach name="goods_list" item="goods">
|
||||
<tr id="data-list-{{$goods.id}}" data-id="{{$goods.id}}" data-goods-id="{{$goods.goods_id}}">
|
||||
<td class="base">
|
||||
<div class="goods-detail">
|
||||
<a href="{{$goods.goods_url}}" target="_blank">
|
||||
<img src="{{$goods.images}}">
|
||||
</a>
|
||||
<div class="goods-base">
|
||||
<a href="{{$goods.goods_url}}" target="_blank" class="goods-title">{{$goods.title}}</a>
|
||||
<notempty name="goods.attribute">
|
||||
<ul class="goods-attr">
|
||||
<foreach name="goods.attribute" item="attr">
|
||||
<li>{{$attr.attr_type_name}}:{{$attr.attr_name}}</li>
|
||||
</foreach>
|
||||
</ul>
|
||||
</notempty>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wap-base am-show-sm-only">
|
||||
<if condition="$goods['original_price'] gt 0">
|
||||
<span class="original-price">¥{{$goods.original_price}}</span>
|
||||
</if>
|
||||
<strong class="total-price-content">¥{{$goods.price}}</strong>
|
||||
<span class="wap-number">x{{$goods.stock}}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="price am-hide-sm-only">
|
||||
<if condition="$goods['original_price'] gt 0">
|
||||
<p class="original-price">¥{{$goods.original_price}}</p>
|
||||
</if>
|
||||
<p class="line-price">¥{{$goods.price}}</p>
|
||||
</td>
|
||||
<td class="number am-hide-sm-only">
|
||||
{{$goods.stock}} {{$goods.inventory_unit}}
|
||||
</td>
|
||||
<td class="total-price am-hide-sm-only">
|
||||
<strong class="total-price-content">¥{{$goods.total_price}}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</foreach>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="buy-message">
|
||||
<!--留言-->
|
||||
<div class="order-extra">
|
||||
<div class="order-user-info">
|
||||
<div id="holyshit257" class="memo">
|
||||
<label>买家留言:</label>
|
||||
<input type="text" title="选填,对本次交易的说明(建议填写已经和卖家达成一致的说明)" placeholder="选填,建议填写和卖家达成一致的说明" class="memo-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--含运费小计 -->
|
||||
<div class="buy-point-discharge ">
|
||||
<p class="price g_price ">
|
||||
合计(含运费) <span>¥</span><em class="pay-sum">{{$base.total_price}}</em>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!--信息 -->
|
||||
<div class="order-go clearfix">
|
||||
<div class="pay-confirm clearfix">
|
||||
<div class="box">
|
||||
<div tabindex="0" class="realPay">
|
||||
<em class="t">实付款:</em>
|
||||
<span class="price g_price">
|
||||
<span>¥</span>
|
||||
<em class="style-large-bold-red">{{$base.total_price}}</em>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="pay-address">
|
||||
<div class="buy-footer-address">
|
||||
<span class="buy-line-title buy-line-title-type">寄送至:</span>
|
||||
<span class="buy-address-detail">
|
||||
<if condition="!empty($base['address'])">
|
||||
{{$base.address.province_name}} {{$base.address.city_name}} {{$base.address.county_name}} {{$base.address.address}}
|
||||
<else />
|
||||
...
|
||||
</if>
|
||||
</span>
|
||||
</div>
|
||||
<div class="buy-footer-address">
|
||||
<span class="buy-line-title">收货人:</span>
|
||||
<span class="buy-user">
|
||||
<if condition="!empty($base['address'])">
|
||||
{{$base.address.name}}
|
||||
<else />
|
||||
...
|
||||
</if>
|
||||
</span>
|
||||
<span class="buy-phone">
|
||||
<if condition="!empty($base['address'])">
|
||||
{{$base.address.tel}}
|
||||
<else />
|
||||
...
|
||||
</if>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="holyshit269" class="submitOrder">
|
||||
<div class="go-btn-wrap">
|
||||
<a id="J_Go" href="success.html" class="btn-go" tabindex="0" title="点击此按钮,提交订单">提交订单</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="theme-popover-mask"></div>
|
||||
<div class="theme-popover">
|
||||
|
||||
<!--标题 -->
|
||||
<div class="am-cf am-padding">
|
||||
<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> / <small>Add address</small></div>
|
||||
</div>
|
||||
<hr/>
|
||||
|
||||
<div class="am-u-md-12">
|
||||
<form class="am-form am-form-horizontal">
|
||||
|
||||
<div class="am-form-group">
|
||||
<label for="user-name" class="am-form-label">收货人</label>
|
||||
<div class="am-form-content">
|
||||
<input type="text" id="user-name" placeholder="收货人">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label for="user-phone" class="am-form-label">手机号码</label>
|
||||
<div class="am-form-content">
|
||||
<input id="user-phone" placeholder="手机号必填" type="email">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label for="user-phone" class="am-form-label">所在地</label>
|
||||
<div class="am-form-content address">
|
||||
<select data-am-selected>
|
||||
<option value="a">浙江省</option>
|
||||
<option value="b">湖北省</option>
|
||||
</select>
|
||||
<select data-am-selected>
|
||||
<option value="a">温州市</option>
|
||||
<option value="b">武汉市</option>
|
||||
</select>
|
||||
<select data-am-selected>
|
||||
<option value="a">瑞安区</option>
|
||||
<option value="b">洪山区</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label for="user-intro" class="am-form-label">详细地址</label>
|
||||
<div class="am-form-content">
|
||||
<textarea class="" rows="3" id="user-intro" placeholder="输入详细地址"></textarea>
|
||||
<small>100字以内写出你的详细地址...</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group theme-poptit">
|
||||
<div class="am-u-sm-9 am-u-sm-push-3">
|
||||
<div class="am-btn am-btn-danger">保存</div>
|
||||
<div class="am-btn am-btn-danger close">取消</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <notempty name="goods_category_list">
|
||||
|
||||
<else />
|
||||
<div class="table-no"><i class="am-icon-warning"></i> {{:L('common_not_data_tips')}}</div>
|
||||
</notempty> -->
|
||||
</div>
|
||||
|
||||
<!-- footer start -->
|
||||
<include file="Public/Footer" />
|
||||
<!-- footer end -->
|
||||
@ -27,19 +27,19 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<foreach name="cart_list" item="cart">
|
||||
<tr id="data-list-{{$cart.id}}" data-id="{{$cart.id}}" data-goods-id="{{$cart.goods_id}}" class="<if condition="$cart['is_shelves'] neq 1">am-warning</if> <if condition="$cart['is_delete_time'] neq 0">am-danger</if>">
|
||||
<foreach name="cart_list" item="goods">
|
||||
<tr id="data-list-{{$goods.id}}" data-id="{{$goods.id}}" data-goods-id="{{$goods.goods_id}}" class="<if condition="$goods['is_shelves'] neq 1">am-warning</if> <if condition="$goods['is_delete_time'] neq 0">am-danger</if>">
|
||||
<td class="base">
|
||||
<input type="checkbox" value="{{$cart.id}}" <if condition="$cart['is_shelves'] neq 1 or $cart['is_delete_time'] neq 0">disabled</if> />
|
||||
<input type="checkbox" value="{{$goods.id}}" <if condition="$goods['is_shelves'] neq 1 or $goods['is_delete_time'] neq 0">disabled</if> />
|
||||
<div class="goods-detail">
|
||||
<a href="{{$cart.goods_url}}" target="_blank">
|
||||
<img src="{{$cart.images}}">
|
||||
<a href="{{$goods.goods_url}}" target="_blank">
|
||||
<img src="{{$goods.images}}">
|
||||
</a>
|
||||
<div class="goods-base">
|
||||
<a href="{{$cart.goods_url}}" target="_blank" class="goods-title">{{$cart.title}}</a>
|
||||
<notempty name="cart.attribute">
|
||||
<a href="{{$goods.goods_url}}" target="_blank" class="goods-title">{{$goods.title}}</a>
|
||||
<notempty name="goods.attribute">
|
||||
<ul class="goods-attr">
|
||||
<foreach name="cart.attribute" item="attr">
|
||||
<foreach name="goods.attribute" item="attr">
|
||||
<li>{{$attr.attr_type_name}}:{{$attr.attr_name}}</li>
|
||||
</foreach>
|
||||
</ul>
|
||||
@ -47,37 +47,37 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="wap-base am-show-sm-only">
|
||||
<if condition="$cart['original_price'] gt 0">
|
||||
<span class="original-price">¥{{$cart.original_price}}</span>
|
||||
<if condition="$goods['original_price'] gt 0">
|
||||
<span class="original-price">¥{{$goods.original_price}}</span>
|
||||
</if>
|
||||
<strong class="total-price-content">¥{{$cart.price}}</strong>
|
||||
<span class="wap-number">x{{$cart.stock}}</span>
|
||||
<strong class="total-price-content">¥{{$goods.price}}</strong>
|
||||
<span class="wap-number">x{{$goods.stock}}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="price am-hide-sm-only">
|
||||
<if condition="$cart['original_price'] gt 0">
|
||||
<p class="original-price">¥{{$cart.original_price}}</p>
|
||||
<if condition="$goods['original_price'] gt 0">
|
||||
<p class="original-price">¥{{$goods.original_price}}</p>
|
||||
</if>
|
||||
<p class="line-price">¥{{$cart.price}}</p>
|
||||
<p class="line-price">¥{{$goods.price}}</p>
|
||||
</td>
|
||||
<td class="number am-hide-sm-only">
|
||||
<div class="am-input-group am-input-group-sm stock-tag" data-inventory="{{$cart.inventory}}" data-price="{{$cart.price}}" data-ajax-url="{{:U('Home/Cart/Stock')}}">
|
||||
<span class="am-input-group-label <if condition="$cart['is_shelves'] eq 1 and $cart['is_delete_time'] eq 0">stock-submit</if>" data-type="min">-</span>
|
||||
<input type="text" class="am-form-field" value="{{$cart.stock}}" <if condition="$cart['is_shelves'] neq 1 or $cart['is_delete_time'] neq 0">disabled</if> />
|
||||
<span class="am-input-group-label <if condition="$cart['is_shelves'] eq 1 and $cart['is_delete_time'] eq 0">stock-submit</if>" data-type="add">+</span>
|
||||
<div class="am-input-group am-input-group-sm stock-tag" data-inventory="{{$goods.inventory}}" data-price="{{$goods.price}}" data-ajax-url="{{:U('Home/Cart/Stock')}}">
|
||||
<span class="am-input-group-label <if condition="$goods['is_shelves'] eq 1 and $goods['is_delete_time'] eq 0">stock-submit</if>" data-type="min">-</span>
|
||||
<input type="text" class="am-form-field" value="{{$goods.stock}}" <if condition="$goods['is_shelves'] neq 1 or $goods['is_delete_time'] neq 0">disabled</if> />
|
||||
<span class="am-input-group-label <if condition="$goods['is_shelves'] eq 1 and $goods['is_delete_time'] eq 0">stock-submit</if>" data-type="add">+</span>
|
||||
</div>
|
||||
<if condition="$cart['is_shelves'] neq 1">
|
||||
<if condition="$goods['is_shelves'] neq 1">
|
||||
<p>商品已下架</p>
|
||||
</if>
|
||||
<if condition="$cart['is_delete_time'] neq 0">
|
||||
<if condition="$goods['is_delete_time'] neq 0">
|
||||
<p>商品已作废</p>
|
||||
</if>
|
||||
</td>
|
||||
<td class="total-price am-hide-sm-only">
|
||||
<strong class="total-price-content">¥{{$cart.total_price}}</strong>
|
||||
<strong class="total-price-content">¥{{$goods.total_price}}</strong>
|
||||
</td>
|
||||
<td class="operation">
|
||||
<a href="javascript:;" class="submit-delete" data-url="{{:U('Home/Cart/Delete')}}" data-id="{{$cart.id}}">删除</a>
|
||||
<a href="javascript:;" class="submit-delete" data-url="{{:U('Home/Cart/Delete')}}" data-id="{{$goods.id}}">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</foreach>
|
||||
@ -94,10 +94,14 @@
|
||||
<a href="javascript:;" class="submit-ajax" data-url="{{:U('Home/Cart/Delete')}}" data-id="{{$base.ids}}" data-view="reload" data-msg="清空后不可恢复、确认操作吗?">清空</a>
|
||||
</div>
|
||||
<div class="am-fr nav-right">
|
||||
<span class="selected-tips am-fl">已选商品 <strong>0</strong> 件</span>
|
||||
<span class="total-price-tips am-fl">合计:</span>
|
||||
<strong class="nav-total-price am-fl">¥0.00</strong>
|
||||
<button type="button" class="am-btn am-btn-primary separate-submit">结算</button>
|
||||
<form action="{{:U('Home/Buy/Index')}}" method="post">
|
||||
<span class="selected-tips am-fl">已选商品 <strong>0</strong> 件</span>
|
||||
<span class="total-price-tips am-fl">合计:</span>
|
||||
<strong class="nav-total-price am-fl">¥0.00</strong>
|
||||
<input type="hidden" name="ids" value="0" />
|
||||
<input type="hidden" name="buy_type" value="cart" />
|
||||
<button type="submit" class="am-btn am-btn-primary separate-submit">结算</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<else />
|
||||
|
||||
@ -184,6 +184,15 @@
|
||||
<button title="加入购物车" href="javascript:;" type="button"><i></i>加入购物车</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 购买表单 -->
|
||||
<form action="{{:U('Home/Buy/Index')}}" method="post" class="buy-form">
|
||||
<input type="hidden" name="goods_id" value="{{$goods.id}}" />
|
||||
<input type="hidden" name="buy_type" value="goods" />
|
||||
<input type="hidden" name="stock" value="1" />
|
||||
<input type="hidden" name="attr" value="" />
|
||||
<button type="submit"></button>
|
||||
</form>
|
||||
<else />
|
||||
<p class="shelves-tips">商品已下架</p>
|
||||
</if>
|
||||
@ -214,7 +223,7 @@
|
||||
</li>
|
||||
</foreach>
|
||||
</if>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="introduce-main">
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
namespace Service;
|
||||
|
||||
use Service\GoodsService;
|
||||
|
||||
/**
|
||||
* 购买服务层
|
||||
* @author Devil
|
||||
@ -55,24 +57,7 @@ class BuyService
|
||||
}
|
||||
|
||||
// 属性处理
|
||||
$attr = [];
|
||||
if(!empty($params['attr']) && is_array($params['attr']))
|
||||
{
|
||||
foreach($params['attr'] as $k=>$v)
|
||||
{
|
||||
$attr_type_name = M('GoodsAttributeType')->where(['goods_id'=>$goods_id, 'id'=>$k])->getField('name');
|
||||
$attr_name = M('GoodsAttribute')->where(['goods_id'=>$goods_id, 'id'=>$v])->getField('name');
|
||||
if(!empty($attr_type_name) && !empty($attr_name))
|
||||
{
|
||||
$attr[] = [
|
||||
'attr_type_id' => $k,
|
||||
'attr_type_name' => $attr_type_name,
|
||||
'attr_id' => $v,
|
||||
'attr_name' => $attr_name,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$attr = self::GoodsAttrParsing($params);
|
||||
|
||||
// 添加购物车
|
||||
$data = [
|
||||
@ -109,6 +94,38 @@ class BuyService
|
||||
return DataReturn(L('common_join_error'), -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品属性解析
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-21
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
private static function GoodsAttrParsing($params = [])
|
||||
{
|
||||
$data = [];
|
||||
if(!empty($params['attr']) && is_array($params['attr']) && !empty($params['goods_id']))
|
||||
{
|
||||
foreach($params['attr'] as $k=>$v)
|
||||
{
|
||||
$attr_type_name = M('GoodsAttributeType')->where(['goods_id'=>$params['goods_id'], 'id'=>$k])->getField('name');
|
||||
$attr_name = M('GoodsAttribute')->where(['goods_id'=>$params['goods_id'], 'id'=>$v])->getField('name');
|
||||
if(!empty($attr_type_name) && !empty($attr_name))
|
||||
{
|
||||
$data[] = [
|
||||
'attr_type_id' => $k,
|
||||
'attr_type_name' => $attr_type_name,
|
||||
'attr_id' => $v,
|
||||
'attr_name' => $attr_name,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取购物车列表
|
||||
* @author Devil
|
||||
@ -134,10 +151,10 @@ class BuyService
|
||||
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';
|
||||
$where = (!empty($params['where']) && is_array($params['where'])) ? $params['where'] : [];
|
||||
$where['c.user_id'] = $params['user']['id'];
|
||||
|
||||
$field = 'c.*, g.title, g.images, g.original_price, g.price, g.inventory, g.inventory_unit, 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))
|
||||
{
|
||||
@ -251,5 +268,113 @@ class BuyService
|
||||
}
|
||||
return DataReturn(L('common_operation_update_error'), -100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下订单 - 正常购买
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-21
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function BuyGoods($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'stock',
|
||||
'error_msg' => '购买数量有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'goods_id',
|
||||
'error_msg' => '商品id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'isset',
|
||||
'key_name' => 'attr',
|
||||
'error_msg' => '属性参数有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user',
|
||||
'error_msg' => '用户信息有误',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 获取商品
|
||||
$p = [
|
||||
'where' => [
|
||||
'g.id' => intval($params['goods_id']),
|
||||
'g.is_delete_time' => 0,
|
||||
'g.is_shelves' => 1,
|
||||
],
|
||||
'field' => 'g.id, g.id AS goods_id, g.title, g.images, g.original_price, g.price, g.inventory, g.inventory_unit',
|
||||
];
|
||||
$goods = GoodsService::GoodsList($p);
|
||||
if(empty($goods[0]))
|
||||
{
|
||||
return DataReturn(L('common_data_no_exist_error'), -10);
|
||||
}
|
||||
|
||||
// 数量/小计
|
||||
$goods[0]['stock'] = $params['stock'];
|
||||
$goods[0]['total_price'] = $params['stock']*$goods[0]['price'];
|
||||
|
||||
// 属性
|
||||
if(!empty($params['attr']))
|
||||
{
|
||||
$params['attr'] = json_decode($params['attr'], true);
|
||||
}
|
||||
$goods[0]['attribute'] = self::GoodsAttrParsing($params);
|
||||
|
||||
return DataReturn(L('common_operation_success'), 0, $goods);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下订单 - 购物车
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-21
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function BuyCart($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'ids',
|
||||
'error_msg' => '购物车id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user',
|
||||
'error_msg' => '用户信息有误',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 获取购物车数据
|
||||
$params['where'] = [
|
||||
'g.is_delete_time' => 0,
|
||||
'g.is_shelves' => 1,
|
||||
'c.id' => ['in', explode(',', $params['ids'])],
|
||||
];
|
||||
return self::CartList($params);
|
||||
}
|
||||
}
|
||||
?>
|
||||
76
service/Application/Service/ResourcesService.class.php
Normal file
76
service/Application/Service/ResourcesService.class.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Service;
|
||||
|
||||
/**
|
||||
* 资源服务层
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class ResourcesService
|
||||
{
|
||||
/**
|
||||
* 获取地区名称
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function RegionName($params = [])
|
||||
{
|
||||
return M('Region')->where(['id'=>intval($params['region_id'])])->getField('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* 快递列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function ExpressList($params = [])
|
||||
{
|
||||
$where = ['is_enable'=>1];
|
||||
$data = M('Express')->where($where)->field('id,icon,name,sort')->order('sort asc')->select();
|
||||
if(!empty($data) && is_array($data))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['icon'] = empty($v['icon']) ? null : $images_host.$v['icon'];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付方式列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-19
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function PaymentList($params = [])
|
||||
{
|
||||
$where = ['is_enable'=>1];
|
||||
$data = M('Payment')->where($where)->field('id,logo,name,sort,payment')->order('sort asc')->select();
|
||||
if(!empty($data) && is_array($data))
|
||||
{
|
||||
$images_host = C('IMAGE_HOST');
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['logo'] = empty($v['logo']) ? null : $images_host.$v['logo'];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
?>
|
||||
95
service/Application/Service/UserService.class.php
Normal file
95
service/Application/Service/UserService.class.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Service;
|
||||
|
||||
use Service\ResourcesService;
|
||||
|
||||
/**
|
||||
* 用户服务层
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class UserService
|
||||
{
|
||||
/**
|
||||
* 用户地址列表列表
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function UserAddressList($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user',
|
||||
'error_msg' => '用户信息有误',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
$where = (!empty($params['where']) && is_array($params['where'])) ? $params['where'] : [];
|
||||
$where['user_id'] = $params['user']['id'];
|
||||
$where['is_delete_time'] = 0;
|
||||
|
||||
// 获取用户地址
|
||||
$field = 'id,alias,name,tel,province,city,county,address,lng,lat,is_default';
|
||||
$data = M('UserAddress')->where($where)->field($field)->order('id desc')->select();
|
||||
if(!empty($data))
|
||||
{
|
||||
foreach($data as &$v)
|
||||
{
|
||||
$v['province_name'] = ResourcesService::RegionName(['region_id'=>$v['province']]);
|
||||
$v['city_name'] = ResourcesService::RegionName(['region_id'=>$v['city']]);
|
||||
$v['county_name'] = ResourcesService::RegionName(['region_id'=>$v['county']]);
|
||||
}
|
||||
}
|
||||
return DataReturn(L('common_operation_success'), 0, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户默认地址
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-08-29
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function UserDefaultAddress($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user',
|
||||
'error_msg' => '用户信息有误',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 获取用户地址
|
||||
$params['where'] = ['is_default'=>1];
|
||||
$ret = self::UserAddressList($params);
|
||||
if(!empty($ret['data'][0]))
|
||||
{
|
||||
$ret['data'] = $ret['data'][0];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
?>
|
||||
211
service/Public/Home/Default/Css/Buy.css
Normal file
211
service/Public/Home/Default/Css/Buy.css
Normal file
@ -0,0 +1,211 @@
|
||||
.hidden { display: none !important;}
|
||||
.address-default { display:block !important;}
|
||||
/*地址管理*/
|
||||
.concent h3,.business-item h3{border-bottom: 2px solid #e7c3c8; margin-top:15px;}
|
||||
h3 { font-size: 14px;font-weight: 700;}
|
||||
.address h3 { border-bottom:none;}
|
||||
ul.address-list li{display:none;width:100%;padding:10px;position: relative;min-height:80px;}
|
||||
.address-left{ width:90%;float:left;position: relative;}
|
||||
.user.DefaultAddr {font-size: 14px;font-weight: 700;}
|
||||
.address-right{ float:right; margin-right:5px;padding-top:15px ;}
|
||||
.deftip {position: absolute;top: 0px;right: 0px;padding: 0px 2px;text-decoration: none;opacity: 0.7; z-index: 3;background: #CCC none repeat scroll 0% 0%;
|
||||
color: #FFF;}
|
||||
|
||||
/*地址操作-编辑删除*/
|
||||
.new-addr-btn {display:none;font-size: 12px;color: #282828;text-align: right; padding-right:5px ;}
|
||||
.new-addr-bar {padding: 0px 5px;vertical-align: top;}
|
||||
|
||||
/*物流*/
|
||||
.business-item ul li { border:1px solid transparent ;overflow: hidden; }
|
||||
ul.logistics-list li.selected, ul.payment-list li.selected {border-color:#d2364c ;position:relative ;}
|
||||
ul.logistics-list li.selected i.icon-active, ul.payment-list li.selected i.icon-active {
|
||||
position: absolute;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
background: url(../images/sys_item_selected.gif) no-repeat right bottom;
|
||||
}
|
||||
.business-item ul { padding: 10px 3px 5px 5px;}
|
||||
.business-item ul li { float: left; cursor: pointer; padding: 5px; border: 1px solid #eee; }
|
||||
ul.logistics-list li img, ul.payment-list li img { width: 36px; height: 36px; }
|
||||
.business-item ul li { margin: 0 10px 10px 0; }
|
||||
|
||||
/*运费、留言*/
|
||||
.buy-message{padding:0px 5px}
|
||||
.td.td-oplist .pay-logis,.td.td-bonus select{position:absolute;top:6px;right:0;}
|
||||
.memo-input{width:calc(100% - 64px);border: 1px solid #ccc;padding: 5px;outline:none;border-radius: 2px;}
|
||||
|
||||
/*合计*/
|
||||
.buy-point-discharge{font-size:14px ;font-weight: 700;padding:10px 0px;text-align: right;}
|
||||
.pay-sum{color:#F64000;margin-left:5px ;}
|
||||
|
||||
.pay-confirm.clearfix{width: 100%;}
|
||||
.box{float:left;width:70%;height:40px ;line-height:40px ;font-size: 14px;text-align: right;padding-right:10px ;}
|
||||
.pay-address{display: none;}
|
||||
.submitOrder a{float:left;width:30%;color:#fff ;background:#f40 ;text-align: center;height:40px ;line-height:40px ;font-size: 14px;}
|
||||
|
||||
.td.td-coupon select, .td.td-bonus select{border-color:#CCC;line-height: 24px;height:24px;margin-top:4px;}
|
||||
.coupon-title,.bonus-title{line-height: 24px;height:24px}
|
||||
.order-go{position: fixed;bottom: 0;width:100% ;background: #fff;border-top:1px solid #F5F5F5 ;}
|
||||
|
||||
.theme-popover{display: none;}
|
||||
|
||||
.link-list h3 { padding: 0 0 5px 5px; }
|
||||
ul.address-list, .business-item ul { overflow: hidden; }
|
||||
|
||||
@media only screen and (min-width:640px)
|
||||
{
|
||||
.pay-way{float: right;}
|
||||
#payTable .th{border-top: none;}
|
||||
.th .td-inner{padding-left:0px ;}
|
||||
.wp{padding: 0px 10px;background: #F5F5F5;}
|
||||
/*地址操作*/
|
||||
.address { padding: 0 1px 0 5px; }
|
||||
.address .control { margin-bottom: 10px; }
|
||||
.address .control h3{ display: -webkit-inline-box; border: none;margin-top:20px; }
|
||||
.am-form-content {margin-left:75px;}
|
||||
.am-form-label {width:60px;float: left;}
|
||||
.link-list{ margin:10px; }
|
||||
.link-list h3 {padding-bottom:5px;}
|
||||
|
||||
/*物流*/
|
||||
.business-item ul li {width:calc(25% - 8px); }
|
||||
.business-item ul li:nth-child(4n) { margin-right: 0; }
|
||||
|
||||
|
||||
/*订单管理*/
|
||||
|
||||
.td.td-info {width: 50%;}
|
||||
.pay-phone{overflow:visible;padding-bottom:0px;margin-bottom:0px;}
|
||||
.th.th-item,.td.td-amount .amount-wrapper .sl{text-align: center;width: auto;}
|
||||
.item-content .price-now {line-height:18px ;font-size:12px ;font-weight: 100;}
|
||||
|
||||
.th.th-item{width:50%;margin-right:0;}
|
||||
.th.th-price, .td.td-price ,.th.th-sum, .td.td-sum {width: 10%;}
|
||||
.th.th-amount, .td.td-amount {width:20%;}
|
||||
.th.th-oplist,.td.td-oplist{width:10%;text-align: center;padding-left:0 ;}
|
||||
|
||||
/*文字说明布局*/
|
||||
.td.td-amount .phone-title,.td.td-oplist .phone-title{display: none;}
|
||||
.td.td-oplist .pay-logis,.td.td-amount .sl,.td.td-coupon select,.td.td-bonus select{position: static;}
|
||||
.td.td-amount .amount-wrapper, .td.td-oplist{padding:0px ; border: none;}
|
||||
|
||||
/*留言*/
|
||||
.buy-message{border:1px solid #eee; overflow: hidden;padding: 10px; margin: 0 5px;}
|
||||
.order-extra{border: none;float: left;width: 60%;}
|
||||
.memo-input{min-width:280px ;width:80%; }
|
||||
|
||||
/*带个人信息的结算*/
|
||||
.box ,.submitOrder a{float:right;width:auto;height:auto;padding:10px 10px;}
|
||||
.pay-address{display:block;}
|
||||
.box{font-size:12px;overflow: hidden;border: 2px solid #f40;}
|
||||
|
||||
.order-go {clear: both;text-align: right;position: relative;margin-top: 10px;border: none;}
|
||||
.order-go .address-confirm .box{position: relative;float: right;z-index: 100;padding-right:2%; padding-bottom:10px;border: 1px solid #f50;font-family: tahoma;display: inline-block;right: 0;background-color: #fff0e8;}
|
||||
|
||||
.submitOrder .go-btn-wrap {width:100%;overflow: hidden;padding-top:10px;margin-bottom: 10px;}
|
||||
.submitOrder .btn-go {display: block;padding: 0 26px;height: 36px;font: 400 18px/36px arial;font-size: 18px;background-color: #f50;color: #fff;text-align: center;cursor: pointer;outline: 0; z-index:999;}
|
||||
.realPay {line-height: 16px;margin: 0px 0px 15px;position: relative;}
|
||||
.realPay .g_price span {font-size: 26px;}
|
||||
.price .style-large-bold-red {color: #FF4200;font: 700 26px tahoma;}
|
||||
.order-go .buy-footer-address .buy-line-title {color: #404040;font-weight: 700;}
|
||||
.td.td-coupon select, .td.td-bonus select {margin-top:0 ;}
|
||||
|
||||
|
||||
.theme-popover-mask{z-index:10000000;position:fixed;left:0;top:0;width:100%;height:100%;background:#000;opacity:0.5;filter:alpha(opacity=50);-moz-opacity:0.5;display:none;}
|
||||
.theme-popover{z-index:10000009;position:fixed;bottom:50%;left:50%;width:500px;height:400px;margin-bottom:-200px;margin-left:-250px;display:none;background:#fff;overflow: hidden;}
|
||||
.theme-poptit{padding:12px;position:relative;}
|
||||
.theme-poptit .close:hover{color:#444;}
|
||||
|
||||
.theme-popover .am-form-content.address select{width:32.3333%;margin-right:1%;float: left;}
|
||||
.am-padding { padding: 10px 10px;}
|
||||
hr {margin: 5px 0px;}
|
||||
.am-form-group {margin-bottom: 10px}
|
||||
|
||||
|
||||
.td.td-amount{margin-top: 15px}
|
||||
|
||||
|
||||
.link-list{margin:0px auto;}
|
||||
/*地址管理*/
|
||||
.address ul{margin-top:10px ;}
|
||||
ul.address-list li{display:block; width: calc(33% - 5px);height: 150px;float: left;background-image: url(../images/peraddbg.png); background-repeat: no-repeat; background-size: 100% 100%; margin:0 10px 10px 0 ;padding:10px;}
|
||||
ul.address-list li.address-default{background-image: url(../images/peraddressbg.png);}
|
||||
ul.address-list li:nth-child(3n) { margin-right: 0; }
|
||||
.address-left{ width:100%;position: relative;}
|
||||
.th .td-inner{padding-left:0 ;}
|
||||
|
||||
/*地址操作*/
|
||||
.new-addr-btn {display:block;position: absolute;bottom:25px ;right:10px ;}
|
||||
.new-addr-bar {padding: 0px 5px;vertical-align: top;}
|
||||
|
||||
.td.td-item ,.td.td-info{width: 50%;}
|
||||
.td.td-info{position: absolute;margin-top:0px;}
|
||||
.td.td-info .item-props{text-align: left;padding-top:0px ;}
|
||||
.address-right .am-icon-angle-right { display: none; }
|
||||
}
|
||||
|
||||
@media only screen and (min-width:1025px)
|
||||
{
|
||||
.link-list{ margin:0; }
|
||||
ul.address-list li { width: calc(25% - 8px); }
|
||||
ul.address-list li:nth-child(4n) { margin-right: 0; }
|
||||
ul.address-list li:nth-child(3n) { margin-right: 10px; }
|
||||
.address { padding: 0; }
|
||||
|
||||
.business-item ul li { width: calc(20% - 8px); }
|
||||
.business-item ul li:nth-child(5n) { margin-right: 0; }
|
||||
.business-item ul li:nth-child(4n) { margin-right: 10px; }
|
||||
.business-item ul { padding: 10px 0 0 0; }
|
||||
.link-list h3 { padding: 0 0 5px 0; }
|
||||
.buy-message { margin: 0; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width:640px)
|
||||
{
|
||||
.address { margin-top: 10px; padding-top: 10px; }
|
||||
.address, .buy-message { border-top: 1px solid #eee; }
|
||||
.address .control { display: none; }
|
||||
.address-default {background: url(../images/peraddress.png) repeat-x; background-position: bottom; }
|
||||
ul.address-list li { padding: 0 5px; min-height: 65px; }
|
||||
|
||||
.business-item ul li { width: calc(50% - 6px); }
|
||||
.business-item ul li:nth-child(2n) { margin-right: 0; }
|
||||
.buy-message { padding-top: 10px; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
.goods-detail img { width: 80px; height: 80px; }
|
||||
.goods-detail { position: relative; }
|
||||
.goods-title { display: block; max-height: 36px; overflow: hidden; text-overflow: ellipsis; }
|
||||
.goods-title:hover { text-decoration: underline; }
|
||||
.goods-base { position: absolute; top: 0; left: 85px; }
|
||||
.goods-attr { margin-top: 5px; }
|
||||
.goods-attr li { color: #888; line-height: 16px; }
|
||||
.original-price, .line-price { font-family: Verdana,Tahoma,arial; }
|
||||
.original-price { color: #9c9c9c; text-decoration: line-through; }
|
||||
.line-price { color: #3c3c3c; }
|
||||
.line-price, strong.total-price-content { font-weight: 700; }
|
||||
strong.total-price-content { color: #d2364c; font-size: 16px; }
|
||||
.am-table { margin-bottom: 10px; }
|
||||
.am-table > tbody > tr > td { border-top: 1px solid #F5F5F5; }
|
||||
.am-table > thead > tr > th { border-bottom: 1px solid #f7f7f7; }
|
||||
@media only screen and (min-width:640px) {
|
||||
.cart-content table tr .base { width: 40%; }
|
||||
.cart-content table tr .price { width: 20%; }
|
||||
.cart-content table tr .number { width: 20%; }
|
||||
.cart-content table tr .total-price { width: 20%; }
|
||||
.cart-content { margin-top: 20px; }
|
||||
}
|
||||
|
||||
@media only screen and (max-width:640px) {
|
||||
.cart-content table tr .base { width: 100%; }
|
||||
}
|
||||
|
||||
|
||||
@ -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.buy-event{display:none}
|
||||
.theme-popover .theme-poptit h3,.btn.close,i.buy-event, form.buy-form {display:none}
|
||||
.theme-span{width:100%;background:transparent;height: 15px;}
|
||||
.theme-popbod.dform{background:#fff;}
|
||||
/*商品信息*/
|
||||
|
||||
47
service/Public/Home/Default/Js/Buy.js
Normal file
47
service/Public/Home/Default/Js/Buy.js
Normal file
@ -0,0 +1,47 @@
|
||||
$(function() {
|
||||
// 地址选择
|
||||
$('ul.address-list li').click(function() {
|
||||
$(this).addClass("address-default").siblings().removeClass("address-default");
|
||||
});
|
||||
|
||||
// 混合列表选择
|
||||
$('.business-item ul li').on('click', function() {
|
||||
if ($(this).hasClass('selected')) {
|
||||
$(this).removeClass('selected');
|
||||
} else {
|
||||
$(this).addClass('selected').siblings("li").removeClass('selected');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 弹出地址选择
|
||||
|
||||
|
||||
var $ww = $(window).width();
|
||||
|
||||
$('.address-submit').click(function() {
|
||||
// 禁止遮罩层下面的内容滚动
|
||||
$(document.body).css("overflow","hidden");
|
||||
|
||||
$(this).addClass("selected");
|
||||
$(this).parent().addClass("selected");
|
||||
|
||||
|
||||
$('.theme-popover-mask').show();
|
||||
$('.theme-popover-mask').height($(window).height());
|
||||
$('.theme-popover').slideDown(200);
|
||||
|
||||
})
|
||||
|
||||
$('.theme-poptit .close,.btn-op .close').click(function() {
|
||||
|
||||
$(document.body).css("overflow","visible");
|
||||
$('.address-submit').removeClass("selected");
|
||||
$('.item-props-can').removeClass("selected");
|
||||
$('.theme-popover-mask').hide();
|
||||
$('.theme-popover').slideUp(200);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@ -5,6 +5,7 @@ $(function()
|
||||
{
|
||||
var total_stock = 0;
|
||||
var total_price = 0.00;
|
||||
var ids = [];
|
||||
$('.am-table input[type="checkbox"]').each(function(k, v)
|
||||
{
|
||||
if($(this).prop('checked'))
|
||||
@ -13,11 +14,12 @@ $(function()
|
||||
var price = parseFloat($(this).parents('tr').find('.stock-tag').data('price'));
|
||||
total_stock += stock;
|
||||
total_price += stock*price;
|
||||
ids.push($(this).val());
|
||||
}
|
||||
});
|
||||
$('.cart-nav .selected-tips strong').text(total_stock);
|
||||
$('.cart-nav .nav-total-price').text('¥'+FomatFloat(total_price));
|
||||
console.log(total_stock, total_price)
|
||||
$('.cart-nav input[name="ids"]').val(ids.toString() || 0);
|
||||
}
|
||||
|
||||
// 购物车数量操作
|
||||
@ -140,4 +142,19 @@ $(function()
|
||||
cart_nav_pop();
|
||||
});
|
||||
|
||||
// 结算事件
|
||||
$('.separate-submit').on('click', function()
|
||||
{
|
||||
// 计算选择的商品总数和总价
|
||||
cart_base_total();
|
||||
|
||||
// 获取购物车id
|
||||
var ids = $(this).parents('form').find('input[name="ids"]').val() || 0;
|
||||
if(ids == 0)
|
||||
{
|
||||
Prompt('请选择商品');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@ -61,7 +61,10 @@ function CartAdd(e)
|
||||
{
|
||||
// 立即购买
|
||||
case 'buy' :
|
||||
alert('buy - stock:'+stock+' , attr:'+ JSON.stringify(attr));
|
||||
var $form_buy = $('form.buy-form');
|
||||
$form_buy.find('input[name="attr"]').val(JSON.stringify(attr));
|
||||
$form_buy.find('input[name="stock"]').val(stock);
|
||||
$form_buy.find('button[type="submit"]').trigger('click');
|
||||
break;
|
||||
|
||||
// 加入购物车
|
||||
|
||||
Reference in New Issue
Block a user