3,143
社区成员
发帖
与我相关
我的任务
分享
Settlement: function () {
var that = this;
console.log(that)
console.log('99999')
wx.request({
url: app.d.ceshiUrl + '&action=product&m=Settlement',
method: 'post',
data: {
cart_id: that.data.cartId, // 购物车id
uid: that.data.userId, // 微信id
num1: that.data.num1, //数量
type: that.data.type, //(1.直接结算 0购物车结算)
},
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
var status = res.data.status;
if (status == 1) {
if (that.data.allow) {
res.data.arr.coupon_money = Number(res.data.arr.coupon_money) - Number(that.data.allow);
}
if (that.data.d_yuan) {
res.data.arr.coupon_money = Number(res.data.arr.coupon_money) - Number(that.data.user_money);
}
console.log(res.data.arr);
console.log('res.data.arr');
that.setData({
addemt: res.data.arr.addemt, // 是否有收货地址
address: res.data.arr.adds, // 收货地址
addrId: res.data.arr.adds.id ? res.data.arr.adds.id : '', // 收货地址id
productData: res.data.arr.pro, // 商品信息
total: res.data.arr.price, // 总价
money: res.data.arr.money, // 优惠券金额
coupon_money: Number(parseFloat(res.data.arr.coupon_money).toFixed(3).slice(0, -1)), // 优惠后金额
user_money: res.data.arr.user_money, // 用户余额
coupon_id: res.data.arr.coupon_id, // 优惠券id
discount: res.data.arr.discount, //控制优惠方式
scorebuy: res.data.arr.scorebuy, //积分消费规则
zhekou: res.data.arr.zhekou ? res.data.arr.zhekou : '', //会员折扣
freight: res.data.arr.yunfei ? res.data.arr.yunfei : 0, //运费
});
setTimeout(function () {
that.setData({
remind: false
});
}, 1000);
} else {
that.setData({
remind: true
});
wx.showToast({
title: res.data.err,
icon: 'none',
duration: 2000,
});
if (status == 0) {
setTimeout(function () {
util.getUesrBgplus(that, app, false)
wx.navigateBack({
delta: 1
})
}, 2000);
} else {
setTimeout(function () {
util.getUesrBgplus(that, app, false)
wx.navigateBack({
delta: 1
})
}, 2000);
}
}
},
error: function (e) {
wx.showToast({
title: '网络异常!',
duration: 2000
});
}
});
},