FeedBack.vue
3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
  <div class="releaseStory">
    <div class="nav">
      <van-nav-bar left-arrow title="意见反馈" :fixed="true" @click-left="onClickLeft" />
    </div>
    <div class="cont">
      <div class="item">
        <textarea v-model="content" name="" id="" cols="30" rows="10" placeholder="请输入您要反馈的问题,我们将尽快回复~"></textarea>
      </div>
    </div>
    <div class="imgs">
      <van-uploader :after-read="uploadFile" @delete="deleFile" v-model="filelist" :max-count="3" />
    </div>
    <div class="btns">
      <span @click="AddFeedBack()">提交</span>
    </div>
  </div>
</template>
<script>
import Axios from 'axios'
export default {
  data() {
    return {
      userInfo: '',
      content: '',
      filelist: [],
      imgsrc: [],
    }
  },
  created() {
    var that = this
    var userInfo = localStorage.getItem('userInfo')
    if (userInfo) {
      this.userInfo = JSON.parse(userInfo)
    }
  },
  methods: {
    deleFile(file, detail) {
      this.imgsrc.splice(detail.index, 1)
    },
    uploadFile(file) {
      var that = this
      let params = new FormData()
      params.append('file', file.file)
      let config = {
        headers: {
          //添加请求头
          'Content-Type': 'multipart/form-data',
        },
      }
      Axios.post('http://121.40.30.78:5000/file/fileUpload', params, config).then((response) => {
        that.imgsrc.push(response.data)
      })
    },
    AddFeedBack() {
      var that = this
      this.$toast.loading({
        message: '请求中...',
      })
      this.http
        .AddFeedBack({
          content: this.content,
          userId: this.userInfo.centerNo,
          imgs: this.imgsrc.join(','),
        })
        .then(function (res) {
          that.$toast.clear()
          if (res.status == 1) {
            that.$toast.success('提交成功')
            setTimeout(function () {
              that.$router.push({ path: '/My' })
            }, 1000)
          }
        })
    },
    onClickLeft() {
      history.back()
    },
  },
}
</script>
<style lang="stylus" scoped>
.releaseStory{
	padding 20px
	padding-top 50px
	box-sizing border-box
	.btns{
		text-align center
		margin-top 20px
		span{
			display inline-block
			padding 10px 0
			width 80%
			text-align center
			border-radius 50px
			border 1px solid #ccc
			font-size 1.4rem
		}
		span:last-child{
			background-color #19D075
			color white
			border none
		}
	}
	.cont{
		textarea{
			width 100%
			font-size 1.2rem
			border none
		}
	}
	.imgs{
		padding 20px 0
		img:first-child::after{
			content '封面图片'
			position absolute
			bottom 0
			left 0
			right 0
			background-color rgba(0,0,0,.5)
			color white
			font-size 1.2rem
			padding 3px
			z-index 1000
		}
		img{
			position relative
			display inline-block
			vertical-align top
			width 50px
			height 50px
			border-radius 5px
			margin-right 10px
		}
		.selectImg{
			display inline-block
			vertical-align top
			width 50px
			height 50px
			text-align center
			line-height 50px
			border-radius 5px
			border 1px solid #eee
			font-size 2rem
			color #eee
		}
	}
}
</style>