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.
272 lines
7.4 KiB
272 lines
7.4 KiB
import { getDemandList, getMyDemandList, demandCancel } from '../../utils/demand'
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
status: String,
|
|
url: String,
|
|
source: String
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
iniLoaded: false,
|
|
currentStatus: 0,
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
finished: false,
|
|
noMoreTitle: '没有更多了',
|
|
noData: '暂无数据',
|
|
list: [
|
|
// {
|
|
// id: '0',
|
|
// demandRecId: '',
|
|
// categoryName: '配餐服务',
|
|
// wantServiceTime: '2021-10-22 11:30',
|
|
// cancelTime: '2021-10-22 11:30',
|
|
// serviceAddress: '青岛市市北区山东路168号时代国际广场1401',
|
|
// awardPoint: '6',
|
|
// demandUserName: '',
|
|
// demandUserMobile: '13388999900',
|
|
// status: 'pending',
|
|
// score: 4.5
|
|
// },
|
|
// {
|
|
// id: '1',
|
|
// demandRecId: '',
|
|
// categoryName: '配餐服务',
|
|
// wantServiceTime: '2021-10-22 11:30',
|
|
// cancelTime: '2021-10-22 11:30',
|
|
// address: '青岛市市北区山东路168号时代国际广场1401',
|
|
// awardPoint: '6',
|
|
// demandUserMobile: '13388999900',
|
|
// status: 'pending',
|
|
// score: 0
|
|
// }
|
|
// ,
|
|
// {
|
|
// id: '2',
|
|
// demandRecId: '',
|
|
// categoryName: '配餐服务',
|
|
// wantServiceTime: '2021-10-22 11:30',
|
|
// cancelTime: '2021-10-22 11:30',
|
|
// address: '青岛市市北区山东路168号时代国际广场1401',
|
|
// awardPoint: '6',
|
|
// demandUserMobile: '13388999900',
|
|
// status: 'pending',
|
|
// score: 3.5
|
|
// },
|
|
// {
|
|
// id: '3',
|
|
// demandRecId: '',
|
|
// categoryName: '配餐服务',
|
|
// wantServiceTime: '2021-10-22 11:30',
|
|
// cancelTime: '2021-10-22 11:30',
|
|
// address: '青岛市市北区山东路168号时代国际广场1401',
|
|
// awardPoint: '6',
|
|
// demandUserMobile: '13388999900',
|
|
// status: 'pending',
|
|
// score: 4
|
|
// }
|
|
]
|
|
},
|
|
pageLifetimes: {
|
|
show() {
|
|
console.log('pageLifetimes---执行了吗')
|
|
this.initApiData()
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
refreshList() {
|
|
this.setData({
|
|
pageNo: 1,
|
|
finished: false
|
|
})
|
|
this.getList()
|
|
},
|
|
initApiData() {
|
|
this.setData({
|
|
pageNo: 1,
|
|
finished: false
|
|
})
|
|
this.getList()
|
|
this.setData({
|
|
iniLoaded: true
|
|
})
|
|
},
|
|
getMore() {
|
|
const { finished } = this.data
|
|
if (finished) return false
|
|
this.getList()
|
|
},
|
|
getList() {
|
|
let { pageNo, pageSize, status, list, finished, noMoreTitle, url } = this.data
|
|
noMoreTitle = '加载中...'
|
|
this.setData({
|
|
noMoreTitle
|
|
})
|
|
let fmData = {
|
|
gridId: wx.getStorageSync("gridId"),
|
|
pageNo,
|
|
pageSize,
|
|
type: status
|
|
}
|
|
if (url.indexOf('mydemand') > -1) {
|
|
getMyDemandList(fmData).then(res => {
|
|
if (res.msg == 'success' && res.code == 0) {
|
|
const _data = res.data && res.data.map(item => {
|
|
return {
|
|
...item,
|
|
serviceUserMobile1: item.serviceUserMobile && this.formatMobile(item.serviceUserMobile) || '',
|
|
score: this.formatScore(item.score).value,
|
|
isFloat: this.formatScore(item.score).isFloat
|
|
}
|
|
})
|
|
if (pageNo == 1) list = _data || []
|
|
else list = _data && list.concat(_data) || list
|
|
|
|
if (res.data.length < pageSize) finished = true
|
|
else pageNo = pageNo + 1
|
|
|
|
this.setData({
|
|
list,
|
|
finished,
|
|
pageNo,
|
|
noMoreTitle: '没有更多了'
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
} else {
|
|
getDemandList(fmData).then(res => {
|
|
if (res.msg == 'success' && res.code == 0) {
|
|
const _data = res.data && res.data.map(item => {
|
|
return {
|
|
...item,
|
|
serviceUserMobile1: item.serviceUserMobile && this.formatMobile(item.serviceUserMobile) || '',
|
|
score: this.formatScore(item.score).value,
|
|
isFloat: this.formatScore(item.score).isFloat
|
|
}
|
|
})
|
|
if (pageNo == 1) list = _data || []
|
|
else list = _data && list.concat(_data) || list
|
|
|
|
if (res.data.length < pageSize) finished = true
|
|
else pageNo = pageNo + 1
|
|
|
|
this.setData({
|
|
list,
|
|
finished,
|
|
pageNo,
|
|
noMoreTitle: '没有更多了'
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
}
|
|
},
|
|
cenaleDemand(id) {
|
|
let fmData = {
|
|
demandRecId: id
|
|
}
|
|
demandCancel(fmData).then(res => {
|
|
if (res.msg == 'success' && res.code == 0) {
|
|
wx.showToast({
|
|
title: '取消成功',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
this.getList()
|
|
}
|
|
}).catch(err => {
|
|
|
|
})
|
|
},
|
|
initList() {
|
|
let { list, status, source } = this.data
|
|
let arr = list.map(item => {
|
|
return {
|
|
...item,
|
|
serviceShowName: source === 'my' ? '青岛亿联信息科技股份有公司 张三 135****5555' : '',
|
|
status: status,
|
|
score: this.formatScore(item.score).value,
|
|
isFloat: this.formatScore(item.score).isFloat
|
|
}
|
|
})
|
|
this.setData({
|
|
list: arr
|
|
})
|
|
},
|
|
formatScore(item) {
|
|
let isFloat = String(item).indexOf('.') != -1 ? true : false
|
|
return {
|
|
value: Math.floor(item),
|
|
isFloat
|
|
}
|
|
},
|
|
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)
|
|
},
|
|
handleTo(e) {
|
|
// wx.setStorageSync('toDetail', true)
|
|
const id = e.currentTarget.dataset.id
|
|
wx.navigateTo({
|
|
url: `/subpages/demand/pages/demandDetail/demandDetail?id=${id}&showRate=0&source=${this.data.source}`
|
|
})
|
|
},
|
|
handleRate(e) {
|
|
const id = e.currentTarget.dataset.id
|
|
wx.navigateTo({
|
|
url: `/subpages/demand/pages/demandDetail/demandDetail?id=${id}&showRate=1&source=${this.data.source}`
|
|
})
|
|
},
|
|
handleFinish(e) {
|
|
const index = e.currentTarget.dataset.index
|
|
const { list } = this.data
|
|
const item = list[index]
|
|
wx.navigateTo({
|
|
url: `/subpages/demand/pages/demandFinish/demandFinish?id=${item.demandRecId}`
|
|
})
|
|
},
|
|
handleTell(e) {
|
|
const tell = e.currentTarget.dataset.tell
|
|
wx.makePhoneCall({
|
|
phoneNumber: tell
|
|
})
|
|
},
|
|
handleEdit(e) {
|
|
const id = e.currentTarget.dataset.id
|
|
wx.navigateTo({
|
|
url: `/subpages/demand/pages/demandCreate/demandCreate?id=${id}`
|
|
})
|
|
},
|
|
handleCancle(e) {
|
|
const id = e.currentTarget.dataset.id
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '取消之后无法恢复,是否取消?',
|
|
confirmText: '是',
|
|
cancelText: '否',
|
|
success: res => {
|
|
if (res.confirm) {
|
|
this.cenaleDemand(id)
|
|
} else {
|
|
console.log('点击了取消')
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|