Home.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div class="home">
  3. <a-alert :message="message" type="info" />
  4. <!-- 重置密码 -->
  5. <a-modal
  6. class="resetPwdModal"
  7. title="重置密码"
  8. width="60%"
  9. centered
  10. :footer="null"
  11. :closable="false"
  12. :maskClosable="false"
  13. :destroyOnClose="true"
  14. @cancel="openResetPwd=false"
  15. v-model="openResetPwd">
  16. <ResetPwd />
  17. </a-modal>
  18. <!-- 新产品上线提醒 -->
  19. <a-modal
  20. class="newProductTips"
  21. :title="'新产品'+(onlineFalg=='1'?'上':'下')+'线提醒'"
  22. :width="800"
  23. centered
  24. :footer="null"
  25. :maskClosable="false"
  26. :destroyOnClose="true"
  27. @cancel="cancelProductTips"
  28. v-model="openNewProduct">
  29. <newProduct :onlineFalg="onlineFalg" @seeMore="seeMore"></newProduct>
  30. </a-modal>
  31. </div>
  32. </template>
  33. <script>
  34. import { commonMixin } from '@/utils/mixin'
  35. import { mapGetters } from 'vuex'
  36. import ResetPwd from '@/views/user/ResetPwd.vue'
  37. import newProduct from '@/views/productManagement/newProduct/modal.vue'
  38. import { queryNewProductPage } from '@/api/product'
  39. export default {
  40. name: 'Home',
  41. mixins: [commonMixin],
  42. components: { ResetPwd, newProduct },
  43. data () {
  44. return {
  45. message: '欢迎登录' + process.env.VUE_APP_PRO_NAME,
  46. openResetPwd: false, // 重置密码是否显示
  47. openNewProduct: false,
  48. onlineFalg: '1' // 上下线标识 1为上线,0为下线
  49. }
  50. },
  51. computed: {
  52. ...mapGetters(['mustChangePwd'])
  53. },
  54. created () {
  55. },
  56. methods: {
  57. hasNewProduct () {
  58. queryNewProductPage({ pageNo: 1, pageSize: 20, onlineFalg: this.onlineFalg }).then(res => {
  59. if (res.status == 200) {
  60. if (res.data.count > 0) {
  61. this.openNewProduct = true
  62. } else {
  63. if (this.onlineFalg == '1') {
  64. this.onlineFalg = '0'
  65. this.hasNewProduct()
  66. }
  67. }
  68. }
  69. })
  70. },
  71. // 查看更多产品
  72. seeMore () {
  73. this.openNewProduct = false
  74. this.$router.push({ name: 'newProductList', params: { onlineFalg: this.onlineFalg } })
  75. },
  76. // 关闭弹框
  77. cancelProductTips () {
  78. const _this = this
  79. this.openNewProduct = false
  80. if (this.onlineFalg == '1') {
  81. this.onlineFalg = '0'
  82. setTimeout(() => { _this.hasNewProduct() }, 100)
  83. }
  84. }
  85. },
  86. beforeRouteEnter (to, from, next) {
  87. next(vm => {
  88. // 判断登录用户是否重置过密码(首次登陆需强制重置密码)
  89. if (vm.mustChangePwd == 0) {
  90. vm.openResetPwd = false
  91. if (from.name == 'login') {
  92. // 判断是否有新产品上线
  93. vm.hasNewProduct()
  94. }
  95. } else {
  96. vm.openResetPwd = true
  97. }
  98. })
  99. }
  100. }
  101. </script>
  102. <style scoped>
  103. .home {
  104. /* width: 900px;
  105. margin: 0 auto;
  106. padding: 25px 0; */
  107. }
  108. </style>