【拼团商品详情】

1. 初步增加活动详情的加载
pull/1/MERGE
YunaiV 2023-06-14 00:16:34 +08:00
parent 6fcb8196c3
commit cb01b3d6c1
3 changed files with 231 additions and 112 deletions

View File

@ -0,0 +1,10 @@
import request from "@/utils/request.js";
// 获得拼团活动明细
export function getCombinationActivity(id) {
return request.get("app-api/promotion/combination-activity/get-detail", {
id
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}

View File

@ -1,6 +1,6 @@
<template> <template>
<view> <view>
<!-- 头部 --> <!-- 顶部的 nav tab -->
<view class='navbar' :style="{height:navH+'rpx',opacity:opacity}"> <view class='navbar' :style="{height:navH+'rpx',opacity:opacity}">
<view class='navbarH' :style='"height:"+navH+"rpx;"'> <view class='navbarH' :style='"height:"+navH+"rpx;"'>
<view class='navbarCon acea-row row-center-wrapper'> <view class='navbarCon acea-row row-center-wrapper'>
@ -13,35 +13,35 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 返回键 -->
<!-- <view class='iconfont icon-xiangzuo' :style="'top:'+navH/2+'rpx'" @tap='returns'></view> --> <view id="home" class="home-nav acea-row row-center-wrapper iconfont icon-xiangzuo" :class="opacity>0.5?'on':''" :style="{ top: homeTop + 'rpx' }" v-if="returnShow" @tap="returns">
</view>
<!-- 详情 --> <!-- 详情 -->
<view class='product-con'> <view class='product-con'>
<scroll-view :scroll-top="scrollTop" scroll-y='true' scroll-with-animation="true" <scroll-view :scroll-top="scrollTop" scroll-y='true' scroll-with-animation="true"
:style="'height:'+height+'px;'" @scroll="scroll"> :style="'height:'+height+'px;'" @scroll="scroll">
<view id="past0"> <view id="past0">
<productConSwiper :imgUrls="imgUrls" class="mb30"></productConSwiper> <productConSwiper :imgUrls='spu.sliderPicUrls' />
<view class="pad30"> <!-- 价格库存销量 -->
<view class="pad30">
<view class='wrapper mb30'> <view class='wrapper mb30'>
<view class='share acea-row row-between row-bottom'> <view class='share acea-row row-between row-bottom'>
<view class='money font-color'> <view class='money font-color'>
<text class='num'>{{storeInfo.price || 0}}</text><text <text class='num'>{{ fen2yuan(spu.price) }}</text>
class='y-money'>{{storeInfo.otPrice || 0}}</text> <text class='y-money'>{{ fen2yuan(spu.marketPrice) }}</text>
</view> </view>
<view class='iconfont icon-fenxiang' @click="listenerActionSheet"></view> <view class='iconfont icon-fenxiang' @click="listenerActionSheet"></view>
</view> </view>
<view class='introduce line2'>{{storeInfo.storeName}}</view> <view class='introduce line2'>{{ spu.name }}</view>
<view class='label acea-row row-between-wrapper'> <view class='label acea-row row-between-wrapper'>
<view class='stock'>类型{{storeInfo.people || 0}}人团</view> <view class='stock'>类型{{ storeInfo.people || 0}}人团</view>
<view>累计销量{{parseFloat(storeInfo.sales) + parseFloat(storeInfo.ficti)}} {{storeInfo.unitName || ''}}</view> <view>累计销量{{parseFloat(storeInfo.sales) + parseFloat(storeInfo.ficti)}} {{storeInfo.unitName || ''}}</view>
<view>限购: {{ storeInfo.quotaShow ? storeInfo.quotaShow : 0 }} <view />
{{storeInfo.unitName || ''}}
</view>
</view> </view>
</view> </view>
<view class='attribute acea-row row-between-wrapper mb30 borRadius14' @tap='selecAttr' <view class='attribute acea-row row-between-wrapper mb30 borRadius14' @tap='selecAttr'
v-if='attribute.productAttr.length'> v-if='attribute.productAttr.length'>
<view class="line1">{{attr}}<text class='atterTxt'>{{attrValue}}</text></view> <view class="line1">{{ attr }}<text class='atterTxt'>{{attrValue}}</text></view>
<view class='iconfont icon-jiantou'></view> <view class='iconfont icon-jiantou'></view>
</view> </view>
<view class='notice acea-row row-middle mb30 borRadius14' v-if="parseFloat(pinkOkSum) >0"> <view class='notice acea-row row-middle mb30 borRadius14' v-if="parseFloat(pinkOkSum) >0">
@ -125,7 +125,7 @@
<navigator class='praise' hover-class='none' <navigator class='praise' hover-class='none'
:url='"/pages/users/goods_comment_list/index?productId="+storeInfo.productId'> :url='"/pages/users/goods_comment_list/index?productId="+storeInfo.productId'>
<i>好评</i><text class='font-color'>{{replyChance || 0}}%</text> <i>好评</i><text class='font-color'>{{replyChance || 0}}%</text>
<text class='iconfont icon-jiantou'></text> <text class='iconfont icon-jiantou'></text>
</navigator> </navigator>
</view> </view>
@ -133,7 +133,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class='product-intro' id="past2"> <view class='product-intro' id="past2">
<view class='title'> <view class='title'>
<image src="../../../static/images/xzuo.png"></image> <image src="../../../static/images/xzuo.png"></image>
@ -239,7 +239,6 @@
import { import {
mapGetters mapGetters
} from "vuex"; } from "vuex";
import { silenceBindingSpread } from "@/utils";
// #ifdef MP // #ifdef MP
import { import {
base64src base64src
@ -257,10 +256,8 @@
getCombinationDetail getCombinationDetail
} from '@/api/activity.js'; } from '@/api/activity.js';
import { import {
postCartAdd,
collectAdd, collectAdd,
collectDel, collectDel,
getReplyList,
getReplyConfig, getReplyConfig,
getReplyProduct getReplyProduct
} from '@/api/store.js'; } from '@/api/store.js';
@ -273,10 +270,13 @@
import userEvaluation from '@/components/userEvaluation/index.vue' import userEvaluation from '@/components/userEvaluation/index.vue'
import countDown from '@/components/countDown/index.vue' import countDown from '@/components/countDown/index.vue'
import shareRedPackets from '@/components/shareRedPackets'; import shareRedPackets from '@/components/shareRedPackets';
import {
getProductCode
} from '@/api/store.js'
import { spread } from "@/api/user"; import { spread } from "@/api/user";
import * as ProductSpuApi from '@/api/product/spu.js';
import * as ProductFavoriteApi from '@/api/product/favorite.js';
import * as ProductCommentApi from '@/api/product/comment.js';
import * as CombinationActivityApi from '@/api/promotion/combination.js';
import * as Util from '@/utils/util.js';
import * as ProductUtil from '@/utils/product.js';
export default { export default {
components: { components: {
shareRedPackets, shareRedPackets,
@ -298,15 +298,31 @@
}), }),
data() { data() {
return { return {
bgColor:{ // ========== ==========
'bgColor': '', id: 0, //
'Color': '#999999', activity: {}, //
'isDay': true status: 1, // 0 - 1 - 2 - 3 -
}, bgColor:{
'bgColor': '',
'Color': '#999999',
'isDay': true
},
// ========== ==========
spu: {}, // SPU
skuMap: [], // SKU Map
attrValue: '', // ,
tagStyle: {
img: 'width:100%;display:block;',
table: 'width:100%',
video: 'width:100%'
},
// TODO
userCollect:false, userCollect:false,
dataShow: 0, dataShow: 0,
navH: '',
id: 0,
userInfo: {}, userInfo: {},
itemNew: [], itemNew: [],
indicatorDots: false, indicatorDots: false,
@ -322,7 +338,6 @@
productValue: [], productValue: [],
isOpen: false, isOpen: false,
attr: '请选择', attr: '请选择',
attrValue: '',
AllIndex: 2, AllIndex: 2,
maxAllIndex: 0, maxAllIndex: 0,
replyChance: '', replyChance: '',
@ -348,11 +363,7 @@
sharePacket: { sharePacket: {
isState: true, // isState: true, //
}, },
tagStyle: {
img: 'width:100%;display:block;',
table: 'width:100%',
video: 'width:100%'
},
posters: false, posters: false,
weixinStatus: false, weixinStatus: false,
posterImageStatus: false, posterImageStatus: false,
@ -436,7 +447,7 @@
try { try {
uni.setStorageSync('comGoodsId', options.id); uni.setStorageSync('comGoodsId', options.id);
} catch (e) {} } catch (e) {}
// #endif // #endif
this.$Cache.set('login_back_url', this.$Cache.set('login_back_url',
`/pages/activity/goods_combination_details/index?id=${options.id}&spread=${options.pid?options.pid:0}` `/pages/activity/goods_combination_details/index?id=${options.id}&spread=${options.pid?options.pid:0}`
); );
@ -460,7 +471,164 @@
}; };
}, },
methods: { methods: {
getProductReplyCount: function() { // ========== ==========
//
combinationDetail() {
CombinationActivityApi.getCombinationActivity(this.id).then(res => {
this.activity = res.data;
// quota
this.activity.quota = this.activity.products.reduce((accumulator, product) => {
return accumulator + product.quota;
}, 0);
//
const now = new Date().getTime();
if (this.activity.status !== 0) {
if (this.activity.startTime > now) {
this.status = 1;
} else if (now <= this.activity.endTime) {
this.status = 2;
} else {
this.status = 3;
}
} else {
this.status = 0;
}
//
this.getGoodsDetails();
});
if (true) {
return
}
var that = this;
var data = that.id;
getCombinationDetail(data).then(function(res) {
that.dataShow = 1;
uni.setNavigationBarTitle({
title: res.data.storeCombination.storeName.substring(0, 16)
})
that.storeInfo = res.data.storeCombination;
that.getProductReplyList();
that.getProductReplyCount();
that.imgUrls = JSON.parse(res.data.storeCombination.sliderImage);
that.attribute.productSelect.num = res.data.storeCombination.onceNum;
that.userCollect = res.data.userCollect;
that.pink = res.data.pinkList || [];
// that.pindAll = res.data.pindAll || [];
that.itemNew = res.data.pinkOkList || [];
that.pinkOkSum = res.data.pinkOkSum;
that.attribute.productAttr = res.data.productAttr || [];
that.productValue = res.data.productValue;
that.onceNum = res.data.storeCombination.onceNum;
// that.PromotionCode = res.data.storeInfo.code_base
// #ifdef H5
that.setShare();
that.storeImage = that.storeInfo.image
that.make();
// #endif
// #ifdef MP
that.getQrcode();
that.imgTop = res.data.storeCombination.image;
// #endif
// #ifndef H5
that.downloadFilestoreImage();
// #endif
let productAttr = res.data.productAttr.map(item => {
return {
attrName : item.attrName,
attrValues: item.attrValues.split(','),
id:item.id,
isDel:item.isDel,
productId:item.productId,
type:item.type
}
});
that.$set(that.attribute,'productAttr',productAttr);
// that.setProductSelect();
that.DefaultSelect();
setTimeout(function() {
that.infoScroll();
}, 500);
}).catch(function(err) {
that.$util.Tips({
title: err
}, {
tab: 3
})
})
},
// ========== ==========
/**
* 获取产品详情
*/
getGoodsDetails: function() {
console.log(this.activity.spuId, '== spuId ==')
ProductSpuApi.getSpuDetail(this.activity.spuId).then(res => {
let spu = res.data;
let skus = res.data.skus;
this.$set(this, 'spu', spu);
// TODO this.attribute
this.$set(this.attribute, 'properties', ProductUtil.convertProductPropertyList(skus));
this.$set(this, 'skuMap', ProductUtil.convertProductSkuMap(skus));
// SKU
this.activity.products.forEach(product => {
this.spu.price = Math.min(this.spu.price, product.combinationPrice); // SPU
});
skus.forEach(sku => {
const product = this.activity.products.find(product => product.skuId === sku.id);
if (product) {
sku.price = product.combinationPrice;
sku.quota = product.quota;
sku.limitCount = product.limitCount;
} else { //
sku.quota = 0;
sku.limitCount = 0;
}
});
// //
// setTimeout(() => {
// this.infoScroll();
// }, 1000);
//
// //
// // #ifdef H5
// this.storeImage = spu.picUrl;
// this.make();
// this.ShareInfo();
// // #endif
// // #ifdef MP
// this.getQrcode();
// this.imgTop = spu.picUrl;
// // #endif
// // #ifndef H5
// this.downloadFilestoreImage();
// // #endif
//
// // sku
// this.selectDefaultSku();
}).catch(err => {
if (true) {
return;
}
return this.$util.Tips({
title: err.toString()
}, {
tab: 3,
url: 1
});
})
},
// TODO
getProductReplyCount: function() {
let that = this; let that = this;
getReplyConfig(that.storeInfo.productId).then(res => { getReplyConfig(that.storeInfo.productId).then(res => {
that.$set(that, 'replyChance', res.data.replyChance * 100); that.$set(that, 'replyChance', res.data.replyChance * 100);
@ -494,7 +662,7 @@
}, },
/** /**
* 购物车手动填写 * 购物车手动填写
* *
*/ */
iptCartNum: function(e) { iptCartNum: function(e) {
if (e > this.onceNum) { if (e > this.onceNum) {
@ -512,68 +680,6 @@
returns() { returns() {
uni.navigateBack(); uni.navigateBack();
}, },
//
combinationDetail() {
var that = this;
var data = that.id;
getCombinationDetail(data).then(function(res) {
that.dataShow = 1;
uni.setNavigationBarTitle({
title: res.data.storeCombination.storeName.substring(0, 16)
})
that.storeInfo = res.data.storeCombination;
that.getProductReplyList();
that.getProductReplyCount();
that.imgUrls = JSON.parse(res.data.storeCombination.sliderImage);
that.attribute.productSelect.num = res.data.storeCombination.onceNum;
that.userCollect = res.data.userCollect;
that.pink = res.data.pinkList || [];
// that.pindAll = res.data.pindAll || [];
that.itemNew = res.data.pinkOkList || [];
that.pinkOkSum = res.data.pinkOkSum;
that.attribute.productAttr = res.data.productAttr || [];
that.productValue = res.data.productValue;
that.onceNum = res.data.storeCombination.onceNum;
// that.PromotionCode = res.data.storeInfo.code_base
// #ifdef H5
that.setShare();
that.storeImage = that.storeInfo.image
that.make();
// #endif
// #ifdef MP
that.getQrcode();
that.imgTop = res.data.storeCombination.image;
// #endif
// #ifndef H5
that.downloadFilestoreImage();
// #endif
let productAttr = res.data.productAttr.map(item => {
return {
attrName : item.attrName,
attrValues: item.attrValues.split(','),
id:item.id,
isDel:item.isDel,
productId:item.productId,
type:item.type
}
});
that.$set(that.attribute,'productAttr',productAttr);
// that.setProductSelect();
that.DefaultSelect();
setTimeout(function() {
that.infoScroll();
}, 500);
}).catch(function(err) {
that.$util.Tips({
title: err
}, {
tab: 3
})
})
},
//#ifdef H5 //#ifdef H5
setShare: function() { setShare: function() {
this.$wechat.isWeixin() && this.$wechat.isWeixin() &&
@ -596,7 +702,7 @@
//#endif //#endif
/** /**
* 默认选中属性 * 默认选中属性
* *
*/ */
DefaultSelect: function() { DefaultSelect: function() {
let self = this let self = this
@ -700,7 +806,7 @@
}, },
/** /**
* 购物车数量加和数量减 * 购物车数量加和数量减
* *
*/ */
ChangeCartNum: function(changeValue) { ChangeCartNum: function(changeValue) {
//changeValue: | //changeValue: |
@ -760,7 +866,7 @@
}, },
/** /**
* 属性变动赋值 * 属性变动赋值
* *
*/ */
ChangeAttr: function(res) { ChangeAttr: function(res) {
this.$set(this, 'cart_num', 1); this.$set(this, 'cart_num', 1);
@ -840,7 +946,7 @@
/** /**
* 分享打开 * 分享打开
* *
*/ */
listenerActionSheet: function() { listenerActionSheet: function() {
if (this.isLogin == false) { if (this.isLogin == false) {
@ -908,7 +1014,7 @@
/** /**
* 获取产品分销二维码 * 获取产品分销二维码
* @param function successFn 下载完成回调 * @param function successFn 下载完成回调
* *
*/ */
downloadFilePromotionCode: function(successFn) { downloadFilePromotionCode: function(successFn) {
let that = this; let that = this;
@ -1117,6 +1223,10 @@
this.lock = true; this.lock = true;
this.scrollTop = index > 0 ? that.topArr[index] - (app.globalData.navHeight / 2) : that.topArr[index] this.scrollTop = index > 0 ? that.topArr[index] - (app.globalData.navHeight / 2) : that.topArr[index]
}, },
fen2yuan(price) {
return Util.fen2yuan(price)
}
}, },
//#ifdef MP //#ifdef MP
onShareAppMessage() { onShareAppMessage() {

View File

@ -15,7 +15,8 @@
<!-- 返回键 --> <!-- 返回键 -->
<view id="home" class="home-nav acea-row row-center-wrapper iconfont icon-xiangzuo" :class="opacity>0.5?'on':''" :style="{ top: homeTop + 'rpx' }" v-if="returnShow" @tap="returns"> <view id="home" class="home-nav acea-row row-center-wrapper iconfont icon-xiangzuo" :class="opacity>0.5?'on':''" :style="{ top: homeTop + 'rpx' }" v-if="returnShow" @tap="returns">
</view> </view>
<view class='product-con'> <!-- 详情 -->
<view class='product-con'>
<scroll-view :scroll-top="scrollTop" scroll-y='true' scroll-with-animation="true" :style="'height:'+height+'px;'" <scroll-view :scroll-top="scrollTop" scroll-y='true' scroll-with-animation="true" :style="'height:'+height+'px;'"
@scroll="scroll"> @scroll="scroll">
<view id="past0"> <view id="past0">
@ -209,7 +210,7 @@
export default { export default {
data() { data() {
return { return {
// // ========== ==========
id: 0, // id: 0, //
activity: {}, // activity: {}, //
status: 1, // 0 - 1 - 2 - 3 - status: 1, // 0 - 1 - 2 - 3 -
@ -221,7 +222,7 @@
'timeTxtwidth': '16rpx', 'timeTxtwidth': '16rpx',
}, },
// // ========== ==========
spu: {}, // SPU spu: {}, // SPU
skuMap: [], // SKU Map skuMap: [], // SKU Map
attrValue: '', // , attrValue: '', // ,
@ -378,9 +379,7 @@
methods: { methods: {
// ========== ========== // ========== ==========
getSeckillDetail: function() { getSeckillDetail: function() {
let that = this;
SeckillActivityApi.getSeckillActivity(this.id).then(res => { SeckillActivityApi.getSeckillActivity(this.id).then(res => {
this.dataShow = 1;
this.activity = res.data; this.activity = res.data;
// quota // quota
this.activity.quota = this.activity.products.reduce((accumulator, product) => { this.activity.quota = this.activity.products.reduce((accumulator, product) => {
@ -397,7 +396,7 @@
this.status = 3; this.status = 3;
} }
} else { } else {
this.status = this.activity; this.status = 0;
} }
// //
@ -411,7 +410,7 @@
app.globalData.openPages = '/pages/activity/goods_seckill_details/index?id=' app.globalData.openPages = '/pages/activity/goods_seckill_details/index?id='
+ this.id + '&spread=' + this.uid; + this.id + '&spread=' + this.uid;
}).catch(err => { }).catch(err => {
that.$util.Tips({ this.$util.Tips({
title:err title:err
},{ },{
tab:3 tab:3