feat: 5.26 update
This commit is contained in:
parent
107ebd7a1d
commit
63a7f0ccf4
@ -36,7 +36,7 @@ const routes = [
|
||||
path: '/My',
|
||||
name: 'My',
|
||||
component: () => import('./views/User/My.vue'),
|
||||
meta: { title: '我的', cache: true }
|
||||
meta: { title: '我的' }
|
||||
},
|
||||
],
|
||||
meta: { noLogin: true }
|
||||
|
||||
@ -43,7 +43,8 @@ export async function toDataURL(selector, options = {}) {
|
||||
canvasHeight,
|
||||
pixelRatio,
|
||||
cors: useCORS,
|
||||
backgroundColor: '#ffffff'
|
||||
backgroundColor: '#ffffff',
|
||||
fetchLikeCORS: true
|
||||
})
|
||||
|
||||
const mimeType = format === 'jpeg' ? 'image/jpeg' : 'image/png'
|
||||
|
||||
@ -165,19 +165,19 @@ export default {
|
||||
const onBridgeReady = () => {
|
||||
WeixinJSBridge.invoke(
|
||||
'getBrandWCPayRequest', {
|
||||
appId: payData.appId,
|
||||
timeStamp: payData.timeStamp,
|
||||
nonceStr: payData.nonceStr,
|
||||
package: payData.package,
|
||||
signType: payData.signType,
|
||||
paySign: payData.paySign
|
||||
},
|
||||
appId: payData.appId,
|
||||
timeStamp: payData.timeStamp,
|
||||
nonceStr: payData.nonceStr,
|
||||
package: payData.package,
|
||||
signType: payData.signType,
|
||||
paySign: payData.paySign
|
||||
},
|
||||
(res) => {
|
||||
if (res.err_msg === 'get_brand_wcpay_request:ok') {
|
||||
this.$showSuccessToast('支付成功');
|
||||
this.onPayCompleted();
|
||||
} else {
|
||||
this.showPayResult = true;
|
||||
// this.showPayResult = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@ -132,7 +132,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
this.$router.back();
|
||||
this.$navigate('/TradeList');
|
||||
},
|
||||
async loadData() {
|
||||
try {
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
<button v-if="item.state === 0" @click="cancelTrade(item)">取消订单</button>
|
||||
<button v-if="!item.shopname" @click="$navigate(`TradeDetail?ordernum=${item.ordernum}`)">查看详情</button>
|
||||
<button v-else @click="$navigate(`MerchantTradeDetail?id=${item.ordernum}`)">查看详情</button>
|
||||
<!-- <button v-if="item.state === 3 || item.state === 4" @click="showLogistics(item)">物流信息</button> -->
|
||||
<button v-if="item.state === 3 || item.state === 4" @click="showLogistics(item)">物流信息</button>
|
||||
|
||||
<button v-if="item.state === 3" @click="confirmReceipt(item)">确认收货</button>
|
||||
<button v-if="item.state === 0" @click="$navigate(`Pay?ordernum=${item.ordernum}`)">立即支付</button>
|
||||
@ -61,6 +61,27 @@
|
||||
</div>
|
||||
</template>
|
||||
</BaseList>
|
||||
|
||||
|
||||
<van-popup v-model:show="logisticsVisible" round position="bottom" teleport="body">
|
||||
<div class="logistics-popup">
|
||||
<div class="logistics-tit">物流信息</div>
|
||||
<div class="logistics-content">
|
||||
<div class="logistics-item">
|
||||
<span class="label">物流公司</span>
|
||||
<span class="value">{{ currentLogistics?.exportname }}</span>
|
||||
</div>
|
||||
<div class="logistics-item">
|
||||
<span class="label">物流单号</span>
|
||||
<span class="value">{{ currentLogistics?.exportnum }}</span>
|
||||
<img src="/img/copy_b.png" @click="$copyText(currentLogistics?.exportnum); $showSuccessToast('复制成功')" alt="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="logistics-close">
|
||||
<van-button type="primary" block round color="#ca2904" @click="logisticsVisible = false">关闭</van-button>
|
||||
</div>
|
||||
</div>
|
||||
</van-popup>
|
||||
</div>
|
||||
</BasePage>
|
||||
</template>
|
||||
@ -111,6 +132,8 @@ export default {
|
||||
}
|
||||
],
|
||||
_initializing: true,
|
||||
logisticsVisible: false,
|
||||
currentLogistics: null,
|
||||
}
|
||||
},
|
||||
|
||||
@ -212,6 +235,12 @@ export default {
|
||||
.catch(err => this.$showFailToast(err.message || '取消失败'))
|
||||
},
|
||||
|
||||
// 显示物流信息
|
||||
showLogistics(item) {
|
||||
this.currentLogistics = item
|
||||
this.logisticsVisible = true
|
||||
},
|
||||
|
||||
back() {
|
||||
this.$navigate('/My');
|
||||
},
|
||||
@ -220,3 +249,53 @@ export default {
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.logistics-popup {
|
||||
padding: 20px;
|
||||
|
||||
.logistics-tit {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.logistics-content {
|
||||
background: #f5f5f5;
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.logistics-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.label {
|
||||
width: 70px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.value {
|
||||
flex: 1;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.logistics-close {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
<template>
|
||||
<BasePage>
|
||||
<!-- v-if="data.Icon" -->
|
||||
<div class="ewm_bg" style="font-family: 'PingFang SC'">
|
||||
<div class="d1">
|
||||
<div class="w100">
|
||||
<img id="invite_bg" :src="bgSrc" crossorigin="anonymous" />
|
||||
<!-- <img id="invite_bg" src="/img/invite_bg.jpg" crossorigin="anonymous"> -->
|
||||
<img id="invite_bg" src="/img/invite_bg.jpg" crossorigin="anonymous">
|
||||
</div>
|
||||
<img class="icon" :src="$file(data.Avatar) + '?t=1'" crossorigin="anonymous">
|
||||
<img class="icon" :src="$file(data.Avatar)" crossorigin="anonymous">
|
||||
<div class="name">
|
||||
<b>{{ $substring(data.NickName, 0, 8) }}</b>
|
||||
</div>
|
||||
@ -15,18 +13,15 @@
|
||||
<div class="ewm_test box box-tb box-align-center">
|
||||
<vue-qr v-if="!loading" :text="link" backgroundColor="rgb(255,255,255)"
|
||||
colorLight="rgb(255,255,255)"></vue-qr>
|
||||
<!-- <span>扫码立即注册</span> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="sc_ewm" class="b_l_w bx" style="font-family: 'PingFang SC'"></div>
|
||||
|
||||
</BasePage>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { toDataURL } from '@/utils/html2image';
|
||||
import html2canvas from 'html2canvas'
|
||||
|
||||
export default {
|
||||
name: 'Invite',
|
||||
@ -34,106 +29,96 @@ export default {
|
||||
return {
|
||||
loading: true,
|
||||
data: {
|
||||
Icon: '',
|
||||
Avatar: '',
|
||||
NickName: '',
|
||||
},
|
||||
link: '',
|
||||
userStore: null,
|
||||
bgSrc: '',
|
||||
};
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.loading = false;
|
||||
this.preloadBackground().then(() => {
|
||||
this.init().then(() => {
|
||||
this.$nextTick(() => {
|
||||
this.CreatePoster(".ewm_bg > div", "#sc_ewm");
|
||||
});
|
||||
});
|
||||
});
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
async preloadBackground() {
|
||||
const bgUrl = this.$file(this.$datadic.getContent('code_yqmbj'));
|
||||
const cacheKey = 'invite_bg_cache';
|
||||
const cached = localStorage.getItem(cacheKey);
|
||||
if (cached) {
|
||||
this.bgSrc = cached;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await fetch(bgUrl, { mode: 'cors' });
|
||||
const blob = await response.blob();
|
||||
const reader = new FileReader();
|
||||
return new Promise((resolve) => {
|
||||
reader.onloadend = () => {
|
||||
localStorage.setItem(cacheKey, reader.result);
|
||||
this.bgSrc = reader.result;
|
||||
resolve();
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Background preload failed:', e);
|
||||
this.bgSrc = bgUrl;
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
async init() {
|
||||
try {
|
||||
// 获取用户信息
|
||||
const userInfo = await this.$get('/v1/client/DUsersClient');
|
||||
const userInfo = await this.$get('/v1/client/DUsersClient')
|
||||
if (userInfo?.data) {
|
||||
this.data.Avatar = userInfo.data.userimg || '';
|
||||
this.data.NickName = userInfo.data.nickname || '';
|
||||
this.data.Icon = userInfo.data.Icon || '';
|
||||
this.data.Avatar = userInfo.data.userimg || ''
|
||||
this.data.NickName = userInfo.data.nickname || ''
|
||||
}
|
||||
// 生成包含邀请码的链接
|
||||
const inviteCode = userInfo?.data?.cellphone || '';
|
||||
this.link = `${location.origin}${location.pathname}#/Login?invite=${inviteCode}`;
|
||||
const inviteCode = userInfo?.data?.cellphone || ''
|
||||
this.link = `${location.origin}${location.pathname}#/Login?invite=${inviteCode}`
|
||||
} catch (err) {
|
||||
console.error('获取用户信息失败:', err);
|
||||
console.error('获取用户信息失败:', err)
|
||||
} finally {
|
||||
this.loading = false
|
||||
this.$nextTick(() => {
|
||||
this.generatePoster()
|
||||
})
|
||||
}
|
||||
},
|
||||
async CreatePoster(divID, targetID) {
|
||||
var shareContent = document.querySelector(divID);
|
||||
|
||||
async generatePoster() {
|
||||
const el = document.querySelector('.ewm_bg > .d1')
|
||||
const bgImg = document.querySelector('#invite_bg')
|
||||
if (!el || !bgImg) return
|
||||
|
||||
try {
|
||||
// Wait for background and avatar images to load
|
||||
const promises = [];
|
||||
const bgImg = shareContent.querySelector('#invite_bg');
|
||||
if (bgImg && !bgImg.complete) {
|
||||
promises.push(new Promise(resolve => {
|
||||
bgImg.onload = resolve;
|
||||
bgImg.onerror = resolve;
|
||||
}));
|
||||
// Convert local image to base64 for Safari compatibility
|
||||
if (bgImg.src.startsWith('/')) {
|
||||
await this.loadImageToBase64(bgImg)
|
||||
}
|
||||
const avatarImg = shareContent.querySelector('.icon');
|
||||
if (avatarImg && !avatarImg.complete) {
|
||||
promises.push(new Promise(resolve => {
|
||||
avatarImg.onload = resolve;
|
||||
avatarImg.onerror = resolve;
|
||||
}));
|
||||
}
|
||||
if (promises.length > 0) {
|
||||
await Promise.all(promises);
|
||||
}
|
||||
// Extra delay for Safari/WeChat compatibility
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
|
||||
var dataUrl = await toDataURL(shareContent, { format: 'png', pixelRatio: 2, useCORS: true });
|
||||
var newImg = document.createElement("img");
|
||||
newImg.src = dataUrl;
|
||||
newImg.width = shareContent.offsetWidth;
|
||||
newImg.height = shareContent.offsetHeight;
|
||||
document.querySelector(targetID).appendChild(newImg);
|
||||
if (document.fonts?.ready) {
|
||||
await document.fonts.ready
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, 500))
|
||||
|
||||
const canvas = await html2canvas(el, {
|
||||
scale: 2,
|
||||
useCORS: true,
|
||||
backgroundColor: '#ffffff',
|
||||
logging: false
|
||||
})
|
||||
const dataUrl = canvas.toDataURL('image/png')
|
||||
|
||||
const target = document.querySelector('#sc_ewm')
|
||||
if (target) {
|
||||
target.innerHTML = ''
|
||||
const img = document.createElement('img')
|
||||
img.src = dataUrl
|
||||
img.style.width = '100%'
|
||||
img.style.display = 'block'
|
||||
target.appendChild(img)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('生成海报失败', err);
|
||||
console.error('生成海报失败', err)
|
||||
}
|
||||
},
|
||||
|
||||
loadImageToBase64(imgEl) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image()
|
||||
img.crossOrigin = 'anonymous'
|
||||
img.onload = () => {
|
||||
try {
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = img.width
|
||||
canvas.height = img.height
|
||||
const ctx = canvas.getContext('2d')
|
||||
ctx.drawImage(img, 0, 0)
|
||||
imgEl.src = canvas.toDataURL('image/png')
|
||||
resolve()
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
}
|
||||
img.onerror = reject
|
||||
img.src = imgEl.src
|
||||
})
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@ -153,7 +138,6 @@ export default {
|
||||
position: absolute;
|
||||
left: 34vw;
|
||||
bottom: 46vw;
|
||||
// line-height: 6vw;
|
||||
width: 100%;
|
||||
|
||||
b {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user