jiaqingjiayi-xiaochengxu/甲情_甲意/miniprogram/pages/pingjia/pingjia.js

108 lines
2.4 KiB
JavaScript
Raw Normal View History

2025-01-21 13:56:53 +00:00
import {url} from '../request'
2024-12-03 11:59:36 +00:00
Page({
2025-01-21 13:56:53 +00:00
data: {
},
2024-12-03 11:59:36 +00:00
onLoad() {},
2024-12-10 10:35:22 +00:00
onChange(value, e) {
console.log(value, e);
},
2025-01-21 13:56:53 +00:00
bindTextAreaBlur(e) {
this.setData({
inputtext:e.detail.value
})
console.log(this.data.inputtext);
},
onUpload(file) {
return new Promise((resolve, reject) => {
console.log('上传文件路径:', file); // 确保文件路径正确
my.uploadFile({
url: url + '/api/file/upload/server/not_login',
fileType: 'image',
name: 'file',
filePath: file.path,
formData: {
biz: 'card',
},
success: res => {
resolve(file.path);
console.log('上传成功:', res);
const cunchu = JSON.parse(res.data)
this.setData({
zhengshu:cunchu.data,
})
console.log(this.data.zhengshu,'hhhhhhhhhhhhhhh');
},
fail: (err) => {
console.log('上传失败:', err);
reject();
},
});
});
},
// 星级改变
handleChange(value) {
console.log(value);
this.setData({
value:value,
});
},
handleChangem(value) {
console.log(value);
this.setData({
valuemeijiashi:value,
});
},
tijiao(){
my.getStorage({
key: 'userInfo',
success: (res) => {
const userInfo = res.data;
this.setData({
id: userInfo.id, // 获取 id
});
if (userInfo && userInfo.cookie) {
my.request({
url: url + '/api/level/add',
method: 'POST',
data: {
businessId: 0,
manicuristId: 0,
manicuristRating: this.data.valuemeijiashi,
orderId: 0,
rating: this.data.value,
review: this.data.inputtext,
userId: this.data.id
},
headers: {
'content-type': 'application/json',
},
dataType: 'json',
success: (res) => {
console.log(res);
if (res.data.code === 0) {
console.log(res);
my.alert({content:'评价成功'})
my.navigateBack();
}
},
fail: (error) => {
my.alert({ content: '评价失败' });
},
});
} else {
my.alert({
content: '您未登录,请先登录。',
success: () => {
my.navigateTo({
url: '/pages/denglu/denglu',
});
},
});
}
},
});
},
2024-12-03 11:59:36 +00:00
});