index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class="container">
  3. <view style="background: #fff;">
  4. <yf-carsousel :img-list="imgList"></yf-carsousel>
  5. </view>
  6. <view @tap="navtoNotice(notice.id)" v-if="notice && notice.id">
  7. <uni-notice-bar single="true" showIcon="true" :text="notice.title"></uni-notice-bar>
  8. </view>
  9. <!-- 一般用法 -->
  10. <view style="padding: 15px; background: #fcfcfc;">
  11. <view class="uni-flex uni-row" style="flex-wrap: wrap;">
  12. <view class="flex-item" @click="navigateToCourse" >
  13. <view class="item-box" style="border-radius: 0px 5px 15px 5px; ">
  14. <image src="../../static/nav/nav01.png" mode="heightFix"></image>
  15. <text class="tt2">课程学习</text>
  16. </view>
  17. </view>
  18. <view class="flex-item" @click="navigateToExam">
  19. <view class="item-box" style="border-radius: 5px 0px 5px 15px;">
  20. <image src="../../static/nav/nav02.png" mode="heightFix"></image>
  21. <text class="tt2">在线考试</text>
  22. </view>
  23. </view>
  24. <view class="flex-item" @click="navigateToRepo">
  25. <view class="item-box" style="border-radius: 5px 15px 5px 0px;">
  26. <image src="../../static/nav/nav03.png" mode="heightFix"></image>
  27. <text class="tt2">题库训练</text>
  28. </view>
  29. </view>
  30. <view class="flex-item" @click="navigateToPaper">
  31. <view class="item-box" style="border-radius: 15px 5px 0px 5px;">
  32. <image src="../../static/nav/nav04.png" mode="heightFix"></image>
  33. <text class="tt2">我的成绩</text>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { noticePaging } from '@/api/notice.js'
  42. export default {
  43. data() {
  44. return {
  45. fileUrl: '',
  46. items: ['我的考试', '训练进度', '消息通知'],
  47. current: 0,
  48. more: 'loading',
  49. query: {
  50. current: 1,
  51. size: 5,
  52. params: {
  53. title: ''
  54. }
  55. },
  56. notice: {
  57. id: '',
  58. title: ''
  59. },
  60. imgList: [
  61. {
  62. url: 'https://cdn.yfhl.net/static/banner/ob1.jpg',
  63. id: 3
  64. },
  65. {
  66. url: 'https://cdn.yfhl.net/static/banner/ob2.jpg',
  67. id: 3
  68. }, {
  69. url: 'https://cdn.yfhl.net/static/banner/ob3.jpg',
  70. id: 4
  71. }]
  72. // imgList: [
  73. // {
  74. // url: 'https://cdn.yfhl.net/static/banner/2.png',
  75. // id: 3
  76. // },
  77. // {
  78. // url: 'https://cdn.yfhl.net/static/banner/3.png',
  79. // id: 3
  80. // }, {
  81. // url: 'https://cdn.yfhl.net/static/banner/4.png',
  82. // id: 4
  83. // }, {
  84. // url: 'https://cdn.yfhl.net/static/banner/5.png',
  85. // id: 5
  86. // }]
  87. }
  88. },
  89. onShow() {
  90. if(uni.getStorageSync('token')){
  91. this.fetchNoticePaging();
  92. }else{
  93. getApp().loginCallBack = () => {
  94. this.fetchNoticePaging()
  95. }
  96. }
  97. },
  98. methods: {
  99. swiperChange(e) {
  100. this.current = e.detail.current
  101. },
  102. fetchNoticePaging() {
  103. noticePaging({
  104. size: 1,
  105. current: 1,
  106. params: {
  107. state: 0
  108. }
  109. }).then(data => {
  110. //打印请求返回的数据
  111. this.notice = data.records[0]
  112. }, error => {
  113. console.log(error);
  114. })
  115. },
  116. // 考试详情页
  117. navtoDetail(id) {
  118. uni.navigateTo({
  119. url: '/pages/exam/detail?id=' + id
  120. });
  121. },
  122. navigateToCourse(){
  123. uni.switchTab({
  124. url: '/pages/course/index'
  125. });
  126. },
  127. navigateToExam() {
  128. uni.switchTab({
  129. url: '/pages/exam/index'
  130. });
  131. },
  132. navigateToRepo() {
  133. uni.switchTab({
  134. url: '/pages/repo/index'
  135. });
  136. },
  137. navigateToPaper() {
  138. uni.navigateTo({
  139. url: '/pages/paper/index'
  140. });
  141. },
  142. navigateHistory() {
  143. uni.navigateTo({
  144. url: '/pages/repo/history'
  145. });
  146. },
  147. navigateToBattle(){
  148. uni.navigateTo({
  149. url: '/pages/battle/battle'
  150. });
  151. },
  152. selectedBanner(item, index) {
  153. console.log('🥒', item, index)
  154. },
  155. // 考试详情页
  156. navtoNotice(id) {
  157. uni.navigateTo({
  158. url: '/pages/notice/detail?id=' + id
  159. });
  160. },
  161. navitoVideo(){
  162. uni.navigateTo({
  163. url: '/pages/video/video'
  164. });
  165. }
  166. }
  167. }
  168. </script>
  169. <style>
  170. .flex-item{
  171. flex: 0 0 50%;
  172. }
  173. .item-box {
  174. display: flex;
  175. flex-direction: column;
  176. align-items: center;
  177. padding: 20px 30px 20px 30px;
  178. border: #E9F3FF 1px solid;
  179. border-radius: 5px;
  180. margin: 10px;
  181. box-shadow: 3px 3px 6px #DEEDFF;
  182. color: #ccc;
  183. }
  184. .item-box image {
  185. height: 40px;
  186. }
  187. .item-box .tt2 {
  188. color: #333;
  189. font-weight: 700;
  190. padding-top: 12px;
  191. }
  192. .notice {
  193. display: flex;
  194. align-items: center;
  195. border-top: #efefef 1px solid;
  196. border-bottom: #efefef 10px solid;
  197. padding: 10px 20px 10px 20px;
  198. }
  199. .notice .tt {
  200. font-weight: bold;
  201. color: #ff0000;
  202. border-right: #eee 2px solid;
  203. padding-right: 10px;
  204. }
  205. .notice .cc {
  206. flex-grow: 1;
  207. padding-left: 10px;
  208. color: #555;
  209. }
  210. .exam-item {
  211. display: flex;
  212. align-items: center;
  213. line-height: 25px;
  214. border-bottom: #f5f5f5 1px solid;
  215. margin-bottom: 10px;
  216. }
  217. .exam-item .left {
  218. text-align: left;
  219. flex-grow: 1;
  220. }
  221. .desc {
  222. color: #888;
  223. }
  224. .exam-item .left .icons {
  225. display: flex;
  226. align-items: center;
  227. color: #666;
  228. }
  229. .exam-item .right {
  230. text-align: right;
  231. }
  232. .nav {
  233. display: flex;
  234. align-items: center;
  235. align-content: space-around;
  236. line-height: 50px;
  237. color: #666;
  238. padding: 20px 0px 0px 0px;
  239. }
  240. .nav .item {
  241. display: flex;
  242. flex-direction: column;
  243. align-items: center;
  244. align-content: center;
  245. width: 25%;
  246. }
  247. .nav .item image {
  248. width: 32px;
  249. height: 32px;
  250. }
  251. .nav .item text {
  252. color: #666;
  253. }
  254. .tab {
  255. display: flex;
  256. align-items: center;
  257. padding: 10px 20px 10px 20px;
  258. border-bottom: #efefef 1px solid;
  259. }
  260. .tab .item {
  261. border-bottom: #fff 2px solid;
  262. color: #666;
  263. margin-right: 15px;
  264. padding-bottom: 5px;
  265. }
  266. .tab .active {
  267. border-bottom: #007AFF 2px solid;
  268. color: #007AFF;
  269. }
  270. </style>