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.
418 lines
9.4 KiB
418 lines
9.4 KiB
// subpages/points/pages/demand/detail.js
|
|
// @ts-nocheck
|
|
import { wxNavigateTo, wxRequestPost } from "@utils/promise-wx-api";
|
|
import {
|
|
nextTick,
|
|
} from "@utils/tools";
|
|
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: async function (options) {
|
|
this.setData({
|
|
showRate: options.showRate == 0 ? false : true,
|
|
source: options.source,
|
|
id: options.id
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: async function () {
|
|
// this.initInfo()
|
|
await this.getInfo(this.data)
|
|
},
|
|
async getInfo(op) {
|
|
const params = {
|
|
demandRecId: op.id
|
|
}
|
|
let url = 'heart/residemand/detail-hall'
|
|
if (op.source == 'my') url = 'heart/residemand/my-detail'
|
|
let {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost(url, params, { isMock: false });
|
|
console.log('getInfo', data)
|
|
if (msg == 'success' && code == 0) {
|
|
let { info } = this.data
|
|
// for(const n in info) {
|
|
// info[n] = data[n]
|
|
// }
|
|
info = { ...data }
|
|
if (data.demandUserMobile) info.demandUserMobile1 = this.formatMobile(data.demandUserMobile)
|
|
if (data.serviceUserMobile) info.serviceUserMobile1 = this.formatMobile(data.serviceUserMobile)
|
|
if (data.status === 'finished' && info.evaluateFlag) {
|
|
info.isFloat = this.formatScore(info.score).isFloat
|
|
info.score = this.formatScore(info.score).value
|
|
}
|
|
this.setData({
|
|
info
|
|
})
|
|
}
|
|
},
|
|
async cenaleDemand() {
|
|
let fmData = {
|
|
demandRecId: this.data.info.demandRecId
|
|
}
|
|
|
|
let {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost('heart/residemand/cancel', fmData, { isMock: false });
|
|
if (msg == 'success' && code == 0) {
|
|
wx.showToast({
|
|
title: '取消成功',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
await nextTick(500)
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}
|
|
},
|
|
async handleTaking() {
|
|
wx.showLoading({
|
|
title: '接单中...'
|
|
})
|
|
let fmData = {
|
|
demandRecId: this.data.info.demandRecId
|
|
}
|
|
|
|
let {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost('heart/residemand/takeorder', fmData, { isMock: false });
|
|
await nextTick(1000)
|
|
wx.hideLoading()
|
|
if (msg == 'success' && code == 0) {
|
|
console.log('data', data)
|
|
if (!data.isVolunteer) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '您还不是志愿者,是否前往注册',
|
|
confirmText: '是',
|
|
cancelText: '否',
|
|
success: res => {
|
|
if (res.confirm) {
|
|
wxNavigateTo('/subpages/heart/pages/volunteer/volunteer')
|
|
} else {
|
|
console.log('点击了取消')
|
|
}
|
|
}
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: '接单成功',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
await nextTick(500)
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}
|
|
}
|
|
},
|
|
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
|
|
wxNavigateTo('/subpages/points/pages/demand/finish', {
|
|
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
|
|
wxNavigateTo('/subpages/points/pages/demand/crate', {
|
|
id: info.demandRecId
|
|
})
|
|
},
|
|
handleRegisterV() {
|
|
wxNavigateTo('/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
|
|
})
|
|
},
|
|
async 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
|
|
}
|
|
|
|
let {
|
|
data: {
|
|
data: { code, data },
|
|
},
|
|
msg,
|
|
} = await wxRequestPost('heart/residemand/evaluate', fmData, { isMock: false });
|
|
await nextTick(1000)
|
|
wx.hideLoading()
|
|
if (msg == 'success' && code == 0) {
|
|
wx.showToast({
|
|
title: '提交成功',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
this.getInfo(this.data)
|
|
this.setData({
|
|
showRate: false
|
|
})
|
|
}
|
|
},
|
|
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)
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|