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.
955 lines
27 KiB
955 lines
27 KiB
// index.js
|
|
// 获取应用实例
|
|
const app = getApp()
|
|
const axios = require('../../api/index')
|
|
const utils = require('../../utils/util')
|
|
const citydata = require('../../utils/city')
|
|
Page({
|
|
data: {
|
|
// 选择all
|
|
show_all_picker: false,
|
|
all_idx: 0,
|
|
all_list: [],
|
|
all_val: '',
|
|
is_picker: '',
|
|
// 设备类型
|
|
show_equipment: false,
|
|
equipment_list: [],
|
|
equipment_idx: 0,
|
|
// 设备品牌
|
|
show_brand: false,
|
|
brand_code: '',
|
|
brand_list: [
|
|
],
|
|
brand_idx: 0,
|
|
// 最大传输量
|
|
show_maxtransmission: false,
|
|
maxtransmission_list: [],
|
|
maxtransmission_idx: 0,
|
|
// 汽车底盘
|
|
show_chassis: false,
|
|
chassis_list: [],
|
|
chassis_idx: 0,
|
|
// 装载方量
|
|
show_volume: false,
|
|
volume_list: [],
|
|
volume_idx: 0,
|
|
// 臂架长度
|
|
show_boom: false,
|
|
boom_list: [],
|
|
boom_idx: 0,
|
|
// 年份
|
|
show_years: false,
|
|
years_list: [],
|
|
years_idx: 0,
|
|
|
|
is_edit: false,
|
|
show_region_picker: false,
|
|
region_list: [],
|
|
form_data: {
|
|
name: '',//姓名
|
|
phone: '',//电话
|
|
equipment_val: '',//设备类型名称classification
|
|
equipment_id: '',//设备类型id
|
|
brand_id: '',//设备品牌id
|
|
brand_val: '',//设备品牌名称
|
|
model: '',//设备型号
|
|
tonnage: '',//吨位
|
|
power: '',//功率
|
|
volume: '',//斗容
|
|
maxtransmission_id: '',//最大传输量id
|
|
maxtransmission_val: '',//最大传输量名称
|
|
volume_id: '',//装载方量id
|
|
volume_val: '',//装载方量名称
|
|
chassis_id: '',//汽车底盘id
|
|
chassis_val: '',//汽车底盘名称
|
|
boom_id: '',//臂架长度id
|
|
boom_val: '',//臂架长度名称
|
|
years_id: '',//出厂年份id
|
|
years_val: '',//出厂年份
|
|
content: '',//设备介绍
|
|
price: '',//价钱
|
|
city_val: '',//地址
|
|
provinceId: '',//省id
|
|
cityId: '',//市id
|
|
equipment_imgs: [],//设备图片
|
|
license_imgs: [],//设备图片
|
|
appearanceDate: ''//出厂年份
|
|
},
|
|
startTime: '1900-01-01',
|
|
endTime: '',
|
|
is_show_lack_currency: false,//发布次数不足提示
|
|
},
|
|
touchStart() {
|
|
// 滑动关闭
|
|
console.log('touchStart')
|
|
this.setData({
|
|
show_equipment: false,
|
|
show_all_picker: false
|
|
})
|
|
},
|
|
allconfirm_equipment(e) {//确定
|
|
console.log(e)
|
|
var idx = e.detail.idx,
|
|
{
|
|
form_data,
|
|
equipment_list
|
|
} = this.data;
|
|
if (form_data.equipment_id == equipment_list[idx].id) {
|
|
return
|
|
}
|
|
form_data.equipment_val = equipment_list[idx].name
|
|
form_data.equipment_id = equipment_list[idx].id
|
|
form_data.brand_id = ''//设备品牌id
|
|
form_data.brand_val = ''//设备品牌名称
|
|
form_data.model = ''//设备型号
|
|
form_data.tonnage = ''//吨位
|
|
form_data.power = ''//功率
|
|
form_data.volume = ''//斗容
|
|
form_data.maxtransmission_id = ''//最大传输量id
|
|
form_data.maxtransmission_val = ''//最大传输量名称
|
|
form_data.volume_id = ''//装载方量id
|
|
form_data.volume_val = ''//装载方量名称
|
|
form_data.chassis_id = ''//汽车底盘id
|
|
form_data.chassis_val = ''//汽车底盘名称
|
|
form_data.boom_id = ''//臂架长度id
|
|
form_data.boom_val = ''//臂架长度名称
|
|
form_data.years_id=''//出厂年份id
|
|
form_data.years_val=''//出厂年份
|
|
form_data.equipment_imgs= []//设备图片
|
|
form_data.license_imgs= []//设备图片
|
|
var brand_code = equipment_list[idx].code
|
|
this.setData({
|
|
// show_equipment_picker: false,
|
|
form_data,
|
|
equipment_idx: idx,
|
|
brand_code
|
|
}, () => {
|
|
this.getbrand_list()
|
|
this.getboom_list()
|
|
this.getchassis_list()
|
|
this.getvolume_list()
|
|
this.getmaxtransmission_list()
|
|
})
|
|
},
|
|
// all
|
|
show_all_picker_fn(e) {
|
|
var is_picker = e.currentTarget.dataset.type
|
|
if (is_picker == 'equipment') {
|
|
this.setData({
|
|
is_picker,
|
|
show_equipment: true
|
|
})
|
|
} else if (is_picker == 'brand') {
|
|
this.setData({
|
|
is_picker,
|
|
show_brand: true
|
|
})
|
|
} else if (is_picker == 'maxtransmission') {
|
|
this.setData({
|
|
is_picker,
|
|
show_maxtransmission: true
|
|
})
|
|
} else if (is_picker == 'chassis') {
|
|
this.setData({
|
|
is_picker,
|
|
show_chassis: true
|
|
})
|
|
} else if (is_picker == 'volume') {
|
|
this.setData({
|
|
is_picker,
|
|
show_volume: true
|
|
})
|
|
} else if (is_picker == 'boom') {
|
|
this.setData({
|
|
is_picker,
|
|
show_boom: true
|
|
})
|
|
} else if (is_picker == 'years') {
|
|
this.setData({
|
|
is_picker,
|
|
show_years: true
|
|
})
|
|
}
|
|
|
|
},
|
|
// 年份选择
|
|
dateChange: function (e) {
|
|
let {
|
|
form_data,
|
|
} = this.data
|
|
form_data.years_val = e.detail.value
|
|
// console.log('点击确定选择的时间是:',e.detail.value)
|
|
this.setData({
|
|
form_data
|
|
})
|
|
},
|
|
allcancel() {//取消
|
|
console.log(1)
|
|
this.setData({
|
|
show_equipment: false,
|
|
show_brand: false,
|
|
show_maxtransmission: false,
|
|
show_chassis: false,
|
|
show_volume: false,
|
|
show_boom: false,
|
|
show_years: false,
|
|
})
|
|
},
|
|
allconfirm(e) {//确定
|
|
var is_picker = this.data.is_picker
|
|
if (is_picker == 'equipment') {
|
|
var idx = e.detail,
|
|
{
|
|
form_data,
|
|
equipment_list
|
|
} = this.data;
|
|
if (form_data.equipment_id == equipment_list[idx].id) {
|
|
return
|
|
}
|
|
form_data.equipment_val = equipment_list[idx].name
|
|
form_data.equipment_id = equipment_list[idx].id
|
|
form_data.brand_id = '',//设备品牌id
|
|
form_data.brand_val = '',//设备品牌名称
|
|
form_data.model = '',//设备型号
|
|
form_data.tonnage = '',//吨位
|
|
form_data.power = '',//功率
|
|
form_data.volume = '',//斗容
|
|
form_data.maxtransmission_id = '',//最大传输量id
|
|
form_data.maxtransmission_val = '',//最大传输量名称
|
|
form_data.volume_id = '',//装载方量id
|
|
form_data.volume_val = '',//装载方量名称
|
|
form_data.chassis_id = '',//汽车底盘id
|
|
form_data.chassis_val = '',//汽车底盘名称
|
|
form_data.boom_id = '',//臂架长度id
|
|
form_data.boom_val = ''//臂架长度名称
|
|
var brand_code = equipment_list[idx].code
|
|
this.setData({
|
|
form_data,
|
|
equipment_idx: idx,
|
|
brand_code
|
|
}, () => {
|
|
// this.getbrand_list()
|
|
// this.getboom_list()
|
|
// this.getchassis_list()
|
|
// this.getvolume_list()
|
|
// this.getmaxtransmission_list()
|
|
})
|
|
} else if (is_picker == 'brand') {
|
|
var idx = e.detail,
|
|
{
|
|
form_data,
|
|
brand_list
|
|
} = this.data;
|
|
form_data.brand_val = brand_list[idx].name
|
|
form_data.brand_id = brand_list[idx].id
|
|
this.setData({
|
|
// show_equipment_picker: false,
|
|
form_data,
|
|
brand_idx: idx
|
|
})
|
|
} else if (is_picker == 'maxtransmission') {
|
|
var idx = e.detail,
|
|
{
|
|
form_data,
|
|
maxtransmission_list
|
|
} = this.data;
|
|
form_data.maxtransmission_val = maxtransmission_list[idx].name
|
|
form_data.maxtransmission_id = maxtransmission_list[idx].id
|
|
this.setData({
|
|
// show_equipment_picker: false,
|
|
form_data,
|
|
maxtransmission_idx: idx
|
|
})
|
|
} else if (is_picker == 'chassis') {
|
|
var idx = e.detail,
|
|
{
|
|
form_data,
|
|
chassis_list
|
|
} = this.data;
|
|
form_data.chassis_val = chassis_list[idx].name
|
|
form_data.chassis_id = chassis_list[idx].id
|
|
this.setData({
|
|
// show_equipment_picker: false,
|
|
form_data,
|
|
chassis_idx: idx
|
|
})
|
|
} else if (is_picker == 'volume') {
|
|
var idx = e.detail,
|
|
{
|
|
form_data,
|
|
volume_list
|
|
} = this.data;
|
|
form_data.volume_val = volume_list[idx].name
|
|
form_data.volume_id = volume_list[idx].id
|
|
this.setData({
|
|
// show_equipment_picker: false,
|
|
form_data,
|
|
volume_idx: idx
|
|
})
|
|
} else if (is_picker == 'boom') {
|
|
var idx = e.detail,
|
|
{
|
|
form_data,
|
|
boom_list
|
|
} = this.data;
|
|
form_data.boom_val = boom_list[idx].name
|
|
form_data.boom_id = boom_list[idx].id
|
|
this.setData({
|
|
// show_equipment_picker: false,
|
|
form_data,
|
|
boom_idx: idx
|
|
})
|
|
} else {
|
|
var idx = e.detail,
|
|
{
|
|
form_data,
|
|
years_list
|
|
} = this.data;
|
|
form_data.years_val = years_list[idx].name
|
|
form_data.years_id = years_list[idx].id
|
|
this.setData({
|
|
// show_equipment_picker: false,
|
|
form_data,
|
|
years_idx: idx
|
|
})
|
|
}
|
|
|
|
},
|
|
// 地区
|
|
show_region_picker_fn() {
|
|
this.setData({
|
|
show_region_picker: true,
|
|
})
|
|
},
|
|
sureCallBack_region(e) {
|
|
let city_val;
|
|
let { form_data } = this.data
|
|
if (e.detail.list[1].regionid != 0) {
|
|
city_val = e.detail.list[0].name + e.detail.list[1].name
|
|
} else {
|
|
city_val = e.detail.list[0].name
|
|
}
|
|
form_data.city_val = city_val
|
|
form_data.provinceId = e.detail.list[0].regionid
|
|
form_data.cityId = e.detail.list[1].regionid
|
|
this.setData({
|
|
form_data,
|
|
provinceId: e.detail.list[0].regionid,
|
|
cityId: e.detail.list[1].regionid,
|
|
})
|
|
},
|
|
cancleCallBack_region(e) {
|
|
this.setData({
|
|
show_region_picker: false
|
|
})
|
|
},
|
|
// 上传设别信息
|
|
up_equipment_imgs() {
|
|
let that = this
|
|
let { form_data } = this.data
|
|
if (form_data.equipment_imgs.length >= 12) {
|
|
wx.showToast({
|
|
title: '最多上传12张',
|
|
icon: "none"
|
|
})
|
|
return
|
|
}
|
|
utils.upLoadImageCos_2((12 - form_data.equipment_imgs.length), ((err, res) => {
|
|
|
|
if (err) {
|
|
wx.showToast({
|
|
title: message || '上传失败',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
console.log(res.statusCode)
|
|
// setTimeout(()=>{
|
|
// wx.showToast({
|
|
// title: JSON.stringify(res.statusCode),
|
|
// icon:'none'
|
|
// })
|
|
// })
|
|
|
|
var pictureLink = res.headers.Location.replace('http://znyc-images-1304677865.cos.ap-guangzhou.myqcloud.com', 'https://zhongnengyunche.com')
|
|
console.log(pictureLink)
|
|
pictureLink=pictureLink+'?watermark/1/image/aHR0cDovL3pueWMtaW1hZ2VzLTEzMDQ2Nzc4NjUuY29zLmFwLWd1YW5nemhvdS5teXFjbG91ZC5jb20vY2xvdWRjYXIvd3gvdXBsb2FkL2VxdWlwbWVudC9Xd3JNZkN0OEFCM1BiYWMzY2ZiMTA3NmEwNDk0NWNkZTQ4MzFiMjY3ODJlYS5wbmc=/gravity/southeast'
|
|
// ?watermark/1/image/aHR0cDovL3pueWMtaW1hZ2VzLTEzMDQ2Nzc4NjUuY29zLmFwLWd1YW5nemhvdS5teXFjbG91ZC5jb20vY2xvdWRjYXIvd3gvdXBsb2FkL2VxdWlwbWVudC9Xd3JNZkN0OEFCM1BiYWMzY2ZiMTA3NmEwNDk0NWNkZTQ4MzFiMjY3ODJlYS5wbmc=/gravity/southeast
|
|
var obj = {
|
|
id: 0,
|
|
pictureLink
|
|
}
|
|
form_data.equipment_imgs.push(obj)
|
|
that.setData({
|
|
form_data
|
|
})
|
|
// arr.push(res.headers.Location.replace('http://znyc-images-1304677865.cos.ap-guangzhou.myqcloud.com', 'https://zhongnengyunche.com'))
|
|
// arr2.push(res.headers.Location.replace('http://znyc-images-1304677865.cos.ap-guangzhou.myqcloud.com', ''))
|
|
}))
|
|
},
|
|
// 删除图片
|
|
del_equipment_imgs(e) {
|
|
console.log(e.currentTarget.dataset.index)
|
|
let { form_data } = this.data
|
|
form_data.equipment_imgs.splice(e.currentTarget.dataset.index, 1)
|
|
this.setData({
|
|
form_data
|
|
})
|
|
},
|
|
// 上传行驶证图片
|
|
up_license_imgs() {
|
|
let that = this
|
|
let { form_data } = this.data
|
|
utils.upLoadImageCos(((err, res) => {
|
|
if (err) {
|
|
wx.showToast({
|
|
title: message || '上传失败',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
// console.log(res.headers.Location)
|
|
var pictureLink = res.headers.Location.replace('http://znyc-images-1304677865.cos.ap-guangzhou.myqcloud.com', 'https://zhongnengyunche.com')
|
|
var obj = {
|
|
id: 0,
|
|
pictureLink
|
|
}
|
|
form_data.license_imgs.push(obj)
|
|
that.setData({
|
|
form_data
|
|
})
|
|
// arr.push(res.headers.Location.replace('http://znyc-images-1304677865.cos.ap-guangzhou.myqcloud.com', 'https://zhongnengyunche.com'))
|
|
// arr2.push(res.headers.Location.replace('http://znyc-images-1304677865.cos.ap-guangzhou.myqcloud.com', ''))
|
|
}))
|
|
},
|
|
// 删除图片
|
|
del_license_imgs(e) {
|
|
console.log(e.currentTarget.dataset.index)
|
|
let { form_data } = this.data
|
|
form_data.license_imgs.splice(e.currentTarget.dataset.index, 1)
|
|
this.setData({
|
|
form_data
|
|
})
|
|
},
|
|
// 其他文本框事件
|
|
input_fn(e) {
|
|
let type = e.currentTarget.dataset.type,
|
|
{
|
|
form_data
|
|
} = this.data;
|
|
form_data[type] = e.detail.value
|
|
this.setData({
|
|
form_data
|
|
})
|
|
},
|
|
// 获取分类
|
|
getequipment_list() {
|
|
axios.getEquipmentCategory().then(res => {
|
|
console.log(res)
|
|
this.setData({
|
|
equipment_list: res.data,
|
|
},()=>{
|
|
if(this.data.form_data.equipment_id!=''){
|
|
this.setData({
|
|
equipment_idx:this.screen(this.data.form_data.equipment_id,this.data.equipment_list)
|
|
})
|
|
}
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 获取品牌
|
|
getbrand_list() {
|
|
// axios.getgetbrand_list(this.data.brand_code).then(res => {
|
|
axios.getEquipmentBrand().then(res => {
|
|
this.setData({
|
|
brand_list: res.data,
|
|
},()=>{
|
|
if(this.data.form_data.brand_id!=''){
|
|
this.setData({
|
|
brand_idx:this.screen(this.data.form_data.brand_id,this.data.brand_list)
|
|
})
|
|
}
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
// 获取臂长
|
|
getboom_list() {
|
|
var that = this
|
|
var boom_list = wx.getStorageSync('boom')
|
|
setTimeout(() => {
|
|
if (boom_list&&boom_list.length!=0) {
|
|
that.setData({
|
|
boom_list: boom_list,
|
|
},()=>{
|
|
if(this.data.form_data.boom_id!=''){
|
|
this.setData({
|
|
boom_idx:this.screen(this.data.form_data.boom_id,this.data.boom_list)
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
axios.getboom_list().then(res => {
|
|
this.setData({
|
|
boom_list: res.data,
|
|
},()=>{
|
|
if(this.data.form_data.boom_id!=''){
|
|
this.setData({
|
|
boom_idx:this.screen(this.data.form_data.boom_id,this.data.boom_list)
|
|
})
|
|
}
|
|
})
|
|
wx.setStorage({
|
|
key: 'boom',
|
|
data: res.data
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
}
|
|
}, 0)
|
|
|
|
},
|
|
// 获取最大传输量
|
|
getmaxtransmission_list() {
|
|
var that = this
|
|
var maxtransmission_list = wx.getStorageSync('maxtransmission')
|
|
setTimeout(() => {
|
|
if (maxtransmission_list&&maxtransmission_list.length!=0) {
|
|
that.setData({
|
|
maxtransmission_list: maxtransmission_list,
|
|
},()=>{
|
|
if(this.data.form_data.maxtransmission_id!=''){
|
|
this.setData({
|
|
maxtransmission_idx:this.screen(this.data.form_data.maxtransmission_id,this.data.maxtransmission_list)
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
axios.getmaxtransmission_list().then(res => {
|
|
this.setData({
|
|
maxtransmission_list: res.data,
|
|
},()=>{
|
|
if(this.data.form_data.maxtransmission_id!=''){
|
|
this.setData({
|
|
maxtransmission_idx:this.screen(this.data.form_data.maxtransmission_id,this.data.maxtransmission_list)
|
|
})
|
|
}
|
|
})
|
|
wx.setStorage({
|
|
key: 'maxtransmission',
|
|
data: res.data
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
}
|
|
}, 0)
|
|
},
|
|
// 获取底盘
|
|
getchassis_list() {
|
|
var that = this
|
|
var chassis_list = wx.getStorageSync('chassis')
|
|
setTimeout(() => {
|
|
if (chassis_list&&chassis_list.length!=0) {
|
|
that.setData({
|
|
chassis_list: chassis_list,
|
|
},()=>{
|
|
if(this.data.form_data.chassis_id!=''){
|
|
this.setData({
|
|
chassis_idx:this.screen(this.data.form_data.chassis_id,this.data.chassis_list)
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
axios.getchassis_list().then(res => {
|
|
this.setData({
|
|
chassis_list: res.data,
|
|
},()=>{
|
|
if(this.data.form_data.chassis_id!=''){
|
|
this.setData({
|
|
chassis_idx:this.screen(this.data.form_data.chassis_id,this.data.chassis_list)
|
|
})
|
|
}
|
|
})
|
|
wx.setStorage({
|
|
key: 'chassis',
|
|
data: res.data
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
}
|
|
}, 0)
|
|
},
|
|
// 获取装载方量
|
|
getvolume_list() {
|
|
var that = this
|
|
var volume_list = wx.getStorageSync('volume')
|
|
setTimeout(() => {
|
|
if (volume_list&&volume_list.length!=0) {
|
|
that.setData({
|
|
volume_list: volume_list,
|
|
},()=>{
|
|
if(this.data.form_data.volume_id!=''){
|
|
this.setData({
|
|
volume_idx:this.screen(this.data.form_data.volume_id,this.data.volume_list)
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
axios.getvolume_list().then(res => {
|
|
console.log(res)
|
|
this.setData({
|
|
volume_list: res.data,
|
|
},()=>{
|
|
if(this.data.form_data.volume_id!=''){
|
|
this.setData({
|
|
volume_idx:this.screen(this.data.form_data.volume_id,this.data.volume_list)
|
|
})
|
|
}
|
|
})
|
|
wx.setStorage({
|
|
key: 'volume',
|
|
data: res.data
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
}
|
|
}, 0)
|
|
},
|
|
// 年份数据
|
|
getyears() {
|
|
var years_list = []
|
|
var year = new Date().getFullYear()
|
|
for (var i = 0; i <= 50; i++) {
|
|
var year_item = {
|
|
id: year - i,
|
|
name: year - i,
|
|
value: year - i
|
|
}
|
|
years_list.push(year_item)
|
|
}
|
|
this.setData({
|
|
years_list
|
|
},()=>{
|
|
if(this.data.form_data.years_id!=''){
|
|
this.setData({
|
|
years_idx:this.screen(this.data.form_data.years_id,this.data.years_list)
|
|
})
|
|
}
|
|
})
|
|
},
|
|
// 筛选选中项目
|
|
screen(screen_id,arr){
|
|
console.log(screen_id,arr)
|
|
var num=0
|
|
arr.forEach((item,index)=>{
|
|
if(item.id==screen_id){
|
|
console.log(index)
|
|
num=index
|
|
}
|
|
})
|
|
return num
|
|
},
|
|
checkPhone(phone) {
|
|
if (!(/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/.test(phone))) {
|
|
return false;
|
|
} else {
|
|
return true
|
|
}
|
|
},
|
|
// 校验
|
|
check() {
|
|
let { form_data } = this.data
|
|
if (form_data.equipment_id == '') {
|
|
wx.showToast({
|
|
title: '请选择设备类型',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
if (form_data.years_val == '') {
|
|
wx.showToast({
|
|
title: '请选择出厂年份',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
if (form_data.price == '') {
|
|
wx.showToast({
|
|
title: '请输入出售价格',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
var reg=/^[0-9]+(.[0-9]{1,10})?$/
|
|
if (!reg.test(form_data.price)) {
|
|
wx.showToast({
|
|
title: '请输入正确出售价格',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
if (form_data.content == '') {
|
|
wx.showToast({
|
|
title: '请填写设备介绍',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
if (form_data.city_val == '') {
|
|
wx.showToast({
|
|
title: '请选择车辆位置',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
if (form_data.name == '') {
|
|
wx.showToast({
|
|
title: '请输入姓名',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
if (form_data.equipment_imgs.length == 0) {
|
|
wx.showToast({
|
|
title: '请上传设备图片',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
if (form_data.license_imgs.length == 0) {
|
|
wx.showToast({
|
|
title: '请上传行驶证图片',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
}
|
|
if (form_data.phone && !this.checkPhone(form_data.phone)) {
|
|
wx.showToast({
|
|
title: '手机号码格式错误',
|
|
icon: 'none'
|
|
});
|
|
return
|
|
};
|
|
this.publish_fn()
|
|
},
|
|
// 发布
|
|
publish_fn() {
|
|
let { form_data } = this.data
|
|
var data = {
|
|
// "title": '0',
|
|
"equipmentType": Number(form_data.equipment_id) || 0,//设备类型
|
|
"equipmentBrand": Number(form_data.brand_id) || 0,//设备品牌
|
|
"automobileChassis": Number(form_data.chassis_id) || 0,//汽车低潘
|
|
"reprintVolume": Number(form_data.volume_id) || 0,//装载方量
|
|
"equipmentModel": form_data.model || '',//设备型号
|
|
"equipmentTonnage": Number(form_data.tonnage) || 0,//设备吨位
|
|
"capacity": Number(form_data.volume) || 0,//斗容
|
|
"power": Number(form_data.power) || '',//功率
|
|
"introduction": form_data.content || 0,//设备介绍
|
|
"appearanceDate": form_data.years_val || 0,//年份
|
|
"sellingPrice": Number(form_data.price) || 0,//出售价格
|
|
"automobileLocation": form_data.city_val || 0,//车辆位置
|
|
"provinceId": Number(form_data.provinceId),//市id
|
|
"cityId": Number(form_data.cityId),//区id
|
|
"contact": form_data.name || 0,//联系人
|
|
"boomLength": Number(form_data.boom_id) || 0,//臂长
|
|
"contactPhone": form_data.phone || 0,//联系人电话
|
|
"equipmentPictures": [],//图片
|
|
"maxTransportation": Number(form_data.maxtransmission_id) || 0,//
|
|
}
|
|
console.log(data)
|
|
form_data.equipment_imgs.forEach(item => {
|
|
var obj = {
|
|
pictureType: 10,
|
|
pictureLink: item.pictureLink,
|
|
id: item.id
|
|
}
|
|
data.equipmentPictures.push(obj)
|
|
});
|
|
form_data.license_imgs.forEach(item => {
|
|
var obj = {
|
|
pictureType: 20,
|
|
pictureLink: item.pictureLink,
|
|
id: item.id
|
|
}
|
|
data.equipmentPictures.push(obj)
|
|
});
|
|
console.log(data)
|
|
wx.requestSubscribeMessage({
|
|
tmplIds: ['dm1yuO5nVqiRQyMWcS4VZOjOZY5rDCjhiqiUcueyMJc'],
|
|
complete: e => {
|
|
console.log(e)
|
|
wx.showLoading({
|
|
title: '正在发布...',
|
|
mask: true
|
|
})
|
|
if (form_data.id) {//编辑
|
|
data.id = form_data.id
|
|
axios.eidtequipment(data).then(res => {
|
|
wx.hideLoading()
|
|
if (!res.successed) {
|
|
this.setData({
|
|
is_show_lack_currency: true
|
|
})
|
|
return
|
|
}
|
|
wx.reLaunch({
|
|
url: '/pages/publishFinish/publishFinish',
|
|
})
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
console.log(err)
|
|
})
|
|
} else {//新增
|
|
axios.addequipment(data).then(res => {
|
|
wx.hideLoading()
|
|
|
|
if (!res.successed) {
|
|
this.setData({
|
|
is_show_lack_currency: true
|
|
})
|
|
return
|
|
}
|
|
wx.reLaunch({
|
|
url: '/pages/publishFinish/publishFinish',
|
|
})
|
|
}).catch(err => {
|
|
wx.hideLoading()
|
|
console.log(err)
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
|
|
|
|
},
|
|
// 发不次数不足
|
|
// 隐藏弹框
|
|
hide_modal() {
|
|
this.setData({
|
|
is_show_lack_currency: false,//
|
|
})
|
|
},
|
|
//发布次数不够的时候确定
|
|
earn_currency() {
|
|
this.setData({
|
|
is_show_lack_currency: false,
|
|
})
|
|
wx.navigateTo({
|
|
url: '/pages/my_obtain/my_obtain?index=1&is_come=1',
|
|
})
|
|
},
|
|
onLoad(options) {
|
|
if (options.data) {
|
|
// 处理数据
|
|
let data = JSON.parse(unescape(options.data))
|
|
console.log(data)
|
|
var form_data = {
|
|
id: data.id,
|
|
name: data.contact,//姓名
|
|
phone: data.contactPhone,//电话
|
|
equipment_val: data.categoryName,//设备类型名称
|
|
equipment_id: data.equipmentType,//设备类型id
|
|
brand_id: data.equipmentBrand,//设备品牌id
|
|
brand_val: data.brandName,//设备品牌名称
|
|
model: data.equipmentModel,//设备型号
|
|
tonnage: data.equipmentTonnage,//吨位
|
|
power: data.power,//功率
|
|
volume: data.capacity,//斗容
|
|
maxtransmission_id: data.maxTransportation,//最大传输量id
|
|
maxtransmission_val: data.maxTransportationName,//最大传输量名称
|
|
volume_id: data.reprintVolume,//装载方量id
|
|
volume_val: data.reprintVolumeName,//装载方量名称
|
|
chassis_id: data.automobileChassis,//汽车底盘id
|
|
chassis_val: data.automobileChassisName,//汽车底盘名称
|
|
boom_id: data.boomLength,//臂架长度id
|
|
boom_val: data.boomLengthName,//臂架长度名称
|
|
years_id: data.appearanceDate,//出厂年份id
|
|
years_val: data.appearanceDate,//出厂年份
|
|
content: data.introduction,//设备介绍
|
|
price: data.sellingPrice,//价钱
|
|
city_val: data.automobileLocation,//地址
|
|
provinceId: data.provinceId,//省id
|
|
cityId:data.cityId,//市id
|
|
equipment_imgs: data.equipmentPictures,//设备图片
|
|
// license_imgs: data.driverlicense,//驾驶证图片
|
|
license_imgs: data.driverLicensePictures,//驾驶证图片
|
|
// appearanceDate:data.appearance//出厂年份
|
|
}
|
|
this.setData({
|
|
form_data
|
|
}, () => {
|
|
this.getequipment_list()
|
|
this.getyears()
|
|
this.getbrand_list()
|
|
this.getboom_list()
|
|
this.getchassis_list()
|
|
this.getvolume_list()
|
|
this.getmaxtransmission_list()
|
|
})
|
|
} else {
|
|
axios.get_newshowinfo().then(res=>{
|
|
if(res.data){
|
|
let form_data=this.data.form_data
|
|
form_data.name=res.data.contact
|
|
form_data.phone=res.data.contactPhone
|
|
this.setData({
|
|
form_data
|
|
})
|
|
}
|
|
})
|
|
this.getequipment_list()
|
|
this.getyears()
|
|
this.getbrand_list()
|
|
this.getboom_list()
|
|
this.getchassis_list()
|
|
this.getvolume_list()
|
|
this.getmaxtransmission_list()
|
|
}
|
|
setTimeout(() => {
|
|
let region_arr = citydata
|
|
let cityId=this.data.form_data.cityId
|
|
let provinceId=this.data.form_data.provinceId
|
|
if(provinceId!=''){
|
|
let city_ids = cityId.toString().split(',')
|
|
let province_ids = provinceId.toString().split(',')
|
|
console.log(city_ids)
|
|
console.log(province_ids)
|
|
region_arr = region_arr.map(item => {
|
|
province_ids = province_ids.filter(v => {
|
|
if (item.regionid == v) {
|
|
item.select = true
|
|
item.childers = item.childers.map(i => {
|
|
city_ids = city_ids.filter(x => {
|
|
if (i.regionid == x) {
|
|
i.select = true
|
|
}
|
|
return i.regionid != x
|
|
})
|
|
return i
|
|
})
|
|
}
|
|
return item.regionid != v
|
|
})
|
|
|
|
return item
|
|
})
|
|
}
|
|
this.setData({
|
|
region_list: region_arr,
|
|
})
|
|
}, 0)
|
|
},
|
|
// onShareAppMessage(e) {
|
|
|
|
// },
|
|
})
|
|
|