Commit 24f34329 authored by beisir's avatar beisir

Merge branch 'feat/group-buy' of git.quantgroup.cn:ui/group-buy-ui into feat/group-buy

parents 8535910a ff0abda8
...@@ -53,6 +53,10 @@ export default { ...@@ -53,6 +53,10 @@ export default {
params params
}); });
}, },
// 获取小程序码
getQrcodeUrl(params) {
return http.get(`${talosHost}/api/kdsp/playBill/getMakePicData`, params);
},
getGroupShareInfo(orderNo) { getGroupShareInfo(orderNo) {
return http.get(`${talosHost}/api/kdsp/groupShareInfo?orderNo=${orderNo}`); return http.get(`${talosHost}/api/kdsp/groupShareInfo?orderNo=${orderNo}`);
} }
......
...@@ -84,6 +84,7 @@ export default { ...@@ -84,6 +84,7 @@ export default {
const getCouponList = function(params) { const getCouponList = function(params) {
return request.get(`${talosHost}/api/kdsp/appconfig/pay-succ-page/guide-stream`, { params }); return request.get(`${talosHost}/api/kdsp/appconfig/pay-succ-page/guide-stream`, { params });
}; };
export { export {
pay, pay,
prepay, prepay,
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</div> </div>
<div class="skuImg"> <div class="skuImg">
<!-- 商品图 --> <!-- 商品图 -->
<img src="https://img.lkbang.net/activity/share/default/skuImg.png" alt="" /> <img :src="sharePicData.skuImg" alt="" />
<div class="skuInfo"> <div class="skuInfo">
<div class="skuPrice"> <div class="skuPrice">
<span class="groupPriceContainer">拼团价 ¥</span> <span class="groupPriceContainer">拼团价 ¥</span>
...@@ -50,12 +50,12 @@ ...@@ -50,12 +50,12 @@
</div> </div>
<div class="skuName"> <div class="skuName">
<!-- 商品名称 --> <!-- 商品名称 -->
SAINT LAURENT PARIS 圣罗兰 方管纯口红 3.8克 女神挚爱款 千颂伊同款 {{ sharePicData.skuName }}
</div> </div>
<div class="shareInfo"> <div class="shareInfo">
<!-- 底部分享信息 --> <!-- 底部分享信息 -->
<div class="qrcode"> <div class="qrcode">
<img src="https://img.lkbang.net/activity/share/default/qrcode.png" alt="" /> <img :src="qrcodeUrl" alt="" />
</div> </div>
<div class="shareDesc"> <div class="shareDesc">
<p>分享自 <span>羊小咩小程序</span></p> <p>分享自 <span>羊小咩小程序</span></p>
...@@ -67,21 +67,40 @@ ...@@ -67,21 +67,40 @@
<script> <script>
import html2canvas from 'html2canvas'; import html2canvas from 'html2canvas';
import qiNiuApi from '@/api/qiniu.api'; import qiNiuApi from '@/api/qiniu.api';
import groupBuyApi from '@/api/groupBuy';
import { upload } from 'qiniu-js'; import { upload } from 'qiniu-js';
import config from '@/config'; import config from '@/config';
export default { export default {
mounted() { props: {
// this.uploadPic(); sharePicData: {
type: Object,
default: () => {
return {};
}
}
},
data() {
return {
qrcodeUrl: ''
};
}, },
methods: { methods: {
async uploadPic() { async createAndUploadPic() {
console.log(999);
const _this = this;
const [qrcodeUrl] = await groupBuyApi.getQrcodeUrl(this.sharePicData);
console.log(888);
this.qrcodeUrl = qrcodeUrl;
const [res] = await qiNiuApi.getQiniuToken(); const [res] = await qiNiuApi.getQiniuToken();
const token = res.token; const token = res.token;
console.log(777);
this.$nextTick(() => {
html2canvas(this.$refs.sharePic, { html2canvas(this.$refs.sharePic, {
width: 1080, width: 1080,
height: 1920, height: 1920,
useCORS: true, useCORS: true,
scale: 1 scale: 1,
allowTaint: false
}).then(function(canvas) { }).then(function(canvas) {
canvas.toBlob( canvas.toBlob(
blob => { blob => {
...@@ -91,22 +110,18 @@ export default { ...@@ -91,22 +110,18 @@ export default {
console.log(err); console.log(err);
}, },
complete({ hash }) { complete({ hash }) {
console.log('success', config.qiniuHost, hash);
const fileLink = config.qiniuHost + hash; const fileLink = config.qiniuHost + hash;
console.log('fileLink', fileLink); _this.$emit('outputPicUrl', fileLink);
} }
}; };
observable.subscribe(observer); observable.subscribe(observer);
// newImg.onload = function() {
// URL.revokeObjectURL(url);
// };
// newImg.src = url;
// document.body.appendChild(newImg);
}, },
'image/jpeg', 'image/jpeg',
0.85 0.85
); );
}); });
});
} }
} }
}; };
......
...@@ -11,7 +11,11 @@ ...@@ -11,7 +11,11 @@
</div> </div>
<div class="goods-product-info"> <div class="goods-product-info">
<div class="goods-product-info-img"> <div class="goods-product-info-img">
<span class="goods-product-info-tag">3人团</span> <span
v-if="detailInfo.groupBuyInfo && detailInfo.groupBuyInfo.groupBuyLimitUserCount"
class="goods-product-info-tag"
>{{ detailInfo.groupBuyInfo.groupBuyLimitUserCount }}人团</span
>
<cr-image width="108px" :src="detailInfo.thumbImageUrl" /> <cr-image width="108px" :src="detailInfo.thumbImageUrl" />
</div> </div>
<div class="goods-product-info-desc"> <div class="goods-product-info-desc">
...@@ -26,7 +30,7 @@ ...@@ -26,7 +30,7 @@
color="#EC1500" color="#EC1500"
track-color="#F7F8F9" track-color="#F7F8F9"
:show-pivot="false" :show-pivot="false"
:percentage="50" :percentage="stockPercentage"
/> />
</div> </div>
<div class="goods-product-info-desc-num"> <div class="goods-product-info-desc-num">
...@@ -116,6 +120,7 @@ export default { ...@@ -116,6 +120,7 @@ export default {
inProgress: false, // 活动是否已经开始 inProgress: false, // 活动是否已经开始
countDownText: '', countDownText: '',
showShareButton: false, // 是否显示分享按钮 showShareButton: false, // 是否显示分享按钮
stockPercentage: 0,
// 以下是原有的data // 以下是原有的data
detailParam: { detailParam: {
skuNo: '', skuNo: '',
...@@ -174,6 +179,15 @@ export default { ...@@ -174,6 +179,15 @@ export default {
localStorage.set('groupBuyGroupId', res.groupBuyInfo.groupId || ''); // 设置groupBuyGroupId,用于下单 localStorage.set('groupBuyGroupId', res.groupBuyInfo.groupId || ''); // 设置groupBuyGroupId,用于下单
this.groupId = +res.groupBuyInfo.groupId || ''; this.groupId = +res.groupBuyInfo.groupId || '';
} }
if (res.saleCount && res.activitySkuTotalCount) {
const percentage = +res.saleCount / +res.activitySkuTotalCount;
if (isNaN(percentage)) {
this.stockPercentage = 0;
} else {
this.stockPercentage = Math.floor(percentage) >= 1 ? 100 : Math.floor(percentage * 100);
}
console.log(this.stockPercentage);
}
this.showShareButton = res.groupBuyInfo.groupBuyStatus == 1 ? true : false; this.showShareButton = res.groupBuyInfo.groupBuyStatus == 1 ? true : false;
this.imgList = res.imageUrl || []; this.imgList = res.imageUrl || [];
this.detailInfo = res; this.detailInfo = res;
......
...@@ -207,9 +207,7 @@ export default { ...@@ -207,9 +207,7 @@ export default {
newUrl: `/pages/pay/index?orderNo=${data.orderNo}&from=groupbuy` newUrl: `/pages/pay/index?orderNo=${data.orderNo}&from=groupbuy`
}); });
} else if (isApp) { } else if (isApp) {
this.nativeBridge.openNewUrl({ this.$router.push({ path: `/pay?orderNo=${data.orderNo}` });
newUrl: `/pay?orderNo=${data.orderNo}`
});
} else { } else {
return; // todo 处理纯h5情况 return; // todo 处理纯h5情况
// this.$dialog({ // this.$dialog({
......
...@@ -59,18 +59,23 @@ ...@@ -59,18 +59,23 @@
</div> </div>
</div> </div>
<Goods /> <Goods />
<sharePic ref="sharePic" :share-pic-data="sharePicData" @outputPicUrl="outputPicUrl" />
</div> </div>
</template> </template>
<script> <script>
import { goUrlExtends } from './extends'; import { goUrlExtends } from './extends';
import CouponCard from './components/CouponCard.vue'; import CouponCard from './components/CouponCard.vue';
import { getCouponList } from '@/api/pay.api'; import { getCouponList } from '@/api/pay.api';
import groupBuyApi from '@/api/groupBuy';
import Goods from '@/components/RecoGoods/RecoGoods.vue'; import Goods from '@/components/RecoGoods/RecoGoods.vue';
import { isApp, isWxMp } from '@/service/validation.service'; import { isApp, isWxMp } from '@/service/validation.service';
import { EventBus } from '@/service/utils.service';
import sharePic from '@/components/sharePic';
export default { export default {
components: { components: {
Goods, Goods,
CouponCard CouponCard,
sharePic
}, },
extends: goUrlExtends, extends: goUrlExtends,
data() { data() {
...@@ -83,7 +88,8 @@ export default { ...@@ -83,7 +88,8 @@ export default {
couponList: [], couponList: [],
payStatusName: '', payStatusName: '',
payMethodName: '', payMethodName: '',
payType: '' payType: '',
sharePicData: {}
}; };
}, },
created() { created() {
...@@ -97,14 +103,36 @@ export default { ...@@ -97,14 +103,36 @@ export default {
this.freeAmount = freeAmount || ''; this.freeAmount = freeAmount || '';
this.payStatus = success ? '订单支付成功' : '订单支付失败'; this.payStatus = success ? '订单支付成功' : '订单支付失败';
this.payStatusName = success ? '支付成功' : '支付失败'; this.payStatusName = success ? '支付成功' : '支付失败';
this.$track?.registeredEvents('h5_RechargeResultPageExposure', {
pay_status: this.payStatus
});
this.getCouponList(); this.getCouponList();
this.setShareData();
},
mounted() {
EventBus.$on('shareClickItem', ({ ev }) => {
if (ev === 'pic') {
this.createPic();
}
});
},
beforeDestroy() {
EventBus.$off('shareClickItem');
}, },
methods: { methods: {
outputPicUrl(res) {
console.log(res);
},
async setShareData() {
const [res] = await groupBuyApi.getGroupShareInfo({
orderNo: this.orderNo
});
this.sharePicData = res;
},
createPic() {
console.log(typeof this.$refs.sharePic.createAndUploadPic);
this.$refs.sharePic.createAndUploadPic();
},
share() { share() {
// 分享 // 分享
this.$store.dispatch('goods_share_open');
}, },
// goPay() { // goPay() {
// this.$track?.registeredEvents('h5_RechargeResultPageClick', { // this.$track?.registeredEvents('h5_RechargeResultPageClick', {
...@@ -125,9 +153,7 @@ export default { ...@@ -125,9 +153,7 @@ export default {
newUrl: `/pages/pay/index?orderNo=${this.orderNo}&from=groupbuy` newUrl: `/pages/pay/index?orderNo=${this.orderNo}&from=groupbuy`
}); });
} else if (isApp) { } else if (isApp) {
this.nativeBridge.openNewUrl({ this.$router.push({ path: `/pay?orderNo=${this.orderNo}` });
newUrl: `/pay?orderNo=${this.orderNo}`
});
} else { } else {
return; // todo 处理纯h5情况 return; // todo 处理纯h5情况
// this.$dialog({ // this.$dialog({
...@@ -141,7 +167,6 @@ export default { ...@@ -141,7 +167,6 @@ export default {
}, },
async getCouponList() { async getCouponList() {
const [data] = await getCouponList({ orderNo: this.orderNo, paySuccess: true }); const [data] = await getCouponList({ orderNo: this.orderNo, paySuccess: true });
console.log(data);
if (data) { if (data) {
this.couponList = data.couponList || []; this.couponList = data.couponList || [];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment