图书馆小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

218 lines
4.8 KiB

2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
1 month ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
  1. <template>
  2. <view class="activity-detail">
  3. <image class="activity-img" :src="detail.imgUrl" mode="aspectFill"></image>
  4. <view class="activity-base">
  5. <text class="title">{{ detail.title }}</text>
  6. <view class="time">
  7. <uni-icons class="detail-icon" custom-prefix="iconfont" type="icon-shijian" size="15"></uni-icons>
  8. <text>{{ detail.time }}</text>
  9. </view>
  10. <view class="location">
  11. <uni-icons class="detail-icon" type="location" size="20"></uni-icons>
  12. <text>{{ detail.location }}</text>
  13. </view>
  14. </view>
  15. <view class="rich-content">
  16. <text class="content-title">活动介绍/回顾</text>
  17. <div v-if="detail.localImg" style="text-align:center; margin:12px 0;">
  18. <image :src="require(`@/static/${detail.localImg}`)" mode="widthFix" style="width:90%; border-radius:8px;"></image>
  19. </div>
  20. <rich-text :nodes="contentNodes"></rich-text>
  21. </view>
  22. <view class="detail-bottom">
  23. <view class="detail-left">
  24. <button open-type="share" class="handle-btn">
  25. <uni-icons custom-prefix="iconfont" type="icon-fenxiang01" size="20"></uni-icons>
  26. <text>分享</text>
  27. </button>
  28. </view>
  29. <button
  30. class="join-btn"
  31. :class="detail.status === 0 ? 'disabled-btn' : ''"
  32. @click="handleJoin"
  33. >
  34. {{ detail.status === 1 ? '我要参加' : '活动结束' }}
  35. </button>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. detail: {},
  44. isCollected: false,
  45. activityId: "",
  46. contentNodes: ""
  47. };
  48. },
  49. onLoad(options) {
  50. const item = JSON.parse(decodeURIComponent(options.item));
  51. this.detail = item;
  52. this.activityId = item.title;
  53. this.formatContent();
  54. this.checkCollectStatus();
  55. },
  56. methods: {
  57. formatContent() {
  58. let content = this.detail.content || "";
  59. // const localImgReg = /<image[^>]*\s+src\s*=\s*['"]@\/static\/([^'"]+)['"][^>]*>/gi;
  60. // content = content.replace(localImgReg, (match, path) => {
  61. // return `
  62. // <div style="text-align:center; margin:12px 0;">
  63. // <img src="/static/${path}" style="width:90%; border-radius:8px;">
  64. // </div>
  65. // `;
  66. // });
  67. const httpImgReg = /https:\/\/mmbiz\.qpic\.cn[^ \n\r'"]+/g;
  68. content = content.replace(httpImgReg, url => {
  69. return `
  70. <div style="text-align:center; margin:12px 0;">
  71. <img src="${url}" style="width:90%; border-radius:8px;">
  72. </div>
  73. `;
  74. });
  75. this.contentNodes = content;
  76. },
  77. checkCollectStatus() {
  78. const list = uni.getStorageSync('activityCollectList') || [];
  79. this.isCollected = list.includes(this.activityId);
  80. },
  81. toggleCollect() {
  82. let list = uni.getStorageSync('activityCollectList') || [];
  83. if (this.isCollected) {
  84. list = list.filter(i => i !== this.activityId);
  85. uni.showToast({ title: "取消收藏" });
  86. } else {
  87. list.push(this.activityId);
  88. uni.showToast({ title: "收藏成功", icon: "success" });
  89. }
  90. uni.setStorageSync('activityCollectList', list);
  91. this.isCollected = !this.isCollected;
  92. },
  93. handleJoin() {
  94. if (this.detail.status === 0) {
  95. return;
  96. }
  97. uni.showToast({
  98. title: '报名成功',
  99. icon: 'success'
  100. });
  101. }
  102. },
  103. onShareAppMessage() {
  104. return {
  105. title: this.detail.title,
  106. path: "/subpkg/pages/activity-detail/activity-detail?item=" + encodeURIComponent(JSON.stringify(this.detail)),
  107. imageUrl: this.detail.imgUrl
  108. };
  109. }
  110. };
  111. </script>
  112. <style lang="scss" scoped>
  113. .activity-detail {
  114. padding-bottom: 60px;
  115. background: #f5f5f5;
  116. }
  117. .activity-img {
  118. width: 100%;
  119. height: 180px;
  120. }
  121. .activity-base {
  122. background: #fff;
  123. padding: 15px;
  124. margin-bottom: 10px;
  125. .title {
  126. font-size: 16px;
  127. font-weight: bold;
  128. padding-bottom: 10px;
  129. }
  130. .time,
  131. .location {
  132. display: flex;
  133. align-items: center;
  134. font-size: 12px;
  135. color: #999;
  136. padding-top: 10px;
  137. .detail-icon {
  138. padding-right: 4px;
  139. }
  140. }
  141. .time{
  142. padding-left: 3px;
  143. }
  144. }
  145. .rich-content {
  146. background: #fff;
  147. padding: 10px 0;
  148. .content-title{
  149. position: relative;
  150. font-size: 16px;
  151. font-weight: bold;
  152. color: #333;
  153. padding-left: 12px;
  154. &::before{
  155. position: absolute;
  156. left: 0;
  157. top: 50%;
  158. margin-top: -9px;
  159. content: "";
  160. width: 4px;
  161. height: 18px;
  162. background-color: #01a4fe;
  163. }
  164. }
  165. }
  166. .detail-bottom {
  167. position: fixed;
  168. bottom: 0;
  169. left: 0;
  170. right: 0;
  171. height: 50px;
  172. background: #fff;
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. padding: 0 15px;
  177. box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
  178. }
  179. .detail-left {
  180. display: flex;
  181. gap: 10px;
  182. }
  183. .handle-btn {
  184. display: flex;
  185. align-items: center;
  186. gap: 4px;
  187. background: #f5f5f5;
  188. border-radius: 30px;
  189. padding: 0 12px;
  190. height: 36px;
  191. font-size: 14px;
  192. }
  193. .join-btn {
  194. background: #01a4fe;
  195. color: #fff;
  196. border-radius: 30px;
  197. padding: 0 20px;
  198. height: 36px;
  199. }
  200. .disabled-btn {
  201. background: #ccc !important;
  202. }
  203. </style>