|
@@ -11,6 +11,7 @@ Page({
|
|
|
host: app.globalData.servsers,
|
|
|
amount:0, //总价
|
|
|
checkAll:false, // 全选
|
|
|
+ checkStatic:false, //默认一个都没有选择
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -24,52 +25,17 @@ Page({
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
- onShow: function () {
|
|
|
let that = this;
|
|
|
that.getCarlist(that)
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面隐藏
|
|
|
- */
|
|
|
- onHide: function () {
|
|
|
-
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
- */
|
|
|
- onUnload: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
- */
|
|
|
- onPullDownRefresh: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
- */
|
|
|
- onReachBottom: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 用户点击右上角分享
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
- onShareAppMessage: function () {
|
|
|
-
|
|
|
- },
|
|
|
+ // onShow: function () {
|
|
|
+
|
|
|
+
|
|
|
+ // },
|
|
|
subtraction(e){ // 减少
|
|
|
let that = this;
|
|
|
console.log(e)
|
|
@@ -106,6 +72,22 @@ Page({
|
|
|
that.totalPrice(that)
|
|
|
|
|
|
},
|
|
|
+ checkboxChangeAll(e){ // 全选
|
|
|
+ console.log(e)
|
|
|
+ let that = this, checkAll= that.data.checkAll , carList=that.data.carList;
|
|
|
+ if (e.detail.value[0]) {
|
|
|
+ checkAll = true; // 表示选中
|
|
|
+ } else {
|
|
|
+ checkAll = false;
|
|
|
+ }
|
|
|
+ carList.forEach(res => {
|
|
|
+ res.checked = checkAll;
|
|
|
+ })
|
|
|
+ that.setData({
|
|
|
+ carList:carList
|
|
|
+ })
|
|
|
+ that.totalPrice(that)
|
|
|
+ },
|
|
|
getCarlist(that){
|
|
|
wx.request({
|
|
|
url: host +'/queryShopCar',
|
|
@@ -132,11 +114,33 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ carSubmit(){ // 提交订单
|
|
|
+ let that = this, carList=[];
|
|
|
+ if (that.data.checkStatic){
|
|
|
+ that.data.carList.forEach(el=>{
|
|
|
+ if(el.checked){
|
|
|
+ carList.push(el)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ wx.setStorageSync('goodsList', carList);
|
|
|
+ wx.setStorageSync('amount', that.data.amount);
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/customized/pages/order/order',
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '您还没有选择商品',
|
|
|
+ icon:'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
totalPrice(that){
|
|
|
- let amount = 0,checkAll = true;
|
|
|
+ let amount = 0, checkAll = true, checkStatic= false;
|
|
|
that.data.carList.forEach(res=>{
|
|
|
if(res.checked){
|
|
|
- amount += res.customgoodsPriceNow * res.customGoodsNum
|
|
|
+ amount += res.customgoodsPriceNow * res.customGoodsNum;
|
|
|
+ checkStatic = true
|
|
|
+
|
|
|
}
|
|
|
if (!res.checked) {
|
|
|
checkAll = false
|
|
@@ -144,7 +148,8 @@ Page({
|
|
|
})
|
|
|
that.setData({
|
|
|
amount:amount.toFixed(2),
|
|
|
- checkAll: checkAll
|
|
|
+ checkAll: checkAll,
|
|
|
+ checkStatic: checkStatic
|
|
|
})
|
|
|
}
|
|
|
})
|