TM
2020-12-14 e9e5c6b88e172ed19cce42c4dbc42b675080a5e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
 
const app = getApp()
let $api = require('../../../utils/ajaxFn.js')
Page({
  data: {
    isBoss: true,
    userStyle: {},
    prodsList: [],
    prodName: '',
    termName: '',
    verName: '',
    info: {
      prodId: '',
    },
    amtList: [
      { name: '商家到账', number: 0 },
      { name: '客户还款总额', number: 0 },
      { name: '客户月还款额', number: 0 }
    ],
    rateList: [
      { name: '智享服务费率', rate: 0 },
      { name: '花呗利率', rate: 0 },
      { name: '支付利率', rate: 0 }
    ],
  },
  onLoad() {
    this.setData({
      userStyle: app.userStyle
    })
    this.getList()
  },
  getList(obj) {
    $api.ajax(
      '/sib/xcx/order/hbCreateInit',
      'POST',
      (res) => {
        this.setData({
          prodsList: res.data.body.prods,
          termsList: res.data.body.terms,
          zfbVersionsList: res.data.body.zfbVersions
        })
      },
      (err) => { },
      true,
      { ...obj }
    )
  },
  orderhbTrial() {
    $api.ajax(
      '/sib/xcx/order/hbTrial',
      'POST',
      (res) => {
        let body = res.data.body
        this.setData({
          amtList: [{ name: '商家到账', number: body.merAmt }, { name: '客户还款总额', number: body.repayAmt }, { name: '客户月还款额', number: body.monthAmt }],
          rateList: [
            { name: '智享服务费率', rate: body.platRate },
            { name: '花呗利率', rate: body.zfbRate },
            { name: '支付利率', rate: body.payRate }]
        })
      },
      (err) => { },
      true,
      {
        amt: this.data.info.amt,
        prodId: this.data.info.prodId,
        term: this.data.info.term,
        zfbVersion: this.data.info.zfbVersion
      }
    )
  },
  confirm(e) {
    let code = e.target.dataset.code,
      value = e.detail.value,
      obj = {};
    if (code == 1) {
      obj.amt = value
    } else if (code == 2) {
      obj.goodsName = value
    } else if (code == 3) {
      obj.userName = value
    } else {
      obj.userMblNo = value
    }
    this.setData({
      info: { ...this.data.info, ...obj }
    })
    if (code == 1) {
      if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) {
        this.setData({
          isBoss: false
        })
      }
      if (this.data.isBoss) {
        this.orderhbTrial()
      }
    }
 
  },
  bindObjPickerChangeProd(e) {
 
    this.setData({
      prodName: this.data.prodsList[e.detail.value].name,
      'info.prodId': this.data.prodsList[e.detail.value].code
    })
    this.getList({ prodId: this.data.info.prodId })
    console.log(this.data.info.amt, this.data.info.prodId, this.data.info.term, this.data.info.zfbVersion)
    if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) {
      this.setData({
        isBoss: false
      })
    } else {
      this.setData({
        isBoss: true
      })
    }
    if (this.data.isBoss) {
      this.orderhbTrial()
    }
  },
  bindObjPickerChangeTerm(e) {
    this.setData({
      termName: this.data.termsList[e.detail.value].name,
      'info.term': this.data.termsList[e.detail.value].code
    })
    console.log(this.data.info.amt, this.data.info.prodId, this.data.info.term, this.data.info.zfbVersion)
    if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) {
      this.setData({
        isBoss: false
      })
    } else {
      this.setData({
        isBoss: true
      })
    }
    if (this.data.isBoss) {
      this.orderhbTrial()
    }
  },
  bindObjPickerChangeVer(e) {
    this.setData({
      zfbVersionName: this.data.zfbVersionsList[e.detail.value].name,
      'info.zfbVersion': this.data.zfbVersionsList[e.detail.value].code
    })
    console.log(this.data.info.amt, this.data.info.prodId, this.data.info.term, this.data.info.zfbVersion)
    this.getList({ prodId: this.data.info.prodId, zfbVersion: this.data.info.zfbVersion })
    if (!this.data.info.amt || !this.data.info.prodId || !this.data.info.term || !this.data.info.zfbVersion) {
      this.setData({
        isBoss: false
      })
    } else {
      this.setData({
        isBoss: true
      })
    }
    if (this.data.isBoss) {
      this.orderhbTrial()
    }
  },
  toQRCode() {
    this.setData({
      'info.payType': 2
    })
    my.scan({
      scanType: ['qrCode', 'barCode'],
      success: (res) => {
        console.log(res)
        $api.ajax(
          '/sib/xcx/order/createHb',
          'POST',
          (res) => {
            my.reLaunch({
              url: `/pages/order/hbfqOrder/hbfqOrder?orderId=${res.data.body.orderId}`,
            })
          },
          (err) => { },
          true,
          {
            ...this.data.info,
            authCode: res.resultStr
          }
        )
      },
    });
  },
  getQRCode() {
    this.setData({
      'info.payType': 1
    })
    for (let key in this.data.info) {
      if (!this.data.info[key]) {
        my.showToast({
          type: 'none',
          content: '请完整输入信息',
          duration: 2000,
        });
        return
      }
    }
    console.log(2)
    let str = JSON.stringify(this.data.info)
    my.navigateTo({
      url: `../qrCode/qrCode?info=${str}`
    });
  }
});