index.vue 5.7 KB

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