detail.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="content">
  3. <uni-card :title="repo.title">
  4. <view>{{repo.remark}}</view>
  5. <view>题目总数:{{repo.quCount}}</view>
  6. <view>创建时间:{{repo.createTime}}</view>
  7. </uni-card>
  8. <view>
  9. <uni-card title="练习模式">
  10. <uni-row :gutter="2">
  11. <uni-col :span="8">
  12. <view class="tr-item" @click="navtoTrain(11)">
  13. <image src="../../static/nav/pattern1.png"></image>
  14. <text>顺序训练</text>
  15. </view>
  16. </uni-col>
  17. <uni-col :span="8">
  18. <view class="tr-item" @click="navtoTrain(12)">
  19. <image src="../../static/nav/pattern2.png"></image>
  20. <text>随机训练</text>
  21. </view>
  22. </uni-col>
  23. <uni-col :span="8">
  24. <view class="tr-item" @click="navtoTrain(13)">
  25. <image src="../../static/nav/pattern3.png"></image>
  26. <text>背题模式</text>
  27. </view>
  28. </uni-col>
  29. </uni-row>
  30. </uni-card>
  31. <uni-card title="题型练习">
  32. <uni-row :gutter="2">
  33. <uni-col :span="8" v-for="item in repo.typeList">
  34. <view class="tr-item" @click="navtoTrain(`2${item.quType}`)">
  35. <image :src="`../../static/nav/qtype${item.quType}.png`"></image>
  36. <text>{{item.quType_dictText}}({{ item.count }})</text>
  37. </view>
  38. </uni-col>
  39. </uni-row>
  40. </uni-card>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import { repoDetail } from '@/api/repo/repo'
  46. export default {
  47. components: {
  48. },
  49. data() {
  50. return {
  51. repoId: null,
  52. repo: {},
  53. }
  54. },
  55. onLoad(option) {
  56. this.repoId = option.id;
  57. this.fetchRepoDetail()
  58. // 支付成功刷新页面
  59. uni.$on('paySuccess', () => {
  60. this.fetchRepoDetail()
  61. });
  62. },
  63. methods: {
  64. // 加载考试列表
  65. fetchRepoDetail() {
  66. repoDetail(this.repoId).then(data => {
  67. //打印请求返回的数据
  68. this.repo = data
  69. }, error => {
  70. console.log(error);
  71. })
  72. },
  73. // 去训练
  74. navtoTrain(mode) {
  75. uni.redirectTo({
  76. url: '/pages/repo/train?repoId=' + this.repoId + '&mode=' + mode
  77. });
  78. }
  79. },
  80. onUnload() {
  81. uni.$off('paySuccess');
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .tr-item {
  87. height: 100%;
  88. display: flex;
  89. align-items: center;
  90. justify-content: center;
  91. align-content: center;
  92. flex-direction: column;
  93. padding: 10px 0px 10px 0px;
  94. border: #efefef 0.5px solid;
  95. margin: 10px;
  96. }
  97. .tr-item image {
  98. width: 18px;
  99. height: 18px;
  100. }
  101. .tr-item text {
  102. color: #666;
  103. }
  104. </style>