activityDetail.vue 34 KB

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