init
This commit is contained in:
119
wx05cb767e6530b48f/pages/flow/index.js
Normal file
119
wx05cb767e6530b48f/pages/flow/index.js
Normal file
@@ -0,0 +1,119 @@
|
||||
var t = require("../../@babel/runtime/helpers/defineProperty"), o = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
goods_list: [],
|
||||
order_total_num: 0,
|
||||
order_total_price: 0,
|
||||
colourList: [],
|
||||
colour_id: 0,
|
||||
hideNotice: !1,
|
||||
storeInfo: {}
|
||||
},
|
||||
onLoad: function(t) {
|
||||
this.pays(), this.getColourList(), this.getStoreInfo();
|
||||
},
|
||||
onShow: function() {
|
||||
this.setData({
|
||||
isLogin: o.checkIsLogin()
|
||||
}), this.data.isLogin && this.getCartList();
|
||||
},
|
||||
pays: function() {
|
||||
var t = this;
|
||||
o._get("index/payList", {}, function(o) {
|
||||
var a = o.data;
|
||||
t.setData({
|
||||
payList: a
|
||||
});
|
||||
});
|
||||
},
|
||||
getStoreInfo: function() {
|
||||
var t = this;
|
||||
o._get("index/getStoreInfo", {}, function(o) {
|
||||
var a = o.data;
|
||||
console.log(a), t.setData({
|
||||
storeInfo: a.store
|
||||
});
|
||||
});
|
||||
},
|
||||
switchNotice: function() {
|
||||
this.setData({
|
||||
hideNotice: !0
|
||||
});
|
||||
},
|
||||
getCartList: function() {
|
||||
var t = this;
|
||||
o._get("cart/lists", {}, function(o) {
|
||||
t.setData(o.data);
|
||||
});
|
||||
},
|
||||
getColourList: function() {
|
||||
var t = this;
|
||||
o._get("goods/getColourList", {}, function(o) {
|
||||
var a = o.data;
|
||||
t.setData({
|
||||
colourList: a.list
|
||||
});
|
||||
});
|
||||
},
|
||||
addCount: function(a) {
|
||||
var e = this, i = a.currentTarget.dataset.index, s = a.currentTarget.dataset.skuId, r = e.data.goods_list[i], n = e.data.order_total_price;
|
||||
wx.showLoading({
|
||||
title: "加载中",
|
||||
mask: !0
|
||||
}), o._post_form("cart/add", {
|
||||
goods_id: r.goods_id,
|
||||
goods_num: 1,
|
||||
goods_sku_id: s
|
||||
}, function() {
|
||||
var o;
|
||||
r.total_num++, e.setData((t(o = {}, "goods_list[" + i + "]", r), t(o, "order_total_price", e.mathadd(n, r.goods_price)),
|
||||
o));
|
||||
});
|
||||
},
|
||||
minusCount: function(a) {
|
||||
var e = this, i = a.currentTarget.dataset.index, s = a.currentTarget.dataset.skuId, r = e.data.goods_list[i], n = e.data.order_total_price;
|
||||
r.total_num > 1 && (wx.showLoading({
|
||||
title: "加载中",
|
||||
mask: !0
|
||||
}), o._post_form("cart/sub", {
|
||||
goods_id: r.goods_id,
|
||||
goods_sku_id: s
|
||||
}, function() {
|
||||
var o;
|
||||
r.total_num--, r.total_num > 0 && e.setData((t(o = {}, "goods_list[" + i + "]", r),
|
||||
t(o, "order_total_price", e.mathsub(n, r.goods_price)), o));
|
||||
}));
|
||||
},
|
||||
del: function(t) {
|
||||
var a = this, e = t.currentTarget.dataset.goodsId, i = t.currentTarget.dataset.skuId;
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "您确定要移除当前商品吗?",
|
||||
success: function(t) {
|
||||
t.confirm && o._post_form("cart/delete", {
|
||||
goods_id: e,
|
||||
goods_sku_id: i
|
||||
}, function(t) {
|
||||
a.getCartList();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
submit: function(t) {
|
||||
wx.navigateTo({
|
||||
url: "../flow/checkout?order_type=cart"
|
||||
});
|
||||
},
|
||||
mathadd: function(t, o) {
|
||||
return (Number(t) + Number(o)).toFixed(2);
|
||||
},
|
||||
mathsub: function(t, o) {
|
||||
return (Number(t) - Number(o)).toFixed(2);
|
||||
},
|
||||
goShopping: function() {
|
||||
wx.switchTab({
|
||||
url: "../index/index"
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user