|
|
@@ -1,181 +1,227 @@
|
|
|
<template>
|
|
|
- <view class="feedbox">
|
|
|
- <u-form :model="model" :rules="rules" ref="uForm" :errorType="errorType">
|
|
|
- <u-form-item label="反馈内容" prop="content" label-width="150">
|
|
|
- <u-input type="textarea" :border="border" placeholder="请输入您的投诉/建议" v-model="model.content" />
|
|
|
- </u-form-item>
|
|
|
- <u-form-item label="图片说明" prop="images" label-width="150">
|
|
|
- <!-- <u-upload></u-upload> -->
|
|
|
- <!-- width="160" height="160" -->
|
|
|
- <u-upload width="160" height="160"
|
|
|
- max-count='1'
|
|
|
- v-model="formData.file"
|
|
|
- :action="action"
|
|
|
- :file-list="fileList"
|
|
|
- :name="uploadName"
|
|
|
- :header="uploadHeader"
|
|
|
- :form-data="formData"
|
|
|
- @on-error="onError"
|
|
|
- @on-remove="onRemove"
|
|
|
- @on-success="onSuccess"></u-upload>
|
|
|
- </u-form-item>
|
|
|
- <u-form-item label="联系方式" prop="contact" label-width="150">
|
|
|
- <!-- type="number" -->
|
|
|
- <!-- <u-input :border="border" placeholder="请输入联系方式" v-model="model.contact"></u-input> -->
|
|
|
- <u-input :border="border" placeholder="请输入您的手机号" v-model="model.contact" type="number"></u-input>
|
|
|
- </u-form-item>
|
|
|
- </u-form>
|
|
|
- <view class="submitBtn">
|
|
|
- <u-button class="" type="primary" @click="submit">提交</u-button>
|
|
|
- </view>
|
|
|
-
|
|
|
-
|
|
|
- </view>
|
|
|
+ <view class="feedback-page">
|
|
|
+ <!-- 顶部banner -->
|
|
|
+ <view class="banner">
|
|
|
+ <image src="../static/feedback.png" mode="aspectFill" class="banner-img"></image>
|
|
|
+ <text class="history-btn" @click="goToHistory">我的历史反馈</text>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 反馈类型区域 -->
|
|
|
+ <view class="form-item type-section flex-a flex-j-b">
|
|
|
+ <view class="label" style="margin-bottom: 0;">
|
|
|
+ 反馈类型
|
|
|
+ <text class="required">*</text>
|
|
|
+ </view>
|
|
|
+ <view class="picker-box" @click="showTypePicker">
|
|
|
+ <text :class="['picker-text', !model.type && 'placeholder']">
|
|
|
+ {{ model.type || '请选择反馈类型' }}
|
|
|
+ </text>
|
|
|
+ <u-icon name="arrow-right" color="#999" size="32" top="2rpx"></u-icon>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 反馈描述区域 -->
|
|
|
+ <view class="form-item content-section">
|
|
|
+ <view class="label">
|
|
|
+ 反馈描述
|
|
|
+ <text class="required">*</text>
|
|
|
+ </view>
|
|
|
+ <view class="textarea-box">
|
|
|
+ <u-input type="textarea" v-model="model.content" placeholder="请输入不少于10个字的描述" :height="200"></u-input>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 图片上传区域 -->
|
|
|
+ <view class="form-item upload-section">
|
|
|
+ <view class="label">上传图片(最多五张):</view>
|
|
|
+ <view class="upload-box">
|
|
|
+ <u-upload :file-list="fileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple
|
|
|
+ :max-count="5" :previewFullImage="true"></u-upload>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 提交按钮 -->
|
|
|
+ <view class="bottom-fixed-con">
|
|
|
+ <button class="common-btn" @click="submit">提交</button>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 反馈类型选择器 -->
|
|
|
+ <u-picker v-model="showPicker" :range="feedbackTypes" @confirm="onTypeConfirm" @cancel="showPicker = false"
|
|
|
+ mode="selector"></u-picker>
|
|
|
+ </view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { hex_sha1 } from '@/utils/sha1.js'
|
|
|
-import { objKeySort,naviBackEmit } from '@/utils/tools.js'
|
|
|
export default {
|
|
|
- data() {
|
|
|
- let that = this;
|
|
|
- let secret = 'yrb1vdc2qc'
|
|
|
- let formData = {
|
|
|
- target: "oss",
|
|
|
- type: 'image',
|
|
|
- }
|
|
|
- let sign = hex_sha1(secret + objKeySort(formData));
|
|
|
- console.log(sign);
|
|
|
- return {
|
|
|
- action: this.$env.apiUrl + "/api/client/index/upload",
|
|
|
- uploadName: 'file',
|
|
|
- uploadHeader:{
|
|
|
- 'Content-Type': 'multipart/form-data',
|
|
|
- sign,
|
|
|
- },
|
|
|
- formData:{
|
|
|
- target: "oss",
|
|
|
- type: 'image',
|
|
|
- file:null
|
|
|
- },
|
|
|
- fileList:[],
|
|
|
- border: false,
|
|
|
- errorType: ['message'],
|
|
|
- model: {
|
|
|
- content: '',
|
|
|
- contact: '',
|
|
|
- images: ''
|
|
|
- },
|
|
|
- rules: {
|
|
|
- content: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入您的投诉/建议'
|
|
|
- },
|
|
|
- {
|
|
|
- min: 5,
|
|
|
- message: '投诉/建议不能少于5个字',
|
|
|
- trigger: 'change' ,
|
|
|
- },
|
|
|
- // 正则校验示例,此处用正则校验是否中文,此处仅为示例,因为uView有this.$u.test.chinese可以判断是否中文
|
|
|
- // {
|
|
|
- // pattern: /^[\u4e00-\u9fa5]+$/gi,
|
|
|
- // message: '简介只能为中文',
|
|
|
- // trigger: 'change',
|
|
|
- // },
|
|
|
- ],
|
|
|
- /* contact: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入您的联系方式',
|
|
|
- trigger: ['change','blur'],
|
|
|
- },
|
|
|
- // {
|
|
|
- // validator: (rule, value, callback) => {
|
|
|
- // // 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
|
|
|
- // return this.$u.test.mobile(value);
|
|
|
- // },
|
|
|
- // message: '手机号码不正确',
|
|
|
- // // 触发器可以同时用blur和change,二者之间用英文逗号隔开
|
|
|
- // trigger: ['change','blur'],
|
|
|
- // }
|
|
|
- ], */
|
|
|
-
|
|
|
- contact: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入正确的手机号',
|
|
|
- trigger: ['change','blur'],
|
|
|
- },
|
|
|
- {
|
|
|
- validator: (rule, value, callback) => {
|
|
|
- // 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
|
|
|
- return this.$u.test.mobile(value);
|
|
|
- },
|
|
|
- message: '请输入正确的手机号',
|
|
|
- // 触发器可以同时用blur和change,二者之间用英文逗号隔开
|
|
|
- trigger: ['change','blur'],
|
|
|
- }
|
|
|
- ],
|
|
|
- },
|
|
|
- };
|
|
|
- },
|
|
|
- onLoad() {
|
|
|
-
|
|
|
- },
|
|
|
- onReady() {
|
|
|
- this.$refs.uForm.setRules(this.rules);
|
|
|
- },
|
|
|
- methods: {
|
|
|
-
|
|
|
- onError(data, index, lists) {
|
|
|
- console.log('onError', data, index, lists);
|
|
|
- },
|
|
|
- onSuccess(data, index, lists) {
|
|
|
- console.log('onSuccess', data, index, lists);
|
|
|
- this.model.images = data.data.full_url;
|
|
|
- },
|
|
|
- onRemove(data, index, lists) {
|
|
|
- this.model.images=null;
|
|
|
- },
|
|
|
- submit() {
|
|
|
- this.$refs.uForm.validate(valid => {
|
|
|
- if (valid) {
|
|
|
- this.addFeedbackFun();
|
|
|
- } else {
|
|
|
- console.log('验证失败');
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- addFeedbackFun(){
|
|
|
- console.log(this.model);
|
|
|
- // return;
|
|
|
- this.$u.api.addFeedbackAjax(this.model).then(({code,data})=>{
|
|
|
- this.$u.toast('已收到您的反馈,我们将尽快处理')
|
|
|
- })
|
|
|
- },
|
|
|
- }
|
|
|
-};
|
|
|
-</script>
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ showPicker: false,
|
|
|
+ feedbackTypes: ['功能建议', '内容建议', '产品建议', '其他'],
|
|
|
+ model: {
|
|
|
+ type: '',
|
|
|
+ content: '',
|
|
|
+ images: []
|
|
|
+ },
|
|
|
+ fileList: [],
|
|
|
+ rules: {
|
|
|
+ type: [{
|
|
|
+ required: true,
|
|
|
+ message: '请选择反馈类型'
|
|
|
+ }],
|
|
|
+ content: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入反馈描述'
|
|
|
+ }, {
|
|
|
+ min: 10,
|
|
|
+ message: '描述不能少于10个字'
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 显示类型选择器
|
|
|
+ showTypePicker() {
|
|
|
+ this.showPicker = true
|
|
|
+ },
|
|
|
+
|
|
|
+ // 类型选择确认
|
|
|
+ onTypeConfirm(e) {
|
|
|
+ this.model.type = e.value[0]
|
|
|
+ this.showPicker = false
|
|
|
+ },
|
|
|
+
|
|
|
+ // 上传图片
|
|
|
+ afterRead(event) {
|
|
|
+ const {
|
|
|
+ file
|
|
|
+ } = event
|
|
|
+ // 上传图片到服务器
|
|
|
+ uni.uploadFile({
|
|
|
+ url: 'your-upload-url',
|
|
|
+ filePath: file.url,
|
|
|
+ name: 'file',
|
|
|
+ success: (res) => {
|
|
|
+ const response = JSON.parse(res.data)
|
|
|
+ if (response.code === 1) {
|
|
|
+ this.model.images.push(response.data.url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除图片
|
|
|
+ deletePic(event) {
|
|
|
+ this.model.images.splice(event.index, 1)
|
|
|
+ },
|
|
|
+
|
|
|
+ // 去历史记录
|
|
|
+ goToHistory() {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/feedback-history/index'
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 提交表单
|
|
|
+ submit() {
|
|
|
+ if (!this.model.type) {
|
|
|
+ return uni.$u.toast('请选择反馈类型')
|
|
|
+ }
|
|
|
+ if (this.model.content.length < 10) {
|
|
|
+ return uni.$u.toast('描述不能少于10个字')
|
|
|
+ }
|
|
|
|
|
|
-<style scoped lang="scss">
|
|
|
- .submitBtn{
|
|
|
- margin: 100rpx 100rpx 0;
|
|
|
- }
|
|
|
-.feedbox {
|
|
|
- padding: 30rpx;
|
|
|
- background-color: #fff;
|
|
|
- min-height: 100vh;
|
|
|
+ // 提交表单
|
|
|
+ uni.showLoading({
|
|
|
+ title: '提交中'
|
|
|
+ })
|
|
|
+ // 这里调用提交接口
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.$u.toast('提交成功')
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.navigateBack()
|
|
|
+ }, 1500)
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.feedback-page {
|
|
|
+ min-height: 100vh;
|
|
|
+ background: #F5F5F5;
|
|
|
+
|
|
|
+ // banner样式保持不变
|
|
|
+ .banner {
|
|
|
+ position: relative;
|
|
|
+ height: 230rpx;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ .banner-img {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .history-btn {
|
|
|
+ position: absolute;
|
|
|
+ right: 30rpx;
|
|
|
+ top: 30rpx;
|
|
|
+ background: rgba(56, 193, 72, 0.9);
|
|
|
+ color: #FFFFFF;
|
|
|
+ padding: 10rpx 20rpx;
|
|
|
+ border-radius: 10rpx;
|
|
|
+ font-size: 24rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 表单项通用样式
|
|
|
+ .form-item {
|
|
|
+ background: #FFFFFF;
|
|
|
+ margin: 20rpx;
|
|
|
+ padding: 30rpx;
|
|
|
+ border-radius: 12rpx;
|
|
|
+
|
|
|
+ .label {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #333;
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+
|
|
|
+ .required {
|
|
|
+ color: #FF5B5B;
|
|
|
+ margin-left: 4rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 反馈类型区域
|
|
|
+ .type-section {
|
|
|
+ position: relative;
|
|
|
+ z-index: 1;
|
|
|
+
|
|
|
+ .picker-box {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+
|
|
|
+ .picker-text {
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #333;
|
|
|
|
|
|
-.agreement {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- margin: 40rpx 0;
|
|
|
+ &.placeholder {
|
|
|
+ color: #999;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- .agreement-text {
|
|
|
- padding-left: 8rpx;
|
|
|
- color: $u-tips-color;
|
|
|
- }
|
|
|
+ // 反馈描述区域
|
|
|
+ .content-section {
|
|
|
+ .textarea-box {
|
|
|
+ background: #F8F8F8;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ padding: 20rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|