activityDetail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view class="container">
  3. <!-- 状态栏占位 -->
  4. <view class="status-bar" :style="{height: statusBarHeight}"></view>
  5. <!-- 顶部导航栏 -->
  6. <view class="header">
  7. <view class="back-btn" @click="goBack">
  8. <image src="@/static/image/back.png" mode="aspectFill"></image>
  9. </view>
  10. <view class="title">活动详情</view>
  11. <view class="header-right">
  12. <text class="more-icon">⋯</text>
  13. <text class="more-icon">○</text>
  14. </view>
  15. </view>
  16. <scroll-view class="content" scroll-y>
  17. <!-- 活动头部 -->
  18. <view class="activity-header">
  19. <view class="logo-section">
  20. <view class="logo-icon">预定</view>
  21. <view class="logo-text">YOUR LOGO</view>
  22. <view class="logo-url">www.gaoding.com</view>
  23. </view>
  24. <view class="activity-title">
  25. <view class="title-main">{{ activityData.title }}</view>
  26. <view class="title-en">{{ activityData.titleEn }}</view>
  27. <view class="title-date">{{ activityData.date }}</view>
  28. </view>
  29. </view>
  30. <!-- 活动主图 -->
  31. <view class="activity-banner">
  32. <image class="banner-image" :src="activityData.bannerImage" mode="aspectFill"></image>
  33. <view class="banner-text">{{ activityData.bannerText }}</view>
  34. </view>
  35. </scroll-view>
  36. <!-- 底部按钮 -->
  37. <view class="bottom-btn" :class="activityData.buttonClass" @click="handleAction">
  38. {{ activityData.buttonText }}
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import { getActivityDetail } from '@/api-js/medicationSurvey'
  44. export default {
  45. data() {
  46. return {
  47. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  48. activityId: '',
  49. activityData: {
  50. title: '世界关节炎日',
  51. titleEn: 'WORLD ARTHRISTIS DAY',
  52. date: '2024年10月12日',
  53. bannerImage: '',
  54. bannerText: '早预防・早诊断・早治疗',
  55. status: 'notStarted', // notStarted, inProgress, ended
  56. buttonText: '活动未开始',
  57. buttonClass: 'not-started',
  58. completedCount: 0,
  59. totalCount: 3
  60. }
  61. }
  62. },
  63. onLoad(options) {
  64. if (options.id) {
  65. this.activityId = options.id
  66. this.loadData()
  67. }
  68. },
  69. methods: {
  70. goBack() {
  71. uni.navigateBack()
  72. },
  73. handleAction() {
  74. if (this.activityData.status === 'notStarted') {
  75. uni.showToast({
  76. icon: 'none',
  77. title: '活动未开始'
  78. })
  79. } else if (this.activityData.status === 'ended') {
  80. uni.showToast({
  81. icon: 'none',
  82. title: '活动已结束'
  83. })
  84. } else {
  85. // 跳转到病例征集页面
  86. uni.navigateTo({
  87. url: `/pages_task/caseCollection?activityId=${this.activityId}`
  88. })
  89. }
  90. },
  91. async loadData() {
  92. try {
  93. uni.showLoading({ title: '加载中...' })
  94. const res = await getActivityDetail({ id: this.activityId })
  95. uni.hideLoading()
  96. if (res.code === 200 && res.data) {
  97. this.activityData = { ...this.activityData, ...res.data }
  98. this.updateButtonText()
  99. }
  100. } catch (e) {
  101. uni.hideLoading()
  102. console.error('加载数据失败', e)
  103. }
  104. },
  105. updateButtonText() {
  106. if (this.activityData.status === 'notStarted') {
  107. this.activityData.buttonText = '活动未开始'
  108. this.activityData.buttonClass = 'not-started'
  109. } else if (this.activityData.status === 'ended') {
  110. this.activityData.buttonText = '活动已结束'
  111. this.activityData.buttonClass = 'ended'
  112. } else {
  113. this.activityData.buttonText = `上传病例 ${this.activityData.completedCount}/${this.activityData.totalCount}`
  114. this.activityData.buttonClass = 'upload-case'
  115. }
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .container {
  122. min-height: 100vh;
  123. background: linear-gradient(180deg, #E6F3FF 0%, #FFFFFF 100%);
  124. display: flex;
  125. flex-direction: column;
  126. }
  127. .status-bar {
  128. width: 100%;
  129. background: transparent;
  130. }
  131. .header {
  132. position: relative;
  133. height: 88rpx;
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. background: transparent;
  138. .back-btn {
  139. position: absolute;
  140. left: 24rpx;
  141. width: 40rpx;
  142. height: 40rpx;
  143. image {
  144. width: 100%;
  145. height: 100%;
  146. }
  147. }
  148. .title {
  149. font-size: 36rpx;
  150. font-weight: bold;
  151. color: #333;
  152. }
  153. .header-right {
  154. position: absolute;
  155. right: 24rpx;
  156. display: flex;
  157. align-items: center;
  158. gap: 16rpx;
  159. .more-icon {
  160. font-size: 32rpx;
  161. color: #333;
  162. }
  163. }
  164. }
  165. .content {
  166. flex: 1;
  167. padding: 24rpx;
  168. }
  169. .activity-header {
  170. margin-bottom: 32rpx;
  171. .logo-section {
  172. display: flex;
  173. align-items: center;
  174. gap: 16rpx;
  175. margin-bottom: 24rpx;
  176. .logo-icon {
  177. width: 48rpx;
  178. height: 48rpx;
  179. background: #388BFF;
  180. border-radius: 50%;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. font-size: 20rpx;
  185. color: #fff;
  186. }
  187. .logo-text {
  188. font-size: 28rpx;
  189. font-weight: bold;
  190. color: #388BFF;
  191. }
  192. .logo-url {
  193. font-size: 24rpx;
  194. color: #388BFF;
  195. }
  196. }
  197. .activity-title {
  198. .title-main {
  199. font-size: 48rpx;
  200. font-weight: bold;
  201. color: #388BFF;
  202. margin-bottom: 8rpx;
  203. }
  204. .title-en {
  205. font-size: 36rpx;
  206. font-weight: bold;
  207. color: #388BFF;
  208. margin-bottom: 8rpx;
  209. }
  210. .title-date {
  211. font-size: 28rpx;
  212. color: #388BFF;
  213. }
  214. }
  215. }
  216. .activity-banner {
  217. position: relative;
  218. width: 100%;
  219. height: 600rpx;
  220. border-radius: 16rpx;
  221. overflow: hidden;
  222. background: linear-gradient(135deg, #E6F3FF 0%, #FFFFFF 100%);
  223. .banner-image {
  224. width: 100%;
  225. height: 100%;
  226. }
  227. .banner-text {
  228. position: absolute;
  229. bottom: 40rpx;
  230. left: 50%;
  231. transform: translateX(-50%);
  232. font-size: 28rpx;
  233. color: #fff;
  234. white-space: nowrap;
  235. }
  236. }
  237. .bottom-btn {
  238. position: fixed;
  239. bottom: 0;
  240. left: 0;
  241. right: 0;
  242. height: 88rpx;
  243. display: flex;
  244. align-items: center;
  245. justify-content: center;
  246. font-size: 32rpx;
  247. color: #fff;
  248. font-weight: 500;
  249. z-index: 100;
  250. &.not-started {
  251. background: #87CEEB;
  252. }
  253. &.upload-case {
  254. background: #388BFF;
  255. }
  256. &.ended {
  257. background: #999;
  258. }
  259. }
  260. </style>