feat: 修改首页未显示红包抽奖,审核文案,邀请好友分享,地址回显问题修改

This commit is contained in:
黄泽群
2026-07-23 14:02:58 +08:00
committed by charles
parent 21225998e5
commit 8b11bbebfc
2 changed files with 155 additions and 124 deletions
@@ -42,12 +42,13 @@
<view v-if="status > 1 && status != 6 && status != 5"> <view v-if="status > 1 && status != 6 && status != 5">
<view class="card_list"> <view class="card_list">
<view class="list_left">邮寄地址</view> <view class="list_left" style="flex:30%;">邮寄地址</view>
<view>{{ product.address || "--" }}</view> <view>{{ product.address || "--" }}</view>
</view> </view>
<view class="card_list"> <view class="card_list">
<view class="list_left">卖家信息</view> <view class="list_left">卖家信息</view>
<view>{{ `${product.name} ${product.phone}` }}</view> <view>{{ (product.name || product.phone) ? `${product.name || ''} ${product.phone || ''}`.trim() : "--" }}
</view>
</view> </view>
<view class="card_list" @click="onSelectExpress"> <view class="card_list" @click="onSelectExpress">
<view class="list_left">请选择快递名称</view> <view class="list_left">请选择快递名称</view>
@@ -250,7 +251,7 @@ export default {
// 售后中--卖家已收货,退款成功 // 售后中--卖家已收货,退款成功
if (this.product.status == 7) { if (this.product.status == 7) {
return 5; return 5;
} }
// 退款 // 退款
if (this.product.status == 8) { if (this.product.status == 8) {
return 6; return 6;
@@ -277,7 +278,7 @@ export default {
/* 根据订单状态显示不label */ /* 根据订单状态显示不label */
topLabel() { topLabel() {
if (this.status == 1) { if (this.status == 1) {
return "您已成功发起退货/退款申请,请耐心等待审"; return "您已成功发起退货/退款申请,请耐心等待审核";
} else if (this.status == 2) { } else if (this.status == 2) {
return "请按照以下地址寄回商品"; return "请按照以下地址寄回商品";
} else if (this.status == 3) { } else if (this.status == 3) {
@@ -297,7 +298,7 @@ export default {
} else if (this.status == 2) { } else if (this.status == 2) {
return "退款申请通过"; return "退款申请通过";
} else if (this.status == 3) { } else if (this.status == 3) {
return "您已成功发起退货/退款申请,请耐心等待处"; return "您已成功发起退货/退款申请,请耐心等待处理";
} else if (this.status == 4) { } else if (this.status == 4) {
return "退款申请失败"; return "退款申请失败";
} else if (this.status == 5) { } else if (this.status == 5) {
@@ -391,7 +392,8 @@ export default {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
height: 96rpx; height: 96rpx;
line-height: 96rpx; align-items: center;
// line-height: 96rpx;
font-size: 28rpx; font-size: 28rpx;
border-bottom: 1px solid #eaeaea; border-bottom: 1px solid #eaeaea;
@@ -1,136 +1,165 @@
<template> <template>
<view class="invite_friends_warp"> <view class="invite_friends_warp">
<view class="invite_img"> <view class="invite_img">
<!-- <up-image :loading="imageLoading" :src="inviteImage" class="invite_imgage" bgColor="#f1f6ff00" shape="square" <image :src="inviteImage" class="invite_imgage" v-if="inviteImage"></image>
radius=10></up-image> --> <view class="loading" v-else>
<image :src="inviteImage" class="invite_imgage"></image> <text>加载分享图片中...</text>
</view> </view>
<view class="invite_but"> </view>
<view class="save_but"> <view class="invite_but">
<text style="margin-left: 10rpx;" @click="saveBaseImgFile">保存图片</text> <!-- 修改为直接分享图片 -->
</view> <button
</view> class="share-btn"
<up-toast ref="uToastRef"></up-toast> @click="shareImage"
>
分享好友
</button>
</view>
<up-toast ref="uToastRef"></up-toast>
</view> </view>
</template> </template>
<script> <script>
import { getSharePoster, generateSharePoster } from '@/api/common.js'; import { getSharePoster, generateSharePoster } from "@/api/common.js";
export default { export default {
data() { data() {
return { return {
inviteImage: null, inviteImage: null,
imageLoading: false, imageLoading: false,
} shareImg:''
};
}, },
mounted() { mounted() {
this.getSharePoster(); this.getSharePoster();
}, },
methods: { methods: {
// 将base64转换为本地临时文件
// 查询分享模版 async base64ToTempFile(base64Data) {
async getSharePoster() { try {
this.imageLoading = true; // 移除base64前缀
const resp = await getSharePoster(); const base64 = base64Data.replace(/^data:image\/\w+;base64,/, '');
if (resp && resp.bizcode === 100) { // 将base64转换为ArrayBuffer
const data = resp.data[0]; const arrayBuffer = uni.base64ToArrayBuffer(base64);
// 生成分享图 // 获取文件系统管理器
const generateResp = await generateSharePoster({ id: data.id }); const fs = uni.getFileSystemManager();
if (generateResp && generateResp.bizcode === 100) { // 生成临时文件路径
this.inviteImage = generateResp.data; const tempFilePath = `${wx.env.USER_DATA_PATH}/share_${Date.now()}.png`;
} // 写入文件
} fs.writeFileSync(tempFilePath, arrayBuffer, 'binary');
this.imageLoading = false; return tempFilePath;
}, } catch (error) {
saveBaseImgFile() { console.error('base64转换为临时文件失败:', error);
uni.showLoading({ throw error;
title: '保存中...',
})
const currentBase64 = this.inviteImage;
const bitmap = new plus.nativeObj.Bitmap('base64')
bitmap.loadBase64Data(currentBase64, () => {
const url = '_doc/' + new Date().getTime() + '.png'
bitmap.save(
url,
{
overwrite: false, // 是否覆盖
},
(i) => {
uni.saveImageToPhotosAlbum({
filePath: url,
success: () => {
uni.hideLoading();
this.$refs.uToastRef.show({
type: 'success',
message: "图片保存到相册成功",
});
bitmap.clear()
}
})
},
(e) => {
uni.hideLoading();
console.log('图片保存失败', e)
this.$refs.uToastRef.show({
type: 'error',
message: "图片保存失败",
});
bitmap.clear()
}
)
},
(e) => {
uni.hideLoading();
console.log('图片保存失败', e)
this.$refs.uToastRef.show({
type: 'error',
message: "图片保存失败",
});
bitmap.clear()
}
)
} }
} },
}
</script>
<style lang="scss" scoped> // 查询分享模版
.invite_friends_warp { async getSharePoster() {
this.imageLoading = true;
try {
const resp = await getSharePoster();
if (resp && resp.bizcode === 100) {
const data = resp.data[0];
// 生成分享图
const generateResp = await generateSharePoster({ id: data.id });
if (generateResp && generateResp.bizcode === 100) {
this.inviteImage = generateResp.data;
// 将base64转换为本地临时文件并存储到shareImg
this.shareImg = await this.base64ToTempFile(generateResp.data);
console.log('图片转换成功:', this.shareImg);
}
}
} catch (error) {
console.error("获取分享图失败:", error);
} finally {
this.imageLoading = false;
}
},
// 使用wx.showShareImageMenu分享图片到微信好友
async shareImage() {
// 确保有分享图再执行分享
if (!this.shareImg) {
this.$refs.uToastRef.show({
type: 'warning',
message: "分享图正在加载,请稍后重试",
});
return;
}
try {
// 使用微信原生API wx.showShareImageMenu分享图片
wx.showShareImageMenu({
path: this.shareImg, // 本地临时文件路径
success: () => {
console.log('分享成功');
this.$refs.uToastRef.show({
type: 'success',
message: "分享成功",
});
},
fail: (err) => {
console.error('分享失败:', err);
this.$refs.uToastRef.show({
type: 'error',
message: "分享失败,请稍后重试",
});
}
});
} catch (error) {
console.error('分享过程出错:', error);
this.$refs.uToastRef.show({
type: 'error',
message: "分享失败,请稍后重试",
});
}
}
}
};
</script>
<style lang="scss" scoped>
.invite_friends_warp {
height: calc(100vh - 80rpx); height: calc(100vh - 80rpx);
padding: 10rpx 40rpx 40rpx; padding: 10rpx 40rpx 40rpx;
} }
// .invite_img { .invite_img {
// height: 920rpx; display: flex;
// } justify-content: center;
align-items: center;
.invite_imgage{ min-height: 920rpx;
// width="100%" height="460" }
img {
.invite_imgage {
width: 100%; width: 100%;
height: 920rpx; height: 920rpx;
} }
::v-deep(uni-image){
width: 100%; .loading {
height: 920rpx; text-align: center;
} color: #999;
} font-size: 28rpx;
}
.invite_but {
.invite_but {
padding: 20rpx 50rpx; padding: 20rpx 50rpx;
margin-top: 52rpx; margin-top: 52rpx;
}
.save_but {
text-align: center; .share-btn {
background: $app-bt-bj; width: 100%;
border-radius: 45rpx; background: $app-bt-bj;
width: 100%; border-radius: 45rpx;
color: #FFF; color: #FFFFFF;
padding: 30rpx 0; font-weight: 500;
font-weight: 500; font-size: 32rpx;
font-size: 32rpx; // 清除默认按钮样式
color: #FFFFFF; border: none;
outline: none;
&:active {
opacity: 0.8;
} }
} }
</style> </style>