【秒杀商品详情】

1. 接入分销
pull/1/MERGE
YunaiV 2023-06-11 22:59:10 +08:00
parent ddf9aa6d8a
commit 0ceb18b823
6 changed files with 274 additions and 284 deletions

View File

@ -4,6 +4,8 @@ import request from "@/utils/request.js";
export function getCommentStatistics(spuId) {
return request.get('app-api/product/comment/statistics', {
spuId
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}
@ -12,5 +14,7 @@ export function getCommentList(spuId, count) {
return request.get('app-api/product/comment/list', {
spuId,
count
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}

View File

@ -4,6 +4,8 @@ import request from "@/utils/request.js";
export function getActivityListBySpuId(spuId) {
return request.get("app-api/promotion/activity/list-by-spu-id", {
spuId
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}
@ -11,5 +13,7 @@ export function getActivityListBySpuId(spuId) {
export function getActivityListBySpuIds(spuIds) {
return request.get("app-api/promotion/activity/list-by-spu-ids", {
spuIds
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}

View File

@ -4,5 +4,7 @@ import request from "@/utils/request.js";
export function getSeckillActivity(id) {
return request.get("app-api/promotion/seckill-activity/get-detail", {
id
}, {
noAuth: true // TODO 芋艿:后续要做调整
});
}

View File

@ -48,9 +48,9 @@
+
</view>
<view v-else class='item plus'
:class='(attr.productSelect.cart_num >= attr.productSelect.quota) //
|| (attr.productSelect.cart_num >= attr.productSelect.stock) //
|| (attr.productSelect.cart_num >= attr.productSelect.limitCount) //
:class='(attr.productSelect.cart_num >= attr.productSelect.quota)
|| (attr.productSelect.cart_num >= attr.productSelect.stock)
|| (attr.productSelect.cart_num >= attr.productSelect.limitCount)
? "on":""'
@click='CartNumAdd'>+</view>
</view>

View File

@ -93,7 +93,7 @@
<view>客服</view>
</navigator>
<!-- #endif -->
<!-- 收藏 TODO -->
<!-- 收藏 -->
<view @tap='setCollect' class='item'>
<view class='iconfont icon-shoucang1' v-if="userCollect"></view>
<view class='iconfont icon-shoucang' v-else></view>
@ -136,7 +136,7 @@
@close="closeAttr"
/>
<home></home>
<!-- 分享按钮 TODO-->
<!-- 分享按钮 -->
<view class="generate-posters acea-row row-middle" :class="posters ? 'on' : ''">
<!-- #ifndef MP -->
<button class="item" hover-class='none' v-if="weixinStatus === true" @click="H5ShareBox = true">
@ -145,7 +145,7 @@
</button>
<!-- #endif -->
<!-- #ifdef MP -->
<button class="item" open-type="share" hover-class='none' @click="goFriend">
<button class="item" open-type="share" hover-class='none' @click="closePosters">
<view class="iconfont icon-weixin3"></view>
<view class="">发送给朋友</view>
</button>
@ -156,7 +156,7 @@
</button>
</view>
<view class="mask" v-if="posters" @click="closePosters"></view>
<view class="mask" v-if="canvasStatus" @click="listenerActionClose"></view>
<view class="mask" v-if="canvasStatus" @click="closePosters"></view>
<!-- 海报展示 TODO -->
<view class='poster-pop' v-if="canvasStatus">
<image src='/static/images/poster-close.png' class='close' @click="posterImageClose"></image>
@ -182,19 +182,7 @@
<script>
const app = getApp();
import uQRCode from '@/js_sdk/Sansnn-uQRCode/uqrcode.js'
import {
mapGetters
} from "vuex";
import {
getSeckillDetail,
seckillCode
} from '@/api/activity.js';
import {
collectAdd,
collectDel,
getReplyList,
getReplyConfig
} from '@/api/store.js';
import { mapGetters } from "vuex";
import productConSwiper from '@/components/productConSwiper/index.vue'
import productWindow from '@/components/productWindow/index.vue'
import userEvaluation from '@/components/userEvaluation/index.vue'
@ -208,12 +196,8 @@
import home from '@/components/home/index.vue'
import countDown from '@/components/countDown';
import shareRedPackets from '@/components/shareRedPackets';
import {
imageBase64
} from "@/api/public";
import {
toLogin
} from '@/libs/login.js';
import { imageBase64 } from "@/api/public";
import { toLogin } from '@/libs/login.js';
import { silenceBindingSpread } from "@/utils";
import { spread } from "@/api/user";
import * as ProductSpuApi from '@/api/product/spu.js';
@ -293,7 +277,7 @@
posterImageStatus: false,
canvasStatus: false, //
storeImage: '', //
PromotionCode: '', //
promotionCode: '', //
posterImage: '', //
posterbackgd: '/static/images/posterbackgd.png',
actionSheetHidden: false,
@ -388,6 +372,15 @@
//
this.getSeckillDetail();
},
//#ifdef MP
onShareAppMessage() {
return {
title: this.spu.name || '',
imageUrl: this.spu.picUrl,
path: app.globalData.openPages
};
},
//#endif
onReady() {
this.$nextTick(() => {
// top
@ -483,7 +476,7 @@
// #ifdef H5
this.storeImage = spu.picUrl;
this.make();
this.setShare();
this.ShareInfo();
// #endif
// #ifdef MP
this.getQrcode();
@ -719,35 +712,244 @@
}
},
// ========== ==========
/**
* 生成二维码设置到 promotionCode 变量
*/
make() {
let href = location.href.split('?')[0] + "?id="+ this.id + "&spread=" + this.uid;
uQRCode.make({
canvasId: 'qrcode',
text: href,
size: this.qrcodeSize,
margin: 10,
success: res => {
this.promotionCode = res;
},
complete: () => {},
fail:res => {
this.$util.Tips({
title: '海报二维码生成失败!'
});
}
})
},
/**
* 设置微信公众号的分享标题内容等信息
*/
ShareInfo: function() {
//
if (!this.$wechat.isWeixin()) {
return
}
const spu = this.spu;
let href = location.href;
href = href.indexOf("?") === -1 ?
href + "?spread=" + this.uid :
href + "&spread=" + this.uid;
const configAppMessage = {
title: spu.name,
imgUrl: spu.picUrl,
desc: spu.description,
link: href
};
this.$wechat.wechatEvevt([
"updateAppMessageShareData",
"updateTimelineShareData",
"onMenuShareAppMessage",
"onMenuShareTimeline"
], configAppMessage);
},
/**
* 获得商品的封面 base64
*/
getImageBase64:function(images) {
imageBase64({
url: images
}).then(res=>{
this.imgTop = res.data.code
})
},
/**
* 获得小程序的二维码
*/
getQrcode() {
let data = {
pid: this.uid,
id: this.id,
path: 'pages/activity/goods_seckill_details/index'
}
getQrcode(data).then(res=>{
base64src(res.data.code, res => {
this.promotionCode = res;
});
}).catch(err => {
this.errT = err;
});
},
/**
* 生成海报
*/
goPoster: function() {
//
uni.showLoading({
title: '海报生成中',
mask: true
});
this.posters = false;
//
if(!this.promotionCode){
uni.hideLoading();
this.$util.Tips({
title: this.errT
});
return
}
//
setTimeout(() => {
if (!this.imgTop) {
uni.hideLoading();
this.$util.Tips({
title: '无法生成商品海报!'
});
}
}, 1000);
//
const that = this;
let arrImagesUrlTop = '';
uni.downloadFile({
url: this.imgTop, //
success: (res) => {
arrImagesUrlTop = res.tempFilePath;
let arrImages = [that.posterbackgd, arrImagesUrlTop, that.promotionCode];
const name = that.spu.name;
const price = that.fen2yuan(that.spu.price);
const marketPrice = that.fen2yuan(that.spu.marketPrice);
setTimeout(() => {
that.$util.PosterCanvas(arrImages, name, price, marketPrice,
function(tempFilePath) {
that.posterImage = tempFilePath;
that.canvasStatus = true;
uni.hideLoading();
});
}, 500);
}
});
},
/**
* 关闭分享弹窗
*/
closePosters: function() {
this.posters = false;
},
/**
* 隐藏海报
*/
posterImageClose: function() {
this.canvasStatus = false
},
/**
* 获取海报产品图解决跨域问题只适用于小程序
*/
downloadFilestoreImage: function() {
let that = this;
uni.downloadFile({
url: that.setDomain(that.spu.picUrl),
success: function(res) {
that.storeImage = res.tempFilePath;
},
fail: function() {
return that.$util.Tips({
title: ''
});
},
});
},
/**
* 替换安全域名
*/
setDomain: function(url) {
url = url ? url.toString() : '';
// ,
if (url.indexOf("https://") > -1) {
return url;
}
return url.replace('http://', 'https://');
},
/**
* 分享打开
*/
listenerActionSheet: function() {
if (!this.isLogin) {
toLogin();
return
}
// #ifdef H5
if (this.$wechat.isWeixin() === true) {
this.weixinStatus = true;
}
// #endif
this.posters = true;
},
/**
* 微信小程序的保存图片到本机
*/
// #ifdef MP
savePosterPath: function() {
let that = this;
uni.getSetting({
success(res) {
if (!res.authSetting['scope.writePhotosAlbum']) {
uni.authorize({
scope: 'scope.writePhotosAlbum',
success() {
uni.saveImageToPhotosAlbum({
filePath: that.posterImage,
success: function(res) {
that.posterImageClose();
that.$util.Tips({
title: '保存成功',
icon: 'success'
});
},
fail: function(res) {
that.$util.Tips({
title: '保存失败'
});
}
})
}
})
} else {
uni.saveImageToPhotosAlbum({
filePath: that.posterImage,
success: function(res) {
that.posterImageClose();
that.$util.Tips({
title: '保存成功',
icon: 'success'
});
},
fail: function(res) {
that.$util.Tips({
title: '保存失败'
});
},
})
}
}
})
},
// #endif
// TODO
closePosters:function(){
this.posters = false;
},
// 退
returns: function() {
uni.navigateBack()
},
setShare: function() {
this.$wechat.isWeixin() &&
this.$wechat.wechatEvevt([
"updateAppMessageShareData",
"updateTimelineShareData",
"onMenuShareAppMessage",
"onMenuShareTimeline"
], {
desc: this.storeInfo.info,
title: this.storeInfo.title,
link: location.href,
imgUrl: this.storeInfo.image
}).then(res => {
}).catch(err => {
console.log(err);
});
},
scroll: function(e) {
var that = this,
@ -802,230 +1004,11 @@
}
},
/**
* 分享打开
*
*/
listenerActionSheet: function() {
if (this.isLogin === false) {
toLogin();
} else {
// #ifdef H5
if(!this.imgTop)this.getImageBase64(this.storeImage);
if (this.$wechat.isWeixin() === true) {
this.weixinStatus = true;
}
// #endif
this.posters = true;
}
},
//
listenerActionClose: function() {
this.posters = false;
},
//
posterImageClose: function() {
this.canvasStatus = false
},
//
setDomain: function(url) {
url = url ? url.toString() : '';
//,
if (url.indexOf("https://") > -1) return url;
else return url.replace('http://', 'https://');
},
//
downloadFilestoreImage: function() {
let that = this;
uni.downloadFile({
url: that.setDomain(that.storeInfo.image),
success: function(res) {
that.storeImage = res.tempFilePath;
},
fail: function() {
return that.$util.Tips({
title: ''
});
that.storeImage = '';
},
});
},
getImageBase64:function(images){
let that = this;
imageBase64({url:images}).then(res=>{
that.imgTop = res.data.code
})
},
//
goFriend: function() {
this.posters = false;
},
/**
* 生成海报
*/
goPoster: function() {
let that = this;
uni.showLoading({
title: '海报生成中',
mask: true
});
that.posters = false;
let arrImagesUrl = '';
let arrImagesUrlTop = '';
if(!that.PromotionCode){
uni.hideLoading();
that.$util.Tips({
title: that.errT
});
return
}
setTimeout(() => {
if (!that.imgTop) {
uni.hideLoading();
that.$util.Tips({
title: '无法生成商品海报!'
});
return
}
}, 1000);
uni.downloadFile({
url: that.imgTop, //
success: (res) => {
arrImagesUrlTop = res.tempFilePath;
let arrImages = [that.posterbackgd, arrImagesUrlTop, that.PromotionCode];
let storeName = that.storeInfo.storeName;
let price = that.storeInfo.price;
setTimeout(() => {
that.$util.PosterCanvas(arrImages, storeName, price, that.storeInfo.otPrice,function(tempFilePath) {
that.posterImage = tempFilePath;
that.canvasStatus = true;
uni.hideLoading();
});
}, 500);
}
});
},
//
getQrcode(){
let that = this;
let data = {
pid: that.uid,
id: that.id,
path: 'pages/activity/goods_seckill_details/index'
}
getQrcode(data).then(res=>{
base64src(res.data.code, res => {
that.PromotionCode = res;
});
}).catch(err => {
that.errT = err;
});
},
//
make() {
let href = location.href.split('?')[0] + "?id="+ this.id + "&spread=" + this.uid;
uQRCode.make({
canvasId: 'qrcode',
text: href,
size: this.qrcodeSize,
margin: 10,
success: res => {
this.PromotionCode = res;
},
complete: (res) => {
},
fail:res=>{
this.$util.Tips({
title: '海报二维码生成失败!'
});
}
})
},
/*
* 保存到手机相册
*/
// #ifdef MP
savePosterPath: function() {
let that = this;
uni.getSetting({
success(res) {
if (!res.authSetting['scope.writePhotosAlbum']) {
uni.authorize({
scope: 'scope.writePhotosAlbum',
success() {
uni.saveImageToPhotosAlbum({
filePath: that.posterImage,
success: function(res) {
that.posterImageClose();
that.$util.Tips({
title: '保存成功',
icon: 'success'
});
},
fail: function(res) {
that.$util.Tips({
title: '保存失败'
});
}
})
}
})
} else {
uni.saveImageToPhotosAlbum({
filePath: that.posterImage,
success: function(res) {
that.posterImageClose();
that.$util.Tips({
title: '保存成功',
icon: 'success'
});
},
fail: function(res) {
that.$util.Tips({
title: '保存失败'
});
},
})
}
}
})
},
// #endif
setShareInfoStatus: function() {
let data = this.storeInfo;
let href = location.href;
if (this.$wechat.isWeixin()) {
href =
href.indexOf("?") === -1 ?
href + "?spread=" + this.uid :
href + "&spread=" + this.uid;
let configAppMessage = {
desc: data.storeInfo,
title: data.storeName,
link: href,
imgUrl: data.image
};
this.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"], configAppMessage)
}
},
fen2yuan(price) {
return Util.fen2yuan(price)
}
},
//#ifdef MP
onShareAppMessage() {
let that = this;
return {
title: that.storeInfo.title,
path: app.globalData.openPages,
imageUrl: that.storeInfo.image
};
},
//#endif
}
</script>

View File

@ -983,25 +983,23 @@
if (!this.$wechat.isWeixin()) {
return
}
let spu = this.spu;
const spu = this.spu;
let href = location.href;
href = href.indexOf("?") === -1 ? href + "?spread=" + this.uid : href + "&spread=" + this.uid;
let configAppMessage = {
desc: spu.description,
href = href.indexOf("?") === -1 ?
href + "?spread=" + this.uid :
href + "&spread=" + this.uid;
const configAppMessage = {
title: spu.name,
link: href,
imgUrl: spu.picUrl
imgUrl: spu.picUrl,
desc: spu.description,
link: href
};
this.$wechat.wechatEvevt([
"updateAppMessageShareData",
"updateTimelineShareData",
"onMenuShareAppMessage",
"onMenuShareTimeline"
], configAppMessage).then(res => {
console.log(res);
}).catch(err => {
console.log(err);
})
], configAppMessage);
},
/**
* 获得商品的封面 base64
@ -1064,12 +1062,11 @@
uni.downloadFile({
url: that.imgTop, //
success: (res) => {
debugger
arrImagesUrlTop = res.tempFilePath;
const arrImages = [that.posterbackgd, arrImagesUrlTop, that.promotionCode];
const name = that.spu.name;
const price = that.fen2yuan(this.spu.price);
const marketPrice = that.fen2yuan(this.spu.marketPrice);
const price = that.fen2yuan(that.spu.price);
const marketPrice = that.fen2yuan(that.spu.marketPrice);
setTimeout(() => {
that.$util.PosterCanvas(arrImages, name, price, marketPrice,
function(tempFilePath) {