You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
375 lines
8.8 KiB
375 lines
8.8 KiB
import { getMyDemandDetail, getDemandDetail, demandCancel, demandTakeOrder, demandEvaluate } from '../../utils/demand'
|
|
Page({
|
|
data: {
|
|
source: 'common',
|
|
id: '',
|
|
info: {
|
|
demandRecId: '',
|
|
categoryName: '',
|
|
awardPoint: '',
|
|
content: '',
|
|
wantServiceTime: '',
|
|
demandUserName: '',
|
|
demandUserMobile: '',
|
|
serviceAddress: '',
|
|
serviceStartTime: '',
|
|
serviceEndTime: '',
|
|
score: 4.5,
|
|
finishDesc: '',
|
|
finishResult: '',
|
|
status: ''
|
|
},
|
|
finishResult: 'resolved',
|
|
showRate: false,
|
|
// rate: [3, 4, 3, 4, 3, 4, 3, 4, 3, 4],
|
|
rate: [
|
|
{
|
|
name: 3,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 4,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 3,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 4,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 3,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 4,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 3,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 4,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 3,
|
|
isBtn: false
|
|
},
|
|
{
|
|
name: 4,
|
|
isBtn: false
|
|
},
|
|
],
|
|
},
|
|
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
showRate: options.showRate == 0 ? false : true,
|
|
source: options.source,
|
|
id: options.id
|
|
})
|
|
},
|
|
|
|
onShow: function () {
|
|
// this.initInfo()
|
|
this.getInfo(this.data)
|
|
},
|
|
getMyDemandDetail (params) {
|
|
getMyDemandDetail(params).then(res => {
|
|
if (res.msg == 'success' && res.code == 0) {
|
|
let { info } = this.data
|
|
// for(const n in info) {
|
|
// info[n] = data[n]
|
|
// }
|
|
info = { ...res.data }
|
|
if (res.data.demandUserMobile) info.demandUserMobile1 = this.formatMobile(res.data.demandUserMobile)
|
|
if (res.data.serviceUserMobile) info.serviceUserMobile1 = this.formatMobile(res.data.serviceUserMobile)
|
|
if (res.data.status === 'finished' && info.evaluateFlag) {
|
|
info.isFloat = this.formatScore(info.score).isFloat
|
|
info.score = this.formatScore(info.score).value
|
|
}
|
|
this.setData({
|
|
info
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
},
|
|
getDemandDetail (params) {
|
|
getDemandDetail(params).then(res => {
|
|
if (res.msg == 'success' && res.code == 0) {
|
|
let { info } = this.data
|
|
// for(const n in info) {
|
|
// info[n] = data[n]
|
|
// }
|
|
info = { ...res.data }
|
|
if (res.data.demandUserMobile) info.demandUserMobile1 = this.formatMobile(res.data.demandUserMobile)
|
|
if (res.data.serviceUserMobile) info.serviceUserMobile1 = this.formatMobile(res.data.serviceUserMobile)
|
|
if (res.data.status === 'finished' && info.evaluateFlag) {
|
|
info.isFloat = this.formatScore(info.score).isFloat
|
|
info.score = this.formatScore(info.score).value
|
|
}
|
|
this.setData({
|
|
info
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
},
|
|
getInfo(op) {
|
|
const params = {
|
|
demandRecId: op.id
|
|
}
|
|
if (op.source == 'my') {
|
|
this.getMyDemandDetail(params)
|
|
} else {
|
|
this.getDemandDetail(params)
|
|
}
|
|
},
|
|
cenaleDemand() {
|
|
let fmData = {
|
|
demandRecId: this.data.info.demandRecId
|
|
}
|
|
demandCancel(fmData).then(res => {
|
|
if (res.msg == 'success' && res.code == 0) {
|
|
wx.showToast({
|
|
title: '取消成功',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 1500)
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
},
|
|
handleTaking() {
|
|
wx.showLoading({
|
|
title: '接单中...'
|
|
})
|
|
let fmData = {
|
|
demandRecId: this.data.info.demandRecId
|
|
}
|
|
demandTakeOrder(fmData).then(res => {
|
|
wx.hideLoading()
|
|
if (res.msg == 'success' && res.code == 0) {
|
|
if (!res.data.isVolunteer) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '您还不是志愿者,是否前往注册',
|
|
confirmText: '是',
|
|
cancelText: '否',
|
|
success: res => {
|
|
if (res.confirm) {
|
|
wx.navigateTo({
|
|
url: '/subpages/heart/pages/volunteer/volunteer'
|
|
})
|
|
} else {
|
|
console.log('点击了取消')
|
|
}
|
|
}
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: '接单成功',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}, 1500)
|
|
}
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
},
|
|
initInfo() {
|
|
let { info } = this.data
|
|
info.isFloat = this.formatScore(info.score).isFloat
|
|
info.score = this.formatScore(info.score).value
|
|
|
|
console.log('infio', info)
|
|
this.setData({
|
|
info
|
|
})
|
|
},
|
|
formatScore(item) {
|
|
let isFloat = String(item).indexOf('.') != -1 ? true : false
|
|
return {
|
|
value: Math.floor(item),
|
|
isFloat
|
|
}
|
|
},
|
|
handleFinish(e) {
|
|
const { info } = this.data
|
|
wx.navigateTo({
|
|
url: `../demandFinish/demandFinish?id=${info.demandRecId}`
|
|
})
|
|
},
|
|
handleTell() {
|
|
const { info, source } = this.data
|
|
const mobile = source === 'my' ? info.serviceUserMobile : info.demandUserMobile
|
|
wx.makePhoneCall({
|
|
phoneNumber: mobile
|
|
})
|
|
},
|
|
handleEdit(e) {
|
|
const { info } = this.data
|
|
wx.navigateTo({
|
|
url: `../demandCreate/demandCreate?id=${info.demandRecId}`
|
|
})
|
|
},
|
|
handleRegisterV() {
|
|
wx.navigateTo({
|
|
url: '/subpages/heart/pages/volunteer/volunteer'
|
|
})
|
|
},
|
|
handleCancle() {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '取消之后无法恢复,是否取消?',
|
|
confirmText: '是',
|
|
cancelText: '否',
|
|
success: res => {
|
|
if (res.confirm) {
|
|
this.cenaleDemand()
|
|
} else {
|
|
console.log('点击了取消')
|
|
}
|
|
}
|
|
})
|
|
},
|
|
handleResolve(e) {
|
|
const name = e.currentTarget.dataset.name
|
|
console.log('finishResult', name)
|
|
this.setData({
|
|
finishResult: name,
|
|
'info.finishResult': name
|
|
})
|
|
},
|
|
handleInput(e) {
|
|
const { value } = e.detail
|
|
this.setData({
|
|
'info.finishDesc': value
|
|
})
|
|
},
|
|
handleCilboard() {
|
|
wx.setClipboardData({
|
|
data: this.data.info.serviceAddress,
|
|
success: res => {
|
|
console.log('复制成功')
|
|
}
|
|
})
|
|
},
|
|
handleShowRate() {
|
|
this.setData({
|
|
showRate: true
|
|
})
|
|
},
|
|
handleSubmitRate() {
|
|
const { info } = this.data
|
|
if (!info.score) {
|
|
wx.showToast({
|
|
title: '评分不能为空',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
return
|
|
}
|
|
// if (!info.finishDesc) {
|
|
// wx.showToast({
|
|
// title: '完成情况不能为空',
|
|
// icon: 'none',
|
|
// duration: 1500
|
|
// })
|
|
// return
|
|
// }
|
|
wx.showLoading({
|
|
title: '提交中...'
|
|
})
|
|
let fmData = {
|
|
demandRecId: info.demandRecId,
|
|
finishResult: info.finishResult || 'resolved',
|
|
finishDesc: info.finishDesc,
|
|
serviceId: info.serviceId,
|
|
score: info.score
|
|
}
|
|
demandEvaluate(fmData).then(res => {
|
|
wx.hideLoading()
|
|
if (res.msg == 'success' && res.code == 0) {
|
|
wx.showToast({
|
|
title: '提交成功',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
this.getInfo(this.data)
|
|
this.setData({
|
|
showRate: false
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
},
|
|
handleRate(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
console.log('index', index)
|
|
let { rate, info } = this.data
|
|
let item = rate[index]
|
|
|
|
let s = new Array()
|
|
for (var i = 0; i < 10; i++) {
|
|
if (i <= index) {
|
|
if (i % 2 == 1) {
|
|
rate[i].name = 2
|
|
} else if (i % 2 == 0) {
|
|
rate[i].name = 1
|
|
}
|
|
} else {
|
|
if (i % 2 == 1) {
|
|
rate[i].name = 4
|
|
} else if (i % 2 == 0) {
|
|
rate[i].name = 3
|
|
}
|
|
}
|
|
}
|
|
if (rate[index].isBtn) {
|
|
if (index % 2 == 1) rate[index].name = 4
|
|
else rate[index].name = 3
|
|
}
|
|
info.score = rate[index].isBtn ? this.formatRate(index) : this.formatRate(index + 1)
|
|
console.log('grade ----', rate[index].isBtn ? this.formatRate(index) : this.formatRate(index + 1))
|
|
// console.log('index % 2 ===', index % 2, this.formatRate(index + 1))
|
|
rate[index].isBtn = !rate[index].isBtn
|
|
this.setData({
|
|
rate: rate,
|
|
info,
|
|
})
|
|
|
|
},
|
|
formatRate(item) {
|
|
let num = 0
|
|
if (item % 2 == 1) num = parseInt(item / 2) + 0.5
|
|
else num = parseInt(item / 2)
|
|
return num
|
|
},
|
|
formatMobile(mobile) {
|
|
const reg = /^(\d{3})\d*(\d{4})$/;
|
|
// var str2 = str1.replace(reg,'$1****$2')
|
|
return mobile.replace(reg,'$1****$2')
|
|
// return mobile.substr(0,3) + "****" + mobile.substr(7)
|
|
},
|
|
})
|