index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <template>
  2. <div class="home">
  3. <div class="top-btns">
  4. <div class="row">
  5. <button class="btn" @click="toInvitePeople">
  6. <img src="@/assets/1.png" alt="邀请百姓" class="btn-icon" />
  7. <span>邀请百姓</span>
  8. </button>
  9. <button class="btn" @click="toOfficialGroup">
  10. <img src="@/assets/2.png" alt="官方群聊" class="btn-icon" />
  11. <span>官方群聊</span>
  12. </button>
  13. </div>
  14. <div class="kefu">
  15. <img src="@/assets/kefu.jpg" alt="客服" />
  16. </div>
  17. <div class="row">
  18. <button class="btn" @click="toAppDownload">
  19. <img src="@/assets/3.png" alt="APP下载" class="btn-icon" />
  20. <span>APP下载</span>
  21. </button>
  22. <button class="btn" @click="toCultureDetail">
  23. <img src="@/assets/4.png" alt="央企文化" class="btn-icon" />
  24. <span>央企文化</span>
  25. </button>
  26. </div>
  27. </div>
  28. <div class="carousel">
  29. <van-swipe
  30. :autoplay="3000"
  31. indicator-color="#ed4b39"
  32. style="width: 100%; height: 100px; border-radius: 8px; overflow: hidden;"
  33. >
  34. <van-swipe-item v-for="(banner, index) in banners" :key="index">
  35. <img
  36. :src="banner"
  37. alt="轮播图"
  38. style="width: 100%; height: 100px; object-fit: cover;"
  39. />
  40. </van-swipe-item>
  41. </van-swipe>
  42. </div>
  43. <div class="reward-section">
  44. <div class="reward-table">
  45. <div class="reward-row header">
  46. <span>团队奖励</span>
  47. <span>一级</span>
  48. <span>二级</span>
  49. <span>三级</span>
  50. </div>
  51. <div class="reward-row value">
  52. <span></span>
  53. <span>20%</span>
  54. <span>10%</span>
  55. <span>5%</span>
  56. </div>
  57. </div>
  58. <button
  59. class="party-btn"
  60. :class="{ 'is-member': userInfo.isdangyuan === 1 }"
  61. @click="userInfo.isdangyuan === 0 && toApply()"
  62. >
  63. {{ userInfo.isdangyuan === 1 ? '已是党员' : '党员申请' }}
  64. </button>
  65. </div>
  66. <div class="news-title">新闻中心</div>
  67. <div class="news-list">
  68. <div
  69. class="news_content"
  70. v-for="(news, index) in newsList"
  71. :key="index"
  72. v-html="news.content"
  73. ></div>
  74. </div>
  75. <van-dialog
  76. v-model="showAuthDialog"
  77. :show-confirm-button="false"
  78. :show-cancel-button="false"
  79. :close-on-click-overlay="true"
  80. class="auth-dialog"
  81. v-if="userInfo.if_real === 0"
  82. >
  83. <div class="close-icon-wrapper">
  84. <van-icon name="cross" class="close-icon" @click="showAuthDialog = false" />
  85. </div>
  86. <div class="auth-content">
  87. <p class="auth-text">你还未进行实名认证</p>
  88. <button class="auth-btn" @click="toAuth">去认证</button>
  89. </div>
  90. </van-dialog>
  91. <van-dialog
  92. v-model="showDialog"
  93. :show-confirm-button="false"
  94. :show-cancel-button="false"
  95. :close-on-click-overlay="true"
  96. class="welcome-dialog"
  97. v-if="userInfo.gonggao"
  98. >
  99. <div class="close-icon-wrapper">
  100. <van-icon name="cross" class="close-icon" @click="showDialog = false" />
  101. </div>
  102. <div class="dialog-title">{{userInfo.gonggao.title}}</div>
  103. <div class="dialog-content" v-html="userInfo.gonggao.value"></div>
  104. </van-dialog>
  105. </div>
  106. </template>
  107. <script>
  108. import { getBanners, getUserInfo, getNews } from '@/api/home';
  109. import { Swipe, SwipeItem, Dialog, Icon } from 'vant';
  110. import Vue from 'vue';
  111. export default {
  112. name: "Home",
  113. data() {
  114. return {
  115. banners: [],
  116. userInfo: {
  117. gonggao: null,
  118. if_real: 0,
  119. link: []
  120. },
  121. newsList: [],
  122. showDialog: true,
  123. showAuthDialog: false,
  124. };
  125. },
  126. components: {
  127. [Swipe.name]: Swipe,
  128. [SwipeItem.name]: SwipeItem,
  129. [Icon.name]: Icon,
  130. },
  131. created() {
  132. Vue.use(Dialog);
  133. },
  134. mounted() {
  135. this.getBanners();
  136. this.getUserInfo();
  137. this.getNewsDetail()
  138. },
  139. methods: {
  140. async getUserInfo() {
  141. const res = await getUserInfo();
  142. this.userInfo = res.data;
  143. if (this.userInfo.if_real === 0) {
  144. this.showAuthDialog = true;
  145. }
  146. },
  147. async getBanners() {
  148. const formData = new FormData();
  149. formData.append('cid', 5);
  150. const res = await getBanners(formData);
  151. this.banners = res.data
  152. },
  153. async getNewsDetail() {
  154. const res = await getNews()
  155. this.newsList = res.data
  156. },
  157. toOfficialGroup() {
  158. window.open(this.userInfo.link[2].value, '_blank');
  159. },
  160. toAppDownload() {
  161. window.open(this.userInfo.link[1].value, '_blank');
  162. },
  163. toCultureDetail() {
  164. this.$router.push('/culture/detail');
  165. },
  166. toInvitePeople() {
  167. this.$router.push('/InvitePeople');
  168. },
  169. toApply(){
  170. this.$router.push('/Apply');
  171. },
  172. toAuth() {
  173. this.$router.push('/user-center');
  174. this.showAuthDialog = false;
  175. }
  176. }
  177. };
  178. </script>
  179. <style lang="scss" scoped>
  180. .home {
  181. min-height: 100vh;
  182. width: 100%;
  183. background: url('~@/assets/dabag.png') no-repeat;
  184. background-size: cover;
  185. background-attachment: fixed;
  186. display: flex;
  187. flex-direction: column;
  188. padding:100px 18px 80px;
  189. box-sizing: border-box;
  190. position: relative;
  191. }
  192. .top-btns {
  193. width: 100%;
  194. display: flex;
  195. justify-content: space-between;
  196. margin-top: 15px;
  197. .row {
  198. display: flex;
  199. justify-content: center;
  200. flex-direction: column;
  201. margin-bottom: 12px;
  202. width: 28%;
  203. }
  204. .kefu {
  205. height: 80px;
  206. background: #fff;
  207. border: 2px solid #fff;
  208. width: 24%;
  209. img {
  210. width: 100%;
  211. height: 100%;
  212. object-fit: cover;
  213. }
  214. }
  215. .btn {
  216. width: 100%;
  217. height: 36px;
  218. background: #fff;
  219. border: none;
  220. border-radius: 6px;
  221. font-size: 14px;
  222. color: #000;
  223. font-weight: 500;
  224. box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  225. cursor: pointer;
  226. transition: background 0.2s;
  227. margin-bottom: 12px;
  228. display: flex;
  229. align-items: center;
  230. padding: 0 8px;
  231. white-space: nowrap;
  232. &:hover {
  233. background: #ffeaea;
  234. }
  235. .btn-icon {
  236. width: 18px;
  237. height: 18px;
  238. margin-right: 4px;
  239. flex-shrink: 0;
  240. }
  241. span {
  242. flex: 0 1 auto;
  243. text-align: left;
  244. }
  245. }
  246. }
  247. .carousel {
  248. width: 100%;
  249. max-width: 500px;
  250. margin: 0 auto 16px auto;
  251. height: 100px;
  252. background: #fff;
  253. border-radius: 8px;
  254. display: flex;
  255. align-items: center;
  256. justify-content: center;
  257. font-size: 20px;
  258. color: #b20000;
  259. font-weight: 500;
  260. box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  261. }
  262. .reward-section {
  263. width: 90%;
  264. background: #fff;
  265. border-radius: 8px;
  266. margin: 0 auto 16px auto;
  267. display: flex;
  268. align-items: center;
  269. justify-content: space-between;
  270. padding: 15px;
  271. box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  272. .reward-table {
  273. display: grid;
  274. grid-template-columns: 1.5fr 1fr 1fr 1fr;
  275. width: 100%;
  276. .reward-row {
  277. display: contents;
  278. &.header span,
  279. &.value span {
  280. padding: 4px 0;
  281. text-align: center;
  282. font-size: 12px;
  283. color: #000;
  284. }
  285. &.header span {
  286. font-weight: bold;
  287. }
  288. }
  289. .reward-row.value span {
  290. font-weight: 500;
  291. }
  292. }
  293. .party-btn {
  294. width: 130px;
  295. background: #ed4b39;
  296. color: #fff;
  297. border: none;
  298. border-radius: 20px;
  299. padding: 4px 8px;
  300. font-size: 14px;
  301. font-weight: 500;
  302. margin-left: 12px;
  303. cursor: pointer;
  304. transition: all 0.2s;
  305. &:hover {
  306. background: #c9301c;
  307. }
  308. &.is-member {
  309. background: #999;
  310. cursor: not-allowed;
  311. &:hover {
  312. background: #999;
  313. }
  314. }
  315. }
  316. }
  317. .news-title {
  318. width: 90%;
  319. margin: 24px auto 0 auto;
  320. color: #fff;
  321. font-size: 20px;
  322. font-weight: bold;
  323. text-shadow: 0 2px 8px rgba(0,0,0,0.12);
  324. }
  325. .news-list {
  326. width: 100%;
  327. padding-bottom: 40px;
  328. overflow-x: hidden;
  329. flex: 1;
  330. display: flex;
  331. flex-direction: column;
  332. }
  333. .news_content {
  334. width: 100%;
  335. min-height: 100px;
  336. border: none;
  337. margin: 16px auto 0;
  338. border-radius: 8px;
  339. background: #fff;
  340. padding: 15px;
  341. box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  342. box-sizing: border-box;
  343. &:last-child {
  344. margin-bottom: 20px;
  345. }
  346. :deep(p) {
  347. margin: 0;
  348. padding: 0;
  349. display: flex;
  350. align-items: flex-start;
  351. gap: 15px;
  352. flex-wrap: wrap;
  353. }
  354. :deep(img) {
  355. width: 120px;
  356. height: 90px;
  357. object-fit: cover;
  358. border-radius: 4px;
  359. flex-shrink: 0;
  360. }
  361. :deep(span) {
  362. flex: 1;
  363. min-width: 200px;
  364. font-size: 14px;
  365. line-height: 1.6;
  366. color: #333;
  367. }
  368. :deep(div) {
  369. width: 100%;
  370. display: flex;
  371. align-items: flex-start;
  372. gap: 15px;
  373. margin-bottom: 10px;
  374. }
  375. :deep(*:not(img)) {
  376. max-width: 100%;
  377. word-break: break-word;
  378. }
  379. }
  380. .close-icon-wrapper {
  381. position: absolute;
  382. top: 16px;
  383. right: 16px;
  384. z-index: 1;
  385. .close-icon {
  386. font-size: 20px;
  387. color: #969799;
  388. cursor: pointer;
  389. padding: 4px;
  390. &:hover {
  391. color: #323233;
  392. }
  393. }
  394. }
  395. .dialog-title {
  396. text-align: center;
  397. font-size: 18px;
  398. font-weight: bold;
  399. padding: 16px 0;
  400. margin-top: 8px;
  401. }
  402. .welcome-dialog {
  403. :deep(.van-dialog__content) {
  404. padding: 20px;
  405. position: relative;
  406. }
  407. }
  408. .dialog-content {
  409. max-width: 80%;
  410. max-height: 70vh;
  411. overflow-y: auto;
  412. text-align: center;
  413. padding: 20px 0;
  414. margin: 0 auto;
  415. p {
  416. margin: 10px 0;
  417. font-size: 16px;
  418. color: #333;
  419. }
  420. }
  421. .auth-dialog {
  422. :deep(.van-dialog__content) {
  423. padding: 30px 20px;
  424. position: relative;
  425. }
  426. }
  427. .auth-content {
  428. text-align: center;
  429. height: 120px;
  430. .auth-text {
  431. font-size: 16px;
  432. color: #333;
  433. margin-bottom: 20px;
  434. margin-top:12px;
  435. }
  436. .auth-btn {
  437. width: 83%;
  438. height: 36px;
  439. background: #ed4b39;
  440. color: #fff;
  441. border: none;
  442. border-radius: 18px;
  443. font-size: 14px;
  444. font-weight: 500;
  445. cursor: pointer;
  446. transition: background 0.2s;
  447. margin-top:20px;
  448. &:hover {
  449. background: #c9301c;
  450. }
  451. }
  452. }
  453. </style>