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.

120 lines
2.8 KiB

// pages/quest/subpage/detail/components/collection/collection.js
import {
http
} from '../../../../../../utils/util'
Component({
/**
* 组件的属性列表
*/
properties: {},
/**
* 组件的初始数据
*/
data: {
form: {
name: '',
tel: '',
add: [],
type: null,
tip: ''
},
brand: false,
brandpage: 1,
brandmax: null,
brands: []
},
/**
* 组件的方法列表
*/
methods: {
blur(e) {
let a = "form." + e.currentTarget.dataset.mes
let b = e.detail.value
this.setData({
[a]: b
})
},
getUserProvince(e) {
this.setData({
'form.add': e.detail.value
})
},
getbrand() {
this.setData({
brand: true
})
http("/brand/list", "post", ).then(res => {
if (this.data.brandpage === this.data.brandmax) {} else {
this.setData({
brands: this.data.brands.concat(res.data.records),
brandmax: res.data.pages,
brandpage: this.data.brandpage
})
this.getbrand()
}
})
},
choosebrand(e) {
this.setData({
'form.type': e.currentTarget.dataset.mes,
brand: false
})
},
update() {
// console.log(this.data.form)
// console.log(this.data.form.tel.match(/^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/))
if (!this.data.form.name) {
wx.showToast({
title: '请输入姓名',
icon: 'none',
duration: 2000
})
} else if (!this.data.form.tel) {
wx.showToast({
title: '请输入手机号',
icon: 'none',
duration: 2000
})
} else if (!this.data.form.tel.match(/^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/)) {
wx.showToast({
title: '请输入正确的手机号',
icon: 'none',
duration: 2000
})
} else if (this.data.form.add.length === 0) {
wx.showToast({
title: '请选择地区',
icon: 'none',
duration: 2000
})
} else {
http("/task/customerNote", "post", {
customerName: this.data.form.name,
tel: this.data.form.tel,
area: this.data.form.add.toString(),
brandId: this.data.form.type ? this.data.form.type.id : '',
remarks: this.data.form.tip
}).then(res => {
wx.showToast({
title: res.data,
icon: 'none',
duration: 2000
})
if (res.success) {
this.setData({
form: {
name: '',
tel: '',
add: [],
type: null,
tip: ''
}
})
}
})
}
}
}
})