| | |
| | | // pages/calculator/index.js |
| | | // import { imageUrl } from '../../utils/config' |
| | | // import { calculatorOption, calculatorSave, decodePhone, bindPhone } from '../../api/index' |
| | | import { getBjParamConfig, saveRenovationCalculator, getDictData, getWxMiniPhone, binDingPhone } from '../../api/index' |
| | | import { |
| | | getBjParamConfig, |
| | | saveRenovationCalculator, |
| | | getDictData, |
| | | getWxMiniPhone, |
| | | binDingPhone |
| | | } from '../../api/index' |
| | | // import Ls from '../../utils/storage' |
| | | // let ls = new Ls |
| | | Page({ |
| | |
| | | this.getCalculatorOption() |
| | | const userInfo = wx.getStorageSync('member') |
| | | if (userInfo.phone) { |
| | | that.setData({ userPhone: userInfo.phone }) |
| | | that.setData({ |
| | | userPhone: userInfo.phone |
| | | }) |
| | | } |
| | | }, |
| | | navigateBack () { |
| | |
| | | |
| | | // picker 选择 |
| | | onChange (e) { |
| | | this.setData({ pickerIndex: e.detail.index }) |
| | | this.setData({ |
| | | pickerIndex: e.detail.index |
| | | }) |
| | | }, |
| | | |
| | | // input 输入 |
| | | inputTyping (e) { |
| | | this.setData({ [e.currentTarget.dataset.index]: e.detail.value }) |
| | | this.setData({ |
| | | [e.currentTarget.dataset.index]: e.detail.value |
| | | }) |
| | | }, |
| | | |
| | | // 选择房屋类型、户型信息 |
| | | toSelectType (e) { |
| | | let index = e.currentTarget.dataset.index |
| | | let { activePicker } = this.data |
| | | let { |
| | | activePicker |
| | | } = this.data |
| | | if ( activePicker === index) { |
| | | this.setData({ showPopup: true }) |
| | | this.setData({ |
| | | showPopup: true |
| | | }) |
| | | } else { |
| | | this.setData({ |
| | | pickerIndex: 0, |
| | |
| | | |
| | | // 取消选择 |
| | | cancelPicker () { |
| | | this.setData({ showPopup: false }) |
| | | this.setData({ |
| | | showPopup: false |
| | | }) |
| | | }, |
| | | |
| | | // 确认选择 |
| | | confirmPicker () { |
| | | let { activePicker, pickerIndex } = this.data |
| | | this.setData({ [activePicker]: pickerIndex, showPopup: false }) |
| | | let { |
| | | activePicker, |
| | | pickerIndex |
| | | } = this.data |
| | | this.setData({ |
| | | [activePicker]: pickerIndex, |
| | | showPopup: false |
| | | }) |
| | | }, |
| | | |
| | | // 获取用户手机号 |
| | | getPhoneNumber (e) { |
| | | const data = { ...e.detail } |
| | | const data = { |
| | | ...e.detail |
| | | } |
| | | console.log('e', e); |
| | | if (data.encryptedData && data.iv) { |
| | | getWxMiniPhone({ |
| | | encryptedData: data.encryptedData, |
| | | iv: data.iv, |
| | |
| | | binDingPhone({ |
| | | phone: res.data |
| | | }).then((res) => { |
| | | this.setData({ userPhone: res.data }) |
| | | this.setData({ |
| | | userPhone: res.data.phone |
| | | }) |
| | | console.log('userPhone', this.data.userPhone); |
| | | if(res.code == 200){ |
| | | this.setData() |
| | | wx.setStorageSync('member', res.data) |
| | |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | // 立即计算 |
| | | submit () { |
| | | // console.log('立即计算') |
| | | let { userPhone } = this.data |
| | | let { |
| | | userPhone |
| | | } = this.data |
| | | const res = wx.getStorageSync('member') |
| | | |
| | | if (userPhone) { |
| | | let { type, info, area, money, typeArray, infoArray, calculatorOptions } = this.data |
| | | let { |
| | | type, |
| | | info, |
| | | area, |
| | | money, |
| | | typeArray, |
| | | infoArray, |
| | | calculatorOptions |
| | | } = this.data |
| | | let submitData = {} |
| | | submitData.name = res.name |
| | | submitData.phone = res.phone |
| | |
| | | // submitData = ['房屋类型:' + typeArray[type], '户型信息:' + infoArray[info], '房屋面积:' + area + '㎡', '装修预算:' + money + '万元'].join('-') |
| | | let activeList = type == '0' ? [...calculatorOptions.exquisiteList] : [...calculatorOptions.roughList] |
| | | activeList.forEach(item => { |
| | | item.money = (money * item.rate / 100).toFixed(1) |
| | | item.money = (money * item.rate / 100).toFixed(2) |
| | | if(item.children && item.children.length > 0){ |
| | | item.children.forEach(child => { |
| | | child.money = (money * child.rate / 100).toFixed(2) |
| | |
| | | console.log(res.msg) |
| | | } |
| | | }) |
| | | this.setData({ activeList, showResultMoney: true, containerContentStyle: 'auto' }) |
| | | this.setData({ |
| | | activeList, |
| | | showResultMoney: true, |
| | | containerContentStyle: 'auto' |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | // 提交计算结果 |
| | | submitCalculatorResult (data) { |
| | | saveRenovationCalculator({ info: data }).then(res => { |
| | | saveRenovationCalculator({ |
| | | info: data |
| | | }).then(res => { |
| | | // console.log(res) |
| | | if (res.success) { |
| | | wx.showToast({ |
| | |
| | | // 获取计算器配置 |
| | | getCalculatorOption () { |
| | | getBjParamConfig().then(res => { |
| | | this.setData({ calculatorOptions: res.data }) |
| | | this.setData({ |
| | | calculatorOptions: res.data |
| | | }) |
| | | }) |
| | | getDictData({ |
| | | code: 'WEIXIN_DEFAULT_IMGS', |
| | | label: 'JISUAN_BG' |
| | | }).then(res => { |
| | | this.setData({ background: res.data.code }) |
| | | this.setData({ |
| | | background: res.data.code |
| | | }) |
| | | }) |
| | | }, |
| | | onReady: function () { |