152 lines
3.5 KiB
Vue
152 lines
3.5 KiB
Vue
<script setup>
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
import { ref, computed } from 'vue'
|
|
import { useUI } from '../../utils/use-ui'
|
|
|
|
const { showToast } = useUI()
|
|
|
|
const groupId = ref('')
|
|
const productId = ref('')
|
|
const qrcodeRef = ref(null)
|
|
|
|
const BASE_URL = computed(() => {
|
|
const { origin } = window.location
|
|
return `${origin}/pages/mall/detail?productId=${productId.value}&groupId=${groupId.value}`
|
|
})
|
|
|
|
// 复制文本通用函数
|
|
const copyText = text => {
|
|
uni.setClipboardData({
|
|
data: BASE_URL.value,
|
|
success: () => {
|
|
console.log('已复制到剪贴板')
|
|
},
|
|
fail: () => {
|
|
console.log('复制失败')
|
|
}
|
|
})
|
|
}
|
|
|
|
onLoad(e => {
|
|
groupId.value = e.id
|
|
productId.value = e.productId
|
|
// /pages/mall/detail
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<view class="share-box">
|
|
<nav-bar title="拼单" targetColor="transparent"></nav-bar>
|
|
<view class="code-box">
|
|
<view class="code-content">
|
|
<view class="code">
|
|
<l-qrcode
|
|
ref="qrcodeRef"
|
|
:value="`/pages/mall/detail?productId=${productId}&groupId=${groupId}`"
|
|
size="160"
|
|
/>
|
|
</view>
|
|
<!-- <view class="btn-box">
|
|
<text>分享二维码</text>
|
|
<text @click="onCode">保存到本地</text>
|
|
</view> -->
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 复制连接 -->
|
|
<!-- #ifdef H5 -->
|
|
<view class="copy-box">
|
|
<text class="link">拼单链接:{{ BASE_URL }}</text>
|
|
<button @click="copyText">复制</button>
|
|
</view>
|
|
<!-- #endif -->
|
|
</view>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.copy-box {
|
|
margin-top: 118rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
.link {
|
|
// 超过宽度显示省略号
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
width: 544rpx;
|
|
font-family: PingFang SC, PingFang SC;
|
|
font-weight: 500;
|
|
font-size: 32rpx;
|
|
font-style: normal;
|
|
text-transform: none;
|
|
color: #00d993;
|
|
}
|
|
|
|
button {
|
|
margin-top: 48rpx;
|
|
width: 256rpx;
|
|
height: 64rpx;
|
|
line-height: 60rpx;
|
|
border-radius: 100rpx;
|
|
border: 2rpx solid #00d993;
|
|
color: #00d993;
|
|
padding: 0;
|
|
background: none;
|
|
|
|
font-family: PingFang SC, PingFang SC;
|
|
font-weight: 500;
|
|
font-size: 28rpx;
|
|
text-align: center;
|
|
font-style: normal;
|
|
text-transform: none;
|
|
&::after {
|
|
display: none !important;
|
|
}
|
|
}
|
|
}
|
|
.share-box {
|
|
height: 100vh;
|
|
width: 100vw;
|
|
// 导入背景图
|
|
background: url('/static/images/discover/share-bg.png');
|
|
background-size: 100%;
|
|
background-position: center;
|
|
background-repeat: no-repeat;
|
|
|
|
.code-box {
|
|
padding-top: 24vh;
|
|
display: flex;
|
|
justify-content: center;
|
|
|
|
.code-content {
|
|
width: 560rpx;
|
|
height: 618rpx;
|
|
background: linear-gradient(0deg, #00d993 0%, #00d9c5 100%);
|
|
border-radius: 32rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
.code {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
width: 332rpx;
|
|
height: 332rpx;
|
|
}
|
|
.btn-box {
|
|
margin-top: 60rpx;
|
|
width: 332rpx;
|
|
display: flex;
|
|
justify-content: center;
|
|
font-weight: bold;
|
|
font-size: 28rpx;
|
|
color: #ffffff;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|