|
|
|
@ -1,5 +1,6 @@ |
|
|
|
// pages/user/cartlist/list.js
|
|
|
|
const device = wx.getSystemInfoSync(),rect = wx.getMenuButtonBoundingClientRect(); // 获取设备信息
|
|
|
|
const device = wx.getSystemInfoSync(), |
|
|
|
rect = wx.getMenuButtonBoundingClientRect(); // 获取设备信息
|
|
|
|
const ratio = 750 / device.windowWidth; |
|
|
|
console.log(rect) |
|
|
|
const width = device.windowWidth // 示例为一个与屏幕等宽的正方形裁剪框
|
|
|
|
@ -18,6 +19,7 @@ Page({ |
|
|
|
allChecked: false, |
|
|
|
allPrice: 0, |
|
|
|
productType: '', |
|
|
|
manageFlag: false, |
|
|
|
flag: false, //判断订单是否同时有商品和票
|
|
|
|
}, |
|
|
|
|
|
|
|
@ -27,6 +29,18 @@ Page({ |
|
|
|
onLoad: function (options) { |
|
|
|
this.getList(); |
|
|
|
}, |
|
|
|
manage: function () { |
|
|
|
let list = this.data.list; |
|
|
|
list.map(item => { |
|
|
|
item.checked = 0; |
|
|
|
}) |
|
|
|
this.setData({ |
|
|
|
manageFlag: !this.data.manageFlag, |
|
|
|
allChecked: 0, |
|
|
|
list: list, |
|
|
|
allPrice: 0 |
|
|
|
}) |
|
|
|
}, |
|
|
|
gotoDetail: function (e) { |
|
|
|
console.log(e) |
|
|
|
let item = e.currentTarget.dataset.item.product; |
|
|
|
@ -42,7 +56,8 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
minus: function (e) { |
|
|
|
let index = e.currentTarget.dataset.index,list = this.data.list; |
|
|
|
let index = e.currentTarget.dataset.index, |
|
|
|
list = this.data.list; |
|
|
|
let num = list[index].num; |
|
|
|
if (num <= 1) return; |
|
|
|
num = num - 1; |
|
|
|
@ -54,7 +69,8 @@ Page({ |
|
|
|
this.updatePrice() |
|
|
|
}, |
|
|
|
add: function (e) { |
|
|
|
let index = e.currentTarget.dataset.index,list = this.data.list; |
|
|
|
let index = e.currentTarget.dataset.index, |
|
|
|
list = this.data.list; |
|
|
|
let num = list[index].num + 1; |
|
|
|
list[index].num = num; |
|
|
|
this.setData({ |
|
|
|
@ -64,7 +80,8 @@ Page({ |
|
|
|
this.updatePrice() |
|
|
|
}, |
|
|
|
select: function (e) { |
|
|
|
let index = e.currentTarget.dataset.index,list = this.data.list; |
|
|
|
let index = e.currentTarget.dataset.index, |
|
|
|
list = this.data.list; |
|
|
|
if (list[index].product.flag != 1 || list[index].sku.flag != 'on') { |
|
|
|
wx.showToast({ |
|
|
|
title: '产品已下架', |
|
|
|
@ -79,7 +96,8 @@ Page({ |
|
|
|
this.updatePrice() |
|
|
|
}, |
|
|
|
selectAll: function () { |
|
|
|
let list = this.data.list,allChecked = this.data.allChecked?false:true; |
|
|
|
let list = this.data.list, |
|
|
|
allChecked = this.data.allChecked ? false : true; |
|
|
|
list.map(item => { |
|
|
|
if (item.sku.flag == 'on' && item.product.flag == 1) { |
|
|
|
item.checked = allChecked; |
|
|
|
@ -95,11 +113,11 @@ Page({ |
|
|
|
commonApi.user_post("cart/update_sku", { |
|
|
|
sku_id: item.sku.id, |
|
|
|
num: item.num |
|
|
|
}).then(res=>{ |
|
|
|
}) |
|
|
|
}).then(res => {}) |
|
|
|
}, |
|
|
|
updatePrice: function () { |
|
|
|
let list = this.data.list,price=0; |
|
|
|
let list = this.data.list, |
|
|
|
price = 0; |
|
|
|
list.map(item => { |
|
|
|
if (item.checked) { |
|
|
|
price = price + item.sku.price * item.num; |
|
|
|
@ -114,7 +132,10 @@ Page({ |
|
|
|
util.pagePoint({ |
|
|
|
event: 'cart_order' |
|
|
|
}, 1) |
|
|
|
let list = this.data.list,price=0,product=[],product1=[] |
|
|
|
let list = this.data.list, |
|
|
|
price = 0, |
|
|
|
product = [], |
|
|
|
product1 = [] |
|
|
|
list.map(item => { |
|
|
|
if (item.checked) { |
|
|
|
// item.product.type="post";
|
|
|
|
@ -182,7 +203,13 @@ Page({ |
|
|
|
let touchMoveX = e.changedTouches[0].clientX, |
|
|
|
touchMoveY = e.changedTouches[0].clientY; |
|
|
|
// 调用计算角度的方法,获取角度
|
|
|
|
var angel = this.angel({ X: startX, Y: startY }, { X: touchMoveX, Y: touchMoveY }) |
|
|
|
var angel = this.angel({ |
|
|
|
X: startX, |
|
|
|
Y: startY |
|
|
|
}, { |
|
|
|
X: touchMoveX, |
|
|
|
Y: touchMoveY |
|
|
|
}) |
|
|
|
// 遍历cartArray
|
|
|
|
this.data.list.forEach((cart, i) => { |
|
|
|
cart.isTouchMove = false; |
|
|
|
@ -212,7 +239,8 @@ Page({ |
|
|
|
return 360 * Math.atan(_Y / _X) / (2 * Math.PI) |
|
|
|
}, |
|
|
|
del: function (e) { |
|
|
|
let index = e.currentTarget.dataset.index,list = this.data.list; |
|
|
|
let index = e.currentTarget.dataset.index, |
|
|
|
list = this.data.list; |
|
|
|
commonApi.user_post("cart/del_sku", { |
|
|
|
sku_id: list[index].sku_id |
|
|
|
}).then(res => { |
|
|
|
@ -228,6 +256,39 @@ Page({ |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
delM() { |
|
|
|
let that = this |
|
|
|
let arr = this.data.list |
|
|
|
let suid = [] |
|
|
|
arr.forEach(item => { |
|
|
|
if (item.checked) { |
|
|
|
suid.push(item.sku_id) |
|
|
|
} |
|
|
|
}); |
|
|
|
let skuids = suid.join(',') |
|
|
|
wx.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '确定要删除选定的产品?', |
|
|
|
success: function (res) { |
|
|
|
if (res.confirm) { |
|
|
|
commonApi.user_post("cart/del_sku", { |
|
|
|
sku_id:skuids |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
wx.showToast({ |
|
|
|
title: '删除成功', |
|
|
|
icon: "success" |
|
|
|
}) |
|
|
|
that.getList(); |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
console.log('取消') |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
|
*/ |
|
|
|
|