国外MOSE官网
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.

267 lines
5.5 KiB

2 days ago
  1. <template>
  2. <view class="page">
  3. <!-- 活动信息卡片 -->
  4. <view class="activity-card">
  5. <image class="activity-image" :src="activityInfo.image" mode="aspectFill"></image>
  6. <view class="activity-info">
  7. <view class="title-row">
  8. <view class="activity-badge">
  9. <text class="badge-text">{{ activityInfo.points }}</text>
  10. </view>
  11. <text class="activity-title">{{ activityInfo.title }}</text>
  12. </view>
  13. <view class="activity-location">
  14. <uv-icon name="map-fill" size="14" color="#999"></uv-icon>
  15. <text class="location-text">{{ activityInfo.location }}</text>
  16. </view>
  17. <view class="activity-time">
  18. <uv-icon name="calendar" size="14" color="#999"></uv-icon>
  19. <text class="time-text">{{ activityInfo.time }}</text>
  20. </view>
  21. <view class="activity-participants">
  22. <uv-icon name="account-fill" size="14" color="#999"></uv-icon>
  23. <text class="participants-text">{{ activityInfo.participants }}/{{ activityInfo.maxParticipants }}人已报名</text>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 二维码区域 -->
  28. <view class="qrcode-container">
  29. <view class="qrcode-wrapper">
  30. <!-- <uv-qrcode ref="qrcode" size="300px" value="https://h5.uvui.cn"></uv-qrcode> -->
  31. <uv-qrcode
  32. ref="qrcode"
  33. :value="qrcodeValue"
  34. size="500rpx"
  35. @complete="onQRCodeComplete"
  36. ></uv-qrcode>
  37. </view>
  38. </view>
  39. <!-- 保存按钮 -->
  40. <view class="save-container">
  41. <uv-button
  42. type="primary"
  43. text="保存到手机"
  44. size="large"
  45. shape="circle"
  46. @click="saveQRCode"
  47. ></uv-button>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import utils from '@/utils/index'
  53. export default {
  54. data() {
  55. return {
  56. activityInfo: {
  57. id: '',
  58. title: '',
  59. image: '/static/bannerImage.png',
  60. location: '',
  61. time: '',
  62. participants: 0,
  63. maxParticipants: 30,
  64. points: 0
  65. },
  66. qrcodeValue: 'https://h5.uvui.cn',
  67. qrCodeReady: false
  68. }
  69. },
  70. onLoad(options) {
  71. // 获取传递的参数
  72. if (options.id) {
  73. this.activityInfo.id = options.id
  74. }
  75. if (options.title) {
  76. this.activityInfo.title = decodeURIComponent(options.title)
  77. }
  78. if (options.points) {
  79. this.activityInfo.points = options.points
  80. }
  81. // 模拟获取活动详细信息
  82. this.loadActivityInfo()
  83. // 生成签到码
  84. this.generateQRCode()
  85. },
  86. methods: {
  87. // 加载活动信息
  88. loadActivityInfo() {
  89. // 这里应该根据活动ID调用API获取详细信息
  90. // 现在使用模拟数据
  91. this.activityInfo = {
  92. ...this.activityInfo,
  93. location: '长沙市雨花区时代阳光大道国际新城2145',
  94. time: '2025-06-12 14:30',
  95. participants: 30,
  96. maxParticipants: 30
  97. }
  98. },
  99. // 生成二维码内容
  100. generateQRCode() {
  101. // 生成包含活动信息的二维码内容
  102. const qrData = {
  103. activityId: this.activityInfo.id,
  104. activityTitle: this.activityInfo.title,
  105. type: 'checkin',
  106. timestamp: Date.now()
  107. }
  108. this.qrcodeValue = JSON.stringify(qrData)
  109. },
  110. // 二维码生成完成事件
  111. onQRCodeComplete(result) {
  112. if (result.success) {
  113. this.qrCodeReady = true
  114. console.log('二维码生成成功')
  115. } else {
  116. console.log('二维码生成失败')
  117. }
  118. },
  119. // 保存二维码到手机
  120. saveQRCode() {
  121. if (!this.qrCodeReady) {
  122. uni.showToast({
  123. title: '二维码还未生成完成',
  124. icon: 'none'
  125. })
  126. return
  127. }
  128. this.$refs.qrcode.save({
  129. success: (res) => {
  130. uni.showToast({
  131. title: '保存成功',
  132. icon: 'success'
  133. })
  134. },
  135. fail: (err) => {
  136. console.log('保存失败:', err)
  137. // 用uniapp获取保存权限
  138. utils.authoriza({
  139. scope: 'writePhotosAlbum',
  140. successfn: () => {
  141. // 保存二维码
  142. this.$refs.qrcode.save({
  143. success: (res) => {
  144. uni.showToast({
  145. title: '保存成功',
  146. icon: 'success'
  147. })
  148. },
  149. fail: (err) => {
  150. console.log('保存失败:', err)
  151. uni.showToast({
  152. title: '保存失败',
  153. icon: 'none'
  154. })
  155. }
  156. })
  157. },
  158. failfn: () => {
  159. uni.showToast({
  160. title: '保存失败',
  161. icon: 'none'
  162. })
  163. }
  164. })
  165. }
  166. })
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .page {
  173. background-color: #f5f5f5;
  174. min-height: 100vh;
  175. padding: 20rpx;
  176. }
  177. .activity-card {
  178. display: flex;
  179. background: #fff;
  180. border-radius: 12rpx;
  181. padding: 20rpx;
  182. margin-bottom: 40rpx;
  183. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  184. }
  185. .activity-image {
  186. width: 180rpx;
  187. height: 180rpx;
  188. border-radius: 8rpx;
  189. margin-right: 20rpx;
  190. }
  191. .activity-info {
  192. flex: 1;
  193. display: flex;
  194. flex-direction: column;
  195. justify-content: space-between;
  196. }
  197. .title-row {
  198. display: flex;
  199. align-items: center;
  200. margin-bottom: 10rpx;
  201. }
  202. .activity-badge {
  203. width: 31px;
  204. height: 20px;
  205. background: #218cdd;
  206. border-radius: 3.5px;
  207. margin-right: 7rpx;
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. }
  212. .badge-text {
  213. font-size: 18rpx;
  214. color: #fff;
  215. }
  216. .activity-title {
  217. font-size: 28rpx;
  218. font-weight: bold;
  219. color: #333;
  220. line-height: 1.4;
  221. }
  222. .activity-location, .activity-time, .activity-participants {
  223. display: flex;
  224. align-items: center;
  225. margin-bottom: 6rpx;
  226. }
  227. .location-text, .time-text, .participants-text {
  228. font-size: 24rpx;
  229. color: #999;
  230. margin-left: 6rpx;
  231. }
  232. .qrcode-container {
  233. display: flex;
  234. justify-content: center;
  235. margin-bottom: 60rpx;
  236. }
  237. .qrcode-wrapper {
  238. background: #fff;
  239. border-radius: 12rpx;
  240. padding: 40rpx;
  241. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  242. }
  243. .save-container {
  244. padding: 0 40rpx;
  245. }
  246. </style>