activityDetail.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  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, couponIds } = await getUserLoveTicket();
  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&&couponIds?.length<activityInfo?.value.valueLimit)){
  254. fail.value = true;
  255. return
  256. }
  257. uni.navigateTo({ url })
  258. }
  259. //取消报名
  260. const handleCancel = () => {
  261. uni.reLaunch({
  262. url:'/pages/nonprofit?type=1'
  263. })
  264. // uni.showModal({
  265. // title:'温馨提示',
  266. // content:'确认取消本次报名吗?取消后可再次报名本活动。',
  267. // success: (res) => {
  268. // if(res.confirm){
  269. // proxy.$api.get(`/core/activity/signup/cancelSignup/${activityInfo.value?.signupId||''}`).then(({data:res})=>{
  270. // if(res.code!==0) return proxy.$showToast(res.msg)
  271. // getActivityDetail(id.value)
  272. // proxy.$showToast('取消报名成功')
  273. // })
  274. // }
  275. // }
  276. // })
  277. }
  278. //我要签到
  279. const handleSignup = () => {
  280. uni.reLaunch({
  281. url:'/pages/nonprofit?type=2'
  282. })
  283. // try{
  284. // uni.scanCode({
  285. // success: (res) => {
  286. // if(res.errMsg=='scanCode:ok'){
  287. // let { id } = JSON.parse(res.result)
  288. // console.log(id);
  289. // proxy.$api.get('/xx',this.params).then(({data:res})=>{
  290. // if(res.code!==0) return proxy.$showToast(res.msg)
  291. // })
  292. // }else proxy.$showToast(res.errMsg)
  293. // },
  294. // fail: (err) => {
  295. // proxy.$showToast('扫描异常,请稍后再试')
  296. // }
  297. // })
  298. // }catch(e){
  299. // proxy.$showToast('签到异常,请稍后再试')
  300. // }
  301. }
  302. //填写公益档案
  303. const handleFill = () => {
  304. uni.reLaunch({
  305. url:'/pages/nonprofit?type=3'
  306. })
  307. }
  308. const getUserLoveTicket = () => {
  309. return new Promise(resolve=>{
  310. let userId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  311. proxy.$api.get(`/core/activity/signup/userAsset/${userId}/${activityInfo.value?.id}`).then(({data:res})=>{
  312. if(res.code!==0) return proxy.$showToast(res.msg)
  313. resolve({loveValue:res.data?.loveValue||0,couponIds:res.data?.couponIds||0})
  314. })
  315. })
  316. }
  317. onShareAppMessage((res) => {
  318. const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  319. return {
  320. title: activityInfo.value?.activityName || '发现一个好物,分享给你!',
  321. path: `/pagesHome/activityDetail?shareADId=${activityInfo.value?.id}&shareUserId=${sharerId}`,
  322. imageUrl: activityInfo.value?.coverFile
  323. };
  324. })
  325. onShareTimeline((res) => {
  326. const sharerId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  327. return {
  328. title: activityInfo.value?.activityName || '发现一个好物,分享给你!',
  329. query: `shareADId=${activityInfo.value?.id}&shareUserId=${sharerId}`,
  330. imageUrl: activityInfo.value?.coverFile
  331. };
  332. })
  333. const showShareOptions = () => {
  334. share.value = true;
  335. uni.showShareMenu({
  336. withShareTicket: true,
  337. menus: ['shareAppMessage', 'shareTimeline'] // 显示分享给朋友和分享到朋友圈
  338. }).then(res => {
  339. console.log('显示分享菜单成功', res);
  340. }).catch(err => {
  341. console.error('显示分享菜单失败', err);
  342. });
  343. }
  344. // 分享到朋友圈
  345. const shareToTimeline = () => {
  346. uni.showModal({
  347. title:'温馨提示',
  348. content:'分享到朋友圈请点击页面右上方的“···”标志后选择“分享到朋友圈”进行分享'
  349. })
  350. }
  351. // 生成海报
  352. const generatePoster = async () => {
  353. share.value = false
  354. uni.showLoading({
  355. title: '正在生成海报...'
  356. })
  357. try {
  358. await createPoster()
  359. uni.hideLoading()
  360. showPoster.value = true
  361. } catch (error) {
  362. uni.hideLoading()
  363. uni.showToast({
  364. title: '海报生成失败',
  365. icon: 'none'
  366. })
  367. }
  368. }
  369. // 创建海报
  370. const createPoster = () => {
  371. return new Promise((resolve, reject) => {
  372. const ctx = uni.createCanvasContext('posterCanvas')
  373. // 设置画布尺寸
  374. const width = canvasWidth.value
  375. const height = canvasHeight.value
  376. // 绘制背景
  377. const gradient = ctx.createLinearGradient(0, 0, 0, height)
  378. gradient.addColorStop(0, '#87CEEB')
  379. gradient.addColorStop(1, '#98FB98')
  380. ctx.fillStyle = gradient
  381. ctx.fillRect(0, 0, width, height)
  382. // 加载并绘制背景图片(山峰)
  383. const bgImg = 'https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/5378bfeb-32f5-4325-aaef-5270e4a55a3a.png'
  384. uni.getImageInfo({
  385. src: bgImg,
  386. success: (res) => {
  387. // 绘制背景图
  388. ctx.drawImage(res.path, 0, 0, width, height * 0.6)
  389. // 绘制绿色标签
  390. ctx.fillStyle = '#B7F358'
  391. ctx.fillRect(20, 30, 120, 30)
  392. // 绘制标签文字
  393. ctx.fillStyle = '#000000'
  394. ctx.font = 'bold 14px PingFang-SC'
  395. ctx.fillText('节能低碳小妙招', 30, 50)
  396. // 绘制主标题
  397. ctx.fillStyle = '#FFFFFF'
  398. ctx.font = 'bold 24px PingFang-SC'
  399. ctx.fillText('环保知识', 50, 120)
  400. ctx.fillText('知多少', 50, 150)
  401. // 绘制白色信息区域背景
  402. ctx.fillStyle = '#FFFFFF'
  403. ctx.fillRect(20, height * 0.6 + 20, width - 40, height * 0.35)
  404. // 绘制活动信息
  405. ctx.fillStyle = '#000000'
  406. ctx.font = '16px PingFang-SC'
  407. const startY = height * 0.6 + 50
  408. // 活动标题
  409. ctx.font = 'bold 16px PingFang-SC'
  410. ctx.fillText(activityData.title.substring(0, 20), 30, startY)
  411. if (activityData.title.length > 20) {
  412. ctx.fillText(activityData.title.substring(20), 30, startY + 25)
  413. }
  414. // 时间图标和文字
  415. ctx.font = '14px PingFang-SC'
  416. ctx.fillStyle = '#666666'
  417. ctx.fillText('🕐', 30, startY + 60)
  418. ctx.fillText(activityData.time, 50, startY + 60)
  419. // 地址图标和文字
  420. ctx.fillText('📍', 30, startY + 85)
  421. ctx.fillText(activityData.address, 50, startY + 85)
  422. // 组织方
  423. ctx.fillText('👥', 30, startY + 110)
  424. ctx.fillText(activityData.organizer, 50, startY + 110)
  425. // 绘制小程序码区域
  426. ctx.fillStyle = '#F5F5F5'
  427. ctx.fillRect(width - 120, height - 140, 100, 100)
  428. ctx.fillStyle = '#000000'
  429. ctx.font = '12px PingFang-SC'
  430. ctx.fillText('微信扫一扫', width - 110, height - 25)
  431. // 执行绘制
  432. ctx.draw(false, () => {
  433. // 导出图片
  434. uni.canvasToTempFilePath({
  435. canvasId: 'posterCanvas',
  436. width: width,
  437. height: height,
  438. destWidth: width * 2,
  439. destHeight: height * 2,
  440. success: (res) => {
  441. posterUrl.value = res.tempFilePath
  442. resolve(res.tempFilePath)
  443. },
  444. fail: reject
  445. })
  446. })
  447. },
  448. fail: () => {
  449. // 如果图片加载失败,绘制纯色背景
  450. drawSimplePoster(ctx, width, height, resolve, reject)
  451. }
  452. })
  453. })
  454. }
  455. // 绘制简单海报(备用方案)
  456. const drawSimplePoster = (ctx, width, height, resolve, reject) => {
  457. // 绘制渐变背景
  458. const gradient = ctx.createLinearGradient(0, 0, 0, height)
  459. gradient.addColorStop(0, '#87CEEB')
  460. gradient.addColorStop(1, '#98FB98')
  461. ctx.fillStyle = gradient
  462. ctx.fillRect(0, 0, width, height)
  463. // 绘制白色内容区域
  464. ctx.fillStyle = '#FFFFFF'
  465. ctx.fillRect(20, 100, width - 40, height - 200)
  466. // 绘制标题
  467. ctx.fillStyle = '#000000'
  468. ctx.font = 'bold 20px PingFang-SC'
  469. ctx.fillText('公益活动邀请', width / 2 - 70, 150)
  470. // 绘制活动信息
  471. ctx.font = '16px PingFang-SC'
  472. ctx.fillText(activityData.title.substring(0, 15), 30, 200)
  473. if (activityData.title.length > 15) {
  474. ctx.fillText(activityData.title.substring(15), 30, 225)
  475. }
  476. ctx.font = '14px PingFang-SC'
  477. ctx.fillStyle = '#666666'
  478. ctx.fillText('活动时间:' + activityData.time, 30, 270)
  479. ctx.fillText('活动地点:' + activityData.address.substring(0, 12), 30, 295)
  480. ctx.draw(false, () => {
  481. uni.canvasToTempFilePath({
  482. canvasId: 'posterCanvas',
  483. width: width,
  484. height: height,
  485. destWidth: width * 2,
  486. destHeight: height * 2,
  487. success: (res) => {
  488. posterUrl.value = res.tempFilePath
  489. resolve(res.tempFilePath)
  490. },
  491. fail: reject
  492. })
  493. })
  494. }
  495. // 保存海报到相册
  496. const savePoster = () => {
  497. uni.saveImageToPhotosAlbum({
  498. filePath: posterUrl.value,
  499. success: () => {
  500. uni.showToast({
  501. title: '保存成功',
  502. icon: 'success'
  503. })
  504. showPoster.value = false
  505. },
  506. fail: (err) => {
  507. if (err.errMsg.includes('auth deny')) {
  508. uni.showModal({
  509. title: '提示',
  510. content: '需要您授权保存图片到相册',
  511. confirmText: '去设置',
  512. success: (res) => {
  513. if (res.confirm) {
  514. uni.openSetting()
  515. }
  516. }
  517. })
  518. } else {
  519. uni.showToast({
  520. title: '保存失败',
  521. icon: 'none'
  522. })
  523. }
  524. }
  525. })
  526. }
  527. // 分享海报给好友
  528. const sharePoster = () => {
  529. // 这里可以实现分享海报的逻辑
  530. uni.showToast({
  531. title: '请保存后手动分享',
  532. icon: 'none'
  533. })
  534. }
  535. const handleLongPress = (url) => {
  536. uni.previewImage({
  537. urls: [url],
  538. current: url,
  539. // 在小程序中,可以设置 longPressActions 来自定义长按菜单
  540. // 但注意:这个自定义菜单会覆盖掉“识别二维码”等原生功能
  541. // 所以我们不设置这个参数,以保留微信原生的预览页长按菜单
  542. /*
  543. longPressActions: {
  544. itemList: ['发送给朋友', '保存图片', '收藏'],
  545. success: function(data) {
  546. console.log('选中了第' + (data.tapIndex + 1) + '个按钮, 内容是' + data.item);
  547. },
  548. fail: function(err) {
  549. console.log(err.errMsg);
  550. }
  551. }
  552. */
  553. })
  554. }
  555. const toWebView = () => {
  556. uni.navigateTo({
  557. url:'/pages/webView?src=https://mp.weixin.qq.com/s/-oQlSBucYU_ifgd1j6eL3A?scene=1&click_id=2'
  558. })
  559. }
  560. const getActivityDetail = (id) => {
  561. proxy.$api.get(`/core/activity/${id}`).then(({data:res})=>{
  562. if(res.code!==0) return proxy.$showToast(res.msg)
  563. activityInfo.value = res.data;
  564. if(activityInfo.value.signupState==0
  565. &&activityInfo.value.activeState===1
  566. &&activityInfo.value.recruitmentNow==(activityInfo.value.recruitmentMax||99999)){
  567. activityInfo.value.activeState = 4;//已报满暂无活动名额
  568. }
  569. imgList.value = activityInfo.value?.imageFiles&&(activityInfo.value?.imageFiles.split(',')||[])
  570. for(let i=0;i<activityInfo.value.recruitmentNow;i++){
  571. avatars.value.push('https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/565ca09a-88e2-4c2c-a89e-98bd51fbea7f.png')
  572. }
  573. })
  574. }
  575. onLoad(options=>{
  576. id.value = options?.id||options?.shareADId||'';
  577. if(id.value) {
  578. getActivityDetail(id.value)
  579. }
  580. })
  581. </script>
  582. <style scoped lang="scss">
  583. .share-btn {
  584. background-color: transparent;
  585. border: none;
  586. padding: 0;
  587. margin: 0;
  588. line-height: 1;
  589. display: flex;
  590. flex-direction: column;
  591. justify-content: center;
  592. align-items: center;
  593. &::after {
  594. border: none;
  595. }
  596. }
  597. .common_page{
  598. padding-bottom: 276rpx;
  599. .lunbo{
  600. width: 100%;
  601. height: 440rpx;
  602. margin-top: 20rpx;
  603. position: relative;
  604. }
  605. .box{
  606. background: linear-gradient(45deg,#FFFFFF 70%,#F2FFE8 100%);
  607. border-radius: 24rpx;
  608. padding: 36rpx 24rpx 30rpx;
  609. margin-top: 20rpx;
  610. position: relative;
  611. &-title{
  612. width: 170rpx;
  613. height: 44rpx;
  614. padding-left: 2rpx;
  615. font-family: PingFang-SC, PingFang-SC;
  616. font-weight: 800;
  617. font-size: 36rpx;
  618. color: #151B29;
  619. line-height: 36rpx;
  620. background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/6ec1f999-fcbb-4a0b-a1a5-d0b5e1374bb1.png');
  621. background-size: 170rpx 31rpx;
  622. background-position: 0 20rpx;
  623. background-repeat: no-repeat;
  624. }
  625. }
  626. .box1{
  627. &-top{
  628. &-status{
  629. padding: 10rpx 20rpx;
  630. background: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/46184afd-e7cd-4ffa-b32f-7390f7a1decc.png') no-repeat;
  631. background-size: 100% 100%;
  632. font-family: PingFang-SC, PingFang-SC;
  633. font-weight: bold;
  634. font-size: 24rpx;
  635. color: #151B29;
  636. line-height: 33rpx;
  637. &.end{
  638. background: linear-gradient( 270deg, #FD8A8A 0%, #FE6161 100%);
  639. border-radius: 16px 4px 16px 4px;
  640. color: #FFFFFF;
  641. }
  642. }
  643. &-title{
  644. font-family: PingFang-SC, PingFang-SC;
  645. font-weight: bold;
  646. font-size: 36rpx;
  647. color: #151B29;
  648. line-height: 54rpx;
  649. margin-left: 10rpx;
  650. }
  651. }
  652. &-line{
  653. width: 100%;
  654. height: 1rpx;
  655. background: #E7E7E7;
  656. }
  657. &-place{
  658. &-left{
  659. width: calc(100% - 228rpx);
  660. text{
  661. font-family: PingFangSC, PingFang SC;
  662. font-weight: 400;
  663. font-size: 24rpx;
  664. color: #989998;
  665. line-height: 26rpx;
  666. }
  667. .addr{
  668. width: 100%;
  669. font-family: PingFang-SC, PingFang-SC;
  670. font-weight: bold;
  671. font-size: 26rpx;
  672. color: #151B29;
  673. line-height: 26rpx;
  674. margin-top: 24rpx;
  675. }
  676. }
  677. &-right{
  678. width: 188rpx;
  679. height: 115rpx;
  680. image{
  681. width: 100%;
  682. height: 100%;
  683. }
  684. }
  685. }
  686. &-member{
  687. margin-top: 37rpx;
  688. &-left{
  689. &>text{
  690. font-family: PingFangSC, PingFang SC;
  691. font-weight: 400;
  692. font-size: 24rpx;
  693. color: #989998;
  694. line-height: 26rpx;
  695. }
  696. .num{
  697. font-family: PingFang-SC, PingFang-SC;
  698. font-weight: bold;
  699. font-size: 26rpx;
  700. color: #676775;
  701. line-height: 48rpx;
  702. margin-top: 25rpx;
  703. text{
  704. font-size: 36rpx;
  705. color: #151B29;
  706. }
  707. }
  708. }
  709. &-right{
  710. .review{
  711. text{
  712. font-family: PingFangSC, PingFang SC;
  713. font-weight: 400;
  714. font-size: 24rpx;
  715. color: #989998;
  716. line-height: 26rpx;
  717. }
  718. image{
  719. width: 28rpx;
  720. height: 28rpx;
  721. margin-left: 8rpx;
  722. }
  723. }
  724. .avatars{
  725. margin-top: 27rpx;
  726. display: flex;
  727. justify-content: flex-end;
  728. }
  729. }
  730. }
  731. &-time{
  732. margin-top: 30rpx;
  733. text{
  734. font-family: PingFangSC, PingFang SC;
  735. font-weight: 400;
  736. font-size: 24rpx;
  737. color: #989998;
  738. line-height: 26rpx;
  739. }
  740. .text{
  741. font-family: PingFang-SC, PingFang-SC;
  742. font-weight: bold;
  743. font-size: 26rpx;
  744. color: #151B29;
  745. line-height: 26rpx;
  746. margin-top: 24rpx;
  747. }
  748. }
  749. &-need{
  750. margin-top: 30rpx;
  751. &>text{
  752. font-family: PingFangSC, PingFang SC;
  753. font-weight: 400;
  754. font-size: 24rpx;
  755. color: #989998;
  756. line-height: 26rpx;
  757. }
  758. .text{
  759. margin-top: 30rpx;
  760. font-family: PingFangSC, PingFang SC;
  761. font-weight: 400;
  762. font-size: 24rpx;
  763. color: #676775;
  764. line-height: 26rpx;
  765. text{
  766. font-weight: bold;
  767. font-size: 36rpx;
  768. color: #151B29;
  769. }
  770. }
  771. .tip{
  772. font-family: PingFangSC, PingFang SC;
  773. font-weight: 400;
  774. font-size: 24rpx;
  775. color: #C9A771;
  776. line-height: 26rpx;
  777. margin-top: 20rpx;
  778. }
  779. }
  780. &-info{
  781. margin-top: 30rpx;
  782. &-pre{
  783. width: 50%;
  784. &.line{
  785. border-left: 1rpx solid #E7E7E7;
  786. padding-left: 24rpx;
  787. box-sizing: border-box;
  788. }
  789. &>text{
  790. font-family: PingFangSC, PingFang SC;
  791. font-weight: 400;
  792. font-size: 24rpx;
  793. color: #989998;
  794. line-height: 26rpx;
  795. }
  796. .text{
  797. font-family: PingFang-SC, PingFang-SC;
  798. font-weight: bold;
  799. font-size: 26rpx;
  800. color: #151B29;
  801. line-height: 26rpx;
  802. margin-top: 24rpx;
  803. }
  804. .hour{
  805. margin-top: 24rpx;
  806. font-family: PingFangSC, PingFang SC;
  807. font-weight: 400;
  808. font-size: 24rpx;
  809. color: #676775;
  810. line-height: 26rpx;
  811. text{
  812. font-weight: bold;
  813. font-size: 36rpx;
  814. color: #151B29;
  815. }
  816. }
  817. }
  818. }
  819. }
  820. .box2{
  821. &-detail{
  822. margin-top: 40rpx;
  823. }
  824. }
  825. .bottom{
  826. width: 100%;
  827. height: 256rpx;
  828. background: #FFFFFF;
  829. box-shadow: 0rpx -2rpx 8rpx 0rpx rgba(178,178,178,0.1);
  830. position: fixed;
  831. left: 0;
  832. right: 0;
  833. bottom: 0;
  834. padding: 30rpx 24rpx 0;
  835. box-sizing: border-box;
  836. .time{
  837. padding: 19rpx 24rpx 12rpx;
  838. background: #F8F8F9;
  839. border-radius: 32rpx;
  840. font-family: PingFangSC, PingFang SC;
  841. font-weight: 400;
  842. font-size: 24rpx;
  843. color: #4B545C;
  844. line-height: 33rpx;
  845. }
  846. .btns{
  847. margin-top: 24rpx;
  848. .left{
  849. margin-left: 30rpx;
  850. text{
  851. font-family: PingFangSC, PingFang SC;
  852. font-weight: 400;
  853. font-size: 26rpx;
  854. color: #151B29;
  855. line-height: 26rpx;
  856. margin-top: 17rpx;
  857. }
  858. }
  859. .right{
  860. width: 540rpx;
  861. height: 90rpx;
  862. background: #B7F358;
  863. border-radius: 45rpx;
  864. font-family: PingFang-SC, PingFang-SC;
  865. font-weight: bold;
  866. font-size: 32rpx;
  867. color: #151B29;
  868. line-height: 90rpx;
  869. text-align: center;
  870. letter-spacing: 2rpx;
  871. &.end{
  872. background: #F7F7F7;
  873. }
  874. }
  875. }
  876. }
  877. .fail{
  878. position: fixed;
  879. left: 0;
  880. right: 0;
  881. top: 0;
  882. bottom: 0;
  883. background: rgba(0,0,0,0.4);
  884. display: flex;
  885. flex-direction: column;
  886. justify-content: flex-end;
  887. .fbox{
  888. background: #FFFFFF;
  889. background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/10/e5ca0b95-ae33-4a93-8955-fe1d5e05ed2d.png');
  890. background-repeat: no-repeat;
  891. background-position: top left;
  892. background-size: 100% 399rpx;
  893. border-radius: 24rpx 24rpx 0 0;
  894. position: relative;
  895. padding: 40rpx 30rpx 123rpx;
  896. .clock{
  897. width: 219rpx;
  898. height: 143rpx;
  899. position: absolute;
  900. left: 51rpx;
  901. top: -37rpx;
  902. }
  903. .close{
  904. width: 40rpx;
  905. height: 40rpx;
  906. position: absolute;
  907. top: 40rpx;
  908. right: 36rpx;
  909. }
  910. .alert{
  911. width: 212rpx;
  912. }
  913. .texts{
  914. width: 100%;
  915. margin-top: 69rpx;
  916. background: #FFFFFF;
  917. border-radius: 24rpx;
  918. border: 1rpx dotted #979797;
  919. padding: 36rpx 0;
  920. .text{
  921. font-family: PingFang-SC, PingFang-SC;
  922. font-weight: bold;
  923. font-size: 36rpx;
  924. color: #252525;
  925. line-height: 36rpx;
  926. }
  927. .tip{
  928. font-family: PingFangSC, PingFang SC;
  929. font-weight: 400;
  930. font-size: 24rpx;
  931. color: #676775;
  932. line-height: 26rpx;
  933. margin-top: 24rpx;
  934. }
  935. }
  936. .down{
  937. width: 514rpx;
  938. height: 34rpx;
  939. margin-top: 20rpx;
  940. }
  941. .user{
  942. width: 100%;
  943. // margin-top: 30rpx;
  944. // padding-left: 50rpx;
  945. margin-top: 50rpx;
  946. box-sizing: border-box;
  947. font-family: PingFang-SC, PingFang-SC;
  948. font-weight: bold;
  949. font-size: 32rpx;
  950. color: #252525;
  951. line-height: 32rpx;
  952. &-left{
  953. image{
  954. width: 98rpx;
  955. height: 98rpx;
  956. }
  957. }
  958. &-right{
  959. margin-left: 20rpx;
  960. .name{
  961. font-family: PingFang-SC, PingFang-SC;
  962. font-weight: bold;
  963. font-size: 32rpx;
  964. color: #252525;
  965. line-height: 32rpx;
  966. }
  967. .memo{
  968. font-family: PingFang-SC, PingFang-SC;
  969. font-weight: bold;
  970. font-size: 24rpx;
  971. color: #05A9FE;
  972. line-height: 24rpx;
  973. margin-top: 24rpx;
  974. }
  975. }
  976. }
  977. .finfo{
  978. width: 100%;
  979. margin-top: 36rpx;
  980. &-code{
  981. width: 310rpx;
  982. height: 310rpx;
  983. background: #FFFFFF;
  984. border: 3rpx solid #C5E3FE;
  985. image{
  986. width: 244rpx;
  987. height: 244rpx;
  988. }
  989. }
  990. &-title{
  991. margin-top: 24rpx;
  992. font-size: 28rpx;
  993. color: #252525;
  994. line-height: 40rpx;
  995. }
  996. &-tip{
  997. margin-top: 10rpx;
  998. font-size: 24rpx;
  999. color: #656775;
  1000. line-height: 40rpx;
  1001. }
  1002. &-btn{
  1003. width: calc(100% - 20rpx);
  1004. height: 90rpx;
  1005. background: #B7F358;
  1006. border-radius: 45rpx;
  1007. font-family: PingFang-SC, PingFang-SC;
  1008. font-weight: bold;
  1009. font-size: 32rpx;
  1010. color: #151B29;
  1011. line-height: 90rpx;
  1012. text-align: center;
  1013. margin-top: 48rpx;
  1014. }
  1015. &-zblj{
  1016. font-family: PingFangSC, PingFang SC;
  1017. font-weight: 400;
  1018. font-size: 28rpx;
  1019. color: #989998;
  1020. line-height: 40rpx;
  1021. margin-top: 48rpx;
  1022. padding-bottom: 5rpx;
  1023. border-bottom: 1rpx solid #989998;
  1024. }
  1025. }
  1026. }
  1027. }
  1028. .share{
  1029. position: fixed;
  1030. left: 0;
  1031. right: 0;
  1032. top: 0;
  1033. bottom: 0;
  1034. background: rgba(0,0,0,0.4);
  1035. display: flex;
  1036. flex-direction: column;
  1037. justify-content: flex-end;
  1038. .sbox{
  1039. position: relative;
  1040. background: #FFFFFF;
  1041. border-radius: 24rpx 24rpx 0rpx 0rpx;
  1042. padding: 50rpx 30rpx 148rpx;
  1043. &-title{
  1044. font-family: PingFang-SC, PingFang-SC;
  1045. font-weight: bold;
  1046. font-size: 36rpx;
  1047. color: #151B29;
  1048. line-height: 36rpx;
  1049. text-align: center;
  1050. }
  1051. .close{
  1052. width: 27rpx;
  1053. height: 27rpx;
  1054. position: absolute;
  1055. top: 50rpx;
  1056. right: 40rpx;
  1057. }
  1058. &-items{
  1059. margin-top: 88rpx;
  1060. &-pre{
  1061. width: calc(100% / 3);
  1062. image{
  1063. width: 94rpx;
  1064. height: 94rpx;
  1065. }
  1066. text{
  1067. font-family: PingFangSC, PingFang SC;
  1068. font-weight: 400;
  1069. font-size: 26rpx;
  1070. color: #252525;
  1071. line-height: 26rpx;
  1072. text-align: center;
  1073. margin-top: 24rpx;
  1074. }
  1075. }
  1076. }
  1077. }
  1078. }
  1079. .poster-preview {
  1080. position: fixed;
  1081. left: 0;
  1082. right: 0;
  1083. top: 0;
  1084. bottom: 0;
  1085. background: rgba(0,0,0,0.8);
  1086. display: flex;
  1087. flex-direction: column;
  1088. justify-content: center;
  1089. align-items: center;
  1090. z-index: 9999;
  1091. .poster-box {
  1092. width: 80%;
  1093. max-width: 600rpx;
  1094. background: #FFFFFF;
  1095. border-radius: 24rpx;
  1096. overflow: hidden;
  1097. .poster-header {
  1098. display: flex;
  1099. justify-content: space-between;
  1100. align-items: center;
  1101. padding: 30rpx;
  1102. border-bottom: 1rpx solid #E7E7E7;
  1103. text {
  1104. font-family: PingFang-SC, PingFang-SC;
  1105. font-weight: bold;
  1106. font-size: 32rpx;
  1107. color: #151B29;
  1108. }
  1109. .close {
  1110. width: 40rpx;
  1111. height: 40rpx;
  1112. }
  1113. }
  1114. .poster-content {
  1115. padding: 30rpx;
  1116. display: flex;
  1117. justify-content: center;
  1118. .poster-img {
  1119. width: 100%;
  1120. border-radius: 12rpx;
  1121. }
  1122. }
  1123. .poster-actions {
  1124. display: flex;
  1125. padding: 0 30rpx 30rpx;
  1126. gap: 20rpx;
  1127. button {
  1128. flex: 1;
  1129. height: 80rpx;
  1130. border-radius: 40rpx;
  1131. border: none;
  1132. font-size: 28rpx;
  1133. font-weight: bold;
  1134. }
  1135. .save-btn {
  1136. background: #F5F5F5;
  1137. color: #151B29;
  1138. }
  1139. .share-btn {
  1140. background: #B7F358;
  1141. color: #151B29;
  1142. }
  1143. }
  1144. }
  1145. }
  1146. }
  1147. </style>