home.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <div id="home">
  3. <!-- <test-user></test-user> -->
  4. <el-image style="width: 100%; height: 10rem" :src="url"></el-image>
  5. <el-row align="middle" class="menu_list">
  6. <!-- drawerTalk = true" -->
  7. <el-col :span="6" class="list_border" @click.native="toHtml('talkList.html#/')">
  8. <el-col :span="24"><div class="el-icon-school icon_zoom"></div></el-col>
  9. <el-col :span="24">
  10. <el-link type="info" :underline="false">宣讲会</el-link>
  11. </el-col>
  12. </el-col>
  13. <el-col :span="6" class="list_border" @click.native="toHtml('jobfairList.html#/')">
  14. <el-col :span="24"><div class="el-icon-s-custom icon_zoom"></div></el-col>
  15. <el-col :span="24">
  16. <el-link type="info" :underline="false">招聘会</el-link>
  17. </el-col>
  18. <el-drawer :visible.sync="drawerJobfair" direction="btt">
  19. <template #title>
  20. <el-row>
  21. <el-col :span="20">选择查看类型</el-col>
  22. </el-row>
  23. </template>
  24. <el-row class="drawer__row">
  25. <el-col :span="24" @click.native="toHtml('jobfairList.html#/?type=in')">
  26. <el-button type="text">校内招聘会</el-button>
  27. </el-col>
  28. <el-col :span="24" @click.native="toHtml('jobfairList.html#/?type=out')">
  29. <el-button type="text">校外招聘会</el-button>
  30. </el-col>
  31. </el-row>
  32. </el-drawer>
  33. </el-col>
  34. <el-col :span="6" class="list_border">
  35. <el-col :span="24"><div class="el-icon-s-platform icon_zoom"></div></el-col>
  36. <el-col :span="24"><el-link type="info" :underline="false" href="jobinfoList.html">在线招聘</el-link></el-col>
  37. </el-col>
  38. <el-col :span="6" class="list_border" @click.native="toHtml('jobsList.html#/')">
  39. <el-col :span="24"><div class="el-icon-school icon_zoom"></div></el-col>
  40. <el-col :span="24">
  41. <el-link type="info" :underline="false">招聘职位</el-link>
  42. </el-col>
  43. </el-col>
  44. <el-col :span="6" class="list_border" @click.native="toHtml('', 'check')">
  45. <el-col :span="24"><div class="el-icon-user icon_zoom"></div></el-col>
  46. <el-col :span="24"><el-link type="info" :underline="false">个人中心</el-link></el-col>
  47. </el-col>
  48. </el-row>
  49. <!-- list部分 -->
  50. <div class="list">
  51. <el-row class="tip" type="flex">
  52. <el-col :span="16">
  53. {{ news.title }}<b class="tip_en">{{ news.title }}</b>
  54. </el-col>
  55. <el-col :span="8" class="more" @click.native="toHtml(`newsList.html#/${news.id}?title=${news.title}`)">
  56. 查看更多
  57. </el-col>
  58. </el-row>
  59. <el-row type="flex" v-for="(item, index) in news.infoList" :key="index" class="data_list">
  60. <el-col :span="6"> 【{{ news.title }}】 </el-col>
  61. <el-col :span="18">{{ item.title }}</el-col>
  62. </el-row>
  63. </div>
  64. <div class="list">
  65. <el-row class="tip" type="flex">
  66. <el-col :span="16">
  67. {{ notice.title }}<b class="tip_en">{{ notice.title }}</b>
  68. </el-col>
  69. <el-col :span="8" class="more" @click.native="toHtml(`newsList.html#/${notice.id}?title=${notice.title}`)">
  70. 查看更多
  71. </el-col>
  72. </el-row>
  73. <el-row type="flex" v-for="(item, index) in notice.infoList" :key="index" class="data_list">
  74. <el-col :span="6"> 【{{ notice.title }}】 </el-col>
  75. <el-col :span="18">{{ item.title }}</el-col>
  76. </el-row>
  77. </div>
  78. <div class="list">
  79. <el-row class="tip" type="flex">
  80. <el-col :span="24"> 联系我们<b class="tip_en">CONTACT</b> </el-col>
  81. </el-row>
  82. <el-row style="font-size: 0.85rem;padding: 0 0.6rem;">
  83. <el-col :span="24" v-html="site.content"></el-col>
  84. </el-row>
  85. </div>
  86. <div class="list">
  87. <el-row class="tip" type="flex">
  88. <el-col :span="24"> 关注我们<b class="tip_en">WECHAT</b> </el-col>
  89. </el-row>
  90. <el-row>
  91. <el-col :span="24" style="text-align:center">
  92. <canvas id="canvas"></canvas>
  93. </el-col>
  94. </el-row>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import QRCode from 'qrcode';
  100. import { mapActions, mapState } from 'vuex';
  101. import testUser from '@/components/test-user.vue';
  102. import _ from 'lodash';
  103. export default {
  104. metaInfo() {
  105. return {
  106. title: this.siteTitle ? this.siteTitle : '就业信息网',
  107. };
  108. },
  109. name: 'home',
  110. props: {},
  111. components: {
  112. // testUser,
  113. },
  114. data: () => ({
  115. url: '',
  116. drawerTalk: false,
  117. drawerJobfair: false,
  118. drawerCenter: false,
  119. site: {},
  120. news: {},
  121. notice: {},
  122. siteTitle: '',
  123. }),
  124. async created() {
  125. await this.getSite();
  126. await this.getModule();
  127. this.$nextTick(() => {
  128. this.initQrcode();
  129. });
  130. },
  131. computed: {
  132. ...mapState({
  133. user: state => state.user.user,
  134. }),
  135. },
  136. methods: {
  137. ...mapActions(['siteOperation', 'moduleOperation', 'columnOperation', 'newsOperation']),
  138. toHtml(uri, type) {
  139. if (type) {
  140. let url = '';
  141. if (typeof this.user === 'object') {
  142. this.user.corpid === undefined ? (url = 'student.html#/') : (url = 'http://hr.smart.cc-lotus.info/mobile/');
  143. } else {
  144. url = 'register.html#/';
  145. }
  146. window.location.href = url;
  147. } else {
  148. window.location.href = uri;
  149. }
  150. },
  151. async getSite() {
  152. let site = sessionStorage.getItem('site');
  153. if (!site) {
  154. let result = await this.siteOperation({ type: 'search', data: { site: this.$site } });
  155. if (`${result.errcode}` === `0`) {
  156. sessionStorage.setItem('site', JSON.stringify(result.data));
  157. this.$set(this, `site`, result.data);
  158. this.$set(this, `siteTitle`, this.site.name);
  159. }
  160. } else {
  161. this.$set(this, `site`, JSON.parse(site));
  162. this.$set(this, `siteTitle`, this.site.name);
  163. }
  164. this.$set(this, `url`, this.site.banner);
  165. },
  166. //获取固定的4个模块
  167. async getModule() {
  168. //获取分站所有模块 TODO:site=>_tenant
  169. let result = await this.moduleOperation({ type: 'list' });
  170. if (`${result.errcode}` === '0') {
  171. let moduleList = result.data;
  172. for (let item of moduleList) {
  173. //item为模块信息,拿着模块信息去查该模块下有什么栏目
  174. if (`${item.is_use}` === '0') {
  175. item = await this.getColumn(item);
  176. await this.makeList(item);
  177. } // console.log(item);
  178. }
  179. }
  180. },
  181. //根据条件获取栏目
  182. async getColumn(item) {
  183. let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id } });
  184. //查詢模块下所有的栏目(因为修改关联方是:抓取栏目和正常栏目关联,栏目类型(type)为bugList.所以bugList需要用content_id再去查下面关联的信息
  185. if (`${res.errcode}` === '0') {
  186. for (const col of res.data) {
  187. if (col.type === 'bugList') {
  188. col.path = `/info/list/${col.content_id}`;
  189. col.children = await this.getNewsList(col, '0');
  190. } else if (col.type === 'column') {
  191. col.path = `/info/list/${col.id}`;
  192. col.children = await this.getNewsList(col, '1');
  193. } else if (col.type === 'content') {
  194. col.path = `/info/detail?id=${col.content_id}`;
  195. }
  196. }
  197. item.children = res.data;
  198. }
  199. return item;
  200. },
  201. //根据条件获取信息
  202. async getNewsList(item, news_type) {
  203. let data = { skip: 0, limit: 4, news_type: news_type };
  204. data.parent_id = news_type === '1' ? item.id : item.content_id;
  205. let res = await this.newsOperation({ type: 'list', data: data });
  206. if (`${res.errcode}` === '0') {
  207. for (const val of res.data) {
  208. let result = await this.newsOperation({ type: 'search', data: { id: val.id } });
  209. if (`${result.errcode}` === '0') {
  210. val.content = result.data.content;
  211. } else {
  212. this.$message.error(result.errmsg ? result.errmsg : 'error');
  213. }
  214. }
  215. return res.data;
  216. } else {
  217. this.$message.error(res.errmsg ? res.errmsg : 'error');
  218. }
  219. },
  220. //组合数据
  221. makeList(item) {
  222. if (!item) return;
  223. if (item.category === 'news') {
  224. let arr = [];
  225. let colObject = {};
  226. for (const col of item.children) {
  227. if (!colObject.id) colObject = col;
  228. for (const news of col.children) {
  229. arr.push(news);
  230. }
  231. }
  232. let object = { ...JSON.parse(JSON.stringify(item)), infoList: arr, column: colObject };
  233. this.$set(this, `news`, object);
  234. } else if (item.category === 'notice') {
  235. let arr = [];
  236. let colObject = {};
  237. for (const col of item.children) {
  238. if (!colObject.id) colObject = col;
  239. for (const news of col.children) {
  240. arr.push(news);
  241. }
  242. }
  243. let object = { ...JSON.parse(JSON.stringify(item)), infoList: arr, column: colObject };
  244. // console.log(object);
  245. this.$set(this, `notice`, object);
  246. }
  247. },
  248. async initQrcode() {
  249. let url = 'http://smart.cc-lotus.info/weixin/auth?redirect_uri=http://smart.cc-lotus.info/mobile/#/';
  250. await QRCode.toCanvas(document.getElementById('canvas'), url, {
  251. width: 100,
  252. margin: 0,
  253. // color: { dark: '#ff4400' }, //{ dark: this.$route.query.type === '0' ? '#00ff14' : '#FF9900' }
  254. });
  255. },
  256. },
  257. };
  258. </script>
  259. <style lang="less" scoped>
  260. .title {
  261. height: 3rem;
  262. }
  263. .menu_list {
  264. padding: 0.5rem 1rem;
  265. }
  266. .list_border {
  267. border: 0.0625rem solid #ebeced;
  268. height: 3.5rem;
  269. text-align: center;
  270. padding: 0.3rem 0;
  271. }
  272. .icon_zoom {
  273. zoom: 1.5;
  274. }
  275. .list_word {
  276. // line-height: 5rem;
  277. font-size: 0.625rem;
  278. }
  279. .list {
  280. margin-bottom: 0.7rem;
  281. }
  282. .tip {
  283. border-left: 0.1875rem solid #25b6ed;
  284. color: #000;
  285. font-size: 1.2rem;
  286. margin-bottom: 0.6rem;
  287. padding: 0.5rem 0 0.5rem 0.8rem;
  288. }
  289. .tip_en {
  290. margin-left: 0.5rem;
  291. color: #ccc;
  292. font-size: 1rem;
  293. font-style: italic;
  294. }
  295. .more {
  296. text-align: right;
  297. margin-right: 0.5rem;
  298. color: #ccc;
  299. font-size: 1rem;
  300. }
  301. .data_list {
  302. font-size: 0.85rem;
  303. overflow: hidden;
  304. white-space: nowrap;
  305. text-overflow: ellipsis;
  306. }
  307. .drawer__row {
  308. .el-col {
  309. border-bottom: 0.0625rem solid #eee;
  310. text-align: center;
  311. }
  312. }
  313. </style>