|
@@ -0,0 +1,192 @@
|
|
|
+<route lang="json">
|
|
|
+{ "style": { "navigationBarTitleText": "邀请设计师", "navigationBarBackgroundColor": "#fff" } }
|
|
|
+</route>
|
|
|
+<script setup lang="ts">
|
|
|
+import SectionHeading from '@/components/section-heading.vue'
|
|
|
+import { getDesignerInfo, updateDesignerInfo } from '../../../core/libs/requests'
|
|
|
+import { useUserStore } from '../../../store'
|
|
|
+import { storeToRefs } from 'pinia'
|
|
|
+import { pick } from 'radash'
|
|
|
+import BottomAppBar from '@/components/bottom-app-bar.vue'
|
|
|
+import { useMessage } from 'wot-design-uni'
|
|
|
+import { NetImages } from '../../../core/libs/net-images'
|
|
|
+
|
|
|
+const { alert } = useMessage()
|
|
|
+const userStore = useUserStore()
|
|
|
+const { userInfo } = storeToRefs(userStore)
|
|
|
+const form = ref<{
|
|
|
+ userId?: number
|
|
|
+ videoNumber?: string
|
|
|
+}>()
|
|
|
+const { data, run: setData } = useRequest(() => getDesignerInfo(userInfo.value.userId))
|
|
|
+const { loading, run: submiting } = useRequest(() => updateDesignerInfo(form.value))
|
|
|
+const posterUrl = ref()
|
|
|
+const handleSubmit = async () => {
|
|
|
+ await submiting()
|
|
|
+ await setData()
|
|
|
+ alert({ title: '关联成功', confirmButtonText: '我知道了' })
|
|
|
+}
|
|
|
+const createPoster = () => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ ;(async () => {
|
|
|
+ const { path } = await uni.getImageInfo({ src: data.value.homePageUrl })
|
|
|
+ // console.log(path)
|
|
|
+ // console.log(logoPath)
|
|
|
+ const { path: bgPath } = await uni.getImageInfo({ src: NetImages.InviteBg })
|
|
|
+ // console.log(bgPath)
|
|
|
+ const { path: logoPath } = await uni.getImageInfo({ src: NetImages.Logo })
|
|
|
+ const { path: avatarPath } = await uni.getImageInfo({
|
|
|
+ src: data.value.headImgUrl || userInfo.value?.avatar || NetImages.DefaultAvatar,
|
|
|
+ })
|
|
|
+ const [{ path: icon1 }, { path: icon2 }, { path: icon3 }, { path: icon4 }] =
|
|
|
+ await Promise.all([
|
|
|
+ uni.getImageInfo({
|
|
|
+ src: 'https://image.zhuchaohui.com/zhucaohui/315c5ca680bc6b47a5344dbff701cf1e6802d8a240754e25ef3d4308bc1deef6.png',
|
|
|
+ }),
|
|
|
+ uni.getImageInfo({
|
|
|
+ src: 'https://image.zhuchaohui.com/zhucaohui/ee83d30d553feb1482920e49c28824d73bb33838d996ec2f6c646ae6deab0330.png',
|
|
|
+ }),
|
|
|
+ uni.getImageInfo({
|
|
|
+ src: 'https://image.zhuchaohui.com/zhucaohui/9f89604f285c33200b7e6fda9acc82e130f34c2f5687cfeb78f3541e1fabcc28.png',
|
|
|
+ }),
|
|
|
+ uni.getImageInfo({
|
|
|
+ src: 'https://image.zhuchaohui.com/zhucaohui/2467be55426018856150bd94bbd21865df3d73ce982bc1c82b7585cf26c822f0.png',
|
|
|
+ }),
|
|
|
+ ])
|
|
|
+ const ctx = uni.createCanvasContext('firstCanvas')
|
|
|
+ const getPx = (width, designPx) => {
|
|
|
+ return (width / 319) * designPx
|
|
|
+ }
|
|
|
+ uni
|
|
|
+ .createSelectorQuery()
|
|
|
+ .select('#firstCanvas')
|
|
|
+ .fields({ size: true }, async ({ width: w, height: h }: any) => {
|
|
|
+ console.log(w, h)
|
|
|
+
|
|
|
+ ctx.drawImage(bgPath, 0, 0, w, h)
|
|
|
+ ctx.drawImage(path, 0, 0, w, w / 1.56)
|
|
|
+ ctx.drawImage(avatarPath, getPx(w, 17), getPx(w, 21), getPx(w, 28), getPx(w, 28))
|
|
|
+ ctx.drawImage(logoPath, getPx(w, 17), getPx(w, 230), getPx(w, 24), getPx(w, 24))
|
|
|
+ // 绘制昵称
|
|
|
+ ctx.setFillStyle('#ffffff')
|
|
|
+ ctx.setFontSize(getPx(w, 14))
|
|
|
+ ctx.fillText(userInfo.value?.nickname, getPx(w, 53), getPx(w, 40))
|
|
|
+ // 绘制文字
|
|
|
+ ctx.setFillStyle('#ffffff')
|
|
|
+ ctx.setFontSize(getPx(w, 18))
|
|
|
+ ctx.fillText('筑巢荟—助力设计师成长平台', getPx(w, 53), getPx(w, 248))
|
|
|
+
|
|
|
+ ctx.setFillStyle('#ffffff')
|
|
|
+ ctx.setFontSize(getPx(w, 12))
|
|
|
+ ctx.fillText('国内外设计游学', getPx(w, 62), getPx(w, 303))
|
|
|
+
|
|
|
+ ctx.setFillStyle('#ffffff')
|
|
|
+ ctx.setFontSize(getPx(w, 12))
|
|
|
+ ctx.fillText('设计赋能项目', getPx(w, 207), getPx(w, 303))
|
|
|
+
|
|
|
+ ctx.setFillStyle('#ffffff')
|
|
|
+ ctx.setFontSize(getPx(w, 12))
|
|
|
+ ctx.fillText('线上获客工具', getPx(w, 62), getPx(w, 339))
|
|
|
+
|
|
|
+ ctx.setFillStyle('#ffffff')
|
|
|
+ ctx.setFontSize(getPx(w, 12))
|
|
|
+ ctx.fillText('丰富线下活动', getPx(w, 207), getPx(w, 339))
|
|
|
+
|
|
|
+ ctx.drawImage(icon1, getPx(w, 41), getPx(w, 290), getPx(w, 18), getPx(w, 18))
|
|
|
+ ctx.drawImage(icon2, getPx(w, 189), getPx(w, 290), getPx(w, 18), getPx(w, 18))
|
|
|
+ ctx.drawImage(icon3, getPx(w, 41), getPx(w, 325), getPx(w, 18), getPx(w, 18))
|
|
|
+ ctx.drawImage(icon4, getPx(w, 189), getPx(w, 325), getPx(w, 18), getPx(w, 18))
|
|
|
+
|
|
|
+ ctx.draw(true, () => {
|
|
|
+ uni.canvasToTempFilePath({
|
|
|
+ canvasId: 'firstCanvas',
|
|
|
+ width: 300,
|
|
|
+ height: 460,
|
|
|
+ success: (res) => {
|
|
|
+ // console.log('生成海报', res)
|
|
|
+ resolve(res.tempFilePath)
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ // uni.hideLoading()
|
|
|
+ reject(err)
|
|
|
+ },
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .exec()
|
|
|
+ })()
|
|
|
+ })
|
|
|
+}
|
|
|
+const save = async () => {
|
|
|
+ await uni.saveImageToPhotosAlbum({ filePath: posterUrl.value })
|
|
|
+ uni.showToast({ title: '已保存相册', icon: 'none' })
|
|
|
+}
|
|
|
+const share = () => {
|
|
|
+ // uni.share({
|
|
|
+ // provider: 'weixin',
|
|
|
+ // scene: 'WXSceneSession',
|
|
|
+ // type: 2,
|
|
|
+ // // title: '你好呀',
|
|
|
+ // // href: 'https://www.baidu.com/',
|
|
|
+ // // summary: '我是图文描述',
|
|
|
+ // imageUrl: posterUrl.value,
|
|
|
+ // success: function (res) {
|
|
|
+ // console.log('success:' + JSON.stringify(res))
|
|
|
+ // },
|
|
|
+ // fail: function (err) {
|
|
|
+ // console.log('fail:' + JSON.stringify(err))
|
|
|
+ // },
|
|
|
+ // })
|
|
|
+}
|
|
|
+onMounted(async () => {
|
|
|
+ await setData()
|
|
|
+ form.value = pick(data.value, ['id', 'userId', 'videoNumber'])
|
|
|
+ posterUrl.value = await createPoster()
|
|
|
+})
|
|
|
+// onAppShare(() => {})
|
|
|
+</script>
|
|
|
+<template>
|
|
|
+ <div
|
|
|
+ class="flex-grow flex flex-col justify-center gap-5 px-3.5 py-6 bg-black bg-[length:100%_100%]"
|
|
|
+ :style="{ backgroundImage: `url(${NetImages.InviteBg})` }"
|
|
|
+ >
|
|
|
+ <div class="block aspect-[0.69/1]">
|
|
|
+ <div class="bg-white mx-7 aspect-[0.69/1] relative rounded-2xl overflow-hidden">
|
|
|
+ <canvas class="w-full h-full" canvas-id="firstCanvas" id="firstCanvas"></canvas>
|
|
|
+ <div class="absolute bottom-5.5 left-5.5">
|
|
|
+ <cover-view>
|
|
|
+ <wd-button custom-class="bg-white/10!" @click="save">保存到相册</wd-button>
|
|
|
+ </cover-view>
|
|
|
+ <!-- <wd-button @click="share">微信</wd-button>
|
|
|
+ <wd-button @click="share">朋友圈</wd-button> -->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- <SectionHeading title="如何关联视频号?" size="sm"></SectionHeading>
|
|
|
+ <img class="w-[347px] h-[186px] rounded-2xl" src="https://via.placeholder.com/347x186" />
|
|
|
+ <SectionHeading title="视频号ID" size="sm"></SectionHeading>
|
|
|
+ <div class="bg-[#f6f6f6] rounded-lg px-3.5 py-2.5">
|
|
|
+ <wd-input
|
|
|
+ v-model="form.videoNumber"
|
|
|
+ placeholder="请输入视频号ID"
|
|
|
+ no-border
|
|
|
+ custom-class="bg-[#f6f6f6]!"
|
|
|
+ ></wd-input>
|
|
|
+ </div>
|
|
|
+ <BottomAppBar fixed :border="false">
|
|
|
+ <div>
|
|
|
+ <div class="text-center mb-5.5">
|
|
|
+ <span class="text-black/40 text-xs font-normal font-['PingFang SC'] leading-tight">
|
|
|
+ 点击确认关联即表示同意
|
|
|
+ </span>
|
|
|
+ <span class="text-[#0cbe7c] text-xs font-normal font-['PingFang SC'] leading-tight">
|
|
|
+ 《个人微信视频号授权使用协议》
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <wd-button :round="false" block :loading="loading" @click="handleSubmit">
|
|
|
+ 确定关联
|
|
|
+ </wd-button>
|
|
|
+ </div>
|
|
|
+ </BottomAppBar> -->
|
|
|
+ </div>
|
|
|
+</template>
|