<template>
  <HeaderNav :title="title" :is-back="true"></HeaderNav>
  <view class="body-background">

  </view>
  <u-row :custom-style="{padding:'16rpx 26rpx',boxSizing:'border-box'}">
    <u-col :span="12" :custom-style="{
      backgroundColor:'#FFFFFF',
      borderRadius:'20rpx',
      padding:'40rpx 32rpx',
      position:'relative'
    }">
      <u-form
          errorType="toast"
          labelWidth="auto"
          labelPosition="left"
          :model="model"
          :rules="rules"
          ref="feedForm"
      >
        <u-form-item
            label="手机号"
            prop="connect"
            borderBottom
            :custom-style="{padding:'34rpx 0'}"
        >
          <u-input
              v-model="model.connect"
              inputAlign="right"
              disabledColor="#ffffff"
              placeholder="请填写帮填用户手机号"
              border="none"
              :custom-style="{paddingRight:'28rpx'}"
          ></u-input>
        </u-form-item>
      </u-form>
      <view class="bottom-btn border-box" style="box-sizing: border-box;">
        <MzButton button-color="#4EC2B7" button-width="100%" font-color="#fff" @click="submit"></MzButton>
      </view>
    </u-col>
  </u-row>
</template>

<script>
import {
  imghost
} from '@/config/host.js'
import api from '@/utils/functions.js';
import HeaderNav from "@/components/HeaderNav/Index.vue";
import MzButton from "@/components/MzButton/Index.vue";
import {feedback} from "@/api/other";

export default {
  components: {
    MzButton,
    HeaderNav,
  },
  data() {
    return {
      title: '帮填',
      loading: true,
      staticImage: {
        bg: imghost + '/BG.png',
        newIcon: imghost + '/new-icon.png',
      },
      isTop: false,
      fileList:[],
      model:{
        connect:'',
        remark:'',
        file:[]
      },
      rules:{
        'connect': {
          type: 'string',
          required: true,
          message: '请填写帮填用户手机号',
          trigger: ['blur', 'change']
        },
      },
    }
  },
  onLoad() {

  },
  computed: {
    api() {
      return api
    },
  },
  methods: {
    submit(){
        feedback(this.model).then((res) => {
          if(res.code === 200){
            uni.$u.toast('反馈成功')
            let user = uni.getStorageSync('user');
            uni.setStorageSync('workerToken',user);
            api.logout();
            uni.setStorageSync('token',res.data);
            this.model = {
              connect:'',
              remark:'',
              file:[]
            }
            this.fileList = [];
          }else{
            uni.$u.toast(res.msg)
          }
        })

    },
  },
  onPageScroll(res) {
    if (res.scrollTop <= 20) {
      uni.$emit('isTop', true);
    } else {
      uni.$emit('isTop', false);
    }
  },
  created() {

  }
}
</script>

<style lang="scss">
@import './components/index.scss';
</style>