From 2faa6546a9f9ddb29f81cbc9770fc25b95703695 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 26 七月 2024 17:02:39 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
wechat_jiaxuan/pages/calculator/index.js | 164 ++++++++++++++++++++++++++++++++++++------------------
1 files changed, 108 insertions(+), 56 deletions(-)
diff --git a/wechat_jiaxuan/pages/calculator/index.js b/wechat_jiaxuan/pages/calculator/index.js
index cb7f226..fc17e17 100644
--- a/wechat_jiaxuan/pages/calculator/index.js
+++ b/wechat_jiaxuan/pages/calculator/index.js
@@ -1,7 +1,13 @@
// 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({
@@ -36,31 +42,41 @@
this.getCalculatorOption()
const userInfo = wx.getStorageSync('member')
if (userInfo.phone) {
- that.setData({ userPhone: userInfo.phone })
+ that.setData({
+ userPhone: userInfo.phone
+ })
}
},
- navigateBack () {
+ navigateBack() {
wx.navigateBack({
delta: 1,
})
},
// picker 閫夋嫨
- onChange (e) {
- this.setData({ pickerIndex: e.detail.index })
+ onChange(e) {
+ this.setData({
+ pickerIndex: e.detail.index
+ })
},
// input 杈撳叆
- inputTyping (e) {
- this.setData({ [e.currentTarget.dataset.index]: e.detail.value })
+ inputTyping(e) {
+ this.setData({
+ [e.currentTarget.dataset.index]: e.detail.value
+ })
},
// 閫夋嫨鎴垮眿绫诲瀷銆佹埛鍨嬩俊鎭�
- toSelectType (e) {
+ toSelectType(e) {
let index = e.currentTarget.dataset.index
- let { activePicker } = this.data
- if ( activePicker === index) {
- this.setData({ showPopup: true })
+ let {
+ activePicker
+ } = this.data
+ if (activePicker === index) {
+ this.setData({
+ showPopup: true
+ })
} else {
this.setData({
pickerIndex: 0,
@@ -71,45 +87,71 @@
},
// 鍙栨秷閫夋嫨
- cancelPicker () {
- this.setData({ showPopup: false })
- },
-
- // 纭閫夋嫨
- confirmPicker () {
- let { activePicker, pickerIndex } = this.data
- this.setData({ [activePicker]: pickerIndex, showPopup: false })
- },
-
- // 鑾峰彇鐢ㄦ埛鎵嬫満鍙�
- getPhoneNumber (e) {
- const data = { ...e.detail }
- getWxMiniPhone({
- encryptedData: data.encryptedData,
- iv: data.iv,
- sessionKey: wx.getStorageSync('sessionKey') || data.iv,
- }).then(res => {
- binDingPhone({
- phone: res.data
- }).then((res) => {
- this.setData({ userPhone: res.data })
- if(res.code == 200){
- this.setData()
- wx.setStorageSync('member', res.data)
- this.submit()
- }
- })
+ cancelPicker() {
+ this.setData({
+ showPopup: false
})
},
+ // 纭閫夋嫨
+ confirmPicker() {
+ let {
+ activePicker,
+ pickerIndex
+ } = this.data
+ this.setData({
+ [activePicker]: pickerIndex,
+ showPopup: false
+ })
+ },
+
+ // 鑾峰彇鐢ㄦ埛鎵嬫満鍙�
+ getPhoneNumber(e) {
+ const data = {
+ ...e.detail
+ }
+ console.log('e', e);
+ if (data.encryptedData && data.iv) {
+ getWxMiniPhone({
+ encryptedData: data.encryptedData,
+ iv: data.iv,
+ sessionKey: wx.getStorageSync('sessionKey') || data.iv,
+ }).then(res => {
+ binDingPhone({
+ phone: res.data
+ }).then((res) => {
+ this.setData({
+ userPhone: res.data.phone
+ })
+ console.log('userPhone', this.data.userPhone);
+ if (res.code == 200) {
+ this.setData()
+ wx.setStorageSync('member', res.data)
+ this.submit()
+ }
+ })
+ })
+ }
+ },
+
// 绔嬪嵆璁$畻
- submit () {
+ 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
@@ -120,21 +162,21 @@
icon: 'none'
})
return false
- }
+ }
if (info === '') {
wx.showToast({
title: '璇烽�夋嫨鎴峰瀷淇℃伅',
icon: 'none'
})
return false
- }
+ }
if (area === '') {
wx.showToast({
title: '璇疯緭鍏ユ埧灞嬮潰绉�',
icon: 'none'
})
return false
- }
+ }
if (money === '') {
wx.showToast({
title: '璇疯緭鍏ヨ淇绠�',
@@ -146,20 +188,20 @@
// 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)
- if(item.children && item.children.length > 0){
+ 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('activeList', activeList);
- saveRenovationCalculator({
+ saveRenovationCalculator({
area,
budget: money,
houseStatus: type,
houseType: info
- }).then(res => {
+ }).then(res => {
// console.log(res)
if (res.success) {
wx.showToast({
@@ -170,13 +212,19 @@
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 => {
+ submitCalculatorResult(data) {
+ saveRenovationCalculator({
+ info: data
+ }).then(res => {
// console.log(res)
if (res.success) {
wx.showToast({
@@ -190,15 +238,19 @@
},
// 鑾峰彇璁$畻鍣ㄩ厤缃�
- getCalculatorOption () {
+ 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 () {
--
Gitblit v1.9.3