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

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