123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- <template>
- <view class="page">
- <!-- <PageHeader title="意见与反馈" class="PageHeader">
- <template slot="center"> </template>
- </PageHeader> -->
- <view class="feedback-container">
- <!-- 举报内容 -->
- <view class="report-content scale-tap" v-if="isReportContent" @click="openReportSheet">
- <view class="report-title">
- 举报内容
- </view>
- <view>
- <text v-if="selectedReportIndex !== null" style="color:#1f1f1f;margin-left:16rpx;">
- {{ reportItems[selectedReportIndex].text }}
- </text>
- <image class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix"></image>
- </view>
- </view>
- <!-- 问题描述区域 -->
- <view class="description-area">
- <view class="title">问题描述</view>
- <textarea class="input-area" v-model="content" placeholder="请尽可能详细地描述您的反馈或问题" :maxlength="200"
- show-count></textarea>
- <view class="word-count">{{ content.length }}/200</view>
- </view>
- <!-- 图片上传区域 -->
- <view class="upload-area">
- <view class="title">上传图片 <text class="subtitle">(最多5张,可选)</text></view>
- <view class="tips">* 上传问题截图更好的帮助我们快速定位您反馈的问题</view>
- <view class="tips" style="margin-bottom: 20rpx;">* 需要您授权相册权限</view>
- <view class="image-list">
- <view class="image-item" v-for="(item, index) in imgList" :key="index">
- <image class="preview" :src="item" mode="aspectFill"></image>
- <view class="delete-btn" @tap="deleteImage(index)">
- <text class="fa fa-times"></text>
- </view>
- </view>
- <view class="upload-btn" @tap="upload" v-if="imgList.length < 5">
- <text class="fa fa-plus"></text>
- </view>
- </view>
- </view>
-
- <!-- 提交按钮 -->
- <view class="submit-btn" @tap="submitFeedback">
- 确认提交
- </view>
- </view>
- <ActionSheet
- ref="actionSheet"
- :title="'举报内容'"
- :items="reportItems"
- @select="onReportSelect"
- />
- </view>
- </template>
- <script>
- import ActionSheet from '@/components/dropDownSelection/ActionSheet.vue';
- export default {
- components: {
- ActionSheet
- },
- data() {
- return {
- content: '',
- imgList: [],
- skey: getApp().globalData.skey || '',
- reportItems: [
- { text: '售后问题' },
- { text: '其他问题' }
- ],
- selectedReportIndex: null,
- isReportContent:false
- }
- },
- onLoad(e) {
- if (e&&e.isReportContent) {
- this.isReportContent = e.isReportContent === 'true'?true:false;
- }
- },
- methods: {
- openReportSheet() {
- this.$refs.actionSheet.show();
- },
- onReportSelect(index, item) {
- this.selectedReportIndex = index;
- console.log('选择的标签',index,item,item.text);
-
- },
- // 上传图片
- upload() {
- if (this.imgList.length >= 5) {
- uni.showToast({
- title: '最多只能上传5张图片',
- icon: 'none'
- });
- return;
- }
- let that = this;
- uni.chooseImage({
- count: 5 - this.imgList.length,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: function (res) {
- let tempFilePaths = [];
- // #ifdef H5
- res.tempFiles.forEach(file => {
- tempFilePaths.push(file.path);
- });
- // #endif
- // #ifdef APP-PLUS || MP
- tempFilePaths = res.tempFilePaths;
- // #endif
- for (let i = 0; i < tempFilePaths.length; i++) {
- const uploadTask = uni.uploadFile({
- url: that.$apiHost + '/Xweb/upload_img?skey=' + that.skey,
- filePath: tempFilePaths[i],
- name: 'file',
- success: function (uploadFileRes) {
- let resdata = JSON.parse(uploadFileRes.data);
- if (resdata.success == 'yes') {
- that.imgList.push(resdata.url);
- } else {
- uni.showToast({
- title: resdata.str || '上传失败',
- icon: 'none'
- });
- }
- },
- fail: function (err) {
- console.error('上传失败:', err);
- uni.showToast({
- title: '图片上传失败',
- icon: 'none'
- });
- }
- });
- }
- }
- });
- },
- // 删除图片
- deleteImage(index) {
- this.imgList.splice(index, 1);
- },
- // 提交反馈
- submitFeedback() {
- if (!this.content.trim()) {
- uni.showToast({
- title: '请输入问题描述',
- icon: 'none'
- });
- return;
- }
- let imgStr = this.imgList.join('|');
- uni.request({
- url: this.$apiHost + '/Member/feedback',
- method: 'POST',
- data: {
- uuid: getApp().globalData.uuid,
- content: this.content,
- image: imgStr
- },
- header: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'sign': getApp().globalData.headerSign,
- uuid: getApp().globalData.uuid,
- },
- success: (res) => {
- if (res.data.success === 'yes') {
- uni.showToast({
- title: '反馈成功!我们将尽快处理',
- icon: 'none'
- });
- setTimeout(() => {
- uni.navigateBack();
- }, 1500);
- } else {
- uni.showToast({
- title: res.data.str || '提交失败',
- icon: 'none'
- });
- }
- },
- fail: (err) => {
- console.error('提交失败:', err);
- uni.showToast({
- title: '网络错误,请稍后重试',
- icon: 'none'
- });
- }
- });
- }
- }
- }
- </script>
- <style lang="scss">
-
- .page {
- min-height: 100vh;
- background-color: #f8f8f8;
- padding-bottom: env(safe-area-inset-bottom);
- }
- .feedback-container {
- padding: 30rpx;
- .report-content{
- display: flex;
- padding: 26rpx 40rpx 22rpx 24rpx;
- background: #fff;
- border-radius: 20rpx;
- margin-bottom: 20rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-size: 32rpx;
- color: #333;
- margin-bottom: 20rpx;
- image{
- width: 28rpx;
- height: 28rpx;
- }
- }
- .description-area {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- margin-bottom: 30rpx;
- position: relative;
- .title {
- font-size: 32rpx;
- color: #333;
- margin-bottom: 20rpx;
- }
- .input-area {
- width: 100%;
- height: 300rpx;
- font-size: 28rpx;
- line-height: 1.6;
- padding: 20rpx;
- background: #f8f8f8;
- border-radius: 12rpx;
- }
- .word-count {
- position: absolute;
- right: 44rpx;
- bottom: 44rpx;
- font-size: 24rpx;
- color: #999;
- }
- }
- .upload-area {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- margin-bottom: 30rpx;
- .title {
- font-size: 32rpx;
- color: #333;
- margin-bottom: 20rpx;
- .subtitle {
- font-size: 24rpx;
- color: #999;
- }
- }
- .image-list {
- display: flex;
- flex-wrap: wrap;
- gap: 16rpx;
- margin-bottom: 20rpx;
- .image-item {
- width: 200rpx;
- height: 200rpx;
- position: relative;
- .preview {
- width: 100%;
- height: 100%;
- border-radius: 12rpx;
- }
- .delete-btn {
- position: absolute;
- top: -16rpx;
- right: -16rpx;
- width: 40rpx;
- height: 40rpx;
- background: rgba(0, 0, 0, 0.5);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- .fa {
- color: #fff;
- font-size: 24rpx;
- }
- }
- }
- .upload-btn {
- width: 200rpx;
- height: 200rpx;
- background: #f8f8f8;
- border-radius: 12rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- .fa {
- font-size: 48rpx;
- color: #999;
- }
- }
- }
- .tips {
- font-size: 24rpx;
- color: #999;
- line-height: 1.6;
- }
- }
- .submit-btn {
- width: 100%;
- height: 88rpx;
- background: #000;
- border-radius: 44rpx;
- color: #fff;
- font-size: 32rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 60rpx;
- &:active {
- opacity: 0.9;
- }
- }
- }
- </style>
|