index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="checkin-page">
  3. <!-- 加载骨架 / 错误态 -->
  4. <LoadingSkeleton v-if="loading" :rows="3" />
  5. <ErrorState v-else-if="error" message="待办状态加载失败" @retry="loadStatus" />
  6. <template v-else>
  7. <view class="section-card">
  8. <text class="section-title">装机打卡</text>
  9. <view v-if="checkinDone" class="status-badge done">✓ 已完成 (+10分)</view>
  10. <view v-else>
  11. <button class="upload-btn" @click="chooseCheckinImage">选择装机截图</button>
  12. <image v-if="checkinImage" :src="checkinImage" class="preview-img" mode="aspectFit" />
  13. <button class="submit-btn" @click="handleCheckin" :loading="checkinLoading" :disabled="!checkinImage || checkinLoading">提交打卡</button>
  14. </view>
  15. </view>
  16. <view class="section-card">
  17. <text class="section-title">数据准备自检</text>
  18. <view v-if="prepDone" class="status-badge done">✓ 已完成 (+5分)</view>
  19. <view v-else>
  20. <view class="check-group">
  21. <label class="check-item">
  22. <checkbox :checked="prepForm.wealthData" @tap="prepForm.wealthData = !prepForm.wealthData" color="#2E6FA8" />
  23. <text>我有财富相关数据</text>
  24. </label>
  25. <label class="check-item">
  26. <checkbox :checked="prepForm.healthData" @tap="prepForm.healthData = !prepForm.healthData" color="#2E6FA8" />
  27. <text>我有健康相关数据</text>
  28. </label>
  29. <label class="check-item">
  30. <checkbox :checked="prepForm.growthData" @tap="prepForm.growthData = !prepForm.growthData" color="#2E6FA8" />
  31. <text>我有成长相关数据</text>
  32. </label>
  33. <label class="check-item">
  34. <checkbox :checked="prepForm.hasNone" @tap="prepForm.hasNone = !prepForm.hasNone" color="#2E6FA8" />
  35. <text>以上都没有(使用脱敏样本数据)</text>
  36. </label>
  37. </view>
  38. <button class="submit-btn" @click="handlePrepCheck" :loading="prepLoading">提交自检</button>
  39. </view>
  40. </view>
  41. <view class="section-card">
  42. <text class="section-title">快捷入口</text>
  43. <view class="shortcut-grid">
  44. <view class="shortcut-item" @click="goTo('/pages/assignment/index')">
  45. <text class="shortcut-icon">📘</text>
  46. <text class="shortcut-text">三本账</text>
  47. </view>
  48. <view class="shortcut-item" @click="goTo('/pages/upload/index')">
  49. <text class="shortcut-icon">📤</text>
  50. <text class="shortcut-text">成果上传</text>
  51. </view>
  52. <view class="shortcut-item" @click="goTo('/pages/teaching/index')">
  53. <text class="shortcut-icon">📋</text>
  54. <text class="shortcut-text">教学卡</text>
  55. </view>
  56. <view class="shortcut-item" @click="goTo('/pages/plan/index')">
  57. <text class="shortcut-icon">📝</text>
  58. <text class="shortcut-text">行动计划</text>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. </view>
  64. </template>
  65. <script>
  66. import { checkin, getCheckinStatus, prepCheck, getPrepCheckStatus, uploadFile } from '@/utils/api.js'
  67. import { guardPage } from '@/utils/guard.js'
  68. import LoadingSkeleton from '@/components/loading-skeleton.vue'
  69. import ErrorState from '@/components/error-state.vue'
  70. export default {
  71. components: { LoadingSkeleton, ErrorState },
  72. data() {
  73. return {
  74. checkinDone: false,
  75. checkinImage: '',
  76. checkinLoading: false,
  77. prepDone: false,
  78. prepForm: {
  79. wealthData: false,
  80. healthData: false,
  81. growthData: false,
  82. hasNone: false,
  83. useSample: 0
  84. },
  85. prepLoading: false,
  86. loading: true,
  87. error: false
  88. }
  89. },
  90. onShow() {
  91. if (!guardPage()) return
  92. this.loadStatus()
  93. },
  94. methods: {
  95. loadStatus() {
  96. var self = this
  97. self.loading = true
  98. self.error = false
  99. var failed = 0
  100. var finish = function() {
  101. self.loading = false
  102. }
  103. getCheckinStatus().then(function(resp) {
  104. self.checkinDone = resp.data === true
  105. finish()
  106. }).catch(function() {
  107. failed = failed + 1
  108. finish()
  109. if (failed >= 2) self.error = true
  110. })
  111. getPrepCheckStatus().then(function(resp) {
  112. self.prepDone = resp.data !== null && resp.data !== undefined
  113. finish()
  114. }).catch(function() {
  115. failed = failed + 1
  116. finish()
  117. if (failed >= 2) self.error = true
  118. })
  119. },
  120. chooseCheckinImage() {
  121. var self = this
  122. uni.chooseImage({
  123. count: 1,
  124. sizeType: ['compressed'],
  125. sourceType: ['album', 'camera'],
  126. success: function(res) {
  127. self.checkinImage = res.tempFilePaths[0]
  128. }
  129. })
  130. },
  131. handleCheckin() {
  132. if (!this.checkinImage || this.checkinLoading) return
  133. this.checkinLoading = true
  134. var self = this
  135. uploadFile(this.checkinImage).then(function(resp) {
  136. var url = resp.data.url
  137. return checkin(url)
  138. }).then(function() {
  139. uni.showToast({ title: '打卡成功 +10分', icon: 'success' })
  140. self.checkinDone = true
  141. }).catch(function(err) {
  142. uni.showToast({ title: (err && err.message) || '打卡失败', icon: 'none' })
  143. }).finally(function() {
  144. self.checkinLoading = false
  145. })
  146. },
  147. handlePrepCheck() {
  148. if (this.prepLoading) return
  149. this.prepLoading = true
  150. var self = this
  151. var data = {
  152. wealthData: this.prepForm.wealthData ? 1 : 0,
  153. healthData: this.prepForm.healthData ? 1 : 0,
  154. growthData: this.prepForm.growthData ? 1 : 0,
  155. hasNone: this.prepForm.hasNone ? 1 : 0,
  156. useSample: this.prepForm.hasNone ? 1 : 0
  157. }
  158. prepCheck(data).then(function() {
  159. uni.showToast({ title: '自检完成 +5分', icon: 'success' })
  160. self.prepDone = true
  161. }).catch(function(err) {
  162. uni.showToast({ title: (err && err.message) || '提交失败', icon: 'none' })
  163. }).finally(function() {
  164. self.prepLoading = false
  165. })
  166. },
  167. goTo(url) {
  168. uni.navigateTo({ url: url })
  169. }
  170. }
  171. }
  172. </script>
  173. <style scoped>
  174. .checkin-page { min-height: 100vh; background: #F5FAFE; padding: 24rpx 32rpx; }
  175. .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
  176. .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E3A5F; margin-bottom: 24rpx; border-left: 8rpx solid #2E6FA8; padding-left: 16rpx; }
  177. .status-badge { padding: 16rpx 24rpx; border-radius: 8rpx; font-size: 26rpx; font-weight: 500; }
  178. .status-badge.done { background: #E6F6EE; color: #0E8A4F; }
  179. .upload-btn { width: 100%; height: 80rpx; line-height: 80rpx; background: #E8F3FC; color: #2E6FA8; font-size: 28rpx; border: 2rpx dashed #2E6FA8; border-radius: 12rpx; margin-bottom: 16rpx; }
  180. .preview-img { width: 100%; height: 300rpx; border-radius: 12rpx; margin-bottom: 16rpx; }
  181. .submit-btn { width: 100%; height: 80rpx; line-height: 80rpx; background: #2E6FA8; color: #FFF; font-size: 28rpx; font-weight: 500; border-radius: 40rpx; border: none; margin-top: 16rpx; }
  182. .submit-btn:active { opacity: 0.85; }
  183. .check-group { margin-bottom: 16rpx; }
  184. .check-item { display: flex; align-items: center; padding: 16rpx 0; font-size: 28rpx; color: #1E3A5F; }
  185. .check-item text { margin-left: 12rpx; }
  186. .shortcut-grid { display: flex; flex-wrap: wrap; gap: 20rpx; }
  187. .shortcut-item { width: calc(25% - 15rpx); display: flex; flex-direction: column; align-items: center; padding: 20rpx 0; }
  188. .shortcut-icon { font-size: 48rpx; margin-bottom: 8rpx; }
  189. .shortcut-text { font-size: 24rpx; color: #1E3A5F; text-align: center; }
  190. </style>