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

166 lines
3.2 KiB

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