| | |
| | | import { |
| | | getDictData, |
| | | getArea, |
| | | saveFreeCustomizationApply |
| | | } from '../../api/index' |
| | | var QQMapWX = require('../../utils/qqmap-wx-jssdk.min'); |
| | | var qqmapsdk; |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | data: { |
| | | name: '', |
| | | phone: '', |
| | | city: '', |
| | | |
| | | showAreaList: false, |
| | | areaList: [], |
| | | addr: {}, |
| | | fieldNames: { |
| | | text: 'name', |
| | | value: 'id', |
| | | children: 'children', |
| | | }, |
| | | cascaderValue: '', |
| | | |
| | | DESIGN_BANNER: '', |
| | | WechatIMG558: '', |
| | | }, |
| | | onLoad(options) { |
| | | this.initData() |
| | | qqmapsdk = new QQMapWX({ |
| | | key: 'HIDBZ-2QXL4-TAWUD-XET6Q-EKTJE-CCBSQ' |
| | | }); |
| | | qqmapsdk.reverseGeocoder({ |
| | | success: (res) => { |
| | | console.log('res', res); |
| | | let addr = { |
| | | // provinceCode: codes[0] + '00', |
| | | provinceName: res.result.ad_info.province, |
| | | // cityCode: codes[1] + '00', |
| | | cityName: res.result.ad_info.city, |
| | | // areaCode: codes[2] + '00', |
| | | areaName: res.result.ad_info.district, |
| | | } |
| | | this.setData({ addr }) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | onSubmit() { |
| | | const { |
| | | name, |
| | | phone |
| | | phone, |
| | | addr |
| | | } = this.data |
| | | if (!name) return wx.showToast({ |
| | | title: '请输入姓名', |
| | |
| | | title: '请输入联系电话', |
| | | icon: 'none' |
| | | }) |
| | | if (phone.length !== 11) return wx.showToast({ |
| | | title: '请输入正确的联系电话', |
| | | icon: 'none' |
| | | }) |
| | | if (!addr.areaCode || !addr.cityCode) return wx.showToast({ |
| | | title: '请选择城市', |
| | | icon: 'none' |
| | | }) |
| | | saveFreeCustomizationApply({ |
| | | name, |
| | | phone |
| | | phone, |
| | | ...addr |
| | | }).then(res => { |
| | | wx.showToast({ |
| | | title: '报名成功' |
| | | }) |
| | | |
| | | wx.switchTab({ |
| | | url: '/pages/index/index', |
| | | }) |
| | | }) |
| | | }, |
| | | // 显示切换城市弹窗 |
| | | // 显示城市弹窗 |
| | | chooseCity () { |
| | | this.setData({ showAreaList: !this.data.showAreaList }) |
| | | console.log('chooseCity', this.data.showAreaList); |
| | | }, |
| | | // 切换城市 |
| | | confirmChange(e) { |
| | | let { |
| | | values |
| | | } = e.detail |
| | | let region = [] |
| | | for (let i in values) { |
| | | region.push(values[i].name) |
| | | onFinish(e) { |
| | | const { selectedOptions, value } = e.detail; |
| | | const addr = { |
| | | provinceCode: selectedOptions[0].id, |
| | | provinceName: selectedOptions[0].name, |
| | | cityCode: selectedOptions[1].id, |
| | | cityName: selectedOptions[1].name, |
| | | areaCode: selectedOptions[2].id, |
| | | areaName: selectedOptions[2].name, |
| | | } |
| | | this.setData({ addr, showAreaList: false }) |
| | | console.log('selectedOptions', addr); |
| | | }, |
| | | positionChange (e) { |
| | | console.log(e.detail.value) |
| | | const names = e.detail.value |
| | | const codes = e.detail.code |
| | | let addr = { |
| | | provinceCode: codes[0] + '00', |
| | | provinceName: names[0], |
| | | cityCode: codes[1] + '00', |
| | | cityName: names[1], |
| | | areaCode: codes[2] + '00', |
| | | areaName: names[2], |
| | | } |
| | | this.setData({ addr }) |
| | | }, |
| | | bindRegionChange(e) { |
| | | console.log('picker发送选择改变,携带值为', e.detail.value) |
| | | const temp = e.detail.value |
| | | this.setData({ |
| | | region, |
| | | cityCode: values[1].code |
| | | region: e.detail.value |
| | | }) |
| | | this.getShopList() |
| | | this.chooseCity() |
| | | }, |
| | | onClose() { |
| | | this.setData({ showAreaList: false }) |
| | | }, |
| | | initData() { |
| | | getArea({ |
| | | "level": "", |
| | | "pid": "" |
| | | }).then(res => { |
| | | this.setData({areaList: res.data}) |
| | | }) |
| | | getDictData({ |
| | | code: 'WEIXIN_DEFAULT_IMGS', |
| | | label: 'DESIGN_BANNER' |