index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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: 'http://124.70.18.168:8617/upload/file/banner/ob1.jpg',
  63. id: 3
  64. }, {
  65. url: 'http://124.70.18.168:8617/upload/file/banner/ob2.jpg',
  66. id: 4
  67. }]
  68. // imgList: [
  69. // {
  70. // url: 'https://cdn.yfhl.net/static/banner/2.png',
  71. // id: 3
  72. // },
  73. // {
  74. // url: 'https://cdn.yfhl.net/static/banner/3.png',
  75. // id: 3
  76. // }, {
  77. // url: 'https://cdn.yfhl.net/static/banner/4.png',
  78. // id: 4
  79. // }, {
  80. // url: 'https://cdn.yfhl.net/static/banner/5.png',
  81. // id: 5
  82. // }]
  83. }
  84. },
  85. onShow() {
  86. if(uni.getStorageSync('token')){
  87. this.fetchNoticePaging();
  88. }else{
  89. getApp().loginCallBack = () => {
  90. this.fetchNoticePaging()
  91. }
  92. }
  93. },
  94. methods: {
  95. swiperChange(e) {
  96. this.current = e.detail.current
  97. },
  98. fetchNoticePaging() {
  99. noticePaging({
  100. size: 1,
  101. current: 1,
  102. params: {
  103. state: 0
  104. }
  105. }).then(data => {
  106. //打印请求返回的数据
  107. this.notice = data.records[0]
  108. }, error => {
  109. console.log(error);
  110. })
  111. },
  112. // 考试详情页
  113. navtoDetail(id) {
  114. uni.navigateTo({
  115. url: '/pages/exam/detail?id=' + id
  116. });
  117. },
  118. navigateToCourse(){
  119. uni.switchTab({
  120. url: '/pages/course/index'
  121. });
  122. },
  123. navigateToExam() {
  124. uni.switchTab({
  125. url: '/pages/exam/index'
  126. });
  127. },
  128. navigateToRepo() {
  129. uni.switchTab({
  130. url: '/pages/repo/index'
  131. });
  132. },
  133. navigateToPaper() {
  134. uni.navigateTo({
  135. url: '/pages/paper/index'
  136. });
  137. },
  138. navigateHistory() {
  139. uni.navigateTo({
  140. url: '/pages/repo/history'
  141. });
  142. },
  143. navigateToBattle(){
  144. uni.navigateTo({
  145. url: '/pages/battle/battle'
  146. });
  147. },
  148. selectedBanner(item, index) {
  149. console.log('🥒', item, index)
  150. },
  151. // 考试详情页
  152. navtoNotice(id) {
  153. uni.navigateTo({
  154. url: '/pages/notice/detail?id=' + id
  155. });
  156. },
  157. navitoVideo(){
  158. uni.navigateTo({
  159. url: '/pages/video/video'
  160. });
  161. }
  162. }
  163. }
  164. </script>
  165. <style>
  166. .flex-item{
  167. flex: 0 0 50%;
  168. }
  169. .item-box {
  170. display: flex;
  171. flex-direction: column;
  172. align-items: center;
  173. padding: 20px 30px 20px 30px;
  174. border: #E9F3FF 1px solid;
  175. border-radius: 5px;
  176. margin: 10px;
  177. box-shadow: 3px 3px 6px #DEEDFF;
  178. color: #ccc;
  179. }
  180. .item-box image {
  181. height: 40px;
  182. }
  183. .item-box .tt2 {
  184. color: #333;
  185. font-weight: 700;
  186. padding-top: 12px;
  187. }
  188. .notice {
  189. display: flex;
  190. align-items: center;
  191. border-top: #efefef 1px solid;
  192. border-bottom: #efefef 10px solid;
  193. padding: 10px 20px 10px 20px;
  194. }
  195. .notice .tt {
  196. font-weight: bold;
  197. color: #ff0000;
  198. border-right: #eee 2px solid;
  199. padding-right: 10px;
  200. }
  201. .notice .cc {
  202. flex-grow: 1;
  203. padding-left: 10px;
  204. color: #555;
  205. }
  206. .exam-item {
  207. display: flex;
  208. align-items: center;
  209. line-height: 25px;
  210. border-bottom: #f5f5f5 1px solid;
  211. margin-bottom: 10px;
  212. }
  213. .exam-item .left {
  214. text-align: left;
  215. flex-grow: 1;
  216. }
  217. .desc {
  218. color: #888;
  219. }
  220. .exam-item .left .icons {
  221. display: flex;
  222. align-items: center;
  223. color: #666;
  224. }
  225. .exam-item .right {
  226. text-align: right;
  227. }
  228. .nav {
  229. display: flex;
  230. align-items: center;
  231. align-content: space-around;
  232. line-height: 50px;
  233. color: #666;
  234. padding: 20px 0px 0px 0px;
  235. }
  236. .nav .item {
  237. display: flex;
  238. flex-direction: column;
  239. align-items: center;
  240. align-content: center;
  241. width: 25%;
  242. }
  243. .nav .item image {
  244. width: 32px;
  245. height: 32px;
  246. }
  247. .nav .item text {
  248. color: #666;
  249. }
  250. .tab {
  251. display: flex;
  252. align-items: center;
  253. padding: 10px 20px 10px 20px;
  254. border-bottom: #efefef 1px solid;
  255. }
  256. .tab .item {
  257. border-bottom: #fff 2px solid;
  258. color: #666;
  259. margin-right: 15px;
  260. padding-bottom: 5px;
  261. }
  262. .tab .active {
  263. border-bottom: #007AFF 2px solid;
  264. color: #007AFF;
  265. }
  266. </style>