This commit is contained in:
HongRun Liu
2026-05-26 15:52:30 +08:00
commit b0744c8ab6
849 changed files with 130587 additions and 0 deletions
+161
View File
@@ -0,0 +1,161 @@
<template>
<s-layout title="邀请好友">
<view class="pages c34">
<view class="con w100" id="conId">
<view class="w100 conBg radius-8 hidden">
<image
class="w100"
:src="$url + 'home/invite1.png'"
mode="widthFix"
@longpress="saveImg"
/>
</view>
<view class="con_center w100 radius-8">
<view class="flex-center ju-flex-start">
<view class="head">
<image v-if="dataInfo?.avatar" :src="dataInfo?.avatar" mode="scaleToFill" />
<image v-else :src="`${$url}home/head.png`" mode="scaleToFill" />
</view>
<view>
<view class="con_name size32 f700 c0"
>{{ dataInfo?.nickname || '昵称' }},邀请您加入优购商城</view
>
<view class="size28 c0">财富未来 全新出发</view>
</view>
</view>
<view class="flex-center f700 size48 m-t-68 m-b-28 c0">
<view>邀请码</view>
<view>|</view>
<view>{{ inviteinfo?.inviteCode }}</view>
</view>
<view class="flex-center">
<view class="img m-b-22">
<Qrcode
ref="qrcodeRef"
:size="300"
@generated="onQrGenerated"
@longpress="saveServiceQrcode"
/>
</view>
</view>
<view class="center size20 c_999">扫描二维码, 注册并登录APP</view>
</view>
</view>
<view class="submit-btn m-t-68" @click="saveImg">保存到相册</view>
</view>
</s-layout>
</template>
<script setup lang="ts">
import Qrcode from './components/Qrcode';
import sheep from '@/sheep';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { ref, reactive, onMounted, onUnmounted, getCurrentInstance, watch, nextTick } from 'vue';
import * as api from '@/sheep/api/home/index';
let { proxy } = getCurrentInstance();
let dataInfo = ref({});
let inviteinfo = ref({});
let qrCodeUrl = ref(); //二维码地址
let qrcodeRef = ref();
onLoad(() => {});
//获取二维码
function generateQRCode(text) {
nextTick(() => {
qrcodeRef.value.createQRcode(text);
});
}
const getData = () => {
sheep
.$store('user')
.getInfo()
.then((res) => {
dataInfo.value = res;
});
};
const getinviteinfo = () => {
api.inviteinfo().then((res) => {
inviteinfo.value = res.data;
generateQRCode(res.data.inviteUrl);
// generateQRCode('http://mall.suwizihe.org.cn:5010/h5/#/?code=' + inviteinfo.value.inviteCode);
});
};
getinviteinfo();
getData();
let conRef = ref();
const saveServiceQrcode = () => {
qrcodeRef.value.savePhoto();
};
const saveImg = async () => {
// uni.saveImageToPhotosAlbum({
// filePath: 'http://mall.suwizihe.org.cn:5010/h5/#/?code=' + inviteinfo.value.inviteCode,//qrcodeUrl.value
// success: () => {
// uni.showToast({
// title: '保存成功!',
// });
// },
// fail: (err) => {
// console.log(err);
// uni.showToast({ title: '保存失败', icon: 'none' });
// },
// });
qrcodeRef.value.savePhoto();
// if (qrcodeUrl.value) {
// return;
// }
// if (qrcodeRef.value?.savePhoto) {
// qrcodeRef.value.savePhoto();
// } else {
// uni.showToast({ title: '二维码未生成', icon: 'none' });
// }
};
const onQrGenerated = (path) => {
qrCodeUrl.value = path;
};
</script>
<style lang="scss" scoped>
.pages {
height: 100vh;
padding: 32rpx 40rpx;
box-sizing: border-box;
}
.con {
position: relative;
.conBg {
position: absolute;
top: 0;
}
.con_center {
// position: absolute;
// top: 0;
position: relative;
padding: 56rpx 28rpx;
box-sizing: border-box;
z-index: 10;
}
}
.head {
width: 96rpx;
height: 96rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 20rpx;
image {
width: 100%;
height: 100%;
}
}
.img {
padding: 20rpx;
background: #fff;
}
.con_name {
}
</style>