|
@@ -13,6 +13,7 @@ Page({
|
|
|
showCart:false,
|
|
|
mask:true,
|
|
|
series:[],//商品分类
|
|
|
+ cartList:[],//购物车列表
|
|
|
currentProductList:[],//商品
|
|
|
totalNum:0,//购物车总数
|
|
|
totalPrice:0.00//购物车总价格
|
|
@@ -94,6 +95,8 @@ Page({
|
|
|
if(this.data.cartList.length ==0){
|
|
|
this.setData({showCart:false})
|
|
|
}
|
|
|
+ await this.initProduct();
|
|
|
+ this.cartWwing();
|
|
|
},
|
|
|
|
|
|
onLoad: async function (options) {
|
|
@@ -101,9 +104,10 @@ Page({
|
|
|
tableId:options.table_id,
|
|
|
storeId:options.store_id
|
|
|
})
|
|
|
+ await this.getCart();
|
|
|
await this.productTypeList();
|
|
|
await this.getProductList();
|
|
|
- await this.getCart();
|
|
|
+
|
|
|
|
|
|
},
|
|
|
|
|
@@ -145,18 +149,31 @@ Page({
|
|
|
initProduct: function(){
|
|
|
let series = this.data.series;
|
|
|
let productList = this.data.productList;
|
|
|
+
|
|
|
+ let cartList = this.data.cartList;
|
|
|
+ cartList.forEach((ite,index) => {
|
|
|
+ productList.forEach((ele,pindex) => {
|
|
|
+ ele.hasChoose = false;
|
|
|
+ if (ele.id == ite.productId){
|
|
|
+ ele.hasChoose = true;
|
|
|
+ ele.hasNum = ite.num;
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
let currentProductList = [];
|
|
|
series.forEach((item,index) => {
|
|
|
currentProductList[index] = [];
|
|
|
let i = 0;
|
|
|
productList.forEach((element,pindex) => {
|
|
|
-
|
|
|
if (element.productTypeId == item.id){
|
|
|
currentProductList[index][i] = element;
|
|
|
i++;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
this.setData({
|
|
|
currentProductList:currentProductList
|
|
|
})
|
|
@@ -178,5 +195,30 @@ Page({
|
|
|
}else{
|
|
|
this.setData({showCart:false})
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 点击商品+号购物车摆动
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+cartWwing: function()
|
|
|
+{
|
|
|
+
|
|
|
+ // 创建动画实例(animation)
|
|
|
+ var animation = wx.createAnimation({
|
|
|
+ duration: 100,//动画持续时间
|
|
|
+ timingFunction: 'ease-in',//动画以低速开始
|
|
|
+ //具体配置项请查看文档
|
|
|
+ })
|
|
|
+
|
|
|
+ // 通过实例描述对象()
|
|
|
+ animation.translateX(6).rotate(21).step()
|
|
|
+ animation.translateX(-6).rotate(-21).step()
|
|
|
+ animation.translateX(0).rotate(0).step()
|
|
|
+
|
|
|
+ // 导出动画
|
|
|
+ this.setData({
|
|
|
+ ani: animation.export()
|
|
|
+ })
|
|
|
+
|
|
|
+},
|
|
|
})
|