From cabbca85b518f561d0dc2b7a7ec11d6922785b86 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期三, 10 七月 2024 17:52:38 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/zbomyoujia
---
wechat_jiaxuan/pages/calculator/index.js | 235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 235 insertions(+), 0 deletions(-)
diff --git a/wechat_jiaxuan/pages/calculator/index.js b/wechat_jiaxuan/pages/calculator/index.js
new file mode 100644
index 0000000..560f42b
--- /dev/null
+++ b/wechat_jiaxuan/pages/calculator/index.js
@@ -0,0 +1,235 @@
+// pages/calculator/index.js
+// import { imageUrl } from '../../utils/config'
+// import { calculatorOption, calculatorSave, decodePhone, bindPhone } from '../../api/index'
+// import Ls from '../../utils/storage'
+// let ls = new Ls
+Page({
+
+ /**
+ * 椤甸潰鐨勫垵濮嬫暟鎹�
+ */
+ data: {
+ // background: imageUrl + 'calculator/background.jpg',
+ userPhone: '',
+ type: '',
+ info: '',
+ area: '',
+ money: '',
+ typeArray: ['绮捐', '姣涘澂'],
+ infoArray: [
+ '涓�瀹や竴鍘�', '涓ゅ涓�鍘�', '涓ゅ涓ゅ巺', '涓夊涓ゅ巺',
+ '鍥涘涓ゅ巺', '浜斿涓ゅ巺鍙婁互涓�'
+ ],
+ calculatorOptions: [],
+ showPopup: false,
+ activePicker: '',
+ pickerIndex: 0,
+ // 灞曠ず璁$畻缁撴灉
+ showResultMoney: false,
+ containerContentStyle: 'hidden;'
+ },
+
+ // 杩斿洖涓婁竴椤�
+ navigateBack () {
+ wx.navigateBack({
+ delta: 1,
+ })
+ },
+
+ // picker 閫夋嫨
+ onChange (e) {
+ this.setData({ pickerIndex: e.detail.index })
+ },
+
+ // input 杈撳叆
+ inputTyping (e) {
+ this.setData({ [e.currentTarget.dataset.index]: e.detail.value })
+ },
+
+ // 閫夋嫨鎴垮眿绫诲瀷銆佹埛鍨嬩俊鎭�
+ toSelectType (e) {
+ let index = e.currentTarget.dataset.index
+ let { activePicker } = this.data
+ if ( activePicker === index) {
+ this.setData({ showPopup: true })
+ } else {
+ this.setData({
+ pickerIndex: 0,
+ activePicker: index,
+ showPopup: true
+ })
+ }
+ },
+
+ // 鍙栨秷閫夋嫨
+ cancelPicker () {
+ this.setData({ showPopup: false })
+ },
+
+ // 纭閫夋嫨
+ confirmPicker () {
+ let { activePicker, pickerIndex } = this.data
+ this.setData({ [activePicker]: pickerIndex, showPopup: false })
+ },
+
+ // 鑾峰彇鐢ㄦ埛鎵嬫満鍙�
+ 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()
+ })
+ }
+ })
+ },
+
+ // 绔嬪嵆璁$畻
+ submit () {
+ // console.log('绔嬪嵆璁$畻')
+ let { userPhone } = this.data
+ ls.get('userInfo').then(res => {
+ // console.log(res)
+ if (userPhone) {
+ let { type, info, area, money, typeArray, infoArray, calculatorOptions: options } = this.data
+ let submitData = {}
+ submitData.name = res.name
+ submitData.phone = res.phone
+
+ if (type === '') {
+ wx.showToast({
+ title: '璇烽�夋嫨鎴垮眿绫诲瀷',
+ 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: '璇疯緭鍏ヨ淇绠�',
+ icon: 'none'
+ })
+ 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)
+ }
+ }
+ this.setData({ calculatorOptions: options, showResultMoney: true, containerContentStyle: 'auto' })
+ this.submitCalculatorResult(submitData)
+ }
+ })
+ },
+
+ // 鎻愪氦璁$畻缁撴灉
+ submitCalculatorResult (data) {
+ calculatorSave({ info: data }).then(res => {
+ // console.log(res)
+ if (res.success) {
+ wx.showToast({
+ title: '璁$畻鎴愬姛',
+ icon: 'none'
+ })
+ } else {
+ console.log(res.msg)
+ }
+ })
+ },
+
+ // 鑾峰彇璁$畻鍣ㄩ厤缃�
+ getCalculatorOption () {
+ calculatorOption().then(res => {
+ this.setData({ calculatorOptions: res.data })
+ })
+ },
+
+ /**
+ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
+ */
+ onLoad: function (options) {
+ let that = this
+ // this.getCalculatorOption()
+ // ls.get('userInfo').then(res => {
+ // if (res.phone) {
+ // that.setData({ userPhone: res.phone })
+ // }
+ // })
+ },
+
+ /**
+ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ /**
+ * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
+ */
+ onShareAppMessage: function () {
+
+ }
+})
\ No newline at end of file
--
Gitblit v1.9.3