index.vue 5.8 KB

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