Files
decode-mini-app-new/wx214944c362629fc7/pages/flow/index.js
2024-08-22 12:53:28 +08:00

119 lines
3.6 KiB
JavaScript

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: {},
utype: 0
},
onLoad: function(t) {
this.getColourList(), this.getStoreInfo(), this.getUserDetail();
},
onShow: function() {
this.setData({
isLogin: o.checkIsLogin()
}), this.data.isLogin && (this.getCartList(), this.getUserDetail());
},
getUserDetail: function() {
var t = this;
o._get("user.index/detail", {}, function(o) {
console.log(o), t.setData({
utype: o.data.userInfo.utype
});
});
},
getStoreInfo: function() {
var t = this;
o._get("index/getStoreInfo", {}, function(o) {
var e = o.data;
console.log(e), t.setData({
storeInfo: e.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 e = o.data;
t.setData({
colourList: e.list
});
});
},
addCount: function(e) {
var a = this, i = e.currentTarget.dataset.index, s = e.currentTarget.dataset.skuId, r = a.data.goods_list[i], n = a.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++, a.setData((t(o = {}, "goods_list[" + i + "]", r), t(o, "order_total_price", a.mathadd(n, r.goods_price)),
o));
});
},
minusCount: function(e) {
var a = this, i = e.currentTarget.dataset.index, s = e.currentTarget.dataset.skuId, r = a.data.goods_list[i], n = a.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 && a.setData((t(o = {}, "goods_list[" + i + "]", r),
t(o, "order_total_price", a.mathsub(n, r.goods_price)), o));
}));
},
del: function(t) {
var e = this, a = 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: a,
goods_sku_id: i
}, function(t) {
e.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"
});
}
});