result.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="result">
  3. <div class="container" v-if="state == 'success'">
  4. <p>发布求购</p>
  5. <img src="/images/applyPurchase/batch-success.png" alt="">
  6. <h1>发布成功</h1>
  7. <h2>成功发布 <span>{{count}}</span> 条求购</h2>
  8. <div class="footer1">前往 <a href="/user#/seekPurchase">买家中心-我的求购</a> <span>{{timer}}s</span></div>
  9. <div class="footer2">返回 <nuxt-link to="/">商城首页</nuxt-link> | <nuxt-link to="/applyPurchase">求购首页</nuxt-link></div>
  10. </div>
  11. <div class="container" v-else>
  12. <p>发布求购</p>
  13. <img src="/images/applyPurchase/batch-error.png" alt="">
  14. <h1>上传失败</h1>
  15. <h2>请完善产品信息</h2>
  16. <div class="footer1">立刻
  17. <label>
  18. <input type="file" @change="upload" accept="*.xls, *.xlsx">
  19. <a>重新上传</a>
  20. </label>
  21. </div>
  22. <div class="footer2">返回 <nuxt-link to="/">商城首页</nuxt-link> | <nuxt-link to="/applyPurchase">求购首页</nuxt-link></div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. export default {
  28. data () {
  29. return {
  30. timer: 5
  31. }
  32. },
  33. mounted () {
  34. if (this.state === 'success') {
  35. setInterval(() => {
  36. this.timer--
  37. if (this.timer === 0) {
  38. window.location.href = '/user#/seekPurchase'
  39. }
  40. }, 1000)
  41. }
  42. },
  43. computed: {
  44. state () {
  45. return this.$route.query.status
  46. },
  47. count () {
  48. return this.$route.query.count || 0
  49. },
  50. user () {
  51. return this.$store.state.option.user
  52. }
  53. },
  54. methods: {
  55. upload: function (e) {
  56. let file = e.target.files[0]
  57. if (file) {
  58. let param = new FormData()
  59. param.append('file', file, file.name)
  60. param.append('chunk', '0')
  61. let config = {
  62. headers: {'Content-Type': 'multipart/form-data'}
  63. }
  64. this.$http.post('/seek/importBom', param, config)
  65. .then(response => {
  66. if (response.data.success) {
  67. window.open('/applyPurchase/' + response.data.data)
  68. } else {
  69. this.$message.error(response.data.message)
  70. }
  71. }, err => {
  72. console.log(err)
  73. if (!this.user.logged) {
  74. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  75. } else {
  76. this.$message.error('上传失败, 系统错误')
  77. }
  78. })
  79. }
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .result {
  86. background: #f5f5f5;
  87. padding: 20px 0 103px 0;
  88. .container {
  89. background: #fff;
  90. text-align: center;
  91. height: 400px;
  92. > p {
  93. height: 40px;
  94. line-height: 40px;
  95. background: #e5edfc;
  96. margin: 0;
  97. font-weight: bold;
  98. font-size: 14px;
  99. padding-left: 22px;
  100. text-align: left;
  101. }
  102. > img {
  103. margin: 61px 0 25px 0;
  104. }
  105. > h1 {
  106. font-size: 18px;
  107. color: #fd4e4e;
  108. margin: 0 0 8px 0;
  109. }
  110. > h2 {
  111. font-size: 14px;
  112. margin: 0;
  113. span {
  114. color: #fd4e4e;
  115. }
  116. }
  117. .footer1 {
  118. margin-top: 38px;
  119. font-size: 16px;
  120. color: #666;
  121. label {
  122. input {
  123. display: none;
  124. }
  125. }
  126. a {
  127. color: #007aff;
  128. font-weight: normal;
  129. }
  130. span {
  131. color: #fd4e4e;
  132. margin-left: 10px;
  133. }
  134. }
  135. .footer2 {
  136. margin-top: 21px;
  137. a {
  138. &:first-child {
  139. color: #4290f7;
  140. }
  141. }
  142. }
  143. }
  144. }
  145. </style>