提交 4c985184 编写于 作者: G gongfuxiang

buy

上级 84d23725
...@@ -189,7 +189,7 @@ textarea { ...@@ -189,7 +189,7 @@ textarea {
font-size: 32rpx; font-size: 32rpx;
} }
.original-price { .original-price {
color: #ccc; color: #888;
font-size: 26rpx; font-size: 26rpx;
text-decoration: line-through; text-decoration: line-through;
margin-left: 10rpx; margin-left: 10rpx;
......
...@@ -47,7 +47,7 @@ App({ ...@@ -47,7 +47,7 @@ App({
// 请求地址 // 请求地址
request_url: "https://demo.shopxo.net/", request_url: "https://demo.shopxo.net/",
//request_url: 'http://localhost/project/shopxo/service/', request_url: 'http://localhost/project/shopxo/service/',
// 基础信息 // 基础信息
application_title: "ShopXO电商系统", application_title: "ShopXO电商系统",
......
<view a:if="{{goods.length > 0}}" class="page"> <view a:if="{{goods_list.length > 0}}" class="page">
<view class="address bg-white arrow-right"> <view class="address bg-white arrow-right">
<navigator url="/pages/user-address/user-address?is_back=1" hover-class="none"> <navigator url="/pages/user-address/user-address?is_back=1" hover-class="none">
<view a:if="{{address != null}}"> <view a:if="{{address != null}}">
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<view class="address-divider spacing-mb"></view> <view class="address-divider spacing-mb"></view>
<view class="goods bg-white spacing-mb"> <view class="goods bg-white spacing-mb">
<view a:for="{{goods}}" class="goods-item oh"> <view a:for="{{goods_list}}" class="goods-item oh">
<image class="goods-image fl" src="{{item.images_url}}" mode="aspectFill" /> <image class="goods-image fl" src="{{item.images_url}}" mode="aspectFill" />
<view class="goods-base"> <view class="goods-base">
<view class="goods-title multi-text">{{item.title}}</view> <view class="goods-title multi-text">{{item.title}}</view>
......
...@@ -5,7 +5,8 @@ Page({ ...@@ -5,7 +5,8 @@ Page({
buy_submit_disabled_status: false, buy_submit_disabled_status: false,
data_list_loding_msg: '', data_list_loding_msg: '',
params: null, params: null,
goods: [], address_list: [],
goods_list: [],
address: null, address: null,
is_first: 1, is_first: 1,
address_id: 0, address_id: 0,
...@@ -17,14 +18,14 @@ Page({ ...@@ -17,14 +18,14 @@ Page({
{ {
my.alert({ my.alert({
title: '温馨提示', title: '温馨提示',
content: '商品信息有误', content: '订单信息有误',
buttonText: '确认', buttonText: '确认',
success: () => { success: () => {
my.navigateBack(); my.navigateBack();
}, },
}); });
} else { } else {
this.setData({params: params.data}); this.setData({ params: JSON.parse(params.data)});
// 删除地址缓存 // 删除地址缓存
my.removeStorageSync({key: app.data.cache_buy_user_address_select_key}); my.removeStorageSync({key: app.data.cache_buy_user_address_select_key});
...@@ -54,36 +55,38 @@ Page({ ...@@ -54,36 +55,38 @@ Page({
} }
} }
var self = this;
// 加载loding // 加载loding
my.showLoading({content: '加载中...'}); my.showLoading({content: '加载中...'});
this.setData({ this.setData({
data_list_loding_status: 1 data_list_loding_status: 1
}); });
var data = this.data.params;
data['address_id'] = this.data.address_id;
my.httpRequest({ my.httpRequest({
url: app.get_request_url("Index", "Buy"), url: app.get_request_url("Index", "Buy"),
method: "POST", method: "POST",
data: {goods: this.data.params, address_id: this.data.address_id}, data: data,
dataType: "json", dataType: "json",
success: res => { success: res => {
my.hideLoading(); my.hideLoading();
if (res.data.code == 0) { if (res.data.code == 0) {
var data = res.data.data; var data = res.data.data;
if(data.goods.length == 0) if (data.goods_list.length == 0)
{ {
self.setData({data_list_loding_status: 0}); this.setData({data_list_loding_status: 0});
} else { } else {
self.setData({ this.setData({
goods: data.goods, goods_list: data.goods_list,
total_price: data.total_price, address_list: data.user_address_list,
address: data.address, total_price: data.base.total_price,
address_id: ((data.address || null) == null) ? 0 : data.address.id, address: data.base.address,
address_id: ((data.base.address || null) == null) ? 0 : data.base.address.id,
data_list_loding_status: 3, data_list_loding_status: 3,
}); });
} }
} else { } else {
self.setData({ this.setData({
data_list_loding_status: 2, data_list_loding_status: 2,
data_list_loding_msg: res.data.msg, data_list_loding_msg: res.data.msg,
}); });
...@@ -95,7 +98,7 @@ Page({ ...@@ -95,7 +98,7 @@ Page({
}, },
fail: () => { fail: () => {
my.hideLoading(); my.hideLoading();
self.setData({ this.setData({
data_list_loding_status: 2, data_list_loding_status: 2,
data_list_loding_msg: '服务器请求出错', data_list_loding_msg: '服务器请求出错',
}); });
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<view class="oh goods-price"> <view class="oh goods-price">
<text class="sales-price">¥{{item.price}}</text> <text class="sales-price">¥{{item.price}}</text>
<text a:if="{{item.original_price > 0}}" class="original-price">¥{{item.original_price}}</text> <text a:if="{{item.original_price > 0}}" class="original-price">¥{{item.original_price}}</text>
<text class="buy-number">x{{item.stock}}</text> <text class="buy-number cr-888">x{{item.stock}}</text>
</view> </view>
</view> </view>
</swipe-action> </swipe-action>
......
...@@ -6,7 +6,7 @@ Page({ ...@@ -6,7 +6,7 @@ Page({
data_bottom_line_status: false, data_bottom_line_status: false,
data_list: [], data_list: [],
swipe_index: null, swipe_index: null,
total_price: 0, total_price: '0.00',
is_selected_all: false, is_selected_all: false,
buy_submit_disabled_status: true, buy_submit_disabled_status: true,
}, },
...@@ -45,7 +45,7 @@ Page({ ...@@ -45,7 +45,7 @@ Page({
get_data() { get_data() {
this.setData({ this.setData({
data_list_loding_status: 1, data_list_loding_status: 1,
total_price: 0, total_price: '0.00',
is_selected_all: false, is_selected_all: false,
buy_submit_disabled_status: true, buy_submit_disabled_status: true,
}); });
...@@ -319,9 +319,7 @@ Page({ ...@@ -319,9 +319,7 @@ Page({
for (var i in temp_data_list) { for (var i in temp_data_list) {
if ((temp_data_list[i]['selected'] || false) == true) { if ((temp_data_list[i]['selected'] || false) == true) {
total_price += temp_data_list[i]['stock'] * temp_data_list[i]['price']; total_price += temp_data_list[i]['stock'] * temp_data_list[i]['price'];
if ((temp_data_list[i]['selected'] || false) == true) { selected_count++;
selected_count++;
}
} }
} }
...@@ -334,17 +332,32 @@ Page({ ...@@ -334,17 +332,32 @@ Page({
// 结算 // 结算
buy_submit_event(e) { buy_submit_event(e) {
my.showToast({content: "开发中..."}); var selected_count = 0;
var ids = [];
var temp_data_list = this.data.data_list;
for (var i in temp_data_list) {
if ((temp_data_list[i]['selected'] || false) == true) {
ids.push(temp_data_list[i]['id']);
selected_count++;
}
}
if (selected_count <= 0) {
my.showToast({
type: "fail",
content: '请选择商品'
});
return false
}
// 进入订单确认页面 // 进入订单确认页面
// var data = [{ var data = {
// "buy_type": "goods", "buy_type": "cart",
// "goods_id": this.data.goods.id, "ids": ids.join(',')
// "stock": this.data.temp_buy_number, };
// "attr": attribute_all.join(',') my.navigateTo({
// }]; url: '/pages/buy/buy?data=' + JSON.stringify(data)
// my.navigateTo({ });
// url: '/pages/buy/buy?data=' + JSON.stringify(data)
// });
} }
}); });
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace Api\Controller; namespace Api\Controller;
use Service\ResourcesService; use Service\ResourcesService;
use Service\BuyService;
use Service\UserService;
/** /**
* 购买确认 * 购买确认
...@@ -45,18 +47,36 @@ class BuyController extends CommonController ...@@ -45,18 +47,36 @@ class BuyController extends CommonController
*/ */
public function Index() public function Index()
{ {
// 清单商品 // 获取商品列表
$goods = $this->GetBuyGoods(); $params = $this->data_post;
$params['user'] = $this->user;
$ret = BuyService::BuyTypeGoodsList($params);
// 用户地址 // 商品校验
$address = $this->GetBuyUserAddress(); if(isset($ret['code']) && $ret['code'] == 0)
{
// 商品/基础信息
$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'],
];
$result = [ // 数据返回组装
'goods' => $goods['goods'], $user_address_list = UserService::UserAddressList(['user'=>$this->user]);
'total_price' => $goods['total_price'], $express_list = ResourcesService::ExpressList(['is_enable'=>1, 'is_open_user'=>1]);
'address' => $address, $payment_list = ResourcesService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]);
]; $result = [
$this->ajaxReturn(L('common_operation_success'), 0, $result); 'goods_list' => $ret['data'],
'user_address_list' => $user_address_list['data'],
'express_list' => $express_list,
'payment_list' => $payment_list,
'base' => $base,
];
$this->ajaxReturn(L('common_operation_success'), 0, $result);
} else {
$this->ajaxReturn(isset($ret['msg']) ? $ret['msg'] : L('common_param_error'), -100);
}
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册