login.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="ng-scope">
  3. <div class="waphide">
  4. <navbar :user="userInfo" @openLoginDialog="openLoginDialog"></navbar>
  5. </div>
  6. <div class="p-wrap-full clear">
  7. <div class="banner">
  8. <div class="category" style="height: 350px;overflow: hidden;">
  9. <div class="category-title">培训类别</div>
  10. <div class="category-tit clear">
  11. <div class="btn-box" v-for="(item, index) in typeList" :key="index" v-show="item.isNew==0">
  12. <el-button @click="gotoCategory(item)" type="primary" style="width: 240px;font-size: 20px;">
  13. {{ item.name }}
  14. </el-button>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="m-login opacity-bg">
  20. <is-login v-if="loginOk" :user="userInfo" @logout="logout"></is-login>
  21. <un-login v-else @login="login" :err="err"></un-login>
  22. </div>
  23. </div>
  24. <div class="p-wrap-full ng-scope waphide">
  25. <div class="title-box mt5 clear">
  26. <h2 class="title">文件通知</h2>
  27. </div>
  28. <el-card style="margin-top: 10px;">
  29. <el-table :data="postList" highlight-current-row
  30. :show-header="false" height="240px" >
  31. <el-table-column min-width="600px">
  32. <template slot-scope="{row, $index}">
  33. <span @click="gotoDetail(row.postId)">{{(page*size)-size+$index+1}}、{{ row.title }}</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column width="160px">
  37. <template slot-scope="{row}">
  38. <span>{{ row.publishTime }}</span>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. <el-pagination class="tc m-page"
  43. @current-change="handlePageChange"
  44. :current-page="page"
  45. :page-size="size"
  46. layout="total, prev, pager, next"
  47. :total="total">
  48. </el-pagination>
  49. </el-card>
  50. </div>
  51. <div class="p-wrap-full ng-scope waphide">
  52. <div class="title-box mt5 clear">
  53. <h2 class="title">友情链接</h2>
  54. </div>
  55. <friendlink></friendlink>
  56. </div>
  57. <el-dialog
  58. class="fc tc login-dialog"
  59. :visible.sync="loginDialog"
  60. :show-close='false'
  61. width="330px"
  62. style="padding:0px;"
  63. @close="closeDialog"
  64. >
  65. <div class="m-login" style="background: none;">
  66. <un-login @login="login" :err="err"></un-login>
  67. </div>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import isLogin from "./components/isLogin.vue";
  73. import unLogin from "./components/unLogin.vue";
  74. import LearnTime from "./components/learnTime/learnTime.vue";
  75. import navbar from "@/components/nav/navbar.vue";
  76. import Friendlink from "./components/friendlink/friendlink.vue";
  77. import { httpServer } from "@/components/httpServer/httpServer.js";
  78. import { mapGetters,mapActions } from "vuex";
  79. export default {
  80. components: {
  81. isLogin,
  82. unLogin,
  83. Friendlink,
  84. navbar
  85. },
  86. data() {
  87. return {
  88. loginOk: false,
  89. periodObj: {
  90. userName: "",
  91. idNum: "",
  92. },
  93. postList:[],
  94. page:1,
  95. size: 5,
  96. total:0,
  97. loginDialog: false,
  98. err: {}
  99. };
  100. },
  101. computed: {
  102. ...mapGetters("user", ["typeList", "userInfo"])
  103. },
  104. // beforeMount(){
  105. // if( this.userInfo && this.userInfo.token){
  106. // this.loginOk = true
  107. // }else{
  108. // this.loginOk = false
  109. // }
  110. // },
  111. created(){
  112. this.loadTypeList()
  113. this.getPostList()
  114. this.loginOk = false
  115. if( this.userInfo && this.userInfo.token && this.userInfo.uid){
  116. this.loadBaseInfo().then(res=>{
  117. if( !res || !res.uid ){
  118. this.loginOk = false
  119. this.doLogout()
  120. }else{
  121. this.loginOk = true
  122. }
  123. })
  124. }
  125. },
  126. methods: {
  127. ...mapActions("user", ["loadBaseInfo", "loadTypeList", "doLogout", "doLogin"]),
  128. logout() {
  129. this.doLogout().then( res=>{
  130. console.log("loginOk", res);
  131. this.loginOk = false;
  132. } )
  133. },
  134. login(param, cb) {
  135. this.doLogin( param ).then( res => {
  136. if( !res ){
  137. this.err.loginErrorEnter = "登入失败"
  138. this.loginOk = false;
  139. cb &&cb()
  140. }else{
  141. this.loginOk = true;
  142. this.loginDialog = false;
  143. }
  144. })
  145. },
  146. getPostList(){
  147. let {page,size} = this;
  148. let param = {page,size}
  149. httpServer("course.getPostList", param).then( res=>{
  150. if( res.code == 200){
  151. this.postList = res.data.list
  152. this.total = res.data.total;
  153. }
  154. })
  155. },
  156. handlePageChange(page){
  157. this.page = page;
  158. this.getPostList()
  159. },
  160. gotoDetail(postId){
  161. this.$router.push({name:'news', query:{postId}})
  162. },
  163. gotoCourse(item){
  164. if( item.link ){
  165. window.open(item.link)
  166. return;
  167. }
  168. if ( !localStorage.token ) {
  169. this.$message.successMsg("请先登入", 1)
  170. return
  171. }
  172. if( !item.isOpen ){
  173. this.$message.errorMsg("暂未开放", 1)
  174. return
  175. }
  176. if( item.isNew){
  177. this.$router.push( {path:'/center/trainMarket', query:{type: item.name}})
  178. }else{
  179. this.$router.push( {path:'/center/market', query:{type: item.name}})
  180. }
  181. },
  182. closeDialog() {
  183. this.loginDialog = false;
  184. },
  185. openLoginDialog() {
  186. this.loginDialog = true
  187. },
  188. gotoCategory(item) {
  189. this.$router.push({path: '/center/market', query: {type: item.label}})
  190. },
  191. },
  192. };
  193. </script>
  194. <style>
  195. @import url("login.css");
  196. .floatbox{
  197. position: fixed;
  198. width: 160px;
  199. height: 60px;
  200. right: 60px;
  201. top: 90px;
  202. border-radius: 1.25rem;
  203. font-size: 30px !important;
  204. background-color: orange;
  205. line-height: 40px;
  206. text-align: center;
  207. color: #fff;
  208. }
  209. .right-nav {
  210. width: 135px;
  211. height: 180px;
  212. background-color: #8bbdf5;
  213. position: fixed;
  214. transition: bottom ease .9s;
  215. z-index: 0;
  216. right: 5px;
  217. top: 260px;
  218. text-align: center;
  219. border-radius: 5px;
  220. }
  221. .right-img {
  222. display: inline-block;
  223. border-radius: 30%;
  224. width: 80%;
  225. height: 64%;
  226. margin: 11px auto 0;
  227. }
  228. </style>