| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <template>
- <view>
- <!-- 表单区域 -->
- <view class="form-container region mar-t-10">
- <view class="form-item">
- <view class="form-label">评分</view>
- <uni-rate size="30" v-model="score.score" />
- </view>
- <view class="form-item">
- <view class="form-label">评价内容</view>
- <view class="textarea-container">
- <textarea style="width: 100%;" v-model="score.content" placeholder="请详细描述申请说明(选填)"
- class="form-textarea" :maxlength="maxLength"></textarea>
- <view class="char-count">
- 您还可以输入{{ remainingChars }} 字
- </view>
- </view>
- </view>
- <!-- 上传凭证 -->
- <view class="form-item">
- <view class="form-label">上传图片/视频(可选)</view>
- <view class=" flex-items">
- <view>
- <uni-file-picker @delete="delFile" v-model="imageValue" fileMediatype="image" mode="grid"
- @select="select">
- <view class="videoUpload flex-items-plus">
- <view class="text-align">
- <uni-icons type="image" size="30"></uni-icons>
- <view>
- 添加图片
- </view>
- </view>
- </view>
- </uni-file-picker>
- </view>
- <view>
- <uni-file-picker @delete="delFile" v-model="imageValue" fileMediatype="video" mode="grid"
- @select="select">
- <view class="videoUpload flex-items-plus">
- <view class="text-align">
- <uni-icons type="videocam" size="30"></uni-icons>
- <view>
- 添加短视频
- </view>
- </view>
- </view>
- </uni-file-picker>
- </view>
- </view>
- </view>
- </view>
- <!-- 提交按钮 -->
- <button class="submit-button" @click="submitForm('customForm')">提交评价</button>
- </view>
- </template>
- <script>
- import {
- UPLOAD_URL
- } from '../../common/config.js';
- import {
- saveScore
- } from '../../config/api.js';
- export default {
- data() {
- return {
- score: {
- imgList: [],
- score: 5,
- content: ""
- },
- token: '',
- imageValue: [],
- fileList: [],
- images: [],
- orderId: "",
- maxLength: 200, // 最大字数
- };
- },
- computed: {
- // 计算剩余字数
- remainingChars() {
- return this.maxLength - this.score.content.length;
- }
- },
- onLoad(op) {
- this.orderId = op.orderId;
- this.token = uni.getStorageSync('access_token');
- },
- methods: {
- delFile(e) {
- this.score.imgList.splice(e.index, 1); // 删除对应 index 的附件
- },
- // 获取选择的文件
- async select(e) {
- console.log(e)
- let list = [].concat(e.tempFiles);
- // for (let i = 0; i < list.length; i++) {
- // const result = await this.uploadFilePromise(list[i].url);
- // this.score.imgList.push(result.data.link);
- // }
- },
- uploadFilePromise(url) {
- return new Promise((resolve, reject) => {
- uni.uploadFile({
- url: UPLOAD_URL,
- filePath: url,
- header: {
- "Blade-Auth": this.token
- },
- name: 'file',
- formData: {
- user: 'test'
- },
- success: (res) => {
- resolve(JSON.parse(res.data));
- }
- });
- });
- },
- // 提交表单
- submitForm() {
- this.score.images = this.score.imgList.join(',');
- this.score.orderId = this.orderId
- saveScore(this.score).then((res) => {
- if (res.code == 200) {
- uni.showToast({
- title: '评价成功',
- icon: 'success'
- });
- setTimeout(() => {
- uni.navigateBack({
- delta: 1
- })
- }, 1000)
- }
- })
- }
- }
- }
- </script>
- <style scoped>
- .page-title {
- font-size: 36rpx;
- font-weight: bold;
- text-align: center;
- padding: 20rpx 0;
- color: #333;
- }
- .form-container {
- padding: 20rpx;
- }
- .form-item {
- margin-bottom: 20rpx;
- }
- .form-label {
- font-size: 28rpx;
- color: #666;
- margin-bottom: 10rpx;
- }
- .textarea-container {
- position: relative;
- }
- .form-textarea {
- border: 1px solid #ccc;
- border-radius: 5rpx;
- padding: 10rpx;
- font-size: 28rpx;
- height: 150rpx;
- resize: none;
- }
- .char-count {
- position: absolute;
- bottom: 10rpx;
- right: 10rpx;
- font-size: 24rpx;
- color: #999;
- }
- .upload-container {
- margin-top: 10rpx;
- }
- .submit-button {
- background-color: #F95B5B;
- color: #fff;
- font-size: 32rpx;
- padding: 5rpx;
- border-radius: 10rpx;
- margin-left: 30rpx;
- margin-right: 30rpx;
- text-align: center;
- margin-top: 30rpx;
- }
- .videoUpload {
- border: 1rpx solid #999;
- height: 200rpx;
- width: 200rpx;
- }
- </style>
|