index.vue
6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<template>
<view class="container" style="">
<view class="background"></view>
<view class="header"
style="display:flex;align-items:center;padding:10px;background-color:white;width:100%;margin:0 auto;">
<view class="tx">
<image :src="user.headicon" style="width:50px;height:50px;border:1px solid white;border-radius:20rpx;">
</image>
</view>
<view class="info" style="display:block;">
<view style="color:black;font-size:12px;">昵称:<text style="margin-left:5px;">{{user.realName}}</text>
</view>
<view style="color:black;font-size:12px;">ID:<text style="margin-left:5px;">{{user.id}}</text>
</view>
</view>
</view>
<view class="centerView">
<view class="comm" style="display:flex;justify-content:center;align-items:center;margin:10px 0px 20px 0px;">
<view style="color:white;">我的评价</view>
<view>
<!-- 设置评分数 -->
<uni-rate :max="3" :margin="10" @change="onChange" />
<!-- <uni-rate bind:__l="__l" bind:change="__e" data-event-opts="{{[ [ '^change',[ ['onChange'] ] ] ]}}" margin="{{10}}" max="{{3}}" vueId="10357bad-1"></uni-rate> -->
</view>
</view>
<view class="contentView"
style="border:1px solid white;width:90%;height:100px;margin:0 auto;padding:10px;border-radius:10px;background-color:white;">
<textarea maxlength="100" placeholder="请输入评价内容(不得高于60字)" placeholderClass="area"
style="color:gray;font-size:25rpx;" v-model="form.txt"></textarea>
</view>
</view>
<view class="uploadView">
<view style="display:flex;justify-content:center;align-items:center;margin:10px 0px 20px 0px;">
<view style="color:white;">图片上传</view>
</view>
<view
style="border:1px solid white;width:90%;height:118px;margin:0 auto;padding:10px;border-radius:10px;background-color:white;">
<view class="fileview">
<uni-file-picker limit="3" mode="grid" @select="select" style="transform:scale(0.5);" @delete="delBanner">
</uni-file-picker>
<!-- <uni-file-picker bind:__l="__l" bind:select="__e" data-event-opts="{{[ [ '^select',[ ['select'] ] ] ]}}" fileMediatype="image" limit="{{3}}" mode="grid" style="transform:scale(0.5);" vueId="10357bad-2" wx:if="{{form.banner.length>0}}"></uni-file-picker> -->
</view>
</view>
</view>
<view class="btnSubmit" style="margin-top:20px;">
<view @click="SubmitBtn" hoverClass="SubmitHover"
style="margin:0 auto;border:1px solid white;padding:10px;text-align:center;color:black;border-radius:10px;background-color:white;width:90%;">
提交评价</view>
</view>
</view>
</template>
<script>
import BASE_URL from '../../common/config.js'
import service from '../../service/service.js'
export default {
data() {
return {
BASE_URL,
user: {},
model: null,
form: {
"userId": "",
"goodsId": "",
"txt": "",
"idNo": "",
"title": "",
"banner": [],
"type": "",
"creatorTime": "2022-12-22T07:26:22.661Z",
"lastModifyTime": "2022-12-22T07:26:22.661Z"
},
orderChangeModel:{
id:'',
type:''
}
}
},
onLoad(data) {
console.log(data.item)
this.model = JSON.parse(decodeURIComponent(data.item))
this.orderChangeModel.id=this.model.id
console.log('这是信息啊', this.model)
this.form.goodsId=this.model.goodsId
let idNos=[]
this.model.jsonDetail.arrayJsons.forEach((item,index)=>{
idNos.push(item.jsonDetail.IdNo)
this.form.title+=item.jsonDetail.Title+','
})
this.form.idNo=idNos.toString()
this.form.title=this.form.title.substr(0,this.form.title.length-1)
console.log('组合信息',this.form)
this.ShowUserInfo()
},
methods: {
SubmitBtn(){
if(this.form.type==''){
uni.showToast({
title:'请选择评分',
icon:'none'
})
return
}
if(this.form.txt==''){
uni.showToast({
title:'请输入评价内容',
icon:'none'
})
return
}
this.form.userId=service.getUser().id
this.API.AddComment(this.form).then(res=>{
console.log('添加评论信息',res)
if(res.code==200){
this.OkOrder()
uni.showToast({
title:'评价成功',
icon:'none'
})
setTimeout(()=>{
uni.reLaunch({
url:'/pages/order/order?type=0'
})
},2000)
}else{
uni.showToast({
title:'评价失败',
icon:'none'
})
}
})
},
// 订单完成
OkOrder() {
this.orderChangeModel.type='4'
this.API.ChangeOrderOptions(this.orderChangeModel).then(res=>{
console.log('更改状态',res)
})
},
delBanner(e){
console.log('这是删除信息',e)
console.log('索引',this.form.banner.findIndex(o=>o.fileId==e.tempFilePath))
this.form.banner.splice(this.form.banner.findIndex(o=>o.fileId==e.tempFilePath),1)
console.log('这是组合',this.form.banner)
},
select(filed){
console.log('这是上传图',filed)
let that=this
uni.uploadFile({
url:that.BASE_URL+'/api/file/Uploader/annexpic',
filePath: filed.tempFilePaths[0],
name: 'file',
header:{
Authorization:service.getToken()
},
formData: {
user: 'test'
},
success(e) {
console.log('这是信息',e)
let data=JSON.parse(e.data)
console.log('dataxinxi',data)
let info={
"name": data.data.name,
"fileId":filed.tempFilePaths[0],
"url": data.data.url
}
that.form.banner.push(info)
console.log('组合数组',that.form.banner)
},
fail(error) {
console.log('错误',error)
uni.showToast({
title:'上传失败',
icon:'none'
})
}
})
},
onChange(e) {
console.log('这是分数', e)
if(e.value=='1'){
this.form.type='3'
}else if(e.value=='2'){
this.form.type='2'
}else {
this.form.type='1'
}
},
ShowUserInfo() {
this.API.GetUserInfo(service.getUser().id).then(res => {
console.log('这是获取得用户信息', res)
this.user = res.data
console.log('这是信息', this.user.headIcon)
if (!res.data.headIcon.startsWith('http')) {
this.user.headIcon = this.BASE_URL + res.data.headIcon
} else {
console.log('包含http')
}
})
}
}
}
</script>
<style>
.container {
margin: 0;
background-color: #8dccff;
background-size: 100% 100%;
height: 100%;
min-height: 100vh;
}
</style>