activityDetail.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. <template>
  2. <view class="common_page adffc" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title="公益活动详情" bgColor="transparent"></cus-header>
  4. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/19/54b75bc8-d926-449b-95a5-1126f700b481.png" class="top_bg_img" mode="widthFix"></image>
  5. <view class="lunbo">
  6. <up-swiper
  7. :list="imgList"
  8. @change="e => current = e.current"
  9. :autoplay="true"
  10. height="440rpx"
  11. >
  12. <template #indicator>
  13. <view class="indicator adf">
  14. <view class="indicator__dot" v-for="(item, index) in imgList" :key="index"
  15. :class="[index === current && 'indicator__dot--active']">
  16. </view>
  17. </view>
  18. </template>
  19. </up-swiper>
  20. </view>
  21. <view class="box box1">
  22. <view class="box1-top">
  23. <text class="box1-top-status" :class="{'end':activityInfo?.activeState==3}">{{statusCfg[activityInfo?.activeState]||'未知'}}</text>
  24. <text class="box1-top-title">{{activityInfo?.activityName||''}}</text>
  25. </view>
  26. <view class="box1-line" style="margin-top: 36rpx;"></view>
  27. <view class="box1-place adfacjb">
  28. <view class="box1-place-left adffcjb">
  29. <text>活动地点</text>
  30. <view class="addr">{{activityInfo?.provinceName||''}}{{activityInfo?.cityName||''}}{{activityInfo?.address||''}}</view>
  31. </view>
  32. <view class="box1-place-right">
  33. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/239a8c29-499b-407b-a9b5-90447248d9ab.png"></image>
  34. </view>
  35. </view>
  36. <view class="box1-line" style="margin-top: 24rpx;"></view>
  37. <view class="box1-member adfacjb">
  38. <view class="box1-member-left adffc">
  39. <text>招募人数</text>
  40. <view class="num"><text>{{activityInfo?.recruitmentNow}}</text> /{{activityInfo?.recruitmentMax||'不限'}}</view>
  41. </view>
  42. <view class="box1-member-right adffc" @tap="handleReviewMembers">
  43. <view class="review adfac">
  44. <text>查看报名人员</text>
  45. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/b7b7531b-33fa-4ec3-841b-796be9035191.png"></image>
  46. </view>
  47. <view class="avatars">
  48. <up-avatar-group :urls="avatars" size="30" gap="0.4" :maxCount="3"></up-avatar-group>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="box1-line" style="margin-top: 33rpx;"></view>
  53. <view class="box1-time adffc">
  54. <text>活动时间</text>
  55. <view class="text">{{activityInfo?.activityStartTime}} - {{activityInfo?.activityEndTime}}</view>
  56. </view>
  57. <view class="box1-line" style="margin-top: 30rpx;"></view>
  58. <view class="box1-need adffc">
  59. <text>报名要求</text>
  60. <template v-if="activityInfo?.activityLimit==1">
  61. <view class="text"><text>{{activityInfo?.valueLimit||0}}</text>爱心值</view>
  62. <view class="tip">{{activityInfo?.loveValueContent||''}}</view>
  63. </template>
  64. <template v-else-if="activityInfo?.activityLimit==2">
  65. <view class="text"><text>{{activityInfo?.valueLimit||0}}</text>张专享券</view>
  66. <view class="tip">{{activityInfo?.loveValueContent||''}}</view>
  67. </template>
  68. <template v-else-if="activityInfo?.activityLimit==3">
  69. <view class="text"><text>免费</text></view>
  70. <view class="tip"></view>
  71. </template>
  72. </view>
  73. <view class="box1-line" style="margin-top: 30rpx;"></view>
  74. <view class="box1-info adfacjb">
  75. <view class="box1-info-pre">
  76. <text>年龄限制</text>
  77. <view class="text" v-if="activityInfo?.userAgeMax">{{activityInfo?.userAgeMin}}岁 到 {{activityInfo?.userAgeMax}}岁</view>
  78. <view class="text" v-else>不限制</view>
  79. </view>
  80. <view class="box1-info-pre line">
  81. <text>可获得义工时长</text>
  82. <!-- typeId=='1977564860095348737'为义工活动,义工时长只有义工活动才有 -->
  83. <view class="hour" v-if="activityInfo?.typeId=='1977564860095348737'"><text>{{activityInfo?.serviceHours||0}}</text> 小时</view>
  84. <view class="hour" v-else>无</view>
  85. </view>
  86. </view>
  87. <view class="box1-line" style="margin-top: 30rpx;"></view>
  88. <view class="box1-info adfacjb">
  89. <view class="box1-info-pre">
  90. <text>联系人</text>
  91. <view class="text">{{activityInfo?.contact||''}}/{{activityInfo?.contactPhone||''}}</view>
  92. </view>
  93. <view class="box1-info-pre line">
  94. <text>公益合作</text>
  95. <view class="text">{{activityInfo?.channelName||''}}</view>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="box box2">
  100. <view class="box-title">活动详情</view>
  101. <view class="box2-detail" v-if="activityInfo&&activityInfo.activityDetails">
  102. <up-read-more :toggle="true" showHeight="374rpx" color="#989998" fontSize="24rpx" openText="收起更多信息" closeText="展开更多信息">
  103. <rich-text :nodes="activityInfo.activityDetails"></rich-text>
  104. </up-read-more>
  105. </view>
  106. </view>
  107. <view class="bottom">
  108. <view class="time">
  109. 报名时间:{{activityInfo?.signupStartTime}} - {{activityInfo?.signupEndTime}}
  110. </view>
  111. <view class="btns adfacjb">
  112. <view class="left adffcacjc" @tap="showShareOptions">
  113. <up-icon name="share-square" color="#252525" size="48rpx"></up-icon>
  114. <text>分享</text>
  115. </view>
  116. <view class="right" @click="handleApply" v-if="activityInfo?.activeState==1&&activityInfo?.signupState==0">立即报名</view>
  117. <view class="right" @click="handleCancel" v-else-if="activityInfo?.activeState==1&&activityInfo?.signupState==1">取消报名</view>
  118. <view class="right" @click="handleSignup" v-else-if="activityInfo?.activeState==2&&activityInfo?.signupState==1">我要签到</view>
  119. <view class="right" @click="handleFill" v-else-if="activityInfo?.activeState==3&&activityInfo?.signupState==1">填写公益档案</view>
  120. <view class="right end" v-else-if="activityInfo?.activeState==0">活动未开始</view>
  121. <view class="right end" v-else-if="activityInfo?.activeState==2&&activityInfo?.signupState==0">活动进行中不可报名</view>
  122. <view class="right end" v-else-if="activityInfo?.activeState==3">活动已结束</view>
  123. <view class="right end" v-else-if="activityInfo?.activeState==4">已报满暂无活动名额</view>
  124. </view>
  125. </view>
  126. <view class="fail" v-if="fail">
  127. <view class="fbox adffcac">
  128. <image class="clock" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/5fe8627b-adc4-4e24-8e86-45771d3ba5a2.png"></image>
  129. <image class="close" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/3d94527a-da92-4d8b-9e99-44683c4f5c84.png" @click="fail=false"></image>
  130. <image class="alert" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/fdf05bfa-5593-4448-940e-437152bbbaf9.png" mode="widthFix"></image>
  131. <view class="texts adffcacjc">
  132. <view class="text">您当前{{activityLimitCfg[activityInfo?.activityLimit]}}不足,无法报名活动</view>
  133. <view class="tip">欢迎联系专属客服,了解更多公益活动,积攒{{activityLimitCfg[activityInfo?.activityLimit]}}</view>
  134. </view>
  135. <image class="down" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/c7d4983d-ca93-4833-8922-e010dd1d450a.png"></image>
  136. <view class="user adfacjc">
  137. <!-- <view class="user adfac"> -->
  138. <!-- <view class="user-left">
  139. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/20ff1438-01a9-454c-b62c-501ed47c39a6.png"></image>
  140. </view>
  141. <view class="user-right">
  142. <view class="name">陈婧航</view>
  143. <view class="memo">@深圳善行少年基金会</view>
  144. </view> -->
  145. "善行少年"咨询微信
  146. </view>
  147. <view class="finfo adffcac">
  148. <view class="finfo-code adffcacjc">
  149. <!-- <image :src="imageUrl" @longpress="handleLongPress(imageUrl)"></image> -->
  150. <image :src="imageUrl" :show-menu-by-longpress="true"></image>
  151. </view>
  152. <view class="finfo-title">长按识别二维码</view>
  153. <view class="finfo-tip">添加您的专属公益向导</view>
  154. <view class="finfo-btn" @click="toWebView">了解善行少年</view>
  155. <view class="finfo-zblj" @click="fail=false">暂不了解</view>
  156. </view>
  157. </view>
  158. </view>
  159. <view class="share" v-if="share">
  160. <view class="sbox">
  161. <view class="sbox-title">分享给好友</view>
  162. <image class="close" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/7d1c7cf4-199a-4008-8114-ee0e1a8f0cc3.png" @click="share=false"></image>
  163. <view class="sbox-items adfac">
  164. <view class="sbox-items-pre adffcac" @click="shareToFriend">
  165. <button class="share-btn" open-type="share">
  166. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/a993c721-a4c7-4f5e-95cc-6451a50bfdce.png"></image>
  167. <text>分享页面</text>
  168. </button>
  169. </view>
  170. <view class="sbox-items-pre adffcac" @click="generatePoster">
  171. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/0c87d8a1-d7c5-466c-84aa-87ec5f163955.png"></image>
  172. <text>生成海报</text>
  173. </view>
  174. <view class="sbox-items-pre adffcac" @click="shareToTimeline">
  175. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/732ac5fd-af58-44d8-9625-aaf96c24fed0.png"></image>
  176. <text>分享到朋友圈</text>
  177. </view>
  178. </view>
  179. </view>
  180. </view>
  181. <!-- 添加海报生成的canvas -->
  182. <canvas
  183. canvas-id="posterCanvas"
  184. :style="{width: canvasWidth + 'px', height: canvasHeight + 'px'}"
  185. style="position: fixed; top: -9999px; left: -9999px;"
  186. ></canvas>
  187. <!-- 海报预览弹窗 -->
  188. <view class="poster-preview" v-if="showPoster">
  189. <view class="poster-box">
  190. <view class="poster-header">
  191. <text>生成海报</text>
  192. <image class="close" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/7d1c7cf4-199a-4008-8114-ee0e1a8f0cc3.png" @click="showPoster=false"></image>
  193. </view>
  194. <view class="poster-content">
  195. <image :src="posterUrl" mode="widthFix" class="poster-img"></image>
  196. </view>
  197. <view class="poster-actions">
  198. <button class="save-btn" @click="savePoster">保存到相册</button>
  199. <button class="share-btn" @click="sharePoster">分享给好友</button>
  200. </view>
  201. </view>
  202. </view>
  203. </view>
  204. </template>
  205. <script setup name="">
  206. import CusHeader from '@/components/CusHeader/index.vue'
  207. import { onLoad } from '@dcloudio/uni-app';
  208. import { ref, reactive, onMounted, getCurrentInstance } from 'vue'
  209. import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  210. const { proxy } = getCurrentInstance()
  211. const id = ref('')
  212. const activityInfo = ref(null)
  213. const statusCfg = ref({
  214. 0:'未开始',
  215. 1:'报名中',
  216. 4:'报名中',
  217. 2:'进行中',
  218. 3:'已结束'
  219. })
  220. const activityLimitCfg = ref({
  221. 1:'爱心值',
  222. 2:'专享券',
  223. 3:'免费'
  224. })
  225. const imgList = ref([])
  226. const detail = ref('')
  227. const avatars = ref([])
  228. const fail = ref(false)
  229. const share = ref(false)
  230. const showPoster = ref(false)
  231. const posterUrl = ref('')
  232. const canvasWidth = ref(375)
  233. const canvasHeight = ref(667)
  234. const activityData = reactive({
  235. title: '《环保知识知多少》让孩子成为大自然的守护者!',
  236. time: '06.01-12:00 ~ 06.02-12:00',
  237. address: '深圳市南山区南山街道丰潭路',
  238. organizer: '锦鲤俱乐部'
  239. })
  240. const imageUrl = ref('https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/fbb4ac12-163e-48bd-9066-27b068078107.png')
  241. const handleReviewMembers = () => {
  242. uni.navigateTo({
  243. url:'/pagesHome/recruitsNumber?activityId='+activityInfo.value?.id+'&recruitmentMax='+activityInfo.value?.recruitmentMax+'&recruitmentMin='+activityInfo.value?.recruitmentMin
  244. })
  245. }
  246. //立即报名
  247. const handleApply = async () => {
  248. let { loveValue, ticketValue } = await getUserLoveValue();
  249. // url:'/pagesHome/signSuccess'
  250. // url:'/pagesHome/fillNonprofitArchives'
  251. let url = `/pagesHome/activityApply?activity=${encodeURIComponent(JSON.stringify(activityInfo.value))}`;
  252. if((activityInfo.value?.activityLimit==1&&loveValue<activityInfo?.value.valueLimit)
  253. ||(activityInfo.value?.activityLimit==2&&ticketValue<activityInfo?.value.valueLimit)){
  254. fail.value = true;
  255. return
  256. }
  257. uni.navigateTo({ url })
  258. }
  259. //取消报名
  260. const handleCancel = () => {
  261. uni.showModal({
  262. title:'温馨提示',
  263. content:'确认取消本地报名吗?取消后可再次报名本活动。',
  264. success: (res) => {
  265. if(res.confirm){
  266. proxy.$api.get(`/core/activity/signup/cancelSignup/${activityInfo.value?.signupId||''}`).then(({data:res})=>{
  267. if(res.code!==0) return proxy.$showToast(res.msg)
  268. getActivityDetail(id.value)
  269. proxy.$showToast('取消报名成功')
  270. })
  271. }
  272. }
  273. })
  274. }
  275. //我要签到
  276. const handleSignup = () => {
  277. }
  278. //填写公益档案
  279. const handleFill = () => {
  280. }
  281. const getUserLoveValue = () => {
  282. return new Promise(resolve=>{
  283. proxy.$api.get('/wx/'+JSON.parse(uni.getStorageSync('userInfo')).id).then(({data:res})=>{
  284. if(res.code!==0) return proxy.$showToast(res.msg)
  285. resolve({loveValue:res.data?.loveValue||0,ticketValue:0})
  286. })
  287. })
  288. }
  289. onShareAppMessage((res) => {
  290. const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  291. return {
  292. title: activityInfo.value?.activityName || '发现一个好物,分享给你!',
  293. path: `/pagesHome/activityDetail?shareADId=${activityInfo.value?.id}&shareUserId=${sharerId}`,
  294. imageUrl: activityInfo.value?.coverFile
  295. };
  296. })
  297. onShareTimeline((res) => {
  298. const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  299. return {
  300. title: activityInfo.value?.activityName || '发现一个好物,分享给你!',
  301. query: `shareADId=${activityInfo.value?.id}&shareUserId=${sharerId}`,
  302. imageUrl: activityInfo.value?.coverFile
  303. };
  304. })
  305. const showShareOptions = () => {
  306. share.value = true;
  307. uni.showShareMenu({
  308. withShareTicket: true,
  309. menus: ['shareAppMessage', 'shareTimeline'] // 显示分享给朋友和分享到朋友圈
  310. }).then(res => {
  311. console.log('显示分享菜单成功', res);
  312. }).catch(err => {
  313. console.error('显示分享菜单失败', err);
  314. });
  315. }
  316. // 分享到朋友圈
  317. const shareToTimeline = () => {
  318. uni.showModal({
  319. title:'温馨提示',
  320. content:'分享到朋友圈请点击页面右上方的“···”标志后选择“分享到朋友圈”进行分享'
  321. })
  322. }
  323. // 生成海报
  324. const generatePoster = async () => {
  325. share.value = false
  326. uni.showLoading({
  327. title: '正在生成海报...'
  328. })
  329. try {
  330. await createPoster()
  331. uni.hideLoading()
  332. showPoster.value = true
  333. } catch (error) {
  334. uni.hideLoading()
  335. uni.showToast({
  336. title: '海报生成失败',
  337. icon: 'none'
  338. })
  339. }
  340. }
  341. // 创建海报
  342. const createPoster = () => {
  343. return new Promise((resolve, reject) => {
  344. const ctx = uni.createCanvasContext('posterCanvas')
  345. // 设置画布尺寸
  346. const width = canvasWidth.value
  347. const height = canvasHeight.value
  348. // 绘制背景
  349. const gradient = ctx.createLinearGradient(0, 0, 0, height)
  350. gradient.addColorStop(0, '#87CEEB')
  351. gradient.addColorStop(1, '#98FB98')
  352. ctx.fillStyle = gradient
  353. ctx.fillRect(0, 0, width, height)
  354. // 加载并绘制背景图片(山峰)
  355. const bgImg = 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/5378bfeb-32f5-4325-aaef-5270e4a55a3a.png'
  356. uni.getImageInfo({
  357. src: bgImg,
  358. success: (res) => {
  359. // 绘制背景图
  360. ctx.drawImage(res.path, 0, 0, width, height * 0.6)
  361. // 绘制绿色标签
  362. ctx.fillStyle = '#B7F358'
  363. ctx.fillRect(20, 30, 120, 30)
  364. // 绘制标签文字
  365. ctx.fillStyle = '#000000'
  366. ctx.font = 'bold 14px PingFang-SC'
  367. ctx.fillText('节能低碳小妙招', 30, 50)
  368. // 绘制主标题
  369. ctx.fillStyle = '#FFFFFF'
  370. ctx.font = 'bold 24px PingFang-SC'
  371. ctx.fillText('环保知识', 50, 120)
  372. ctx.fillText('知多少', 50, 150)
  373. // 绘制白色信息区域背景
  374. ctx.fillStyle = '#FFFFFF'
  375. ctx.fillRect(20, height * 0.6 + 20, width - 40, height * 0.35)
  376. // 绘制活动信息
  377. ctx.fillStyle = '#000000'
  378. ctx.font = '16px PingFang-SC'
  379. const startY = height * 0.6 + 50
  380. // 活动标题
  381. ctx.font = 'bold 16px PingFang-SC'
  382. ctx.fillText(activityData.title.substring(0, 20), 30, startY)
  383. if (activityData.title.length > 20) {
  384. ctx.fillText(activityData.title.substring(20), 30, startY + 25)
  385. }
  386. // 时间图标和文字
  387. ctx.font = '14px PingFang-SC'
  388. ctx.fillStyle = '#666666'
  389. ctx.fillText('🕐', 30, startY + 60)
  390. ctx.fillText(activityData.time, 50, startY + 60)
  391. // 地址图标和文字
  392. ctx.fillText('📍', 30, startY + 85)
  393. ctx.fillText(activityData.address, 50, startY + 85)
  394. // 组织方
  395. ctx.fillText('👥', 30, startY + 110)
  396. ctx.fillText(activityData.organizer, 50, startY + 110)
  397. // 绘制小程序码区域
  398. ctx.fillStyle = '#F5F5F5'
  399. ctx.fillRect(width - 120, height - 140, 100, 100)
  400. ctx.fillStyle = '#000000'
  401. ctx.font = '12px PingFang-SC'
  402. ctx.fillText('微信扫一扫', width - 110, height - 25)
  403. // 执行绘制
  404. ctx.draw(false, () => {
  405. // 导出图片
  406. uni.canvasToTempFilePath({
  407. canvasId: 'posterCanvas',
  408. width: width,
  409. height: height,
  410. destWidth: width * 2,
  411. destHeight: height * 2,
  412. success: (res) => {
  413. posterUrl.value = res.tempFilePath
  414. resolve(res.tempFilePath)
  415. },
  416. fail: reject
  417. })
  418. })
  419. },
  420. fail: () => {
  421. // 如果图片加载失败,绘制纯色背景
  422. drawSimplePoster(ctx, width, height, resolve, reject)
  423. }
  424. })
  425. })
  426. }
  427. // 绘制简单海报(备用方案)
  428. const drawSimplePoster = (ctx, width, height, resolve, reject) => {
  429. // 绘制渐变背景
  430. const gradient = ctx.createLinearGradient(0, 0, 0, height)
  431. gradient.addColorStop(0, '#87CEEB')
  432. gradient.addColorStop(1, '#98FB98')
  433. ctx.fillStyle = gradient
  434. ctx.fillRect(0, 0, width, height)
  435. // 绘制白色内容区域
  436. ctx.fillStyle = '#FFFFFF'
  437. ctx.fillRect(20, 100, width - 40, height - 200)
  438. // 绘制标题
  439. ctx.fillStyle = '#000000'
  440. ctx.font = 'bold 20px PingFang-SC'
  441. ctx.fillText('公益活动邀请', width / 2 - 70, 150)
  442. // 绘制活动信息
  443. ctx.font = '16px PingFang-SC'
  444. ctx.fillText(activityData.title.substring(0, 15), 30, 200)
  445. if (activityData.title.length > 15) {
  446. ctx.fillText(activityData.title.substring(15), 30, 225)
  447. }
  448. ctx.font = '14px PingFang-SC'
  449. ctx.fillStyle = '#666666'
  450. ctx.fillText('活动时间:' + activityData.time, 30, 270)
  451. ctx.fillText('活动地点:' + activityData.address.substring(0, 12), 30, 295)
  452. ctx.draw(false, () => {
  453. uni.canvasToTempFilePath({
  454. canvasId: 'posterCanvas',
  455. width: width,
  456. height: height,
  457. destWidth: width * 2,
  458. destHeight: height * 2,
  459. success: (res) => {
  460. posterUrl.value = res.tempFilePath
  461. resolve(res.tempFilePath)
  462. },
  463. fail: reject
  464. })
  465. })
  466. }
  467. // 保存海报到相册
  468. const savePoster = () => {
  469. uni.saveImageToPhotosAlbum({
  470. filePath: posterUrl.value,
  471. success: () => {
  472. uni.showToast({
  473. title: '保存成功',
  474. icon: 'success'
  475. })
  476. showPoster.value = false
  477. },
  478. fail: (err) => {
  479. if (err.errMsg.includes('auth deny')) {
  480. uni.showModal({
  481. title: '提示',
  482. content: '需要您授权保存图片到相册',
  483. confirmText: '去设置',
  484. success: (res) => {
  485. if (res.confirm) {
  486. uni.openSetting()
  487. }
  488. }
  489. })
  490. } else {
  491. uni.showToast({
  492. title: '保存失败',
  493. icon: 'none'
  494. })
  495. }
  496. }
  497. })
  498. }
  499. // 分享海报给好友
  500. const sharePoster = () => {
  501. // 这里可以实现分享海报的逻辑
  502. uni.showToast({
  503. title: '请保存后手动分享',
  504. icon: 'none'
  505. })
  506. }
  507. const handleLongPress = (url) => {
  508. uni.previewImage({
  509. urls: [url],
  510. current: url,
  511. // 在小程序中,可以设置 longPressActions 来自定义长按菜单
  512. // 但注意:这个自定义菜单会覆盖掉“识别二维码”等原生功能
  513. // 所以我们不设置这个参数,以保留微信原生的预览页长按菜单
  514. /*
  515. longPressActions: {
  516. itemList: ['发送给朋友', '保存图片', '收藏'],
  517. success: function(data) {
  518. console.log('选中了第' + (data.tapIndex + 1) + '个按钮, 内容是' + data.item);
  519. },
  520. fail: function(err) {
  521. console.log(err.errMsg);
  522. }
  523. }
  524. */
  525. })
  526. }
  527. const toWebView = () => {
  528. uni.navigateTo({
  529. url:'/pages/webView?src=https://mp.weixin.qq.com/s/-oQlSBucYU_ifgd1j6eL3A?scene=1&click_id=2'
  530. })
  531. }
  532. const getActivityDetail = (id) => {
  533. proxy.$api.get(`/core/activity/${id}`).then(({data:res})=>{
  534. if(res.code!==0) return proxy.$showToast(res.msg)
  535. activityInfo.value = res.data;
  536. if(activityInfo.value.signupState==0
  537. &&activityInfo.value.activeState===1
  538. &&activityInfo.value.recruitmentNow==(activityInfo.value.recruitmentMax||99999)){
  539. activityInfo.value.activeState = 4;//已报满暂无活动名额
  540. }
  541. imgList.value = activityInfo.value?.imageFiles&&(activityInfo.value?.imageFiles.split(',')||[])
  542. for(let i=0;i<activityInfo.value.recruitmentNow;i++){
  543. avatars.value.push('https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/565ca09a-88e2-4c2c-a89e-98bd51fbea7f.png')
  544. }
  545. })
  546. }
  547. onLoad(options=>{
  548. id.value = options?.id||options?.shareADId||'';
  549. if(id.value) {
  550. getActivityDetail(id.value)
  551. }
  552. })
  553. </script>
  554. <style scoped lang="scss">
  555. .share-btn {
  556. background-color: transparent;
  557. border: none;
  558. padding: 0;
  559. margin: 0;
  560. line-height: 1;
  561. display: flex;
  562. flex-direction: column;
  563. justify-content: center;
  564. align-items: center;
  565. &::after {
  566. border: none;
  567. }
  568. }
  569. .common_page{
  570. padding-bottom: 276rpx;
  571. .lunbo{
  572. width: 100%;
  573. height: 440rpx;
  574. margin-top: 20rpx;
  575. position: relative;
  576. }
  577. .box{
  578. background: linear-gradient(45deg,#FFFFFF 70%,#F2FFE8 100%);
  579. border-radius: 24rpx;
  580. padding: 36rpx 24rpx 30rpx;
  581. margin-top: 20rpx;
  582. position: relative;
  583. &-title{
  584. width: 170rpx;
  585. height: 44rpx;
  586. padding-left: 2rpx;
  587. font-family: PingFang-SC, PingFang-SC;
  588. font-weight: 800;
  589. font-size: 36rpx;
  590. color: #151B29;
  591. line-height: 36rpx;
  592. background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/6ec1f999-fcbb-4a0b-a1a5-d0b5e1374bb1.png');
  593. background-size: 170rpx 31rpx;
  594. background-position: 0 20rpx;
  595. background-repeat: no-repeat;
  596. }
  597. }
  598. .box1{
  599. &-top{
  600. &-status{
  601. padding: 10rpx 20rpx;
  602. background: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/46184afd-e7cd-4ffa-b32f-7390f7a1decc.png') no-repeat;
  603. background-size: 100% 100%;
  604. font-family: PingFang-SC, PingFang-SC;
  605. font-weight: bold;
  606. font-size: 24rpx;
  607. color: #151B29;
  608. line-height: 33rpx;
  609. &.end{
  610. background: linear-gradient( 270deg, #FD8A8A 0%, #FE6161 100%);
  611. border-radius: 16px 4px 16px 4px;
  612. color: #FFFFFF;
  613. }
  614. }
  615. &-title{
  616. font-family: PingFang-SC, PingFang-SC;
  617. font-weight: bold;
  618. font-size: 36rpx;
  619. color: #151B29;
  620. line-height: 54rpx;
  621. margin-left: 10rpx;
  622. }
  623. }
  624. &-line{
  625. width: 100%;
  626. height: 1rpx;
  627. background: #E7E7E7;
  628. }
  629. &-place{
  630. &-left{
  631. width: calc(100% - 228rpx);
  632. text{
  633. font-family: PingFangSC, PingFang SC;
  634. font-weight: 400;
  635. font-size: 24rpx;
  636. color: #989998;
  637. line-height: 26rpx;
  638. }
  639. .addr{
  640. width: 100%;
  641. font-family: PingFang-SC, PingFang-SC;
  642. font-weight: bold;
  643. font-size: 26rpx;
  644. color: #151B29;
  645. line-height: 26rpx;
  646. margin-top: 24rpx;
  647. }
  648. }
  649. &-right{
  650. width: 188rpx;
  651. height: 115rpx;
  652. image{
  653. width: 100%;
  654. height: 100%;
  655. }
  656. }
  657. }
  658. &-member{
  659. margin-top: 37rpx;
  660. &-left{
  661. &>text{
  662. font-family: PingFangSC, PingFang SC;
  663. font-weight: 400;
  664. font-size: 24rpx;
  665. color: #989998;
  666. line-height: 26rpx;
  667. }
  668. .num{
  669. font-family: PingFang-SC, PingFang-SC;
  670. font-weight: bold;
  671. font-size: 26rpx;
  672. color: #676775;
  673. line-height: 48rpx;
  674. margin-top: 25rpx;
  675. text{
  676. font-size: 36rpx;
  677. color: #151B29;
  678. }
  679. }
  680. }
  681. &-right{
  682. .review{
  683. text{
  684. font-family: PingFangSC, PingFang SC;
  685. font-weight: 400;
  686. font-size: 24rpx;
  687. color: #989998;
  688. line-height: 26rpx;
  689. }
  690. image{
  691. width: 28rpx;
  692. height: 28rpx;
  693. margin-left: 8rpx;
  694. }
  695. }
  696. .avatars{
  697. margin-top: 27rpx;
  698. display: flex;
  699. justify-content: flex-end;
  700. }
  701. }
  702. }
  703. &-time{
  704. margin-top: 30rpx;
  705. text{
  706. font-family: PingFangSC, PingFang SC;
  707. font-weight: 400;
  708. font-size: 24rpx;
  709. color: #989998;
  710. line-height: 26rpx;
  711. }
  712. .text{
  713. font-family: PingFang-SC, PingFang-SC;
  714. font-weight: bold;
  715. font-size: 26rpx;
  716. color: #151B29;
  717. line-height: 26rpx;
  718. margin-top: 24rpx;
  719. }
  720. }
  721. &-need{
  722. margin-top: 30rpx;
  723. &>text{
  724. font-family: PingFangSC, PingFang SC;
  725. font-weight: 400;
  726. font-size: 24rpx;
  727. color: #989998;
  728. line-height: 26rpx;
  729. }
  730. .text{
  731. margin-top: 30rpx;
  732. font-family: PingFangSC, PingFang SC;
  733. font-weight: 400;
  734. font-size: 24rpx;
  735. color: #676775;
  736. line-height: 26rpx;
  737. text{
  738. font-weight: bold;
  739. font-size: 36rpx;
  740. color: #151B29;
  741. }
  742. }
  743. .tip{
  744. font-family: PingFangSC, PingFang SC;
  745. font-weight: 400;
  746. font-size: 24rpx;
  747. color: #C9A771;
  748. line-height: 26rpx;
  749. margin-top: 20rpx;
  750. }
  751. }
  752. &-info{
  753. margin-top: 30rpx;
  754. &-pre{
  755. width: 50%;
  756. &.line{
  757. border-left: 1rpx solid #E7E7E7;
  758. padding-left: 24rpx;
  759. box-sizing: border-box;
  760. }
  761. &>text{
  762. font-family: PingFangSC, PingFang SC;
  763. font-weight: 400;
  764. font-size: 24rpx;
  765. color: #989998;
  766. line-height: 26rpx;
  767. }
  768. .text{
  769. font-family: PingFang-SC, PingFang-SC;
  770. font-weight: bold;
  771. font-size: 26rpx;
  772. color: #151B29;
  773. line-height: 26rpx;
  774. margin-top: 24rpx;
  775. }
  776. .hour{
  777. margin-top: 24rpx;
  778. font-family: PingFangSC, PingFang SC;
  779. font-weight: 400;
  780. font-size: 24rpx;
  781. color: #676775;
  782. line-height: 26rpx;
  783. text{
  784. font-weight: bold;
  785. font-size: 36rpx;
  786. color: #151B29;
  787. }
  788. }
  789. }
  790. }
  791. }
  792. .box2{
  793. &-detail{
  794. margin-top: 40rpx;
  795. }
  796. }
  797. .bottom{
  798. width: 100%;
  799. height: 256rpx;
  800. background: #FFFFFF;
  801. box-shadow: 0rpx -2rpx 8rpx 0rpx rgba(178,178,178,0.1);
  802. position: fixed;
  803. left: 0;
  804. right: 0;
  805. bottom: 0;
  806. padding: 30rpx 24rpx 0;
  807. box-sizing: border-box;
  808. .time{
  809. padding: 19rpx 24rpx 12rpx;
  810. background: #F8F8F9;
  811. border-radius: 32rpx;
  812. font-family: PingFangSC, PingFang SC;
  813. font-weight: 400;
  814. font-size: 24rpx;
  815. color: #4B545C;
  816. line-height: 33rpx;
  817. }
  818. .btns{
  819. margin-top: 24rpx;
  820. .left{
  821. margin-left: 30rpx;
  822. text{
  823. font-family: PingFangSC, PingFang SC;
  824. font-weight: 400;
  825. font-size: 26rpx;
  826. color: #151B29;
  827. line-height: 26rpx;
  828. margin-top: 17rpx;
  829. }
  830. }
  831. .right{
  832. width: 540rpx;
  833. height: 90rpx;
  834. background: #B7F358;
  835. border-radius: 45rpx;
  836. font-family: PingFang-SC, PingFang-SC;
  837. font-weight: bold;
  838. font-size: 32rpx;
  839. color: #151B29;
  840. line-height: 90rpx;
  841. text-align: center;
  842. letter-spacing: 2rpx;
  843. &.end{
  844. background: #F7F7F7;
  845. }
  846. }
  847. }
  848. }
  849. .fail{
  850. position: fixed;
  851. left: 0;
  852. right: 0;
  853. top: 0;
  854. bottom: 0;
  855. background: rgba(0,0,0,0.4);
  856. display: flex;
  857. flex-direction: column;
  858. justify-content: flex-end;
  859. .fbox{
  860. background: #FFFFFF;
  861. background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/e5ca0b95-ae33-4a93-8955-fe1d5e05ed2d.png');
  862. background-repeat: no-repeat;
  863. background-position: top left;
  864. background-size: 100% 399rpx;
  865. border-radius: 24rpx 24rpx 0 0;
  866. position: relative;
  867. padding: 40rpx 30rpx 123rpx;
  868. .clock{
  869. width: 219rpx;
  870. height: 143rpx;
  871. position: absolute;
  872. left: 51rpx;
  873. top: -37rpx;
  874. }
  875. .close{
  876. width: 40rpx;
  877. height: 40rpx;
  878. position: absolute;
  879. top: 40rpx;
  880. right: 36rpx;
  881. }
  882. .alert{
  883. width: 212rpx;
  884. }
  885. .texts{
  886. width: 100%;
  887. margin-top: 69rpx;
  888. background: #FFFFFF;
  889. border-radius: 24rpx;
  890. border: 1rpx dotted #979797;
  891. padding: 36rpx 0;
  892. .text{
  893. font-family: PingFang-SC, PingFang-SC;
  894. font-weight: bold;
  895. font-size: 36rpx;
  896. color: #252525;
  897. line-height: 36rpx;
  898. }
  899. .tip{
  900. font-family: PingFangSC, PingFang SC;
  901. font-weight: 400;
  902. font-size: 24rpx;
  903. color: #676775;
  904. line-height: 26rpx;
  905. margin-top: 24rpx;
  906. }
  907. }
  908. .down{
  909. width: 514rpx;
  910. height: 34rpx;
  911. margin-top: 20rpx;
  912. }
  913. .user{
  914. width: 100%;
  915. // margin-top: 30rpx;
  916. // padding-left: 50rpx;
  917. margin-top: 50rpx;
  918. box-sizing: border-box;
  919. font-family: PingFang-SC, PingFang-SC;
  920. font-weight: bold;
  921. font-size: 32rpx;
  922. color: #252525;
  923. line-height: 32rpx;
  924. &-left{
  925. image{
  926. width: 98rpx;
  927. height: 98rpx;
  928. }
  929. }
  930. &-right{
  931. margin-left: 20rpx;
  932. .name{
  933. font-family: PingFang-SC, PingFang-SC;
  934. font-weight: bold;
  935. font-size: 32rpx;
  936. color: #252525;
  937. line-height: 32rpx;
  938. }
  939. .memo{
  940. font-family: PingFang-SC, PingFang-SC;
  941. font-weight: bold;
  942. font-size: 24rpx;
  943. color: #05A9FE;
  944. line-height: 24rpx;
  945. margin-top: 24rpx;
  946. }
  947. }
  948. }
  949. .finfo{
  950. width: 100%;
  951. margin-top: 36rpx;
  952. &-code{
  953. width: 310rpx;
  954. height: 310rpx;
  955. background: #FFFFFF;
  956. border: 3rpx solid #C5E3FE;
  957. image{
  958. width: 244rpx;
  959. height: 244rpx;
  960. }
  961. }
  962. &-title{
  963. margin-top: 24rpx;
  964. font-size: 28rpx;
  965. color: #252525;
  966. line-height: 40rpx;
  967. }
  968. &-tip{
  969. margin-top: 10rpx;
  970. font-size: 24rpx;
  971. color: #656775;
  972. line-height: 40rpx;
  973. }
  974. &-btn{
  975. width: calc(100% - 20rpx);
  976. height: 90rpx;
  977. background: #B7F358;
  978. border-radius: 45rpx;
  979. font-family: PingFang-SC, PingFang-SC;
  980. font-weight: bold;
  981. font-size: 32rpx;
  982. color: #151B29;
  983. line-height: 90rpx;
  984. text-align: center;
  985. margin-top: 48rpx;
  986. }
  987. &-zblj{
  988. font-family: PingFangSC, PingFang SC;
  989. font-weight: 400;
  990. font-size: 28rpx;
  991. color: #989998;
  992. line-height: 40rpx;
  993. margin-top: 48rpx;
  994. padding-bottom: 5rpx;
  995. border-bottom: 1rpx solid #989998;
  996. }
  997. }
  998. }
  999. }
  1000. .share{
  1001. position: fixed;
  1002. left: 0;
  1003. right: 0;
  1004. top: 0;
  1005. bottom: 0;
  1006. background: rgba(0,0,0,0.4);
  1007. display: flex;
  1008. flex-direction: column;
  1009. justify-content: flex-end;
  1010. .sbox{
  1011. position: relative;
  1012. background: #FFFFFF;
  1013. border-radius: 24rpx 24rpx 0rpx 0rpx;
  1014. padding: 50rpx 30rpx 148rpx;
  1015. &-title{
  1016. font-family: PingFang-SC, PingFang-SC;
  1017. font-weight: bold;
  1018. font-size: 36rpx;
  1019. color: #151B29;
  1020. line-height: 36rpx;
  1021. text-align: center;
  1022. }
  1023. .close{
  1024. width: 27rpx;
  1025. height: 27rpx;
  1026. position: absolute;
  1027. top: 50rpx;
  1028. right: 40rpx;
  1029. }
  1030. &-items{
  1031. margin-top: 88rpx;
  1032. &-pre{
  1033. width: calc(100% / 3);
  1034. image{
  1035. width: 94rpx;
  1036. height: 94rpx;
  1037. }
  1038. text{
  1039. font-family: PingFangSC, PingFang SC;
  1040. font-weight: 400;
  1041. font-size: 26rpx;
  1042. color: #252525;
  1043. line-height: 26rpx;
  1044. text-align: center;
  1045. margin-top: 24rpx;
  1046. }
  1047. }
  1048. }
  1049. }
  1050. }
  1051. .poster-preview {
  1052. position: fixed;
  1053. left: 0;
  1054. right: 0;
  1055. top: 0;
  1056. bottom: 0;
  1057. background: rgba(0,0,0,0.8);
  1058. display: flex;
  1059. flex-direction: column;
  1060. justify-content: center;
  1061. align-items: center;
  1062. z-index: 9999;
  1063. .poster-box {
  1064. width: 80%;
  1065. max-width: 600rpx;
  1066. background: #FFFFFF;
  1067. border-radius: 24rpx;
  1068. overflow: hidden;
  1069. .poster-header {
  1070. display: flex;
  1071. justify-content: space-between;
  1072. align-items: center;
  1073. padding: 30rpx;
  1074. border-bottom: 1rpx solid #E7E7E7;
  1075. text {
  1076. font-family: PingFang-SC, PingFang-SC;
  1077. font-weight: bold;
  1078. font-size: 32rpx;
  1079. color: #151B29;
  1080. }
  1081. .close {
  1082. width: 40rpx;
  1083. height: 40rpx;
  1084. }
  1085. }
  1086. .poster-content {
  1087. padding: 30rpx;
  1088. display: flex;
  1089. justify-content: center;
  1090. .poster-img {
  1091. width: 100%;
  1092. border-radius: 12rpx;
  1093. }
  1094. }
  1095. .poster-actions {
  1096. display: flex;
  1097. padding: 0 30rpx 30rpx;
  1098. gap: 20rpx;
  1099. button {
  1100. flex: 1;
  1101. height: 80rpx;
  1102. border-radius: 40rpx;
  1103. border: none;
  1104. font-size: 28rpx;
  1105. font-weight: bold;
  1106. }
  1107. .save-btn {
  1108. background: #F5F5F5;
  1109. color: #151B29;
  1110. }
  1111. .share-btn {
  1112. background: #B7F358;
  1113. color: #151B29;
  1114. }
  1115. }
  1116. }
  1117. }
  1118. }
  1119. </style>