achievement.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <view class="common_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
  3. <!-- 页面头部和主要内容 (保持不变) -->
  4. <cus-header title="我的成就" bgColor="transparent"></cus-header>
  5. <image src="https://oss.familydaf.cn/sxsnfile/20251218/14dde55f252a4df4a67886c57e083c6d.png" class="top_bg_img" mode="widthFix"></image>
  6. <view class="info">
  7. <view class="info-top adfac">
  8. <image class="avatar" :src="userInfo?.avatarPath||'https://oss.familydaf.cn/sxsnfile/20251218/ad5a1a788b6944358b0bc93e2506bf17.png'"></image>
  9. <view class="name">Hi~ {{userInfo?.realName||userInfo?.name||''}}</view>
  10. <view class="level adfac" @click="handleTurnPage('/pagesMy/levelDetail')"><text>Lv&nbsp;</text><text>{{userLevel}}</text></view>
  11. </view>
  12. <view class="info-num">收获勋章:{{numInfo?.myMedals||0}} <text>枚</text></view>
  13. <view class="info-memo">共参与<text>{{numInfo?.activityCount||0}}</text>次公益活动,累计义工时长<text>{{numInfo?.volunteerHours||0}}</text>小时</view>
  14. </view>
  15. <view class="tab adfacjc">
  16. <view class="tab-pre" :class="{'active':queryParams.obtained===1}" @click="changeTab(1)">全部</view>
  17. <view class="tab-pre" :class="{'active':queryParams.obtained===''}" @click="changeTab('')">未获得</view>
  18. </view>
  19. <view class="list" v-if="list.length">
  20. <view class="list-pre adffcac" v-for="(item,index) in list" :key="index" @click="showSz(item)">
  21. <image :src="item.imageUrl||''"></image>
  22. <view class="p">{{item?.medalName||''}}</view>
  23. <view class="p tip" v-if="item?.lightUp">{{item?.lightUpDate2||''}}点亮</view>
  24. <view class="p tip" v-else>未获得</view>
  25. </view>
  26. </view>
  27. <view class="dataEmpty" v-else>
  28. <page-empty text="暂无勋章"></page-empty>
  29. </view>
  30. <!-- 分享按钮 -->
  31. <view class="btn" @click="showSave">晒出我的成就</view>
  32. <!-- 勋章详情弹窗 (保持不变) -->
  33. <view class="dialog adffcac" :style="{'height':'calc(100vh - '+mt+')px', 'top':mt+'px'}" v-if="xzShow" @click="xzShow=false;xzInfo=null">
  34. <view class="title">"恭喜您获得荣誉勋章"</view>
  35. <view class="img adfacjc">
  36. <image :src="xzInfo.imageUrl"></image>
  37. </view>
  38. <view class="name adfac">
  39. <image src="https://oss.familydaf.cn/sxsnfile/20251218/3f1a0b7c92ed479c908b705936cefa45.png"></image>
  40. <text>{{xzInfo.medalName}}</text>
  41. <image src="https://oss.familydaf.cn/sxsnfile/20251218/1768e4e2e276413fb3c59b17e4242501.png"></image>
  42. </view>
  43. <view class="date">{{xzInfo.lightUpDate}}获得</view>
  44. <!-- <view class="btn adfacjc" @click="shareMedal">
  45. <image src="https://oss.familydaf.cn/sxsnfile/20251218/3e76bc6c59144bb7995975063a250435.png"></image>
  46. <text>炫耀一下</text>
  47. </view> -->
  48. <image class="close" @click="xzShow=false;xzInfo=null" src="https://oss.familydaf.cn/sxsnfile/20251218/78386a7b48674761b0e33fc9c621cc3f.png"></image>
  49. </view>
  50. <!-- 分享弹窗:显示生成的图片 -->
  51. <view class="save adffcacjc" :style="{'height':'calc(100vh - '+mt+')px', 'top':mt+'px'}" v-if="saveShow">
  52. <view class="share_box">
  53. <image
  54. :src="generatedImagePath"
  55. class="share_image"
  56. mode="widthFix"
  57. @longpress="saveImageToAlbum"
  58. ></image>
  59. <image
  60. class="share_close_btn"
  61. @click="saveShow=false"
  62. src="https://oss.familydaf.cn/sxsnfile/20251218/098d0e537ce34d4f8ca3d0523452a025.png"
  63. ></image>
  64. </view>
  65. <view class="text">长按图片,保存到手机</view>
  66. </view>
  67. <!-- 用于绘制分享图的 Canvas -->
  68. <canvas canvas-id="shareCanvas" id="shareCanvas" :style="{width: canvasWidth + 'px', height: canvasHeight + 'px', position: 'fixed', top: '-99999px', left: '-99999px'}"></canvas>
  69. </view>
  70. </template>
  71. <script setup name="">
  72. import CusHeader from '@/components/CusHeader/index.vue'
  73. import PageEmpty from '@/components/pageEmpty/index.vue'
  74. import { onLoad } from '@dcloudio/uni-app'
  75. import { ref, getCurrentInstance } from 'vue'
  76. const { proxy } = getCurrentInstance()
  77. const userLevel = ref(0)
  78. const userInfo = ref(null)
  79. const numInfo = ref(null)
  80. const queryParams = ref({
  81. page:1,
  82. limit:-1,
  83. userId:'',
  84. memberId:'',
  85. obtained:1
  86. })
  87. const list = ref([])
  88. const xzShow = ref(false)
  89. const xzInfo = ref(null)
  90. const saveShow = ref(false)
  91. const generatedImagePath = ref('')
  92. const isGenerating = ref(false)
  93. const canvasWidth = ref(0)
  94. const canvasHeight = ref(0)
  95. const changeTab = type => {
  96. queryParams.value.obtained = type;
  97. getList()
  98. }
  99. const handleTurnPage = (url) => {
  100. uni.navigateTo({ url })
  101. }
  102. const showSz = item => {
  103. if(!item.lightUpDate) return
  104. xzInfo.value = item;
  105. if(xzInfo.value.lightUpDate) xzInfo.value.lightUpDate = new Date(xzInfo.value.lightUpDate).Format('yyyy.MM.dd hh:mm:ss')
  106. xzShow.value = true;
  107. }
  108. const showSave = async () => {
  109. const xzImgList = list.value.filter(l => l.lightUpDate).map(l => l.imageUrl) || [];
  110. if (xzImgList.length === 0) {
  111. return proxy.$showToast('您还没有已获得的勋章可以分享哦');
  112. }
  113. if (isGenerating.value) return;
  114. isGenerating.value = true;
  115. uni.showLoading({ title: '分享图生成中...', mask: true });
  116. try {
  117. const imagePath = await generateShareImage(xzImgList);
  118. generatedImagePath.value = imagePath;
  119. saveShow.value = true;
  120. } catch (error) {
  121. proxy.$showToast(error.errMsg || '图片生成失败,请稍后重试');
  122. console.error('Share image generation failed:', error);
  123. } finally {
  124. uni.hideLoading();
  125. isGenerating.value = false;
  126. }
  127. }
  128. const saveImageToAlbum = () => {
  129. if (!generatedImagePath.value) return;
  130. uni.saveImageToPhotosAlbum({
  131. filePath: generatedImagePath.value,
  132. success: () => {
  133. proxy.$showToast('图片已保存到相册');
  134. },
  135. fail: (err) => {
  136. if (err.errMsg.includes('auth deny') || err.errMsg.includes('auth denied')) {
  137. uni.showModal({
  138. title: '保存失败',
  139. content: '您未授权保存图片到相册,请前往设置页开启权限。',
  140. showCancel: true,
  141. success: (res) => { if (res.confirm) { uni.openSetting(); } }
  142. })
  143. } else {
  144. proxy.$showToast('图片保存失败');
  145. }
  146. }
  147. })
  148. }
  149. const shareMedal = () => {
  150. if (!xzInfo.value || !xzInfo.value.imageUrl) {
  151. proxy.$showToast('勋章信息不完整,无法分享');
  152. return;
  153. }
  154. // 1. 使用 uni.previewImage 预览图片
  155. // 用户在预览界面可以长按图片,选择“发送给朋友”或“保存图片”
  156. uni.previewImage({
  157. urls: [xzInfo.value.imageUrl], // 需要预览的图片链接列表
  158. current: xzInfo.value.imageUrl, // 当前显示图片的链接
  159. success: () => {
  160. // 预览成功后,给用户一个提示
  161. proxy.$showToast('长按图片可保存或分享给好友', 3000);
  162. // 提示后可以关闭弹窗,也可以不关,取决于产品需求
  163. // xzShow.value = false;
  164. },
  165. fail: (err) => {
  166. console.error('预览图片失败', err);
  167. proxy.$showToast('预览图片失败,请稍后再试');
  168. // 预览失败的备用方案:尝试直接保存图片到相册
  169. uni.getImageInfo({
  170. src: xzInfo.value.imageUrl,
  171. success: (res) => {
  172. uni.saveImageToPhotosAlbum({
  173. filePath: res.path,
  174. success: () => {
  175. proxy.$showToast('勋章图片已保存到相册,请前往微信选择分享给好友');
  176. },
  177. fail: (saveErr) => {
  178. proxy.$showToast('图片保存失败,请检查相册权限');
  179. console.error('保存图片失败', saveErr);
  180. }
  181. });
  182. },
  183. fail: (infoErr) => {
  184. proxy.$showToast('获取图片信息失败,无法保存');
  185. console.error('获取图片信息失败', infoErr);
  186. }
  187. });
  188. }
  189. });
  190. };
  191. /**
  192. * @description 【核心】使用 Canvas 绘制分享图,并返回图片临时路径
  193. * @param {Array} xzImgList - 已获得的勋章图片URL列表
  194. * @returns {Promise<string>} 返回生成的图片临时路径
  195. */
  196. const generateShareImage = (xzImgList) => {
  197. return new Promise(async (resolve, reject) => {
  198. try {
  199. const systemInfo = uni.getSystemInfoSync();
  200. const screenWidth = systemInfo.screenWidth;
  201. const upx2px = (rpx) => rpx / 2;
  202. const boxWidth = upx2px(622);
  203. const boxHeight = upx2px(720);
  204. canvasWidth.value = boxWidth;
  205. canvasHeight.value = boxHeight;
  206. const ctx = uni.createCanvasContext('shareCanvas', proxy);
  207. const imageUrls = {
  208. bg: 'https://oss.familydaf.cn/sxsnfile/20251218/1e4ec3ed6384416980ec32a49de49223.png',
  209. avatar: userInfo.value?.avatarPath || 'https://oss.familydaf.cn/sxsnfile/20251218/255ec4b8760b4dada7ffbcf1bf6b2928.png',
  210. qrCode: 'https://oss.familydaf.cn/sxsnfile/20251218/7d2336f662ac41b9811a863772263290.jpg',
  211. };
  212. xzImgList.forEach((url, index) => { imageUrls[`medal_${index}`] = url; });
  213. const imageInfos = await preloadImages(imageUrls);
  214. ctx.drawImage(imageInfos.bg.path, 0, 0, boxWidth, boxHeight);
  215. ctx.save();
  216. const paddingX = upx2px(36);
  217. const paddingTop = upx2px(34);
  218. // --- 1. 顶部信息 ---
  219. const avatarSize = upx2px(90);
  220. ctx.save();
  221. ctx.beginPath();
  222. ctx.arc(paddingX + avatarSize / 2, paddingTop + avatarSize / 2, avatarSize / 2, 0, 2 * Math.PI);
  223. ctx.clip();
  224. ctx.drawImage(imageInfos.avatar.path, paddingX, paddingTop, avatarSize, avatarSize);
  225. ctx.restore();
  226. ctx.fillStyle = '#FAE5B9';
  227. ctx.font = `bold ${upx2px(32)}px "PingFang-SC", sans-serif`;
  228. ctx.textBaseline = 'middle';
  229. ctx.fillText(`${userInfo.value?.realName || ''}的公益勋章墙`, paddingX + avatarSize + upx2px(18), paddingTop + avatarSize / 2);
  230. // --- 2. 勋章数量 (已根据反馈修复对齐和间距) ---
  231. const numTop = paddingTop + avatarSize + upx2px(10);
  232. const numLineBaseY = numTop + upx2px(40); // 设定一个公共的文字基线
  233. // 绘制数字部分
  234. ctx.font = `bold ${upx2px(40)}px "PingFang-SC", sans-serif`;
  235. ctx.fillStyle = '#FAE5B9';
  236. ctx.textBaseline = 'alphabetic'; // 使用字母基线对齐
  237. const medalsNumText = `${numInfo.value?.myMedals || 0}`;
  238. ctx.fillText(medalsNumText, paddingX, numLineBaseY);
  239. // 绘制文字部分
  240. const numTextMetrics = ctx.measureText(medalsNumText);
  241. ctx.font = `400 ${upx2px(28)}px "PingFang-SC", sans-serif`;
  242. ctx.fillStyle = '#FFFFFF';
  243. ctx.textBaseline = 'alphabetic'; // 使用相同的基线
  244. // 使用修复后的间距
  245. ctx.fillText('枚公益勋章', paddingX + numTextMetrics.width + upx2px(8), numLineBaseY);
  246. // --- 勋章墙 (逻辑不变) ---
  247. const numLineHeight = upx2px(56); // 按CSS中大的line-height计算
  248. const xzImgsTop = numTop + numLineHeight + upx2px(48);
  249. const xzImgsHeight = upx2px(328);
  250. const xzImgsBgRadius = upx2px(16);
  251. drawRoundRect(ctx, paddingX, xzImgsTop, boxWidth - 2 * paddingX, xzImgsHeight, xzImgsBgRadius, '#222632');
  252. const xzBoxPadding = upx2px(26);
  253. const medalSize = upx2px(111);
  254. const medalMargin = upx2px(23);
  255. xzImgList.forEach((url, index) => {
  256. const medalX = paddingX + xzBoxPadding + index * (medalSize + medalMargin);
  257. const medalY = xzImgsTop + (xzImgsHeight - medalSize) / 2;
  258. ctx.drawImage(imageInfos[`medal_${index}`].path, medalX, medalY, medalSize, medalSize);
  259. });
  260. // --- 3. 底部信息 (已根据反馈修复对齐和间距) ---
  261. const bottomTop = xzImgsTop + xzImgsHeight + upx2px(26);
  262. const qrSize = upx2px(100);
  263. ctx.save();
  264. ctx.beginPath();
  265. ctx.arc(paddingX + qrSize / 2, bottomTop + qrSize / 2, qrSize / 2, 0, 2 * Math.PI);
  266. ctx.clip();
  267. ctx.drawImage(imageInfos.qrCode.path, paddingX, bottomTop, qrSize, qrSize);
  268. ctx.restore();
  269. // 绘制二维码右侧文字 (修复垂直居中)
  270. const qrTextX = paddingX + qrSize + upx2px(24);
  271. const textLine1Height = upx2px(20);
  272. const textLineMargin = upx2px(20);
  273. const totalTextBlockHeight = textLine1Height * 2 + textLineMargin;
  274. const textBlockStartY = bottomTop + (qrSize - totalTextBlockHeight) / 2;
  275. ctx.fillStyle = '#FFFFFF';
  276. ctx.font = `400 ${upx2px(20)}px "PingFang-SC", sans-serif`;
  277. ctx.textBaseline = 'top';
  278. ctx.textAlign = 'left'; // 重置对齐
  279. ctx.fillText('扫描二维码', qrTextX, textBlockStartY);
  280. ctx.fillText('查看你的公益勋章', qrTextX, textBlockStartY + textLine1Height + textLineMargin);
  281. // --- 4. 绘制右下角 "善行少年" (已根据反馈修复对齐) ---
  282. ctx.fillStyle = '#FFFFFF';
  283. ctx.font = `italic 400 ${upx2px(22)}px "kuaikanshijieti", sans-serif`;
  284. ctx.textAlign = 'right';
  285. ctx.textBaseline = 'middle';
  286. // 添加微调值以改善自定义字体垂直居中效果
  287. const yOffset = upx2px(4);
  288. ctx.fillText('善行少年', boxWidth - paddingX - upx2px(10), bottomTop + qrSize / 2 + yOffset);
  289. ctx.restore();
  290. // 绘制完成,导出图片
  291. ctx.draw(true, () => {
  292. uni.canvasToTempFilePath({
  293. canvasId: 'shareCanvas',
  294. success: (res) => resolve(res.tempFilePath),
  295. fail: (err) => reject(err)
  296. }, proxy);
  297. });
  298. } catch (error) {
  299. reject(error);
  300. }
  301. });
  302. }
  303. const preloadImages = (urls) => {
  304. const promises = Object.entries(urls).map(([key, url]) => {
  305. return new Promise((resolve, reject) => {
  306. uni.getImageInfo({
  307. src: url,
  308. success: (res) => resolve({ key, ...res }),
  309. fail: reject
  310. });
  311. });
  312. });
  313. return Promise.all(promises).then(results => {
  314. return results.reduce((acc, res) => {
  315. acc[res.key] = res;
  316. return acc;
  317. }, {});
  318. });
  319. }
  320. const drawRoundRect = (ctx, x, y, width, height, radius, fillColor) => {
  321. ctx.save(); ctx.beginPath();
  322. ctx.moveTo(x + radius, y);
  323. ctx.arcTo(x + width, y, x + width, y + height, radius);
  324. ctx.arcTo(x + width, y + height, x, y + height, radius);
  325. ctx.arcTo(x, y + height, x, y, radius);
  326. ctx.arcTo(x, y, x + width, y, radius);
  327. ctx.closePath();
  328. if (fillColor) { ctx.fillStyle = fillColor; ctx.fill(); }
  329. ctx.restore();
  330. }
  331. const getList = () => {
  332. proxy.$api.get('/core/love/value/record/obtainedMedalList',queryParams.value).then(({data:res})=>{
  333. if(res.code!==0) return proxy.$showToast(res.msg)
  334. list.value = queryParams.value.obtained?res.data.list:res.data.list.filter(d=>!d.lightUpDate)
  335. list.value.forEach(l=>l.lightUpDate2 = l.lightUpDate?new Date(l.lightUpDate).Format('yyyy.MM.dd'):'');
  336. })
  337. }
  338. onLoad((options)=>{
  339. try{
  340. userInfo.value = uni.getStorageSync('isFamilyMember')?JSON.parse(uni.getStorageSync('familyMemberInfo')):JSON.parse(uni.getStorageSync('userInfo'));
  341. numInfo.value = options.numInfo&&JSON.parse(options.numInfo);
  342. userLevel.value = options.userLevel||0;
  343. queryParams.value.userId = userInfo.value&&userInfo.value.id;
  344. if(uni.getStorageSync('isFamilyMember')) queryParams.value.memberId = userInfo.value&&userInfo.value.id;
  345. getList()
  346. }catch(e){
  347. //TODO handle the exception
  348. }
  349. })
  350. </script>
  351. <style scoped lang="scss">
  352. /* --- 样式部分完全保持不变 --- */
  353. .scroll-view_H { white-space: nowrap; width: 100%; }
  354. .scroll-view-item_H { display: inline-block; width: 111rpx; height: 100%; margin-left: 23rpx; &:first-child{ margin-left: 0; } }
  355. .common_page { background: #FFFFFF; overflow: hidden; }
  356. .info { position: relative; margin-top: 31rpx; }
  357. .info-top { .avatar{ width: 98rpx; height: 98rpx;border-radius: 50%; } .name{ font-family: PingFang-SC, PingFang-SC; font-weight: bold; font-size: 32rpx; color: #252525; line-height: 54rpx; margin-left: 15rpx; } .level{ width: 127rpx; height: 42rpx; background: url('https://oss.familydaf.cn/sxsnfile/20251218/685ccddc71104cd4b1c6520e79cb9648.png') no-repeat; background-size: 100% 100%; margin-left: 20rpx; text{ font-family: PingFangSC, PingFang SC; font-weight: 600; font-size: 26rpx; color: #FFFFFF; line-height: 26rpx; margin-left: 16rpx; } } }
  358. .info-num { font-family: PingFang-SC, PingFang-SC; font-weight: bold; font-size: 44rpx; color: #252525; line-height: 48rpx; margin-top: 24rpx; text{ font-weight: 400; font-size: 24rpx; line-height: 40rpx; } }
  359. .info-memo { margin-top: 29rpx; font-family: PingFangSC, PingFang SC; font-weight: 400; font-size: 28rpx; color: #252525; line-height: 28rpx; text{ font-weight: bold; margin: 0 10rpx; } }
  360. .tab { position: relative; margin-top: 92rpx; }
  361. .tab-pre { padding: 0 65rpx; font-family: PingFangSC, PingFang SC; font-weight: 400; font-size: 32rpx; color: #676775; line-height: 48rpx; position: relative; &.active{ font-weight: bold; font-size: 36rpx; color: #252525; &::after{ content: ''; width: 42rpx; height: 6rpx; background: #77F99B; border-radius: 3rpx; position: absolute; left: 50%; margin-left: -21rpx; bottom: -15rpx; } } }
  362. .list { margin-left: -60rpx; overflow: hidden; flex: 1; overflow-y: auto; }
  363. .list-pre { width: calc(100% / 3 - 60rpx); margin-top: 48rpx; float: left; margin-left: 60rpx; image{ width: 180rpx; height: 176rpx; } .p{ font-family: PingFang-SC, PingFang-SC; font-weight: bold; font-size: 28rpx; color: #252525; line-height: 28rpx; text-align: center; margin-top: 24rpx; &.tip{ font-weight: 400; font-size: 24rpx; color: #676775; line-height: 24rpx; } } }
  364. .btn { width: 100%; height: 90rpx; background: #B7F358; border-radius: 45rpx; font-family: PingFang-SC, PingFang-SC; font-weight: bold; font-size: 32rpx; color: #151B29; line-height: 90rpx; text-align: center; letter-spacing: 2rpx; margin-top: 60rpx; }
  365. .dialog { position: fixed; left: 0; right: 0; top: 0; bottom: 0; background: #252525; .title{ font-family: FZZCHJW--GB1, FZZCHJW--GB1; font-weight: normal; font-size: 36rpx; color: #FDE2B2; line-height: 44rpx; text-align: center; margin-top: 113rpx; } .img{ perspective: 1000px; width: 567rpx; height: 496rpx; background: url('https://oss.familydaf.cn/sxsnfile/20251218/c55f852845f147d09aea676a187531e6.png') no-repeat; background-size: 96% 100%; margin-top: 27rpx; image{ width: 279rpx; height: 275rpx; animation:flip-in 0.6s ease-out forwards,hover-3d 2s ease-in-out 0.6s infinite; } } .name{ margin-top: 18rpx; image{ width: 53rpx; height: 67rpx; } text{ font-family: FZZCHJW--GB1, FZZCHJW--GB1; font-weight: normal; font-size: 64rpx; color: #FDE2B2; line-height: 77rpx; text-align: center; } } .date{ font-family: PingFangSC, PingFang SC; font-weight: 400; font-size: 26rpx; color: #B2AB95; line-height: 37rpx; text-align: center; margin-top: 23rpx; } .btn{ width: 368rpx; height: 88rpx; background: linear-gradient( 270deg, #F8D7AC 0%, #FEFAD9 100%); border-radius: 44rpx; margin-top: 89rpx; image{ width: 30rpx; height: 25rpx; } text{ font-family: PingFang-SC, PingFang-SC; font-weight: bold; font-size: 32rpx; color: #252525; line-height: 45rpx; margin-left: 14rpx; } } .close{ width: 48rpx; height: 48rpx; margin-top: 73rpx; } }
  366. /* 定义入场动画:从中间翻转并放大出现 */
  367. @keyframes flip-in {
  368. from {
  369. /* 从旋转90度(看不见)并缩小开始 */
  370. transform: rotateY(90deg) scale(0.7);
  371. opacity: 0;
  372. }
  373. to {
  374. /* 结束时恢复正常状态 */
  375. transform: rotateY(0deg) scale(1);
  376. opacity: 1;
  377. }
  378. }
  379. /* 定义3D悬浮摆动动画 */
  380. @keyframes hover-3d {
  381. 0% {
  382. transform: rotateY(-10deg); /* 向左偏转 */
  383. }
  384. 50% {
  385. transform: rotateY(10deg); /* 向右偏转 */
  386. }
  387. 100% {
  388. transform: rotateY(-10deg); /* 回到左偏转,形成无缝循环 */
  389. }
  390. }
  391. .save {
  392. position: fixed;
  393. left: 0;
  394. right: 0;
  395. bottom: 0;
  396. background: rgba(0, 0, 0, .8);
  397. .share_box {
  398. position: relative;
  399. width: calc(100% - 128rpx);
  400. .share_image {
  401. width: 100%;
  402. display: block;
  403. }
  404. .share_close_btn {
  405. width: 48rpx;
  406. height: 48rpx;
  407. position: absolute;
  408. top: 0;
  409. right: 0;
  410. }
  411. }
  412. .text {
  413. font-family: PingFangSC, PingFang SC;
  414. font-weight: 400;
  415. font-size: 28rpx;
  416. color: #FFFFFF;
  417. line-height: 40rpx;
  418. text-align: center;
  419. margin-top: 44rpx;
  420. }
  421. }
  422. </style>