纸通宝小程序
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.
 

176 lines
4.6 KiB

import { getBaseInfo, getOrderOutInfo, getReceiveInfo, feedbackReceiveInfo, deleteReceive, getCancelReceive, putReceive } from "../../api/saas"
import { $wuxDialog } from '../../../components/index'
const util = require('../../../utils/util')
const event = require('../../../utils/event')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
requesting: false,
orderId: null,
type: null,
dataDetails: {},
content: null,
safeBottom: app.globalData.safeBottom
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options.id) {
this.data.orderId = options.id
}
if (options.type) {
this.setData({ type: Number(options.type) })
}
this.setData({ safeBottom: app.globalData.safeBottom })
this.getDetailsInfo()
},
/**
* 获取支出详情
*/
getDetailsInfo: function () {
wx.showLoading({ title: '加载中', mask: true })
if (util.isEmpty(app.globalData.userInfo.userName)) {
getBaseInfo().then(result => {
app.globalData.userInfo = result.data
}).catch(err => {
})
}
if (this.data.type == 1) {
getReceiveInfo(this.data.orderId).then(res => {
this.setData({ dataDetails: res.data })
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
})
} else if (this.data.type == 2) {
getOrderOutInfo(this.data.orderId).then(res => {
this.setData({ dataDetails: res.data })
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
})
}
},
bindAndSet(e) {
let key = e.currentTarget.dataset.name
this.setData({ [key]: e.detail.value })
},
// 提交反馈
subFeedBack(feed) {
var that = this
const alert = (content) => {
$wuxDialog('#wux-dialog--alert').alert({
resetOnClose: true,
title: '提示',
content: content,
})
}
$wuxDialog().prompt({
resetOnClose: true,
title: '反馈内容',
fieldtype: 'textarea',
defaultText: '',
placeholder: '请输入反馈内容',
maxlength: 100,
onConfirm(e, response) {
var postModel = { remark: response, orderId: that.data.orderId }
if (response == "") {
util.showToast('反馈内容不能为空!')
return
}
wx.showLoading({ title: '处理中', mask: true })
feedbackReceiveInfo(postModel).then(res => {
wx.hideLoading()
util.showToast('提交反馈成功!')
}).catch(err => {
//异常回调
wx.hideLoading()
util.showToast(err)
})
},
})
},
ViewImage(e) {
var list = []
this.data.dataDetails.imgList.forEach(element => {
list.push(element.imgUrl)
});
wx.previewImage({ urls: list, current: e.currentTarget.dataset.url })
},
showDialog: function () {
var that = this
$wuxDialog().open({
resetOnClose: true,
title: '温馨提示',
content: '确定取消当前订单?',
buttons: [{
text: '取消'
}, {
text: '确定',
type: 'primary',
onTap(e) {
that.stopReceviePost()
}
}]
})
},
deleteOrder: function () {
var that = this
$wuxDialog().open({
resetOnClose: true,
title: '温馨提示',
content: '确定删除当前订单?',
buttons: [{
text: '取消'
}, {
text: '确定',
type: 'primary',
onTap(e) {
wx.showLoading({ title: '处理中', mask: true })
deleteReceive(that.data.orderId).then(res => {
event.emit('EventMessage', { what: 13, desc: '订单已删除' })
wx.hideLoading()
util.showBackToast('订单已删除!')
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
}]
})
},
//取消订单
stopReceviePost: function () {
wx.showLoading({ title: '处理中', mask: true })
getCancelReceive(this.data.orderId).then(result => {
event.emit('EventMessage', { what: 13, desc: '订单已取消' })
wx.hideLoading()
util.showToast('订单已取消!')
this.setData({ ['dataDetails.status']: 5 })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
},
// 确认订单
receviePost() {
wx.showLoading({ title: '处理中', mask: true })
putReceive(this.data.orderId).then(res => {
wx.hideLoading()
util.showBackToast('订单已确认!')
event.emit('EventMessage', { what: 13, desc: '订单已订单' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
})