Browse Source

Merge branch 'dev' of http://git.ycjcjy.com/zhiyuxing/miniapp-v3 into dev

xujing 5 years ago
parent
commit
5f75bc45c8
1 changed files with 59 additions and 19 deletions
  1. 59
    19
      src/onlineSelling/pages/raiseMoney/index.js

+ 59
- 19
src/onlineSelling/pages/raiseMoney/index.js View File

10
 import NextStep from './NextStep'
10
 import NextStep from './NextStep'
11
 import { fetch, apis } from '@/utils/request'
11
 import { fetch, apis } from '@/utils/request'
12
 import Captcha from './Captcha'
12
 import Captcha from './Captcha'
13
-import { raiseOrder, cancelOrder } from '@/services/project'
13
+import { raiseOrder, cancelOrder, queryPreselectionRecord } from '@/services/project'
14
 import { getCodeMessage } from '@/services/getCode'
14
 import { getCodeMessage } from '@/services/getCode'
15
 import { checkIDCard, isEmpty } from '@/utils/tools'
15
 import { checkIDCard, isEmpty } from '@/utils/tools'
16
 import ContactConsultant from '../../components/ContactConsultant'
16
 import ContactConsultant from '../../components/ContactConsultant'
45
     navigationBarTitleText: '认筹确认'
45
     navigationBarTitleText: '认筹确认'
46
   }
46
   }
47
   state = {
47
   state = {
48
-    current: 3,
48
+    current: 0,
49
     inputName: '',
49
     inputName: '',
50
-    raiseProfile: undefined,
51
-    record: {},
52
-    protocolCountdown: 5, // 单位 s
53
-    captchaCountdown: 60, // 单位 s
54
-    raiseIdRecord:'',
55
-    payType: '', // 缴费方式
50
+    raiseProfile: undefined,  // 认筹主记录
51
+    record: {},               // 认筹单
52
+    preselectList: [],        // 我的预选 - 当前批次
53
+    protocolCountdown: 10,    // 单位 s
54
+    captchaCountdown: 60,     // 单位 s
55
+    payType: '',              // 缴费方式
56
+    failInfo: undefined,      // 操作失败 - 对象 { title, desc }
56
     payTypeList: [
57
     payTypeList: [
57
       { label: '线上缴费', value: 'onLine' },
58
       { label: '线上缴费', value: 'onLine' },
58
       { label: '线下缴费', value: 'offLine' },
59
       { label: '线下缴费', value: 'offLine' },
109
           pageNumber: 1,
110
           pageNumber: 1,
110
         })
111
         })
111
       }
112
       }
113
+
114
+      this.getMyPreselection({
115
+        personId,
116
+        pageNumber: 1,
117
+        pageSize: 999,
118
+        salesBatchId: res.salesBatchId,
119
+      }).then((res2) => {
120
+        // 如果认筹必须预选
121
+        if (res.needPreselection && res2.length < 1) {
122
+          this.setState({ current: 4, failInfo: { title: '认筹失败', desc: '请先预选房源' } })  
123
+        }
124
+      })
125
+    })
126
+  }
127
+
128
+  // 我的预选
129
+  getMyPreselection = (params) => {
130
+    return new Promise((resolve, reject) => {
131
+      queryPreselectionRecord(params).then((res) => {
132
+        this.setState({ preselectList: res.records })
133
+        resolve(res.records)        
134
+      }).catch(() => {
135
+        resolve([])
136
+        // reject()
137
+      })
112
     })
138
     })
113
   }
139
   }
114
 
140
 
172
   }
198
   }
173
   renderHouse() {
199
   renderHouse() {
174
     const { house: { raiseCart } } = this.props
200
     const { house: { raiseCart } } = this.props
175
-    const { raiseProfile } = this.state
201
+    const { raiseProfile = {} } = this.state
176
     const disabled = raiseProfile.houseLockingType === 'auto'
202
     const disabled = raiseProfile.houseLockingType === 'auto'
177
 
203
 
178
     return (
204
     return (
502
   }
528
   }
503
 
529
 
504
   makePay = () => {
530
   makePay = () => {
505
-    const { payType } = this.state
531
+    const { payType, record = {} } = this.state
506
     if (!payType) {
532
     if (!payType) {
507
       Taro.showToast({
533
       Taro.showToast({
508
         title: '请确定支付方式',
534
         title: '请确定支付方式',
516
     }
542
     }
517
 
543
 
518
     const params = {
544
     const params = {
519
-      targetId: this.$router.params.raiseRecordId || this.state.raiseIdRecord,
545
+      targetId: this.$router.params.raiseRecordId || record.raiseRecordId,
520
       targetType: 'house'
546
       targetType: 'house'
521
     }
547
     }
522
 
548
 
554
     })
580
     })
555
   }
581
   }
556
   renderResult() {
582
   renderResult() {
557
-    const { raiseProfile = {} } = this.state
583
+    const { raiseProfile = {}, failInfo } = this.state
584
+    const isOk = !failInfo
585
+    const showIcon = isOk ? require('../../assets/success2.png') : require('../../assets/fail2.png')
586
+    const showTitle = isOk ? '提交成功' : failInfo.title
587
+
558
     return (
588
     return (
559
       <View className="result">
589
       <View className="result">
560
-        <Image className="result-img" src={require('../../assets/success2.png')}></Image>
590
+        <Image className="result-img" src={showIcon}></Image>
561
 
591
 
562
-        <View className="status">提交成功</View>
592
+        <View className="status">{showTitle}</View>
593
+
594
+        {
595
+          isOk &&
596
+          (
597
+            <Block>
598
+              <View className="tip" style="margin-bottom:10rpx">详情请查看认筹单</View>
599
+              <View className="tip">支付结果请留意微信支付通知</View>
600
+            </Block>
601
+          )
602
+        }
603
+
604
+        {
605
+          !isOk && (<View className="tip">{(failInfo || {}).desc}</View>)
606
+        }
563
 
607
 
564
-        <View className="tip" style="margin-bottom:10rpx">详情请查看认筹单</View>
565
-        <View className="tip">支付结果请留意微信支付通知</View>
566
         <ContactConsultant buildingId={raiseProfile.buildingId} style=" position: absolute;bottom: 11vh;" />
608
         <ContactConsultant buildingId={raiseProfile.buildingId} style=" position: absolute;bottom: 11vh;" />
567
 
609
 
568
         <View className="look-btn" onClick={() => this.toRaiseProfile(raiseProfile.raiseId)}>查看认筹单</View>
610
         <View className="look-btn" onClick={() => this.toRaiseProfile(raiseProfile.raiseId)}>查看认筹单</View>
587
         this.makeRaiseRecord().then((res) => {
629
         this.makeRaiseRecord().then((res) => {
588
           console.log(res, "res")
630
           console.log(res, "res")
589
           this.setState({
631
           this.setState({
590
-            current: current + 1,
591
-            raiseIdRecord: res.raiseRecordId
592
-
632
+            current: current + 1
593
           })
633
           })
594
         })
634
         })
595
         return;
635
         return;