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.
351 lines
12 KiB
351 lines
12 KiB
import { getVehicleList } from "../../../api/ztb"
|
|
const util = require('../../../utils/util')
|
|
const math = require('../../../utils/math')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
height: app.globalData.fragmentHeight,
|
|
safeBottom: app.globalData.safeBottom,
|
|
keyboardHeight: 0,
|
|
form: {
|
|
paperCategoryId: '',
|
|
unitPrice: ''
|
|
},
|
|
timeList: [],
|
|
cateName: '',
|
|
factoryDetail: null,
|
|
vehicleList: [{}],
|
|
plateList: [],
|
|
vateList: [],
|
|
cateList: [],
|
|
plateNumber: '',
|
|
plateString: '',
|
|
vindex: -1,
|
|
requesting: false,
|
|
columns: [],
|
|
toolbar: '',
|
|
toolId: '',
|
|
visible: false,
|
|
code: '',
|
|
editing: false,
|
|
focusTop: '100%', // 输入框获取焦点时的top值
|
|
platform: false, // 机型
|
|
domHeight: 'auto', // dom元素高度
|
|
focusTime: 0 // 获取焦点的时间 yiling 20200408 14:43:56
|
|
},
|
|
onLoad: function (options) {
|
|
if(Number(options.type) == 1){
|
|
let channel = this.getOpenerEventChannel()
|
|
let that = this
|
|
channel.once('onParam', function (data) {
|
|
that.initForm(data)
|
|
})
|
|
} else if(options.orderId){
|
|
// wx.showLoading({ title: '加载中', mask: true })
|
|
// getProxyOrderInfo(options.orderId).then(result => {
|
|
// this.setData({ form: result.data, cateName: result.data.paperCategory, safeBottom: app.globalData.safeBottom,
|
|
// ['form.totalEstimatedWeight']: math.divide(result.data.estimatedWeight, 1000)
|
|
// })
|
|
// wx.hideLoading()
|
|
// }).catch(err => {
|
|
// wx.hideLoading()
|
|
// util.showToast(err)
|
|
// })
|
|
}
|
|
var day = new Date()
|
|
for (let i = 0; i < 7; i++) {
|
|
day.setDate(day.getDate() + (i > 1 ? 1 : i))
|
|
this.data.timeList.push(util.formatDate(day, 'Y-M-D'))
|
|
}
|
|
},
|
|
initForm: function(detail){
|
|
for (let index = 0; index < detail.agentPaperCategoryList.length; index++) {
|
|
const element = detail.agentPaperCategoryList[index]
|
|
this.data.cateList.push(element.displayName + '(预估单价:' + element.paperMillPrice + '元/吨)')
|
|
}
|
|
var item = detail.agentPaperCategoryList[detail.cateIndex || 0]
|
|
this.setData({
|
|
cateName: item.displayName,
|
|
millName: detail.paperMillName,
|
|
['form.unitPrice']: item.paperMillPrice,
|
|
['form.priceOfAgentSold']: detail.priceOfAgentSold
|
|
})
|
|
},
|
|
onInput: function(e){
|
|
if(e.currentTarget.id == 'totalEstimatedWeight'){
|
|
this.data.form.totalEstimatedWeight = e.detail
|
|
this.data.amout = 0
|
|
if(Number(e.detail) > 0){
|
|
this.data.amout = math.times(e.detail, this.data.form.unitPrice)
|
|
}
|
|
this.setData({ amout: this.data.amout })
|
|
} else if(e.currentTarget.id == 'priceOfAgentSold'){
|
|
this.data.form.priceOfAgentSold = e.detail
|
|
}
|
|
},
|
|
onEdit: function(e){
|
|
this.setData({ editing: true })
|
|
},
|
|
bindInput: function (e) {
|
|
if(!util.isEmpty(e.currentTarget.id)){
|
|
var form_data = 'form.' + e.currentTarget.id
|
|
if(e.currentTarget.id == 'remark'){
|
|
this.setData({ [form_data]: e.detail })
|
|
} else {
|
|
this.setData({ [form_data]: e.detail.value })
|
|
}
|
|
} else {
|
|
this.data.code = e.detail.value
|
|
}
|
|
},
|
|
showKeyboard: function(e){
|
|
var item = this.data.vehicleList[e.currentTarget.dataset.index]
|
|
this.keyboard = this.keyboard || this.selectComponent('#wux-keyboard')
|
|
this.keyboard.show(item.plateNumber, e.currentTarget.dataset.index)
|
|
},
|
|
onPlatenumber: function({detail}){
|
|
if(detail && detail.plateNumber){
|
|
this.setData({ ['vehicleList[' + detail.type + '].plateNumber']: detail.plateNumber })
|
|
}
|
|
},
|
|
addCate: function (e) {
|
|
if(this.data.vehicleList.length >= 5){
|
|
util.showToast('一次预约不能超过5辆车')
|
|
return
|
|
}
|
|
this.data.vehicleList.push({ plateNumber: '', driverName: '', driverPhone: '', packageNum: '' })
|
|
this.setData({ vehicleList: this.data.vehicleList })
|
|
},
|
|
deleteCate: function (e) {
|
|
this.data.vehicleList.splice(e.currentTarget.dataset.index, 1)
|
|
this.setData({ vehicleList: this.data.vehicleList })
|
|
},
|
|
bindList: function(event){
|
|
this.setData({ ['vehicleList[' + event.currentTarget.dataset.index + '].' + event.target.id]: event.detail.value })
|
|
},
|
|
showPicker: function (e) {
|
|
if(!util.isEmpty(this.data.form.activityId) && e.currentTarget.id == 'cateName'){
|
|
return
|
|
}
|
|
this.data.toolId = e.currentTarget.id
|
|
if(e.currentTarget.id == 'deliveryTime'){
|
|
this.setData({ visible: true, columns: this.data.timeList, toolbar: '选择到货时间' })
|
|
} else if(e.currentTarget.id == 'cateName'){
|
|
this.setData({ visible: true, columns: this.data.cateList, toolbar: '选择纸品' })
|
|
}
|
|
},
|
|
onHide: function(){
|
|
this.setData({ visible: false })
|
|
},
|
|
onConfirm: function ({detail}) {
|
|
if(this.data.toolId == 'deliveryTime'){
|
|
this.setData({ ['form.deliveryTime']: detail.value, visible: false })
|
|
} else if(this.data.toolId == 'cateName'){
|
|
const element = this.data.factoryDetail.paperCategoryList[detail.index]
|
|
if(element.publicSubsidies && Number(element.publicSubsidies) > 0){
|
|
this.data.form.publicSubsidies = element.publicSubsidies
|
|
this.data.form.unitPrice = math.plus(element.unitPrice, element.publicSubsidies)
|
|
} else {
|
|
this.data.form.unitPrice = element.unitPrice
|
|
this.data.form.publicSubsidies = 0
|
|
}
|
|
this.data.cateName = element.categoryName
|
|
this.data.form.paperCategoryId = element.categoryId
|
|
this.setData({ ['form.unitPrice']: this.data.form.unitPrice, ['form.publicSubsidies']: this.data.form.publicSubsidies,
|
|
cateName: this.data.cateName, visible: false })
|
|
}
|
|
},
|
|
tagChange: function(e){
|
|
var item = this.data.vateList[e.target.dataset.index]
|
|
if(item.fold == 1){
|
|
this.data.vateList = this.data.plateList.slice(0, 16)
|
|
// this.data.vateList.push({plateNumber: '收起', fold: 2})
|
|
this.setData({ vateList: this.data.vateList })
|
|
return
|
|
}
|
|
if(item.fold == 2){
|
|
this.data.vateList = this.data.plateList.slice(0, 7)
|
|
this.data.vateList.push({plateNumber: '展开', fold: 1})
|
|
this.setData({ vateList: this.data.vateList })
|
|
return
|
|
}
|
|
for (let index = 0; index < this.data.vehicleList.length; index++) {
|
|
if(this.data.vehicleList[index].plateNumber == item.plateNumber){
|
|
return
|
|
}
|
|
}
|
|
for (let index = 0; index < this.data.vehicleList.length; index++) {
|
|
if(util.isEmpty(this.data.vehicleList[index].plateNumber)){
|
|
this.setData({ ['vehicleList[' + index+ '].plateNumber']: item.plateNumber })
|
|
return
|
|
}
|
|
}
|
|
if(this.data.vehicleList.length >= 5){
|
|
util.showToast('一次预约不能超过5辆车')
|
|
return
|
|
}
|
|
this.data.vehicleList.push({plateNumber: item.plateNumber})
|
|
this.setData({ vehicleList: this.data.vehicleList })
|
|
},
|
|
submitForm: function (e) {
|
|
// if(!app.userInfo.isAuth) {
|
|
// Dialog.alert({ title: '温馨提示', message: '您暂未实名认证,请实名认证后提交订单。' }).then(() => {
|
|
// wx.navigateTo({ url: '/pages/setting/authory/index' })
|
|
// })
|
|
// return
|
|
// }
|
|
if (util.isEmpty(this.data.form.totalEstimatedWeight)) {
|
|
util.showToast('请输入预估重量')
|
|
return
|
|
}
|
|
if (Number(this.data.form.totalEstimatedWeight) <= 0) {
|
|
util.showToast('预估重量必须大于0')
|
|
return
|
|
}
|
|
if (util.isEmpty(this.data.form.deliveryTime)) {
|
|
util.showToast('请选择货到时间')
|
|
return
|
|
}
|
|
if (Number(this.data.form.priceOfAgentSold) <= 0) {
|
|
util.showToast('请输入代卖费,且大于0')
|
|
return
|
|
}
|
|
var vehicleList = []
|
|
for (let index = 0; index < this.data.vehicleList.length; index++) {
|
|
const element = this.data.vehicleList[index]
|
|
if(!util.isEmpty(element.plateNumber)){
|
|
vehicleList.push(element)
|
|
}
|
|
}
|
|
if (vehicleList.length < 1) {
|
|
util.showToast('请选择或者输入车牌号码')
|
|
return
|
|
}
|
|
this.data.form.carInfos = vehicleList
|
|
var that = this
|
|
wx.requestSubscribeMessage({
|
|
tmplIds: app.tmplIds,
|
|
complete(res) {
|
|
that.submitOrder()
|
|
}
|
|
})
|
|
},
|
|
submitOrder: function(){
|
|
if(this.data.requesting){
|
|
return
|
|
}
|
|
this.data.form.totalEstimatedWeight = math.times(this.data.form.totalEstimatedWeight, 1000)
|
|
this.setData({ requesting: true })
|
|
wx.showLoading({ title: '处理中', mask: true })
|
|
createProxyOrder(this.data.form).then(result => {
|
|
wx.hideLoading()
|
|
wx.redirectTo({ url: '/xtends/proxysell/result/index' })
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
util.showToast(err)
|
|
this.data.form.totalEstimatedWeight = math.divide(this.data.form.totalEstimatedWeight, 1000)
|
|
this.setData({ requesting: false })
|
|
})
|
|
},
|
|
/************************************** TextArea ********************************************/
|
|
handleEvaluationFocus(e) {
|
|
/* 获取焦点时记录时间 yiling 202000408 14:43:56 start */
|
|
this.setData({ focusTime: Date.now() })
|
|
/* 获取焦点时记录时间 yiling 202000408 14:43:56 end */
|
|
const { height } = e.detail // 为键盘高度
|
|
const windowHeight = wx.getSystemInfoSync().windowHeight // 可使用窗口高度,单位px
|
|
if (this.data.oldFocusTop) {
|
|
this.setData({ focusTop: this.data.oldFocusTop })
|
|
} else {
|
|
const query = wx.createSelectorQuery().in(this) // 自定义组件内必须添加.in(this),否则获取不到dom数据!
|
|
query.select('.popup-evaluation-wrap').boundingClientRect()
|
|
query.exec(res => {
|
|
if (res[0]) {
|
|
const domHeight = res[0].height || 156
|
|
this.setData({
|
|
focusTop: (windowHeight - domHeight - height) + 'px',
|
|
oldFocusTop: (windowHeight - domHeight - height) + 'px',
|
|
domHeight: domHeight + 'px', // 固定高度,防止部分机型中多行文本时布局错乱
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* @author: yiling
|
|
* @description: 监听输入框输入内容,统计字数
|
|
* @param {Object} event event
|
|
* @return {void}
|
|
* @Date: 2019-12-16 15:46:22
|
|
*/
|
|
handleEvaluationInput({detail}) {
|
|
this.setData({ ['form.remark']: detail.value })
|
|
},
|
|
/**
|
|
* @author: yiling
|
|
* @description: 点击完成按钮时关闭弹窗
|
|
* @return {void}
|
|
* @Date: 2019-12-16 15:46:22
|
|
*/
|
|
handleEvaluationConfirm() {
|
|
this.handleClose()
|
|
},
|
|
/**
|
|
* @author: yiling
|
|
* @description: 点击发表评论按钮
|
|
* @return {void}
|
|
* @Date: 2019-12-16 15:46:22
|
|
*/
|
|
handleEvaluationRelease() {
|
|
this.handleClose((object) => {
|
|
object.id = this.data.info.id // id
|
|
object.content = this.data.commentsText // 评论内容
|
|
object.typeName = this.data.info.typeName // 类型:名片 / 资讯 / 商城 / ...
|
|
})
|
|
},
|
|
/**
|
|
* @author: yiling
|
|
* @description: 关闭输入框的弹窗
|
|
* @param {Function} callback 回调
|
|
* @return {void}
|
|
* @Date: 2019-12-16 15:46:22
|
|
*/
|
|
handleClose(callback) {
|
|
this.setData({ focusTop: '100%', editing: false })
|
|
},
|
|
/**
|
|
* @author: yiling
|
|
* @description: 防页面穿透
|
|
* @return {void}
|
|
* @Date: 2019-12-16 15:46:22
|
|
*/
|
|
handleEvaluationtouchmove() {
|
|
this.handleClose()
|
|
return false
|
|
},
|
|
/**
|
|
* @author: yiling
|
|
* @description: 失去焦点(安卓机软键盘右上角的小三角会触发)
|
|
* @return {void}
|
|
* @Date: 2019-12-19
|
|
*/
|
|
handleEvaluationBlur() {
|
|
if (Date.now() > this.data.focusTime && this.data.focusTime !== 0) {
|
|
this.handleClose()
|
|
}
|
|
},
|
|
noop: function(){
|
|
|
|
},
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|