Merge pull request 'order 7.23' (#77) from zhy into master

Reviewed-on: http://git.luyuan.tk/luyuan/deming/pulls/77
This commit is contained in:
hansu 2020-07-23 14:57:42 +08:00
commit 937640f19d
9 changed files with 209 additions and 142 deletions

View File

@ -77,6 +77,10 @@ export default {
getGoodsClassifyList() {
return vm.$u.post('Goods/getGoodsClassifyList');
},
// 商品推荐的分类
getGoodsClassRecommend() {
return vm.$u.post('Goods/getGoodsClassRecommend');
},
// 商品推荐
getGoodsRecommend({page, gc_id}){
return vm.$u.post('Goods/getGoodsRecommend', {
@ -172,11 +176,6 @@ export default {
id: id
});
},
goodsInfo({id}){
return vm.$u.post('goods/goodsInfo', {
goods_id: id
});
},
// 商品搜索
ShopSearch({keyword,page = 1,order = 'goods_salenum'}){
return vm.$u.post('ShopSearch/search',{

View File

@ -39,6 +39,7 @@ export default {
goodsClass: Array,
},
created() {
// console.log(this.goodsClass);
// console.log(this.couponInfo);
},
filters: {
@ -51,9 +52,6 @@ export default {
}
},
methods: {
exchange() {
this.$emit('exchange', this.couponInfo.vouchertemplate_id);
},
use() {
this.$emit('use', this.couponInfo);
},
@ -64,6 +62,7 @@ export default {
.c-coupon {
position: relative;
z-index: 9;
margin-bottom: 30rpx;
@mixin coupon-image($url) {
width: 690rpx;
height: 194rpx;

View File

@ -3,19 +3,13 @@
<view class="top">
商品推荐
</view>
<!-- <view class="label">
<text v-for="item in classifyList" :key="item.gc_id">{{ item.gc_name }}</text>
</view>
<view class="item">
<item v-for="item in goodsList" :key="item.goods_id" :info="item"></item>
</view> -->
<view>
<u-tabs-swiper ref="uTabs" :list="classifyList" name="gc_name" :is-scroll="true" active-color="#FF780F" :current="current" font-size="24" :show-bar="false" @change="tabsChange" height="60" ></u-tabs-swiper>
</view>
<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" >
<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" :style="{height: swiperHeight}">
<swiper-item class="swiper-item" v-for="(_, index) in classifyList" :key="index">
<!-- <scroll-view scroll-y style="height: 800rpx;width: 100%;"> -->
<view class="item">
<view class="goods-item">
<item v-for="item in goodsList" :key="item.goods_id" :info="item"></item>
</view>
<u-empty text="暂无商品" mode="list" color="#000" v-if="!goodsList.length"></u-empty>
@ -30,17 +24,16 @@ export default {
name:"list",
data() {
return {
current: Number,
current: -1,
swiperCurrent: 0,
goodsList: [],
classifyList: [],
swiperHeight: '',
}
},
components:{
item
},
props: {
classifyList: Array
},
watch: {
current(index) {
const id = this.classifyList[index].gc_id;
@ -48,21 +41,35 @@ export default {
}
},
created() {
this.current = 0;
console.log(this.classifyList);
this.getGoodsClassRecommend();
},
methods: {
getGoodsClassRecommend(gc_id) {
this.$u.api.getGoodsClassRecommend().then(res => {
if (res.errCode == 0) {
// current
this.current = 0;
this.classifyList = res.data.gc_recommend;
// this.getGoodsRecommend(this.classifyList[0].gc_id);
}
})
},
getGoodsRecommend(gc_id) {
this.$u.api.getGoodsRecommend({
page: 1,
gc_id: gc_id,
}).then((res)=>{
}).then(res => {
if (res.errCode == 0) {
this.goodsList = res.data.goodsList;
console.log(this.goodsList);
// console.log(this.goodsList);
this.setSwiperHeight();
}
})
},
setSwiperHeight() {
// height: 230px, margin-bottom: 13
this.swiperHeight = Math.ceil(this.goodsList.length / 2) * (230 + 13) + 'px';
},
// tabsswiper
tabsChange(index) {
this.swiperCurrent = index;
@ -108,5 +115,11 @@ export default {
// margin-top: 20rpx;
// }
.goods-item {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-top: 20rpx;
}
}
</style>

View File

@ -4,7 +4,7 @@
<view class="info">
<text class="title u-line-1">{{ info.goods_name }}</text>
<text class="jianjie u-line-2">{{ info.goods_advword }}</text>
<text class="price">{{ info.goods_price }}</text>
<text class="price">{{ info.goods_price }}</text>
</view>
</view>
</template>
@ -16,43 +16,53 @@ export default {
},
methods: {
toDetailsPage() {
this.$u.route({
url: 'pageB/sdetails/index',
params: {
id: this.info.goods_id
this.$u.api.getGoodsDetails({ id: this.info.goods_id }).then((res)=>{
if (res.errCode == 0) {
const goods = {
goods: res.data,
type: 1,
}
this.$store.commit('setGoodsDetails', goods);
this.$store.commit('setGoodsId', this.info.goods_id);
this.$u.route({
url: 'pageB/sdetails/index',
})
// console.log(this.goodsInfo.mobile_body);
}
})
})
}
},
}
</script>
<style lang="scss" scoped>
.item{
width: 330rpx;
height: 469rpx;
margin-bottom: 27rpx;
height: 460rpx;
margin-bottom: 26rpx;
background-color: #f8f8f8;
border-radius: 10rpx;
overflow: hidden;
border-radius: 10rpx 10rpx 0rpx 0rpx;
.img{
width: 100%;
height: 272rpx;
width: 330rpx;
height: 272rpx;
background: rgba(245,245,245,1);
border-radius: 10rpx 10rpx 0rpx 0rpx;
margin-bottom: 24rpx;
}
.info{
width: 320rpx;
padding: 0 12rpx;
padding: 0 12rpx 28rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
.title{
font-size: 30rpx;
color: #333;
margin-bottom: 13rpx;
}
.jianjie{
font-size: 26rpx;
color: #666;
margin-bottom: 20rpx;
}
.price{
color: #FF3131;

View File

@ -9,31 +9,30 @@
<image src="/static/image/common/19.png"></image>
客服
</view>
<view class="button" style="background:rgba(253,211,96,0.6);">试穿试送</view>
<view class="button" style="background:rgba(253,211,96,0.6);" v-if="info.goods_try == 1">试穿试送</view>
<view class="button" style="background:rgba(253,211,96,1);" @click="buy(2)">加入购物车</view>
<view class="button" style="background:rgba(255,120,15,1);" @click="buy(1)">立即购买</view>
</view>
<u-popup v-model="show" mode="bottom">
<scroll-view scroll-y="true" class="popup">
<view>
<view class="head">
<image class="image" :src="info.goods_image"></image>
<view class="info">
<text class="u-line-2">{{info.goods_name}}</text>
<text>{{info.goods_price}}</text>
</view>
</view>
<guige @sel="self" ref="guige" v-for="(item,index) in info.spec_value" :key="index" :title="info.spec_name[index]" :item="item"></guige>
<view class="num">
<text>购买数量</text>
<u-number-box v-model="value" @change="valChange"></u-number-box>
</view>
<view style="height:180rpx"></view>
</view>
<u-toast ref="uToast" />
</scroll-view>
</u-popup>
<scroll-view scroll-y="true" class="popup">
<view>
<view class="head">
<image class="image" :src="info.goods_image"></image>
<view class="info">
<text class="u-line-2">{{info.goods_name}}</text>
<text>{{info.goods_price}}</text>
</view>
</view>
<guige @sel="self" ref="guige" v-for="(item,index) in info.spec_value" :key="index" :title="info.spec_name[index]" :item="item"></guige>
<view class="num">
<text>购买数量</text>
<u-number-box v-model="value" @change="valChange"></u-number-box>
</view>
<view style="height:100rpx"></view>
</view>
<u-toast ref="uToast" />
</scroll-view>
</u-popup>
</view>
</template>
@ -41,26 +40,29 @@
import guige from "./guige"
export default {
name:"tloos",
props: ['id','info'],
props: ['id', 'info'],
components:{
guige
},
data(){
return {
show:false,
value:1,
sel:"",
quanxuan:false
show: false,
value: 1,
sel: "",
quanxuan: false
}
},
},
created() {
this.show = false;
},
methods: {
buy(type){
let that = this;
if(this.show){
if(this.info.spec_value == null){
this.$emit("buy",{type,value:that.value})
this.$emit("buy", { type, value: that.value })
}else if(this.quanxuan){
this.$emit("buy",{type,value:that.value})
this.$emit("buy", { type, value: that.value })
}else{
this.$refs.uToast.show({
title: '请选择规格',
@ -68,7 +70,7 @@ export default {
})
}
}else{
this.show = true
this.show = true;
}
},
@ -87,7 +89,6 @@ export default {
if(sel != 0){
arr.push(sel)
}
}
// console.log(arr.length)
if(arr.length == index){

View File

@ -26,8 +26,9 @@
<view class="hr"></view>
<!-- <navs :value="领券"></navs> -->
<navs :value="'产品规格'"></navs>
<navs :value="'产品颜色'"></navs>
<navs :value="'选择尺码'"></navs>
<!-- <navs :value="'产品颜色'"></navs> -->
<!-- <navs :value="'选择尺码'"></navs> -->
<!-- <navs v-for="(value, index) in goodsInfo.spec_name" :value="value" :key="index"></navs> -->
<view class="hr"></view>
<view class="group-user" v-if="groupUser.length">
<view class="top">
@ -84,7 +85,7 @@
<view class="name u-line-1">{{ user.member_nickname }}</view>
</view>
</view>
<view class="involvement-btn" @click="settlementOrder('involvement')">参与拼团</view>
<view class="involvement-btn" @click="settlementOrder({ type: 'involvement' })">参与拼团</view>
<image class="close" src="/static/image/common/17.png" @click="showInvolvementUser=false"></image>
</view>
</u-popup>
@ -119,7 +120,7 @@
</view>
</view>
<!-- 普通商品 tool -->
<tloos @buy="buy" @xuanze="xuanze" :id="goodsInfo.goods_commonid" :info="info" v-if="type==1"></tloos>
<tloos @buy="buy" @xuanze="xuanze" :id="goodsInfo.goods_commonid" :info="goodsInfo" v-if="type==1"></tloos>
<u-toast ref="uToast" />
</view>
</template>
@ -186,7 +187,7 @@ export default {
this.setTitle();
},
spikeGoods() {
this.settlementOrder(3)
this.settlementOrder()
},
setSpikeTime() {
const time = this.groupbuyInfo.groupbuy_endtime;
@ -210,45 +211,48 @@ export default {
}, 1000)
},
buy(info){
if(info.type == 2){
if(info.type == 2){ //
this.$u.api.addCart({
goods_id: this.id,
quantity: info.value,
}).then(res => {
this.$refs.uToast.show({
title: res.errCode[1],
title: res.message,
type: res.errCode == 0 ? 'success' : 'warning',
})
})
}
} else if (info.type == 1) { //
this.settlementOrder({num: info.value});
}
},
getGoodsDetails(id) {
this.id = id;
this.$u.api.getGoodsDetails({ id: id }).then((res)=>{
if (res.errCode == 0) {
this.goodsInfo = res.data.goods;
let list = [];
res.data.goods_image[0].forEach(item => {
let temp = {
image: item
}
list.push(temp);
})
this.list = list;
// console.log(this.goodsInfo.mobile_body);
}
})
this.$u.api.goodsInfo({id}).then((res)=>{
// console.log(res)
this.info = res.data.goods;
this.glist = res.data.spec_list;
})
},
settlementOrder(type) {
// getGoodsDetails(id) {
// this.id = id;
// this.$u.api.getGoodsDetails({ id: id }).then((res)=>{
// if (res.errCode == 0) {
// this.goodsInfo = res.data.goods;
// let list = [];
// res.data.goods_image[0].forEach(item => {
// let temp = {
// image: item
// }
// list.push(temp);
// })
// this.list = list;
// this.info = res.data.goods;
// this.glist = res.data.spec_list;
// // console.log(this.goodsInfo.mobile_body);
// }
// })
// },
//
/*
* @params {Number} type 拼团或者开团
**/
settlementOrder({type, num = 1} = {}) {
// ifcart 1: 0://
let params = {
ifcart: 0,
cart_id: [this.goodsInfo.goods_id + '|' + 1],
cart_id: [this.goodsInfo.goods_id + '|' + num],
}
if(this.type == 2) {
if(type == 'involvement') {
@ -288,7 +292,7 @@ export default {
let title = '';
switch (this.type) {
case 1:
title = '商品详情';
break;
case 2:
title = '拼团商品详情';

View File

@ -33,10 +33,10 @@
</view>
</view>
<view class="order-info">
<view @click="showCoupon({type: 2, store_id: item[0].store_id})" v-if="orderInfo.ifcart != 0">
<view @click="showCoupon({type: 2, store_id: item[0].store_id})" v-if="orderType == 1 || orderType == 5">
<view class="title">优惠券折扣</view>
<view class="value">
<view>{{ item.coupon_price ? item.coupon_price : '0.00' }}</view>
<view>-{{ storeCoupon[item[0].store_id] ? storeCoupon[item[0].store_id].voucher_price.toFixed(2) : '0.00' }}</view>
<image src="../static/image/1.png"></image>
</view>
</view>
@ -50,10 +50,10 @@
</view>
</view>
<view class="common-active">
<view @click="showCoupon({type: 1})" v-if="orderInfo.ifcart != 0">
<view @click="showCoupon({type: 1})" v-if="orderType == 1 || orderType == 5">
<view class="title">平台优惠券</view>
<view class="value">
<view>-{{ choiceCoupon.vouchertemplate_id ? choiceCoupon.voucher_price : '0.00' }}</view>
<view>-{{ choiceCoupon.vouchertemplate_id ? choiceCoupon.voucher_price.toFixed(2) : '0.00' }}</view>
<image src="../static/image/1.png"></image>
</view>
</view>
@ -66,11 +66,17 @@
</view>
</view>
<u-popup v-model="couponStatus" mode="bottom">
<scroll-view class="coupon-choose" style="height: 800rpx;">
<scroll-view class="coupon-choose" scroll-y style="height: 800rpx;" v-if="this.couponType.type == 1">
<view class="title">优惠券详情</view>
<view class="text">使用优惠券</view>
<Coupon :couponInfo="coupon" @use="useCoupon($event)" :goodsClass="goodsClass" v-for="(coupon, index) in couponList" :key="index"></Coupon>
<u-empty text="无可用优惠券" mode="coupon" v-if="!couponList.length"></u-empty>
<view class="text">店铺优惠券</view>
<Coupon :couponInfo="coupon" @use="useCoupon($event)" :goodsClass="goodsClass" v-for="(coupon, index) in orderInfo.store_voucher_all_list" :key="index"></Coupon>
<u-empty text="无可用优惠券" mode="coupon" v-if="!orderInfo.store_voucher_all_list.length"></u-empty>
</scroll-view>
<scroll-view class="coupon-choose" scroll-y style="height: 800rpx;" v-if="this.couponType.type == 2">
<view class="title">优惠券详情</view>
<view class="text">平台优惠券</view>
<Coupon :couponInfo="coupon" @use="useCoupon($event)" :goodsClass="goodsClass" v-for="(coupon, index) in orderInfo.store_voucher_list[this.couponType.store_id]" :key="index"></Coupon>
<u-empty text="无可用优惠券" mode="coupon" v-if="!orderInfo.store_voucher_list[this.couponType.store_id].length"></u-empty>
</scroll-view>
</u-popup>
<view class="bottom">
@ -110,9 +116,12 @@ export default {
}, //
couponList: [],
couponStatus: false,
couponType: {}, //
storeCoupon: {}, //
choiceCoupon: {}, // 使
goodsClass: [],
orderType: '', // 1 2 3 4 5
}
},
components: {
@ -140,6 +149,7 @@ export default {
this.orderInfo = this.$store.state.orderInfo;
console.log(this.orderType);
console.log(this.orderInfo);
this.getGoodsClass();
},
onShow() {
//
@ -156,7 +166,21 @@ export default {
'$store.state.orderAddress'(value) {
this.addressInfo = value;
this.getFreight();
}
},
// storeCoupon: {
// deep: true,
// handler() {
// console.log(222);
// this.setTotalPrice(); //
// }
// },
// choiceCoupon: {
// deep: true,
// handler() {
// console.log(111);
// this.setTotalPrice(); //
// }
// },
},
methods: {
// pintuangroup_headid
@ -198,16 +222,32 @@ export default {
})
}
}
//
let coupon = [];
for (const key in this.storeCoupon) {
if (this.storeCoupon.hasOwnProperty(key)) {
const element = this.storeCoupon[key];
temp = key + '|' + element.voucher_id;
coupon.push(temp);
temp = '';
}
}
// store_id0
if(JSON.stringify(this.choiceCoupon) != '{}') {
coupon.push(0 + '|' + this.choiceCoupon.voucher_id)
}
let params = {
ifcart: ifcart,
cart_id: id,
address_id: this.addressInfo.address_id,
buy_city_id: this.addressInfo.city_id,
voucher_id: coupon,
}
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 })
}
// console.log(params);
this.$u.api.sendOrder(params).then(res => {
if(res.errCode == 0) {
this.$u.route({
@ -222,36 +262,24 @@ export default {
}
})
},
async getCoupon({ type, store_id, status }) {
const res = await this.$u.api.getMemberCouponList({
showCoupon({ type, store_id = -1 } = {}) {
this.couponType = {
type: type,
store_id: store_id,
status: status,
})
return res;
},
showCoupon({ type, gc_id, store_id }) {
// this.getCoupon({
// type: type, // : 1, 2
// store_id: store_id,
// status: 1, // 1: 2: 3: 4:
// }).then(res => {
// this.couponStatus = true;
// })
let params = {
type: type, // : 1, 2
status: 1, // 1: 2: 3: 4:
store_id: store_id
}
if(store_id) Object.assign(params, 'store_id', store_id);
if(gc_id) Object.assign(params, 'gc_id', gc_id);
this.$u.api.getMemberCouponList(params).then(res => {
this.couponList = res.data;
this.couponStatus = true;
})
this.couponStatus = true;
},
useCoupon(coupon) {
this.choiceCoupon = coupon;
if(this.couponType.type == 1) this.choiceCoupon = coupon;
if(this.couponType.type == 2) {
Object.assign(this.storeCoupon, {
[this.couponType.store_id]: coupon
})
}
// console.log(this.choiceCoupon);
// console.log(this.storeCoupon);
this.couponStatus = false;
this.setTotalPrice(); //
},
getFreight() {
this.$u.api.getFreight({
@ -267,10 +295,11 @@ export default {
}
})
},
setTotalPrice(object) {
setTotalPrice() {
const goods = this.orderInfo.store_goods_total;
const freight = this.freight;
let price = 0;
//
[goods, freight].forEach(object => {
for (const key in object) {
if (object.hasOwnProperty(key)) {
@ -279,8 +308,20 @@ export default {
}
}
})
//
//
if(JSON.stringify(this.choiceCoupon) != '{}') price -= Number(this.choiceCoupon.voucher_price);
//
if(JSON.stringify(this.storeCoupon) != '{}') {
for (const key in this.storeCoupon) {
if (this.storeCoupon.hasOwnProperty(key)) {
const element = this.storeCoupon[key];
price -= element.voucher_price;
}
}
}
// console.log(price);
this.totalPrice = price.toFixed(2);
this.totalPrice = price.toFixed(2);
},
setDelivery(index) {
if(index == 1) {

View File

@ -100,7 +100,7 @@ export default {
// ifcart 1: 0://
this.$u.api.settlementOrder({ ifcart: 1, cart_id: id }).then(res => {
if(res.errCode == 0) {
this.$store.commit('orderType', 2);
this.$store.commit('setOrderType', 5);
this.$store.commit('updateOrderInfo', res.data);
this.$u.route({
url: '/pageC/cart/ConfirmOrder'

View File

@ -48,7 +48,7 @@
<image class="lingquan"></image>
<youhq></youhq>
<view class="hr" style="margin-top:40rpx"></view>
<list v-if="couponGroupList.length" :classifyList="couponGroupList"></list>
<list></list>
<view class="cart" @click="toCartPage">
<image src="/static/image/common/3.png"></image>
</view>
@ -196,7 +196,7 @@ export default {
</script>
<style lang="scss" scoped>
.shop{
padding: 0 33rpx;
padding: 0 33rpx 100rpx;
.top{
width: 100%;
height: 88rpx;