123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
-
- <su-popup :show="show && !Android" round="10" @close="closeSubscribeModal">
- <view class="login-wrap">
- <view class="head-box">
- <view class=" ss-m-b-20">
- <view class="head-title ss-m-r-40 head-title-animation">
- {{ t('pop.follow_public_account') }}
- </view>
- <view class="ss-flex ss-row-center">
- <canvas class="hideCanvas" canvas-id="myCanvas" style="width: 300px; height: 300px;"></canvas>
-
- <image :src="imagePath" mode="widthFix" />
- </view>
- </view>
- </view>
- </view>
- </su-popup>
- </template>
- <script setup>
- import {
- computed,
- onMounted,
- ref,
- watchEffect,
- nextTick
- } from 'vue';
- import sheep from '@/sheep';
- import QSCanvas from 'qs-canvas';
- import {
- onShow,
-
- } from '@dcloudio/uni-app';
- import {
- closeSubscribeModal,
-
- } from '@/sheep/hooks/useModal';
- import { t } from '@/locale'
- import { isAndroid } from '@/sheep/hooks/useApp';
- const Android = isAndroid();
- const show = computed(() => sheep.$store('modal').subscribe);
-
-
- const imagePath = ref('');
-
- async function drawQrCode(url) {
- console.log(url)
- const qsc = new QSCanvas({
- canvasId: 'myCanvas',
- width: 300,
- height: 300,
- setCanvasWH: (canvas) => {
-
- canvas.width = 300;
- canvas.height = 300;
- },
- });
- await qsc.drawQrCode({
- val: url,
- x: 25,
- y: 15,
- size: 250,
- background: '#ffffff',
- foreground: '#000000',
- pdground: '#000000',
- correctLevel: 3,
- });
-
- const qrY = 15;
- const qrHeight = 250;
- const textX = 300 / 2;
- const textY = qrY + qrHeight + 15;
-
-
- await qsc.drawText({
- val: t('pop.long_press_qrcode_follow'),
- x: textX,
- y: textY,
- maxWidth: 250,
-
- paintbrushProps: {
- fillStyle: '#333',
- textAlign: 'center',
- textBaseline: 'middle',
- font: {
-
-
- fontStyle: 'normal',
- fontVariant: 'normal',
- fontWeight: 'normal',
- fontSize: 14,
- fontFamily: 'sans-serif'
- },
- },
- });
-
-
- await qsc.draw();
-
- const imagePathData = await qsc.toImage();
- if (imagePathData) {
- imagePath.value = imagePathData;
- }
- }
-
- function createQrcode() {
-
- let SHOPRO_DEV_BASE_URL = import.meta.env.SHOPRO_DEV_BASE_URL;
- console.log("当前接口Url",SHOPRO_DEV_BASE_URL)
- if (SHOPRO_DEV_BASE_URL.includes('letcgo.com')) {
-
- drawQrCode(import.meta.env.SHOPRO_MP_HOME_PAGE_LETCGO);
-
- } else {
-
- drawQrCode(import.meta.env.SHOPRO_MP_HOME_PAGE_FEIFAN);
- }
- }
-
- watchEffect(() => {
- if (show.value) {
- nextTick().then(() => {
- createQrcode()
- });
- }
- });
-
- </script>
- <style lang="scss" scoped>
- .hideCanvas {
- position: fixed;
- top: -99999rpx;
- left: -99999rpx;
- z-index: -99999;
- }
- .login-wrap {
- padding: 50rpx 34rpx;
- min-height: 500rpx;
- background-color: #fff;
- border-radius: 20rpx 20rpx 0 0;
- }
- .head-box {
- .head-title {
- min-width: 160rpx;
- font-size: 36rpx;
- font-weight: bold;
- color: #333333;
- line-height: 36rpx;
- }
- .head-title-active {
- width: 160rpx;
- font-size: 32rpx;
- font-weight: 600;
- color: #999;
- line-height: 36rpx;
- }
- .head-title-animation {
- animation-name: title-animation;
- animation-duration: 0.1s;
- animation-timing-function: ease-out;
- animation-fill-mode: forwards;
- }
- .head-title-line {
- position: relative;
- &::before {
- content: '';
- width: 1rpx;
- height: 34rpx;
- background-color: #e4e7ed;
- position: absolute;
- left: -30rpx;
- top: 50%;
- transform: translateY(-50%);
- }
- }
- .head-subtitle {
- font-size: 26rpx;
- font-weight: 400;
- color: #afb6c0;
- text-align: left;
- display: flex;
- }
- }
- </style>
|