123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <template>
- <view class="feedback">
- <view class="header-bg"></view>
- <view class="header">
- <view class="title">
- 意见反馈
- </view>
- </view>
- <view class="" style="margin: 0 20upx;">
- <view class="">
- <label class="label" for="">我要反馈</label>
- <view style="background: white;margin: 20upx 0;border-radius: 10upx;">
- <view>
- <textarea class="textarea" v-model="form.content" placeholder="" maxlength="300" />
- </view>
- <view class="tips">您还能输入{{300-form.content.length}}个字符</view>
- </view>
- </view>
- <view class="">
- <label class="label" for="">上传图片</label>
- <view style="background: white;border-radius: 10upx;margin-top: 20upx;">
- <view class="images-wrapper">
- <view class="image-item" v-for="(image,i) in mainImages">
- <view class="del" @tap="mainImages.splice(i,1)">删除</view>
- <image class="image" :src="image|imagesFilter" mode="aspectFill" @tap="replaceImage(i)">
- </image>
- </view>
- <view class="image-item" v-if="mainImagesLimit>mainImages.length">
- <view class="add" @tap="addImage">
- <uni-icons type="plusempty" size="40" color="#EEEEEE" style="font-weight: 500;">
- </uni-icons>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="" style="margin-top: 100upx;">
- <button type="default" class="btn submit-btn" @tap="submit">提交</button>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- mainImages: [],
- mainImagesLimit: 4,
- form: {
- content: ''
- }
- }
- },
- methods: {
- addImage() {
- this.chooseImage().then((res) => {
- console.log(res)
- for (let i in res.tempFilePaths) {
- this.$http.upload({
- file: res.tempFiles[i],
- filePath: res.tempFilePaths[i],
- name: 'file',
- success: (res) => {
- console.log(res.data.data)
- this.mainImages.push(res.data.data.url)
- }
- })
- }
- });
- },
- replaceImage(index) {
- console.log(index)
- this.chooseImage().then((res) => {
- this.$http.upload({
- file: res.tempFiles[0],
- filePath: res.tempFilePaths[0],
- name: 'file',
- success: (res) => {
- // this.mainImages[index] = res.data.data.url
- this.$set(this.mainImages, index, res.data.data.url)
- }
- })
- });
- },
- chooseImage() {
- return new Promise((resolve, reject) => {
- uni.chooseImage({
- count: this.mainImagesLimit - this.mainImages.length,
- extension: ['jpg', 'png', 'bmp', 'jpeg'],
- success(res) {
- resolve(res)
- },
- fail(err) {
- reject(err)
- }
- })
- })
- },
- submit() {
- if (this.$verified.required(this.form.content,"请输入反馈内容")) {
- this.$http.post({
- url: "/feedback/create",
- data: this.form,
- success: (res) => {
- console.log(res)
- uni.showModal({
- title: "意见反馈",
- content: "提交成功,平台将于三个工作日之内为您处理",
- success: (res) => {
- if (res.confirm) {
- uni.navigateBack()
- }
- }
- })
- }
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .feedback {
- position: relative;
- overflow: hidden;
- }
- .header-bg {
- background: $primary-color;
- height: 100upx;
- position: absolute;
- top: 0;
- width: 100%;
- z-index: 1;
- }
- .header {
- margin: 20upx;
- background: white;
- text-align: center;
- border-radius: 20upx;
- position: relative;
- z-index: 2;
- .title {
- height: 100upx;
- font-size: 32upx;
- line-height: 100upx;
- // font-weight: bold;
- }
- }
- .label {
- font-size: 30upx;
- }
- .tips {
- font-size: 28upx;
- text-align: right;
- padding: 10upx;
- color: #999999;
- }
- .textarea {
- padding: 20upx;
- font-size: 28upx;
- width: 100%;
- box-sizing: border-box;
- }
- .images-wrapper {
- padding: 0;
- padding-top: 40upx;
- display: flex;
- flex-wrap: wrap;
- // justify-content: space-between;
- .image-item {
- position: relative;
- width: 25%;
- text-align: center;
- margin-bottom: 40upx;
- .del {
- position: absolute;
- top: 0;
- right: 30upx;
- z-index: 1;
- font-size: 24upx;
- background-color: $primary-color;
- color: white;
- padding: 2upx 15upx;
- }
- }
- .image {
- width: 120upx;
- height: 120upx;
- background: #EEEEEE;
- flex: 0 0 150upx;
- }
- .add {
- width: 120upx;
- height: 120upx;
- display: inline-block;
- line-height: 110upx;
- border: 8upx #EEEEEE solid;
- box-sizing: border-box;
- }
- }
- .submit-btn {
- font-size: 30upx;
- line-height: 60upx;
- width: 250upx;
- background: $primary-color;
- color: white;
- }
- </style>
|