posture-guide.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="posture-guide">
  3. <view class="guide-content">
  4. <view class="guide-title">体态评估环节</view>
  5. <view class="guide-subtitle">请仔细阅读下方说明,完整展示手臂</view>
  6. <!-- 添加轮播图组件 -->
  7. <swiper
  8. class="guide-swiper"
  9. :indicator-dots="true"
  10. indicator-color="rgba(0, 0, 0, .3)"
  11. indicator-active-color="#000000"
  12. :autoplay="false"
  13. @change="handleSwiperChange"
  14. >
  15. <swiper-item v-for="(item, index) in guideImages" :key="index">
  16. <view class="swiper-item">
  17. <image :src="item.url" mode="aspectFit" class="guide-image"></image>
  18. <view class="image-description">{{item.description}}</view>
  19. </view>
  20. </swiper-item>
  21. </swiper>
  22. <!-- <view class="guide-instructions">
  23. <text>{{currentInstruction}}</text>
  24. </view> -->
  25. <!-- 按钮根据是否是最后一张图片来决定是否禁用 -->
  26. <button
  27. class="confirm-button"
  28. :class="{'button-disabled': !isLastSlide}"
  29. :disabled="!isLastSlide"
  30. @click="handleConfirm"
  31. >
  32. {{isLastSlide ? '我知道了,开始采集' : '请查看完所有说明'}}
  33. </button>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. currentIndex: 0,
  42. isLastSlide: false,
  43. guideImages: [
  44. {
  45. url: 'https://data.qicai321.com/minlong/85fbafbd-1b80-48cd-bcd6-fc4911e9ff54.jpg',
  46. description: '左手手掌'
  47. },
  48. {
  49. url: 'https://data.qicai321.com/minlong/17d141e0-8f99-4a54-a534-f6b954c600f8.png',
  50. description: '左手手背'
  51. },
  52. {
  53. url: 'https://data.qicai321.com/minlong/5c7d7d6f-5e14-4cd6-bb9f-11509473a8bb.png',
  54. description: '左手握拳'
  55. },
  56. {
  57. url: 'https://data.qicai321.com/minlong/148eea00-21b4-49e1-a3b6-712fff08a5a8.png',
  58. description: '右手手掌'
  59. },
  60. {
  61. url: 'https://data.qicai321.com/minlong/c67c303e-91c0-4e79-8e82-84096435481f.png',
  62. description: '右手手背'
  63. },
  64. {
  65. url: 'https://data.qicai321.com/minlong/5a093f70-d397-4a36-9539-a8b4d11e0a13.png',
  66. description: '右手握拳'
  67. },
  68. ],
  69. instructions: [
  70. '第1步:请按图示展示左手手掌',
  71. '第2步:请按图示展示左手手背',
  72. '第3步:请按图示展示左手握拳',
  73. '第4步:请按图示展示右手手掌',
  74. '第5步:请按图示展示右手手背',
  75. '第6步:请按图示展示右手握拳'
  76. ]
  77. }
  78. },
  79. computed: {
  80. currentInstruction() {
  81. return this.instructions[this.currentIndex];
  82. }
  83. },
  84. methods: {
  85. handleSwiperChange(e) {
  86. this.currentIndex = e.detail.current;
  87. // 判断是否是最后一张图片
  88. this.isLastSlide = this.currentIndex === this.guideImages.length - 1;
  89. },
  90. handleConfirm() {
  91. if (this.isLastSlide) {
  92. uni.navigateTo({
  93. url: '/pages/interview/interview',
  94. success: () => {
  95. console.log('跳转成功');
  96. },
  97. fail: (err) => {
  98. console.error('跳转失败:', err);
  99. // 如果 navigateTo 失败,尝试使用 redirectTo
  100. uni.redirectTo({
  101. url: '/pages/interview/interview',
  102. fail: (redirectErr) => {
  103. console.error('redirectTo 也失败了:', redirectErr);
  104. uni.showToast({
  105. title: '页面跳转失败,请重试',
  106. icon: 'none'
  107. });
  108. }
  109. });
  110. }
  111. });
  112. } else {
  113. uni.showToast({
  114. title: '请查看完所有说明',
  115. icon: 'none'
  116. });
  117. }
  118. }
  119. }
  120. }
  121. </script>
  122. <style>
  123. .posture-guide {
  124. min-height: 100vh;
  125. background-color: #fff;
  126. padding: 30rpx;
  127. }
  128. .guide-content {
  129. display: flex;
  130. flex-direction: column;
  131. align-items: center;
  132. }
  133. .guide-title {
  134. font-size: 36rpx;
  135. font-weight: bold;
  136. margin-bottom: 20rpx;
  137. color: #333;
  138. }
  139. .guide-subtitle {
  140. font-size: 28rpx;
  141. color: #666;
  142. margin-bottom: 40rpx;
  143. }
  144. /* 轮播图样式 */
  145. .guide-swiper {
  146. width: 100%;
  147. height: 800rpx;
  148. margin: 30rpx 0;
  149. position: relative;
  150. padding-bottom: 40rpx; /* 添加底部padding为指示点留出空间 */
  151. }
  152. .swiper-item {
  153. display: flex;
  154. flex-direction: column;
  155. align-items: center;
  156. justify-content: center;
  157. height: 100%;
  158. }
  159. .guide-image {
  160. width: 90%;
  161. height: 600rpx;
  162. object-fit: contain;
  163. }
  164. .image-description {
  165. margin-top: 20rpx;
  166. font-size: 28rpx;
  167. color: #333;
  168. text-align: center;
  169. }
  170. .guide-instructions {
  171. padding: 20rpx;
  172. margin: 30rpx 0;
  173. text-align: center;
  174. font-size: 28rpx;
  175. color: #666;
  176. background-color: #f8f8f8;
  177. border-radius: 10rpx;
  178. width: 90%;
  179. margin-top: 60rpx;
  180. }
  181. .confirm-button {
  182. width: 80%;
  183. height: 88rpx;
  184. line-height: 88rpx;
  185. background-color: #0039b3;
  186. color: #fff;
  187. border-radius: 44rpx;
  188. font-size: 32rpx;
  189. margin-top: 40rpx;
  190. }
  191. /* 禁用状态的按钮样式 */
  192. .button-disabled {
  193. background-color: #cccccc;
  194. opacity: 0.8;
  195. }
  196. /* 修改指示点容器样式 */
  197. :deep(.uni-swiper-dots) {
  198. display: flex;
  199. justify-content: center;
  200. position: absolute;
  201. bottom: 0;
  202. left: 0;
  203. right: 0;
  204. }
  205. /* 修改指示点样式 */
  206. :deep(.uni-swiper-dot) {
  207. width: 16rpx !important;
  208. height: 16rpx !important;
  209. margin: 0 8rpx !important;
  210. border-radius: 50%;
  211. background: rgba(0, 0, 0, 0.3) !important;
  212. }
  213. :deep(.uni-swiper-dot-active) {
  214. background: #000000 !important;
  215. }
  216. </style>