作者 wangxuyu

修改购物车默认选中

... ... @@ -6,9 +6,9 @@ Page({
* 页面的初始数据
*/
data: {
choose: false,
choose: true,
choose2: true,
chooseAll2: false,
chooseAll2: true,
number: 1,
goodsList: [],
goodsId: 0,
... ... @@ -21,10 +21,10 @@ Page({
is_vip: 0,
cartId: 1,
listlist: [],
all_both_choose: false,
all_both_choose: true,
chuandi: 0,
chuandis: 0,
xuanzhong: false,
xuanzhong: true,
shengyu: 0
},
//跳转至详情页
... ... @@ -119,6 +119,65 @@ Page({
})
this.totalPrice();
},
allBothChooses() {
let that = this
let goodsList = that.data.goodsList
let promotion = that.data.promotion
let all_both_choose = !that.data.all_both_choose
if (all_both_choose) {
all_both_choose = false
} else {
all_both_choose = true
}
goodsList.forEach(function (ele, index) {
if (all_both_choose) {
ele.chooseAll = true
for (let i = 0; i < ele.list.length; i++) {
ele.list[i].flag = true
}
that.setData({
goodsList: goodsList,
xuanzhong: true
})
} else {
ele.chooseAll = false
for (let i = 0; i < ele.list.length; i++) {
ele.list[i].flag = false
}
that.setData({
goodsList: goodsList,
xuanzhong: false,
})
}
})
promotion.forEach(function (ele, index) {
if (all_both_choose) {
ele.chooseAll = true
for (let i = 0; i < ele.list.length; i++) {
ele.list[i].flag = true
}
that.setData({
promotion: promotion,
xuanzhong: true
})
} else {
ele.chooseAll = false
for (let i = 0; i < ele.list.length; i++) {
ele.list[i].flag = false
}
that.setData({
promotion: promotion,
xuanzhong: false
})
}
})
that.setData({
all_both_choose: all_both_choose,
})
console.log(all_both_choose + "前")
this.totalPrice();
console.log(all_both_choose+"后")
},
//fetchUser
fetchUser() {
let url = '/wxapp/user/index'
... ... @@ -140,12 +199,16 @@ Page({
var list = {};
var number = 1;
var g_price = 0;
var totalPrice = 0
var chuandis = null
var chuandi = null
var vip = that.data.is_vip
var shipprice = null
app.post(url).then(r => {
r.data.list.forEach(function(ele, index) {
ele.chooseAll = false
ele.chooseAll = true
for (let v in ele.list) {
ele.list[v].flag = false
ele.list[v].flag = true
if (vip == 1) {
var price = ele.list[v].vip_price
price = price.substring(0, price.length - 3) * 1
... ... @@ -155,10 +218,12 @@ Page({
price = price.substring(0, price.length - 3) * 1
ele.list[v].goods_price = ele.list[v].number * price
}
totalPrice += ele.list[v].goods_price
}
})
r.data.promotion.forEach(function(ele, index) {
ele.chooseAll=false
ele.chooseAll=true
for (let v in ele.list) {
ele.list[v].t = false
if (vip == 1) {
... ... @@ -170,8 +235,20 @@ Page({
price = price.substring(0, price.length - 3) * 1
ele.list[v].goods_price = ele.list[v].number * price
}
totalPrice += ele.list[v].goods_price
}
})
chuandis = totalPrice
if (totalPrice > r.data.shipment.free) {
shipprice = 0
} else {
shipprice = r.data.shipment.price
}
var ship_balance = that.data.shipment.free * 1 - totalPrice
if (ship_balance <= 0) {
shipprice = 0
}
chuandi = totalPrice * 1 + shipprice * 1
that.setData({
listlist: r.data,
goodsList: r.data.list,
... ... @@ -179,7 +256,10 @@ Page({
number: number,
shipment: r.data.shipment,
shipPrice: r.data.shipment.price,
shengyu: r.data.minimum_price
shengyu: r.data.minimum_price,
totalPrice: totalPrice,
chuandi:chuandi,
chuandis:chuandis
});
});
},
... ... @@ -191,7 +271,6 @@ Page({
var vip = that.data.is_vip * 1
goodsList.forEach(function(ele, index) {
for (let v in ele.list) {
console.log("进来了goodsList")
if (vip == 1) {
var price = ele.list[v].vip_price
price = price.substring(0, price.length - 3) * 1
... ... @@ -341,6 +420,8 @@ Page({
*/
onLoad: function(options) {
this.fetchUser();
this.allBothChooses()
console.log(this.data.all_both_choose + "zhong")
},
// 再逛逛
get_return() {
... ... @@ -829,13 +910,14 @@ Page({
let a=this.data.shipment.free
this.fetchCartList();
this.setData({
chooseAll: false,
chooseAll2: false,
// chooseAll: false,
// chooseAll2: false,
totalPrice: 0,
all_both_choose: false,
// all_both_choose: false,
ship_balance:a
})
this.fetchCartNum()
this.allBothChooses()
},
/**
... ...
... ... @@ -33,7 +33,7 @@ Page({
last_total_price: 0,
deliverTime: false,
deliverList: [],
deliverTimeId: 0,
deliverTimeId: null,
deliverTimeStr: '请选择时间',
order_sn: 0,
... ... @@ -106,7 +106,7 @@ Page({
let c = ele.labelArray.week
if (e == c) {
ele.children.forEach(function (eles, indexs) {
if (!eles.disabled) {
if (eles.disabled) {
if (b == eles.label) {
deliveryTimeId = eles.value
}
... ... @@ -114,6 +114,7 @@ Page({
timeflag: false
})
} else {
console.log(909090)
wx.showToast({
title: '亲,该时间段已排满咯~',
icon: 'none'
... ... @@ -166,6 +167,8 @@ Page({
// weeks[1] = week_right
// weeks[1] = ["13.00-15.00","15.00-17.00"]
var weeks_two = week_right
console.log('000')
console.log(week_arr)
this.setData({
timeDataArray: canlda,
week_arr: week_arr,
... ... @@ -182,6 +185,8 @@ Page({
this.setData({
multiArray: [week_arr, arr1[0]]
})
console.log(111)
console.log([week_arr, arr1[0]])
},
//返回
get_my() {
... ... @@ -235,13 +240,18 @@ Page({
let params = {
ids: this.data.ids
}
let addid = null
app.post(url, params).then(r => {
console.log(r)
var list = r.data.list;
var addid = null
r.data.vips.forEach(function(ele, index) {
ele.t = false
});
r.data.timeDataArray.forEach(function(ele, index) {
if(index==0){
addid = ele.children[0].value
}
var new_arr = []
for (let i = 0; i < ele.children.length; i++) {
new_arr.push(ele.children[i].label)
... ... @@ -258,8 +268,10 @@ Page({
timeDataArray: r.data.timeDataArray,
deliverList: r.data.timeDataArray,
addressList: r.data.address,
amount: that.data.amount
amount: that.data.amount,
addressId:addid
});
console.log(addid+'刚进来')
if (that.data.num == 0) {
that.goodsTotalPrice();
}
... ... @@ -275,10 +287,14 @@ Page({
ids: this.data.ids,
num: this.data.num
}
let addid = null
app.post(url, params).then(r => {
if (r.code == 1) {
var list = r.data.list;
r.data.timeDataArray.forEach(function(ele, index) {
r.data.timeDataArray.forEach(function (ele, index) {
if (index == 0) {
addid = ele.children[0].value
}
var new_arr = []
for (let i = 0; i < ele.children.length; i++) {
new_arr.push(ele.children[i].label)
... ... @@ -292,7 +308,8 @@ Page({
vipList: r.data.vips,
timeDataArray: r.data.timeDataArray,
deliverList: r.data.timeDataArray,
ship_ment_price: r.data.priceData.shipment_price
ship_ment_price: r.data.priceData.shipment_price,
addressId:addid
});
// that.fetchAmount();
that.amount()
... ... @@ -345,10 +362,14 @@ Page({
ids: that.data.ids,
id: that.data.proId
}
let addid = null
var totalPrice = that.data.totalPrice
app.post(url, params).then(r => {
if (r.code == 1) {
r.data.timeDataArray.forEach(function(ele, index) {
r.data.timeDataArray.forEach(function (ele, index) {
if (index == 0) {
addid = ele.children[0].value
}
var new_arr = []
for (let i = 0; i < ele.children.length; i++) {
new_arr.push(ele.children[i].label)
... ... @@ -362,7 +383,8 @@ Page({
vipList: r.data.vips,
timeDataArray: r.data.timeDataArray,
deliverList: r.data.timeDataArray,
ship_ment_price: r.data.priceData.shipment_price
ship_ment_price: r.data.priceData.shipment_price,
addressId:addid
})
this.getWeek();
}
... ... @@ -408,10 +430,14 @@ Page({
id: that.data.packId,
ids: that.data.packIds
}
let addid = null
app.post(url, params).then(r => {
if (r.code == 1) {
console.log(r)
r.data.timeDataArray.forEach(function(ele, index) {
r.data.timeDataArray.forEach(function (ele, index) {
if (index == 0) {
addid = ele.children[0].value
}
var new_arr = []
for (let i = 0; i < ele.children.length; i++) {
new_arr.push(ele.children[i].label)
... ... @@ -434,7 +460,8 @@ Page({
ship_ment_price: r.data.priceData.shipment_price,
amount: price,
goodsTotalPrice: price,
last_total_price: price
last_total_price: price,
addressId: addid
});
this.getWeek();
}
... ...
... ... @@ -134,6 +134,9 @@ position: relative;
padding-right:16rpx;
box-sizing: border-box;
flex-grow: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
/* background: red */
}
... ...