result.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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">返回 <a @click="go('/')">商城首页</a> | <a @click="go('/applyPurchase')">求购首页</a></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. isChange: false
  32. }
  33. },
  34. mounted () {
  35. if (this.state === 'success') {
  36. let interval = setInterval(() => {
  37. this.timer--
  38. if (this.timer === 0 && !this.isChange) {
  39. clearInterval(interval)
  40. window.location.href = '/user#/seekPurchase'
  41. } else if (this.timer < 0) {
  42. clearInterval(interval)
  43. }
  44. }, 1000)
  45. }
  46. },
  47. computed: {
  48. state () {
  49. return this.$route.query.status
  50. },
  51. count () {
  52. return this.$route.query.count || 0
  53. },
  54. user () {
  55. return this.$store.state.option.user
  56. }
  57. },
  58. methods: {
  59. upload: function (e) {
  60. let file = e.target.files[0]
  61. if (file) {
  62. let param = new FormData()
  63. param.append('file', file, file.name)
  64. param.append('chunk', '0')
  65. let config = {
  66. headers: {'Content-Type': 'multipart/form-data'}
  67. }
  68. this.$http.post('/seek/importBom', param, config)
  69. .then(response => {
  70. if (response.data.success) {
  71. window.open('/applyPurchase/' + response.data.data)
  72. } else {
  73. this.$message.error(response.data.message)
  74. }
  75. }, err => {
  76. console.log(err)
  77. if (!this.user.logged) {
  78. this.$router.push('/auth/login?returnUrl=' + window.location.href)
  79. } else {
  80. this.$message.error('上传失败, 系统错误')
  81. }
  82. })
  83. }
  84. },
  85. go: function (url) {
  86. this.isChange = true
  87. this.$router.push(url)
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .result {
  94. background: #f5f5f5;
  95. padding: 20px 0 103px 0;
  96. .container {
  97. background: #fff;
  98. text-align: center;
  99. height: 400px;
  100. > p {
  101. height: 40px;
  102. line-height: 40px;
  103. background: #e5edfc;
  104. margin: 0;
  105. font-weight: bold;
  106. font-size: 14px;
  107. padding-left: 22px;
  108. text-align: left;
  109. }
  110. > img {
  111. margin: 61px 0 25px 0;
  112. }
  113. > h1 {
  114. font-size: 18px;
  115. color: #fd4e4e;
  116. margin: 0 0 8px 0;
  117. }
  118. > h2 {
  119. font-size: 14px;
  120. margin: 0;
  121. span {
  122. color: #fd4e4e;
  123. }
  124. }
  125. .footer1 {
  126. margin-top: 38px;
  127. font-size: 16px;
  128. color: #666;
  129. label {
  130. input {
  131. display: none;
  132. }
  133. }
  134. a {
  135. color: #007aff;
  136. font-weight: normal;
  137. }
  138. span {
  139. color: #fd4e4e;
  140. margin-left: 10px;
  141. }
  142. }
  143. .footer2 {
  144. margin-top: 21px;
  145. a {
  146. &:first-child {
  147. color: #4290f7;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. </style>