Merge pull request 'order 7.22' (#76) from zhy into master

Reviewed-on: http://git.luyuan.tk/luyuan/deming/pulls/76
This commit is contained in:
hansu 2020-07-22 18:52:49 +08:00
commit 2e087313d4
8 changed files with 122 additions and 66 deletions

View File

@ -122,7 +122,7 @@ export default {
});
},
// 订单步骤2发起订单返回订单信息
sendOrder({ ifcart, cart_id, address_id, buy_city_id }) {
sendOrder({ ifcart, cart_id, address_id, buy_city_id, pintuan_id, pintuangroup_id, voucher_id }) {
return vm.$u.post('buy/buy_step2', {
ifcart: ifcart,
cart_id: cart_id,

View File

@ -4,11 +4,12 @@ Vue.use(Vuex)
const store = new Vuex.Store({
state: {
orderType: '', // 订单类型 1 普通订单 2 购物车订单 3 拼团订单 4 秒杀订单
orderType: '', // 订单类型 1 普通订单 2 拼团订单 3 秒杀订单 4 优惠券 5 购物车订单 和 goodsDetails 的 type 相同
orderInfo: {}, // 订单数据 订单步骤1展示结算数据
orderAddress: {}, // 下单时选择的地址
goodsDetails: {}, // 商品详情 1普通 2拼团 3秒杀 4优惠券
goods_id: '', // 拼团商品 id
pintuangroup_headid: '', // 拼团团长id 有为开团 无为参团
groupbuyInfo: {}, // 秒杀详情
},
getters: {
@ -41,6 +42,9 @@ const store = new Vuex.Store({
setGroupbuyInfo(state, info) {
state.groupbuyInfo = info;
},
setGroupHeadId(state, id) {
state.pintuangroup_headid = id;
},
}
})
export default store;

View File

@ -1,10 +1,10 @@
<template>
<view class="item">
<view class="item" @click="spikeGoods">
<image class="head" :src="item.groupbuy_image1"></image>
<text class="title u-line-2">{{ item.goods_name }}</text>
<view class="price">
<text>{{ item.groupbuy_price }}</text>
<text>{{ item.goods_price }}</text>
<text class="origin">{{ item.goods_price }}</text>
</view>
<view class="info">
<text>剩余{{ item.inventory | formatValue }}</text>
@ -22,6 +22,27 @@ export default {
if(temp > 999) temp = '999+';
return temp;
}
},
methods: {
spikeGoods() {
// console.log(this.item.groupbuy_id);
this.$u.api.getSpikeInfo({
groupbuy_id: this.item.groupbuy_id
}).then(res => {
if(res.errCode == 0) {
const goods = {
goods: res.data.goodsInfo,
type: 3, // 1 2 3 4
}
this.$store.commit('setGoodsDetails', goods);
this.$store.commit('setGroupbuyInfo', res.data.groupbuyInfo);
this.$store.commit('setGoodsId', this.item.groupbuy_id);
this.$u.route({
url: 'pageB/sdetails/index',
})
}
})
},
}
}
</script>

View File

@ -36,12 +36,12 @@ export default {
type: String,
},
created() {
console.log(this.item);
console.log(this.type);
// console.log(this.item);
// console.log(this.type);
},
methods: {
spikeGoods() {
console.log(this.item.groupbuy_id);
// console.log(this.item.groupbuy_id);
this.$u.api.getSpikeInfo({
groupbuy_id: this.item.groupbuy_id
}).then(res => {

View File

@ -40,9 +40,9 @@
<view class="bottom">
<view class="left" @click="showGroupUser=true">
<view class="avatar">
<image v-for="(user, i) in groupUser.slice(0, 3)" :src="user[0].member_avatar" :key="i"></image>
<image v-for="(user, i) in user_suc" :src="user[0].member_avatar" :key="i"></image>
</view>
<view class="all">
<view class="all" @click="showGroupUser=true">
<text>查看全部</text>
<image src="/static/image/common/1.png"></image>
</view>
@ -84,7 +84,7 @@
<view class="name u-line-1">{{ user.member_nickname }}</view>
</view>
</view>
<view class="involvement-btn" @click="withImmediate('involvement')">参与拼团</view>
<view class="involvement-btn" @click="settlementOrder('involvement')">参与拼团</view>
<image class="close" src="/static/image/common/17.png" @click="showInvolvementUser=false"></image>
</view>
</u-popup>
@ -98,7 +98,7 @@
</view>
<!-- 拼团 tool -->
<view class="group-tool" v-if="type==2">
<view class="launch" @click="withImmediate">发起拼团</view>
<view class="launch" @click="settlementOrder">发起拼团</view>
<view class="involvement" @click="showGroupUser=true">参与拼团</view>
</view>
<!-- 秒杀 -->
@ -113,7 +113,8 @@
<text>客服</text>
</view>
</view>
<view class="btn" :class="{'cannot': groupbuyInfo.groupbuy_state == 32 || groupbuyInfo.inventory == groupbuyInfo.groupbuy_buy_quantity}">
<view class="btn" v-if="groupbuyInfo.groupbuy_state == 20 && groupbuyInfo.inventory > groupbuyInfo.groupbuy_buy_quantity" @click="spikeGoods">立即秒杀</view>
<view class="btn" :class="{'cannot': groupbuyInfo.groupbuy_state == 32 || groupbuyInfo.inventory == groupbuyInfo.groupbuy_buy_quantity}" v-else>
{{ groupbuyInfo.groupbuy_state == 32 ? '时间已结束' : (groupbuyInfo.inventory > groupbuyInfo.groupbuy_buy_quantity ? '立即秒杀' : '已售空') }}
</view>
</view>
@ -133,10 +134,12 @@ export default {
goodsInfo: {},
info:{},
glist:[],
id:0,
id:0, // id
type: '', // 1 2 3 4
groupUser: [], //
user_suc: [], //
avatarWidth: '',
pintuan_id: '', // id
showGroupUser: false, //
showInvolvementUser: false, //
involvemenGroupInfo: [], //
@ -160,14 +163,16 @@ export default {
this.id = this.$store.state.goods_id;
this.type = this.$store.getters.getGoodsType;
const info = this.$store.getters.getGoodsInfo;
if(this.type == 2) {
this.user_suc = info.user_suc;
this.groupUser = info.user;
this.pintuan_id = info.pintuan_id;
}
if (this.type == 3) {
this.groupbuyInfo = this.$store.state.groupbuyInfo;
this.setSpikeTime();
}
// console.log(this.groupbuyInfo);
if(this.type == 2) {
this.groupUser = info.user;
}
this.goodsInfo = info.goods;
//
let list = [];
@ -180,21 +185,26 @@ export default {
this.list = list;
this.setTitle();
},
spikeGoods() {
this.settlementOrder(3)
},
setSpikeTime() {
const time = this.groupbuyInfo.groupbuy_endtime;
// console.log(new Date(time*1000));
// console.log(new Date());
this.timer = setInterval(() => {
let spikeTime = time * 1000 - new Date();
let spikeTime = time * 1000 - new Date().getTime();
//
const days = Math.floor(spikeTime/(24*3600*1000));
//
const leave1 = spikeTime % (24*3600*1000) //
const hours = Math.floor(leave1/(3600*1000))
const leave1 = spikeTime % (24*3600*1000) //
let hours = Math.floor(leave1/(3600*1000));
//
const leave2 = leave1 % (3600*1000) //
const leave2 = leave1 % (3600*1000) //
const minutes = Math.floor(leave2 / (60*1000))
//
const leave3 = leave2 % (60*1000) //
const leave3 = leave2 % (60*1000) //
const seconds = Math.round(leave3 / 1000)
//
hours = days * 24 + hours;
this.spikeTime = hours + ':' + minutes + ':' + seconds;
// console.log(this.spikeTime);
}, 1000)
@ -234,37 +244,29 @@ export default {
this.glist = res.data.spec_list;
})
},
// pintuangroup_headid
withImmediate(type) {
let params = {
pintuan_id: this.id,
}
// console.log(this.involvemenGroupInfo);
if(type == 'involvement' && this.involvemenGroupInfo.length) {
Object.assign(params, { pintuangroup_headid: this.involvemenGroupInfo[0].user_id });
Object.assign(params, { pintuangroup_id: this.involvemenGroupInfo[0].pintuangroup_id });
}
// console.log(params);
this.$u.api.withImmediate(params).then(res => {
this.showGroupUser = false;
this.showInvolvementUser = false;
if(res.errCode == 0) {
this.settlementOrder();
} else {
this.$u.toast(res.message);
}
})
},
settlementOrder() {
settlementOrder(type) {
// ifcart 1: 0://
this.$u.api.settlementOrder({
let params = {
ifcart: 0,
cart_id: [this.goodsInfo.goods_id + '|' + 1],
pintuan_id: this.involvemenGroupInfo[0].user_id,
}
if(this.type == 2) {
if(type == 'involvement') {
Object.assign(params, {
pintuan_id: this.pintuan_id,
pintuangroup_id: this.involvemenGroupInfo[0].pintuangroup_id
}).then(res => {
})
} else {
const userId = uni.getStorageSync('user_info').member.member_id;
this.$store.commit('setGroupHeadId', userId);
Object.assign(params, {
pintuan_id: this.pintuan_id,
})
}
}
this.$u.api.settlementOrder(params).then(res => {
if(res.errCode == 0) {
this.$store.commit('orderType', 3);
this.$store.commit('setOrderType', this.type);
this.$store.commit('updateOrderInfo', res.data)
this.$u.route({
url: '/pageC/cart/ConfirmOrder'
@ -276,7 +278,7 @@ export default {
this.involvemenGroupInfo = user;
this.showGroupUser = false;
this.showInvolvementUser = true;
console.log(this.involvemenGroupInfo);
// console.log(this.involvemenGroupInfo);
},
xuanze(id){
// console.log(id)
@ -291,8 +293,8 @@ export default {
case 2:
title = '拼团商品详情';
break;
case 1:
case 3:
title = '秒杀商品详情';
break;
case 1:
@ -340,6 +342,7 @@ export default {
}
.origin-price {
font-size: 26rpx;
text-decoration: line-through;
}
}
.num {

View File

@ -33,7 +33,7 @@
</view>
</view>
<view class="order-info">
<view @click="showCoupon({type: 2, store_id: item[0].store_id})">
<view @click="showCoupon({type: 2, store_id: item[0].store_id})" v-if="orderInfo.ifcart != 0">
<view class="title">优惠券折扣</view>
<view class="value">
<view>{{ item.coupon_price ? item.coupon_price : '0.00' }}</view>
@ -50,7 +50,7 @@
</view>
</view>
<view class="common-active">
<view @click="showCoupon({type: 1})">
<view @click="showCoupon({type: 1})" v-if="orderInfo.ifcart != 0">
<view class="title">平台优惠券</view>
<view class="value">
<view>-{{ choiceCoupon.vouchertemplate_id ? choiceCoupon.voucher_price : '0.00' }}</view>
@ -80,7 +80,7 @@
</view>
<view class="right">
<view class="num">共件{{ orderInfo.store_cart_list | setTotalNumber }}商品</view>
<view class="btn" @click="sendOrder">结算</view>
<view class="btn" @click="intermediate">结算</view>
</view>
</view>
<u-action-sheet :list="deliveryList" @click="setDelivery" border-radius="10" v-model="showDelivery"></u-action-sheet>
@ -112,7 +112,7 @@ export default {
couponStatus: false,
choiceCoupon: {}, // 使
goodsClass: [],
orderType: '', // 1 2 3 4
orderType: '', // 1 2 3 4 5
}
},
components: {
@ -138,7 +138,8 @@ export default {
onLoad(option) {
this.orderType = this.$store.state.orderType;
this.orderInfo = this.$store.state.orderInfo;
// console.log(this.orderInfo);
console.log(this.orderType);
console.log(this.orderInfo);
},
onShow() {
//
@ -158,7 +159,32 @@ export default {
}
},
methods: {
sendOrder() {
// pintuangroup_headid
async withImmediate(type) {
let params = {
pintuan_id: this.orderInfo.pintuan_id,
}
// console.log(this.involvemenGroupInfo);
if(this.orderInfo.pintuangroup_id) {
Object.assign(params, { pintuangroup_headid: this.$store.state.pintuangroup_headid });
Object.assign(params, { pintuangroup_id: this.orderInfo.pintuangroup_id });
}
// console.log(params);
this.$u.api.withImmediate(params).then(res => {
this.showGroupUser = false;
this.showInvolvementUser = false;
if(res.errCode == 0) {
this.sendOrder(0);
} else {
this.$u.toast(res.message);
}
})
},
intermediate() {
if(this.orderType == 2) this.withImmediate();
else this.sendOrder(1);
},
sendOrder(ifcart) {
//
let id = [], temp = '';
const object = this.orderInfo.store_cart_list;
@ -173,14 +199,15 @@ export default {
}
}
let params = {
ifcart: 1,
ifcart: ifcart,
cart_id: id,
address_id: this.addressInfo.address_id,
buy_city_id: this.addressInfo.city_id,
}
// if(this.orderType == 3) {
// Object.assign(params, { pintuan_id: })
// }
if(this.orderType == 2) {
Object.assign(params, { pintuan_id: this.orderInfo.pintuan_id })
if(this.orderInfo.pintuangroup_id) Object.assign(params, { pintuangroup_id: this.orderInfo.pintuangroup_id })
}
this.$u.api.sendOrder(params).then(res => {
if(res.errCode == 0) {
this.$u.route({
@ -190,6 +217,8 @@ export default {
price: res.data.order_total_amount,
}
})
} else {
this.$u.toast(res.message);
}
})
},

View File

@ -38,7 +38,7 @@ export default {
disabled: false,
}
],
pay_way: '',
pay_way: 'wxpay_app',
pay_sn: '',
price: '',
}

View File

@ -33,7 +33,7 @@ export default {
},
watch: {
current(index) {
console.log(this.tabList);
// console.log(this.tabList);
this.getPinTuanList(this.tabList[index].gc_id);
}
},
@ -69,7 +69,6 @@ export default {
// swipertabsswiper
animationfinish(e) {
let current = e.detail.current;
this.$refs.uTabs.setFinishCurrent(current);
this.swiperCurrent = current;
this.current = current;
},