猫妈狗爸伴宠师小程序前端代码
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.

197 lines
4.1 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="page">
  3. <view class="header">
  4. <view class="flex-rowl color-fff size-28 title">
  5. {{ `答题进度 ${answered}/${total}` }}
  6. </view>
  7. <up-line-progress class="progress" :percentage="progress" activeColor="#FFBF60" inactiveColor="#D9D9D9" height="16rpx" :showText="false"></up-line-progress>
  8. </view>
  9. <view class="box">
  10. <view class="content bg-fff">
  11. <view>
  12. <view class="label size-22">
  13. 选择题
  14. </view>
  15. </view>
  16. <view class="">
  17. <questionCard
  18. v-for="(item, qIdx) in list"
  19. :key="`question-${qIdx}`"
  20. :index="qIdx"
  21. :data="item"
  22. v-model="item.value"
  23. ></questionCard>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="footer-btn">
  28. <view class="btn" @click="toNext">
  29. 提交
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import { ref, computed } from 'vue'
  36. import { onShow } from '@dcloudio/uni-app'
  37. import { usePageList } from "@/utils/pageList";
  38. import questionCard from '../components/questionCard.vue';
  39. // todo
  40. const { list, total, getData } = usePageList()
  41. onShow(() => {
  42. // todo: delete test data
  43. total.value = 100
  44. list.value = [
  45. {
  46. question: '猫咪每天在地上走路,时不时还会打滚,身上是很不干净的,最好每个星期洗次澡',
  47. options: [
  48. {
  49. label: '对',
  50. value: 0,
  51. },
  52. {
  53. label: '错',
  54. value: 1,
  55. },
  56. ],
  57. value: null,
  58. },
  59. {
  60. question: '当狗狗出现乱拉乱尿或者捣乱拆家等反映时,您会如何处理?',
  61. options: [
  62. {
  63. label: '暴力制止,根据情况是否严重来判断下手轻重,让狗狗知道这样做会受到惩罚',
  64. value: 0,
  65. },
  66. {
  67. label: '奖罚分明,制止后耐心引导,直到狗狗做出正确的行为,并立马给出奖励',
  68. value: 1,
  69. },
  70. {
  71. label: '狗狗也不是故意的,也不会造成什么很大的影响,默默打扫好就算了吧',
  72. value: 2,
  73. },
  74. ],
  75. value: null,
  76. },
  77. {
  78. question: '狗狗和猫咪一样是肉食性动物,最好可以纯肉喂养,对狗狗的身心健康有很大好处',
  79. options: [
  80. {
  81. label: '对',
  82. value: 0,
  83. },
  84. {
  85. label: '错',
  86. value: 1,
  87. },
  88. ],
  89. value: null,
  90. },
  91. {
  92. question: '猫咪每天在地上走路,时不时还会打滚,身上是很不干净的,最好每个星期洗次澡',
  93. options: [
  94. {
  95. label: '对',
  96. value: 0,
  97. },
  98. {
  99. label: '错',
  100. value: 1,
  101. },
  102. ],
  103. value: null,
  104. },
  105. {
  106. question: '当狗狗出现乱拉乱尿或者捣乱拆家等反映时,您会如何处理?',
  107. options: [
  108. {
  109. label: '暴力制止,根据情况是否严重来判断下手轻重,让狗狗知道这样做会受到惩罚',
  110. value: 0,
  111. },
  112. {
  113. label: '奖罚分明,制止后耐心引导,直到狗狗做出正确的行为,并立马给出奖励',
  114. value: 1,
  115. },
  116. {
  117. label: '狗狗也不是故意的,也不会造成什么很大的影响,默默打扫好就算了吧',
  118. value: 2,
  119. },
  120. ],
  121. value: null,
  122. },
  123. {
  124. question: '狗狗和猫咪一样是肉食性动物,最好可以纯肉喂养,对狗狗的身心健康有很大好处',
  125. options: [
  126. {
  127. label: '对',
  128. value: 0,
  129. },
  130. {
  131. label: '错',
  132. value: 1,
  133. },
  134. ],
  135. value: null,
  136. },
  137. ]
  138. })
  139. const answered = computed(() => {
  140. return list.value.filter(item => item.value !== null).length
  141. })
  142. const progress = computed(() => {
  143. return Math.floor(answered.value / total.value * 100)
  144. })
  145. const toNext = () => {
  146. uni.navigateTo({
  147. url: "/otherPages/authentication/examination/baseCompleted"
  148. })
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .page {
  153. padding-bottom: 144rpx;
  154. }
  155. .header {
  156. padding: 0 36rpx;
  157. position: sticky;
  158. top: 0;
  159. background-image: linear-gradient(180deg, #FFBF60 0, #ffbf60 2%, #ffbf60 8%, #f2f2f2 90%);
  160. .progress {
  161. margin-top: 19rpx;
  162. }
  163. }
  164. .box {
  165. margin-top: 31rpx;
  166. padding: 16rpx;
  167. .content {
  168. border-radius: 20rpx;
  169. padding: 15rpx 20rpx;
  170. .label {
  171. display: inline-block;
  172. padding: 5rpx 15rpx;
  173. color: #fff;
  174. background-color: #FFBF60;
  175. }
  176. }
  177. }
  178. </style>