From 0d3fc39d118fe82335b4a02624b17d60db53d2ef Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 16 七月 2024 17:38:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
wechat_jiaxuan/pages/calculator/index.js | 81 +++++++++++++++++++++++++---------------
1 files changed, 51 insertions(+), 30 deletions(-)
diff --git a/wechat_jiaxuan/pages/calculator/index.js b/wechat_jiaxuan/pages/calculator/index.js
index 03cd517..e8ef0df 100644
--- a/wechat_jiaxuan/pages/calculator/index.js
+++ b/wechat_jiaxuan/pages/calculator/index.js
@@ -1,7 +1,7 @@
// pages/calculator/index.js
// import { imageUrl } from '../../utils/config'
// import { calculatorOption, calculatorSave, decodePhone, bindPhone } from '../../api/index'
-import { getBjParamConfig, saveRenovationCalculator } from '../../api/index'
+import { getBjParamConfig, saveRenovationCalculator, getDictData, getWxMiniPhone, binDingPhone } from '../../api/index'
// import Ls from '../../utils/storage'
// let ls = new Ls
Page({
@@ -10,7 +10,7 @@
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
data: {
- // background: imageUrl + 'calculator/background.jpg',
+ background: '',
userPhone: '',
type: '',
info: '',
@@ -21,7 +21,8 @@
'涓�瀹や竴鍘�', '涓ゅ涓�鍘�', '涓ゅ涓ゅ巺', '涓夊涓ゅ巺',
'鍥涘涓ゅ巺', '浜斿涓ゅ巺鍙婁互涓�'
],
- calculatorOptions: [],
+ calculatorOptions: {},
+ activeList: [],
showPopup: false,
activePicker: '',
pickerIndex: 0,
@@ -38,7 +39,6 @@
that.setData({ userPhone: userInfo.phone })
}
},
- // 杩斿洖涓婁竴椤�
navigateBack () {
wx.navigateBack({
delta: 1,
@@ -83,24 +83,21 @@
// 鑾峰彇鐢ㄦ埛鎵嬫満鍙�
getPhoneNumber (e) {
- // console.log(e)
- let that = this
- decodePhone({ code: e.detail.code })
- .then(res => {
- if (res.phone === undefined || res.phone.length === null || !res.phone) {
- wx.showToast({
- title: res.msg,
- icon: 'none'
- })
- } else {
- bindPhone({ phone: res.phone })
- .then(newInfo => {
- ls.set('userInfo', newInfo.member)
- that.setData({ userPhone: res.phone })
- that.submit()
- })
+ 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) => {
+ if(res.code == 200){
+ wx.setStorageSync('member', res.data)
+ this.submit()
}
})
+ })
},
// 绔嬪嵆璁$畻
@@ -110,7 +107,7 @@
const res = wx.getStorageSync('member')
if (userPhone) {
- let { type, info, area, money, typeArray, infoArray, calculatorOptions: options } = this.data
+ let { type, info, area, money, typeArray, infoArray, calculatorOptions } = this.data
let submitData = {}
submitData.name = res.name
submitData.phone = res.phone
@@ -144,16 +141,34 @@
return false
}
- submitData = ['鎴垮眿绫诲瀷锛�' + typeArray[type], '鎴峰瀷淇℃伅锛�' + infoArray[info], '鎴垮眿闈㈢Н锛�' + area + '銕�', '瑁呬慨棰勭畻锛�' + money + '涓囧厓'].join('-')
- for (let i in options) {
- options[i].money = (money * options[i].rate / 100).toFixed(2)
- let childList = options[i].childList
- for(let j in childList) {
- childList[j].money = (money * childList[j].rate / 100).toFixed(2)
+ // 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.children.forEach(child => {
+ child.money = (money * child.rate / 100).toFixed(2)
+ })
}
- }
- this.setData({ calculatorOptions: options, showResultMoney: true, containerContentStyle: 'auto' })
- this.submitCalculatorResult(submitData)
+ })
+ console.log('activeList', activeList);
+ saveRenovationCalculator({
+ area,
+ budget: money,
+ houseStatus: type,
+ houseType: info
+ }).then(res => {
+ // console.log(res)
+ if (res.success) {
+ wx.showToast({
+ title: '璁$畻鎴愬姛',
+ icon: 'none'
+ })
+ } else {
+ console.log(res.msg)
+ }
+ })
+ this.setData({ activeList, showResultMoney: true, containerContentStyle: 'auto' })
}
},
@@ -177,6 +192,12 @@
getBjParamConfig().then(res => {
this.setData({ calculatorOptions: res.data })
})
+ getDictData({
+ code: 'WEIXIN_DEFAULT_IMGS',
+ label: 'JISUAN_BG'
+ }).then(res => {
+ this.setData({ background: res.data.code })
+ })
},
onReady: function () {
--
Gitblit v1.9.3