diff --git a/alipay/pages/cart/cart.axml b/alipay/pages/cart/cart.axml
index ced969448ac0b984812cb9b1b8bf2f43db3db7b4..cfaf8c5c1dcd54e6b7caef628d4895a81f9cc4d0 100644
--- a/alipay/pages/cart/cart.axml
+++ b/alipay/pages/cart/cart.axml
@@ -39,7 +39,7 @@
-
+
@@ -55,18 +55,18 @@
+
-
-
-
- 购物车空空如也
-
-
+
+
+
+ 购物车空空如也
+
+
-
-
-
-
-
\ No newline at end of file
+
+
+
+
\ No newline at end of file
diff --git a/alipay/pages/cart/cart.js b/alipay/pages/cart/cart.js
index 5e7d51141375b8ba48395de720b5ac01f678f194..21f27d99f1c9410a1e12362966b876e6c65a86f8 100644
--- a/alipay/pages/cart/cart.js
+++ b/alipay/pages/cart/cart.js
@@ -8,6 +8,7 @@ Page({
swipe_index: null,
total_price: 0,
is_selected_all: false,
+ buy_submit_disabled_status: true,
},
onShow() {
@@ -43,7 +44,10 @@ Page({
// 获取数据
get_data() {
this.setData({
- data_list_loding_status: 1
+ data_list_loding_status: 1,
+ total_price: 0,
+ is_selected_all: false,
+ buy_submit_disabled_status: true,
});
my.httpRequest({
@@ -57,7 +61,7 @@ Page({
var data = res.data.data;
if (data.length > 0) {
for (var i in data) {
- data[i]['right'] = [{ type: 'edit', text: '收藏' }, { type: 'delete', text: '删除' }];
+ data[i]['right'] = [{ type: 'edit', text: '加入收藏' }, { type: 'delete', text: '删除' }];
}
}
this.setData({
@@ -160,6 +164,9 @@ Page({
if (res.data.code == 0) {
temp_data_list[index]['stock'] = buy_number;
this.setData({ data_list: temp_data_list });
+
+ // 选择处理
+ this.selected_calculate();
} else {
my.showToast({
type: "fail",
@@ -274,13 +281,12 @@ Page({
// 选中处理
selectedt_event(e) {
var type = e.currentTarget.dataset.type || null;
-
if (type != null)
{
var temp_data_list = this.data.data_list;
var temp_is_selected_all = this.data.is_selected_all;
- var total_price = 0;
switch(type) {
+ // 批量操作
case 'all' :
temp_is_selected_all = (temp_is_selected_all == true) ? false : true;
for (var i in temp_data_list) {
@@ -288,24 +294,57 @@ Page({
}
break;
+ // 节点操作
case 'node' :
var index = e.currentTarget.dataset.index || 0;
temp_data_list[index]['selected'] = (temp_data_list[index]['selected'] == true) ? false : true;
break;
}
- for (var i in temp_data_list) {
- if ((temp_data_list[i]['selected'] || false) == true) {
- total_price += temp_data_list[i]['stock'] * temp_data_list[i]['price'];
- }
- }
-
this.setData({
data_list: temp_data_list,
is_selected_all: temp_is_selected_all,
- total_price: total_price.toFixed(2),
- })
+ });
+
+ // 选择处理
+ this.selected_calculate();
}
+ },
+
+ // 选中计算
+ selected_calculate() {
+ var total_price = 0;
+ var selected_count = 0;
+ var temp_data_list = this.data.data_list;
+ for (var i in temp_data_list) {
+ if ((temp_data_list[i]['selected'] || false) == true) {
+ total_price += temp_data_list[i]['stock'] * temp_data_list[i]['price'];
+ if ((temp_data_list[i]['selected'] || false) == true) {
+ selected_count++;
+ }
+ }
+ }
+
+ this.setData({
+ total_price: total_price.toFixed(2),
+ buy_submit_disabled_status: (selected_count <= 0),
+ is_selected_all: (selected_count >= temp_data_list.length),
+ });
+ },
+
+ // 结算
+ buy_submit_event(e) {
+ my.showToast({content: "开发中..."});
+ // 进入订单确认页面
+ // var data = [{
+ // "buy_type": "goods",
+ // "goods_id": this.data.goods.id,
+ // "stock": this.data.temp_buy_number,
+ // "attr": attribute_all.join(',')
+ // }];
+ // my.navigateTo({
+ // url: '/pages/buy/buy?data=' + JSON.stringify(data)
+ // });
}
});
diff --git a/alipay/pages/goods-detail/goods-detail.js b/alipay/pages/goods-detail/goods-detail.js
index 5c090a8f9c9b776ca953bfb64d9bdbc40394750c..b948193b513a71b232ca9fcd92c1a84ff722ff4f 100755
--- a/alipay/pages/goods-detail/goods-detail.js
+++ b/alipay/pages/goods-detail/goods-detail.js
@@ -355,13 +355,15 @@ Page({
case 'buy' :
// 进入订单确认页面
var data = [{
+ "buy_type": "goods",
"goods_id": this.data.goods.id,
- "buy_number": this.data.temp_buy_number,
- "attribute": attribute_all.join(',')
- }]
+ "stock": this.data.temp_buy_number,
+ "attr": attribute_all.join(',')
+ }];
my.navigateTo({
url: '/pages/buy/buy?data=' + JSON.stringify(data)
});
+ this.popup_close_event();
break;
case 'cart' :
@@ -378,8 +380,6 @@ Page({
}
},
-
-
// 详情图片查看
goods_detail_images_view_event(e) {
var value = e.currentTarget.dataset.value || null;