Commit 8973d4c0 by songbingqi

修复部分bug

parent 55ed3236
...@@ -372,6 +372,7 @@ export default { ...@@ -372,6 +372,7 @@ export default {
this.canUse = true this.canUse = true
const { category, ...goods } = this.goodInfo; const { category, ...goods } = this.goodInfo;
goods.skus = [sku]; goods.skus = [sku];
goods.origDiscount = sku.origDiscount
goods.sku = sku; goods.sku = sku;
goods.flag = true; goods.flag = true;
goods.skuId = selectedSku; goods.skuId = selectedSku;
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<div class="goods_name"> <div class="goods_name">
<div class="name">{{ item.name }}</div> <div class="name">{{ item.name }}</div>
<div class="price"> <div class="price">
¥{{ Utils.isInteger(setPrice(item.sku.discount)) }} ¥{{ Utils.isInteger(setPrice(hasCoupon?item.sku.origDiscount:item.sku.discount)) }}
</div> </div>
</div> </div>
<div class="goods_psce"> <div class="goods_psce">
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
<div class="price">总优惠¥{{ reduction }}</div> <div class="price">总优惠¥{{ reduction }}</div>
</div> --> </div> -->
</div> </div>
<view v-if="userms" class="payment" @click="messageAndSave">付款</view> <view v-if="userms" class="payment" @click="messageAndSave" :style="{'background-color':submitLoading?'gray':''}">付款</view>
<button <button
v-if="!userms" v-if="!userms"
class="payment" class="payment"
...@@ -368,6 +368,7 @@ export default { ...@@ -368,6 +368,7 @@ export default {
sendMsgFlag3: false, sendMsgFlag3: false,
}, },
optionDecode: {}, optionDecode: {},
submitLoading: false
}; };
}, },
computed: { computed: {
...@@ -389,45 +390,61 @@ export default { ...@@ -389,45 +390,61 @@ export default {
}); });
return totalNum; return totalNum;
}, },
reduction() { // reduction() {
if (JSON.stringify(this.goods) == "{}") return 0; // if (JSON.stringify(this.goods) == "{}") return 0;
let price = 0; // let price = 0;
let discountNum = 0; // let discountNum = 0;
this.goods.forEach((item) => { // this.goods.forEach((item) => {
const sku = item.sku; // const sku = item.sku;
if (item.flag) { // if (item.flag) {
discountNum += item.num * sku.discount; // discountNum += item.num * sku.discount;
price += item.num * sku.price; // price += item.num * sku.price;
} else { // } else {
discountNum += 0; // discountNum += 0;
price += 0; // price += 0;
} // }
}); // });
return (price - discountNum).toFixed(2); // return (price - discountNum).toFixed(2);
}, // },
amountOld() { amountOld() {
if (JSON.stringify(this.goods) == "{}") return 0; if (JSON.stringify(this.goods) == "{}") return 0;
let totalPrice = 0; let totalPrice = 0;
this.goods.forEach((item) => { if(this.hasCoupon) {
const sku = item.sku; this.goods.forEach((item) => {
item.flag ? (totalPrice += item.num * sku.discount) : (totalPrice += 0); const sku = item.sku;
}); item.flag ? (totalPrice += item.num * sku.origDiscount) : (totalPrice += 0);
});
} else {
this.goods.forEach((item) => {
const sku = item.sku;
item.flag ? (totalPrice += item.num * sku.discount) : (totalPrice += 0);
});
}
return totalPrice.toFixed(2); return totalPrice.toFixed(2);
}, },
totalPrice() { totalPrice() {
if (JSON.stringify(this.goods) == "{}") return 0; if (JSON.stringify(this.goods) == "{}") return 0;
let totalPrice = 0; let totalPrice = 0;
console.log(this.goods,'goods') if(this.hasCoupon) {
this.goods.forEach((item) => { this.goods.forEach((item) => {
const sku = item.sku; const sku = item.sku;
item.flag ? (totalPrice += item.num * sku.discount) : (totalPrice += 0); item.flag ? (totalPrice += item.num * sku.origDiscount) : (totalPrice += 0);
}); });
totalPrice -= this.selectCoupon.couponAmount || 0;
totalPrice -= this.selectCoupon.couponAmount || 0; } else {
this.goods.forEach((item) => {
const sku = item.sku;
item.flag ? (totalPrice += item.num * sku.discount) : (totalPrice += 0);
});
totalPrice -= this.selectCoupon.couponAmount || 0;
}
return totalPrice.toFixed(2); return totalPrice.toFixed(2);
}, },
hasCoupon() {
const {selectCoupon} = this
const {couponAmount} = selectCoupon
return (couponAmount!=null && couponAmount!=undefined)
}
}, },
methods: { methods: {
goHome() { goHome() {
...@@ -499,9 +516,9 @@ export default { ...@@ -499,9 +516,9 @@ export default {
}); });
}, },
itemReduction(discount, price, num) { // itemReduction(discount, price, num) {
return ((price - discount) * num).toFixed(2); // return ((price - discount) * num).toFixed(2);
}, // },
// 手机号授权登录 // 手机号授权登录
getPhoneNumber(e) { getPhoneNumber(e) {
if (e.detail.errMsg == "getPhoneNumber:ok") { if (e.detail.errMsg == "getPhoneNumber:ok") {
...@@ -532,6 +549,8 @@ export default { ...@@ -532,6 +549,8 @@ export default {
"Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74", "Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74",
]; ];
const val = {}; const val = {};
if(this.submitLoading) return
this.submitLoading = true
wx.requestSubscribeMessage({ wx.requestSubscribeMessage({
tmplIds: tmpid, tmplIds: tmpid,
success: (res) => { success: (res) => {
...@@ -649,8 +668,10 @@ export default { ...@@ -649,8 +668,10 @@ export default {
this.buyType, this.buyType,
this.agreeTerms this.agreeTerms
); );
this.submitLoading = false
this.cleanFlag = true; this.cleanFlag = true;
} else { } else {
this.submitLoading = false
} }
} }
}, },
......
...@@ -191,7 +191,7 @@ export default { ...@@ -191,7 +191,7 @@ export default {
if (q) { if (q) {
const optionDecode = Utils.getUrlParams2(decodeURIComponent(q)); const optionDecode = Utils.getUrlParams2(decodeURIComponent(q));
console.log(Utils.getUrlParams2(decodeURIComponent(q)), this.userInfo); console.log(Utils.getUrlParams2(decodeURIComponent(q)), this.userInfo);
const { num, serial_no, source } = optionDecode; const { num, serial_no, source, serials } = optionDecode;
if (source && this.userms) { if (source && this.userms) {
const sendData = { const sendData = {
phone: this.userInfo.phoneNumber, phone: this.userInfo.phoneNumber,
...@@ -200,6 +200,7 @@ export default { ...@@ -200,6 +200,7 @@ export default {
param: JSON.stringify({ param: JSON.stringify({
serial_no, serial_no,
num, num,
serials
}), }),
}; };
Menu.sendUserCoupon(sendData); Menu.sendUserCoupon(sendData);
......
...@@ -12,6 +12,7 @@ export default { ...@@ -12,6 +12,7 @@ export default {
let item = shopCarInfo[i]; let item = shopCarInfo[i];
let res = { let res = {
origDiscount: item.origDiscount, // sku金额
goodsId: item.goodsId, //商品id goodsId: item.goodsId, //商品id
goodsName: item.name, //商品名称 goodsName: item.name, //商品名称
machineId: undefined, //点单屏机器ID machineId: undefined, //点单屏机器ID
...@@ -44,7 +45,6 @@ export default { ...@@ -44,7 +45,6 @@ export default {
}, },
// 加入购物车数据 // 加入购物车数据
async getallNum(Obj, unCheckCount) { async getallNum(Obj, unCheckCount) {
console.log(Obj);
let shopCarInfo = uni.getStorageSync("shopCarInfo") || []; let shopCarInfo = uni.getStorageSync("shopCarInfo") || [];
let size = 0; let size = 0;
shopCarInfo.forEach((item) => (size += item.num)); shopCarInfo.forEach((item) => (size += item.num));
...@@ -72,7 +72,6 @@ export default { ...@@ -72,7 +72,6 @@ export default {
} else { } else {
shopCarInfo = [Obj]; shopCarInfo = [Obj];
} }
console.log(Obj);
uni.setStorageSync("shopCarInfo", shopCarInfo); uni.setStorageSync("shopCarInfo", shopCarInfo);
$EventBus.$emit("updateCar"); $EventBus.$emit("updateCar");
// if (callback) { // if (callback) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment