【订单详情】

1. 将商品相关的方法挪到最前面
pull/1/MERGE
YunaiV 2023-06-08 21:55:18 +08:00
parent 8b2291d8b4
commit 83a6955778
1 changed files with 255 additions and 253 deletions

View File

@ -520,177 +520,7 @@
},
// #endif
methods: {
kefuClick() {
location.href = this.chatUrl;
},
closeChange: function() {
this.$set(this.sharePacket, 'isState', true);
},
goActivity: function(e) {
let item = e;
if (item.type === "1") {
uni.navigateTo({
url: `/pages/activity/goods_seckill_details/index?id=${item.id}`
});
} else if (item.type === "2") {
uni.navigateTo({
url: `/pages/activity/goods_bargain_details/index?id=${item.id}&startBargainUid=${this.uid}`
});
} else {
uni.navigateTo({
url: `/pages/activity/goods_combination_details/index?id=${item.id}`
});
}
},
/**
* 购物车手动填写
*
* @param number 数量
*/
iptCartNum: function(number) {
this.$set(this.attr.productSelect, 'cart_num', number ? number : 1);
},
/**
* 去商品详情页
*/
goDetail(item) {
if (!item.activityH5) {
uni.redirectTo({
url: '/pages/goods_details/index?id=' + item.id
})
return
}
if (item.activityH5.length == 0) {
uni.redirectTo({
url: '/pages/goods_details/index?id=' + item.id
})
return
}
//
if (item.activityH5 && item.activityH5.type == 2) {
uni.redirectTo({
url: `/pages/activity/goods_bargain_details/index?id=${item.activityH5.id}&bargain=${this.uid}`
})
return
}
//
if (item.activityH5 && item.activityH5.type == 3) {
uni.redirectTo({
url: `/pages/activity/goods_combination_details/index?id=${item.activityH5.id}`
})
return
}
//
if (item.activityH5 && item.activityH5.type == 1) {
uni.redirectTo({
url: `/pages/activity/goods_seckill_details/index?id=${item.activityH5.id}`
})
}
},
//
onLoadFun: function(e) {
this.getCouponList();
this.getCartCount();
},
ChangCouponsClone: function() {
this.$set(this.coupon, 'coupon', false)
},
/**
* 购物车数量加和数量减
*
* @param changeValue true 增加false 减少
*/
ChangeCartNum: function(changeValue) {
// sku
let sku = this.attr.productSelect;
if (!sku) {
return;
}
//
let stock = sku.stock || 0;
if (changeValue) {
sku.cart_num++;
if (sku.cart_num > stock) {
this.$set(this.attr.productSelect, "cart_num", stock);
this.$set(this, "cart_num", stock);
}
} else {
sku.cart_num--;
if (sku.cart_num < 1) {
this.$set(this.attr.productSelect, "cart_num", 1);
this.$set(this, "cart_num", 1);
}
}
},
/**
* 属性变动赋值
*
* @param newSkuKey 新的 skuKey
* @param propertyIndex properties 的下标
* @param valueIndex values 的下标
*/
ChangeAttr: function(newSkuKey, propertyIndex, valueIndex) {
// SKU
let sku = this.skuMap[newSkuKey];
if (!sku) {
return;
}
this.$set(this.attr.productSelect, "id", sku.id);
this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
this.$set(this.attr.productSelect, "price", sku.price);
this.$set(this.attr.productSelect, "stock", sku.stock);
this.$set(this.attr.productSelect, "cart_num", 1);
// SKU
this.$set(this.attr.properties[propertyIndex], 'index', this.attr.properties[propertyIndex].values[valueIndex].name);
this.$set(this, "attrValue", newSkuKey);
},
/**
* 关闭 productWindow 弹窗
*/
closeAttr: function () {
this.$set(this.attr, "cartAttr", false);
},
/**
* 领取完毕移除当前页面领取过的优惠券展示
*/
ChangCoupons: function(e) {
let coupon = e;
let couponList = this.$util.ArrayRemove(this.couponList, 'id', coupon.id);
this.$set(this, 'couponList', couponList);
this.getCouponList();
},
/**
* 优品推荐
*/
getGoods() {
getProductGood().then(res => {
let good_list = res.data.list || [];
let count = Math.ceil(good_list.length / 6);
let goodArray = new Array();
for (let i = 0; i < count; i++) {
let list = good_list.slice(i * 6, i * 6 + 6);
if (list.length) goodArray.push({
list: list
});
}
this.$set(this, 'good_list', goodArray);
// nav bar
let navList = ['商品', '评价', '详情'];
if (goodArray.length) {
navList.splice(2, 0, '推荐')
}
this.$set(this, 'navList', navList);
this.$nextTick(() => {
if (good_list.length) {
this.setClientHeight();
}
})
});
},
// ========== ==========
/**
* 获取产品详情
*/
@ -749,44 +579,6 @@
});
})
},
getProductReplyList: function() {
getReplyProduct(this.id).then(res => {
this.reply = res.data.productReply ? [res.data.productReply] : [];
})
},
getProductReplyCount: function() {
let that = this;
getReplyConfig(that.id).then(res => {
that.$set(that, 'replyChance', res.data.replyChance * 100);
that.$set(that, 'replyCount', res.data.sumCount);
});
},
/**
* 拨打电话
*/
makePhone: function() {
uni.makePhoneCall({
phoneNumber: this.systemStore.phone
})
},
/**
* 打开地图
*
*/
showMaoLocation: function() {
if (!this.systemStore.latitude || !this.systemStore.longitude) return this.$util.Tips({
title: '缺少经纬度信息无法查看地图!'
});
uni.openLocation({
latitude: parseFloat(this.systemStore.latitude),
longitude: parseFloat(this.systemStore.longitude),
scale: 8,
name: this.systemStore.name,
address: this.systemStore.address + this.systemStore.detailed_address,
success: function() {},
});
},
/**
* 查找默认选中的 sku设置到 attr.productSelect
*
@ -821,8 +613,312 @@
this.$set(this.attr.productSelect, "stock", sku.stock);
this.$set(this.attr.productSelect, "cart_num", 1);
this.$set(this, "attrValue", skuKey.join(","));
this.$set(this, "attrTxt", "已选择");
},
/**
* 打开 SKU 属性的选择
*/
openAttr: function() {
this.$set(this.attr, 'cartAttr', true);
},
/**
* 关闭 productWindow 弹窗
*/
closeAttr: function () {
this.$set(this.attr, "cartAttr", false);
},
/**
* 属性变动赋值
*
* @param newSkuKey 新的 skuKey
* @param propertyIndex properties 的下标
* @param valueIndex values 的下标
*/
ChangeAttr: function(newSkuKey, propertyIndex, valueIndex) {
// SKU
let sku = this.skuMap[newSkuKey];
if (!sku) {
return;
}
this.$set(this.attr.productSelect, "id", sku.id);
this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
this.$set(this.attr.productSelect, "price", sku.price);
this.$set(this.attr.productSelect, "stock", sku.stock);
this.$set(this.attr.productSelect, "cart_num", 1);
// SKU
this.$set(this.attr.properties[propertyIndex], 'index', this.attr.properties[propertyIndex].values[valueIndex].name);
this.$set(this, "attrValue", newSkuKey);
},
/**
* 购物车数量加和数量减
*
* @param changeValue true 增加false 减少
*/
ChangeCartNum: function(changeValue) {
// sku
let sku = this.attr.productSelect;
if (!sku) {
return;
}
//
let stock = sku.stock || 0;
if (changeValue) {
sku.cart_num++;
if (sku.cart_num > stock) {
this.$set(this.attr.productSelect, "cart_num", stock);
this.$set(this, "cart_num", stock);
}
} else {
sku.cart_num--;
if (sku.cart_num < 1) {
this.$set(this.attr.productSelect, "cart_num", 1);
this.$set(this, "cart_num", 1);
}
}
},
/**
* 购物车手动填写
*
* @param number 数量
*/
iptCartNum: function(number) {
this.$set(this.attr.productSelect, 'cart_num', number ? number : 1);
},
/**
* 打开属性加入购物车
*/
joinCart: function() {
//
if (!this.isLogin) {
toLogin();
return;
}
// attr
if (!this.attr.cartAttr) {
this.openAttr();
return
}
//
let sku = this.attr.productSelect;
if (sku.stock === 0) {
return that.$util.Tips({
title: "产品库存不足,请选择其它"
});
}
//
TradeCartApi.addCart({
count: sku.cart_num,
skuId: sku.id,
addStatus: true // TODO addStatus
}).then(res => {
// attr
this.attr.cartAttr = false;
//
this.$util.Tips({
title: "添加购物车成功",
success: () => {
this.getCartCount(true);
}
});
}).catch(res => {
this.$util.Tips({
title: res
});
});
},
/**
* 立即购买
*/
goBuy: function() {
//
if (!this.isLogin) {
toLogin();
return;
}
// attr
if (!this.attr.cartAttr) {
this.openAttr();
return;
}
//
let sku = this.attr.productSelect;
uni.navigateTo({
url: '/pages/users/order_confirm/index?skuId=' + sku.id + '&count=' + sku.cart_num
});
},
/**
* 获取购物车数量
*
* @param isAnima 是否展示购物车动画和重置属性
*/
getCartCount: function(isAnima) {
const isLogin = this.isLogin;
if (!isLogin) {
return
}
TradeCartApi.getCartCount().then(res => {
this.cartCount = res.data;
//
if (isAnima) {
this.cartAnimated = true;
setTimeout(() => {
this.cartAnimated = false;
}, 500);
}
});
},
// === TODO ====
kefuClick() {
location.href = this.chatUrl;
},
closeChange: function() {
this.$set(this.sharePacket, 'isState', true);
},
goActivity: function(e) {
let item = e;
if (item.type === "1") {
uni.navigateTo({
url: `/pages/activity/goods_seckill_details/index?id=${item.id}`
});
} else if (item.type === "2") {
uni.navigateTo({
url: `/pages/activity/goods_bargain_details/index?id=${item.id}&startBargainUid=${this.uid}`
});
} else {
uni.navigateTo({
url: `/pages/activity/goods_combination_details/index?id=${item.id}`
});
}
},
/**
* 去商品详情页
*/
goDetail(item) {
if (!item.activityH5) {
uni.redirectTo({
url: '/pages/goods_details/index?id=' + item.id
})
return
}
if (item.activityH5.length == 0) {
uni.redirectTo({
url: '/pages/goods_details/index?id=' + item.id
})
return
}
//
if (item.activityH5 && item.activityH5.type == 2) {
uni.redirectTo({
url: `/pages/activity/goods_bargain_details/index?id=${item.activityH5.id}&bargain=${this.uid}`
})
return
}
//
if (item.activityH5 && item.activityH5.type == 3) {
uni.redirectTo({
url: `/pages/activity/goods_combination_details/index?id=${item.activityH5.id}`
})
return
}
//
if (item.activityH5 && item.activityH5.type == 1) {
uni.redirectTo({
url: `/pages/activity/goods_seckill_details/index?id=${item.activityH5.id}`
})
}
},
//
onLoadFun: function(e) {
this.getCouponList();
this.getCartCount();
},
ChangCouponsClone: function() {
this.$set(this.coupon, 'coupon', false)
},
/**
* 领取完毕移除当前页面领取过的优惠券展示
*/
ChangCoupons: function(e) {
let coupon = e;
let couponList = this.$util.ArrayRemove(this.couponList, 'id', coupon.id);
this.$set(this, 'couponList', couponList);
this.getCouponList();
},
/**
* 优品推荐
*/
getGoods() {
getProductGood().then(res => {
let good_list = res.data.list || [];
let count = Math.ceil(good_list.length / 6);
let goodArray = new Array();
for (let i = 0; i < count; i++) {
let list = good_list.slice(i * 6, i * 6 + 6);
if (list.length) goodArray.push({
list: list
});
}
this.$set(this, 'good_list', goodArray);
// nav bar
let navList = ['商品', '评价', '详情'];
if (goodArray.length) {
navList.splice(2, 0, '推荐')
}
this.$set(this, 'navList', navList);
this.$nextTick(() => {
if (good_list.length) {
this.setClientHeight();
}
})
});
},
getProductReplyList: function() {
getReplyProduct(this.id).then(res => {
this.reply = res.data.productReply ? [res.data.productReply] : [];
})
},
getProductReplyCount: function() {
let that = this;
getReplyConfig(that.id).then(res => {
that.$set(that, 'replyChance', res.data.replyChance * 100);
that.$set(that, 'replyCount', res.data.sumCount);
});
},
/**
* 拨打电话
*/
makePhone: function() {
uni.makePhoneCall({
phoneNumber: this.systemStore.phone
})
},
/**
* 打开地图
*/
showMaoLocation: function() {
if (!this.systemStore.latitude || !this.systemStore.longitude) return this.$util.Tips({
title: '缺少经纬度信息无法查看地图!'
});
uni.openLocation({
latitude: parseFloat(this.systemStore.latitude),
longitude: parseFloat(this.systemStore.longitude),
scale: 8,
name: this.systemStore.name,
address: this.systemStore.address + this.systemStore.detailed_address,
success: function() {},
});
},
/**
* 获取优惠券
*/
@ -873,12 +969,6 @@
}
}
},
/**
* 打开 SKU 属性的选择
*/
openAttr: function() {
this.$set(this.attr, 'cartAttr', true);
},
/**
* 打开优惠券插件
*/
@ -891,94 +981,6 @@
that.$set(that.coupon, 'coupon', true);
}
},
/**
* 打开属性加入购物车
*/
joinCart: function() {
//
if (!this.isLogin) {
toLogin();
return;
}
// attr
if (!this.attr.cartAttr) {
this.openAttr();
return
}
//
let sku = this.attr.productSelect;
if (sku.stock === 0) {
return that.$util.Tips({
title: "产品库存不足,请选择其它"
});
}
//
TradeCartApi.addCart({
count: sku.cart_num,
skuId: sku.id,
addStatus: true // TODO addStatus
}).then(res => {
// attr
this.attr.cartAttr = false;
//
this.$util.Tips({
title: "添加购物车成功",
success: () => {
this.getCartCount(true);
}
});
}).catch(res => {
this.$util.Tips({
title: res
});
});
},
/**
* 获取购物车数量
*
* @param isAnima 是否展示购物车动画和重置属性
*/
getCartCount: function(isAnima) {
const isLogin = this.isLogin;
if (!isLogin) {
return
}
TradeCartApi.getCartCount().then(res => {
this.cartCount = res.data;
//
if (isAnima) {
this.cartAnimated = true;
setTimeout(() => {
this.cartAnimated = false;
}, 500);
}
});
},
/**
* 立即购买
*/
goBuy: function() {
//
if (!this.isLogin) {
toLogin();
return;
}
// attr
if (!this.attr.cartAttr) {
this.openAttr();
return;
}
//
let sku = this.attr.productSelect;
uni.navigateTo({
url: '/pages/users/order_confirm/index?skuId=' + sku.id + '&count=' + sku.cart_num
});
},
//
authColse: function(e) {
this.isShowAuth = e