import { FunCode } from "../../../constants/enum/funcode" import Toast from "../../../miniprogram_npm/@vant/weapp/toast/toast" import services from "../../../services/index" import { queryBankAccountSign } from "../../../services/api/account/index" import { sendMsgToMQ } from "../../../services/api/common/index" import { accountid, isEncrypted, loginQuery, protoHeader, timetample, userid } from "../../../services/utils" import { formatDate } from "../../../utils/util" // mMine/pages/inoutgold/index.ts Page({ /** * 页面的初始数据 */ data: { /// tab激活索引 active: 0, /// tabs tabs: [{id: 0, name: '充值'}, {id: 1, name: '提现'}], /// 签约账户信息 bankAccountSign: {}, /// 入金金额 inamount: 0.0, /// 出金金额 outamount: 0.0, /// 当前可出金额 enableOutAmount: 0.0, /// 出入金时间 time: '', /// 文件上传列表 fileList: [], /// 上传的文件路径 filePath: '' }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /** * tab触发事件 */ onTabChange(e: any) { /// 设置激活项 this.setData({ active: e.detail.index }) }, /** * 按钮点击响应事件 */ onButtonPressed(e: any) { switch (e.currentTarget.id) { case "submit": /// 提交申请 this.data.active == 0 ? this.doInMoneyApply() : this.doOutMoneyApply() break; default: /// 全部 this.setData({ outamount: this.data.enableOutAmount }) break; } }, /// 照片上传 afterRead(e: any) { const { file } = e.detail; // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 wx.uploadFile({ url: services.config.uploadUrl, filePath: file.url, name: 'file', formData: { user: 'test' }, success: (res) => { if (res.statusCode != 200) { Toast({message: '图片上传失败,原因:'+res.errMsg}) return } // 上传完成需要更新 fileList const { fileList = [] } = this.data; fileList.push({ ...file, url: res.data}); this.setData({ fileList }); /// 设置文件路径 this.setData({ filePath: JSON.parse(res.data)[0].filePath }) }, }); }, /// 删除图片 deleteImage(e: any) { const {index} = e.detail.index // 上传完成需要更新 fileList const { fileList = [] } = this.data; fileList.splice(index, 1) this.setData({ fileList }); }, /** * 查询用户已签约信息 */ queryBankAccountSign() { /// loding..... Toast.loading({message: '查询账户签约信息.....'}) /// 发送请求 queryBankAccountSign({ data: { userid: userid() }, success: (res) => { /// 请求失败 if (res.code != 200) { Toast.fail({message: '用户签约信息请求失败,原因:'+res.msg}) return } /// 数据赋值 this.setData({ bankAccountSign: res.data[0] }) }, fail: (emsg) => { Toast.fail({message: '托管银行请求失败,原因:'+emsg}) }, complete: () => {} }) }, /// 账户资金信息请求 accountFundInfo() { /// 参数信息 const param = { /// 头部 Header: protoHeader(FunCode.AccountFundInfoReq), /// uint32 查询位掩码 QueryBitMask: 2, /// uint64 查询资金账号 AccountId: accountid(), /// uint64 查询委托单号 OrderId: timetample() } /// loding.... Toast.loading({message: '账户资金信息请求中......'}) /// 发送请求 sendMsgToMQ({ data: { isEncrypted: isEncrypted(), funCodeReq: FunCode.AccountFundInfoReq, funCodeRsp: FunCode.AccountFundInfoReq, data: JSON.stringify(param) }, success: (res) => { /// 请求失败 if (res.code != 0) { Toast({message: '账户资金信息请求失败,原因:'+res.msg, duration: 3000}) return } }, fail: (emsg) => { Toast({message: '账户资金信息请求失败,原因:'+emsg, duration: 3000}) }, complete: () => { /// 清除Toast Toast.clear() } }) }, /// 入金申请请求 doInMoneyApply() { /// 合规性校验 if (!this.check()) { return } /// 参数信息 const param = { /// 头部 Header: protoHeader(FunCode.T2bBankDepositReq), /// 外部操作流水号 ExtOperatorID: timetample(), /// 托管银行编号 CusBankID: this.data.bankAccountSign.cusbankid, /// 金额 Amount: this.data.inamount, /// 币种 Currency: this.data.bankAccountSign.currency, /// 银行卡号 BankAccoutNum: this.data.bankAccountSign.bankaccountno2, /// 银行子账号名 BankAccoutName: this.data.bankAccountSign.bankaccountname2, /// 资金账户 AccountCode: this.data.bankAccountSign.accountcode, /// 扩展信息(JSON串,参考配置要求进行填充) extend_info: {"sex": 1, "certificate_photo_url": this.data.filePath}, } /// loding.... Toast.loading({message: '入金请求中......'}) /// 发送请求 sendMsgToMQ({ data: { isEncrypted: isEncrypted(), funCodeReq: FunCode.T2bBankDepositReq, funCodeRsp: FunCode.T2bBankDepositRsp, data: JSON.stringify(param) }, success: (res) => { /// 请求失败 if (res.code != 0) { Toast({message: '入金申请请求失败,原因:'+res.msg, duration: 3000}) return } /// 请求成功 Toast.success({message: '入金申请请求成功', onClose: () => { /// 返回上层视图 wx.navigateBack() }}) }, fail: (emsg) => { Toast({message: '入金申请请求失败,原因:'+emsg, duration: 3000}) }, complete: () => { /// 清除Toast Toast.clear() } }) }, /// 出金申请请求 doOutMoneyApply() { /// 合规性校验 if (!this.check()) { return } /// 参数信息 const param = { /// 头部 Header: protoHeader(FunCode.T2bBankWithdrawReq), /// 外部操作流水号 ExtOperatorID: timetample(), /// 托管银行编号 CusBankID: this.data.bankAccountSign.cusbankid, /// 金额 Amount: this.data.outamount, /// 币种 Currency: this.data.bankAccountSign.currency, /// 银行卡号 BankAccoutNum: this.data.bankAccountSign.bankaccountno2, /// 银行子账号名 BankAccoutName: this.data.bankAccountSign.bankaccountname2, /// 资金账户 AccountCode: this.data.bankAccountSign.accountcode, /// 扩展信息(JSON串,参考配置要求进行填充) extend_info: {"sex": 1}, /// 银行卡行号 OpenCardBankId: this.data.bankAccountSign.bankid, /// 收款支行名称 BranchBankName: this.data.bankAccountSign.branchbankname, /// 申请日期和时间 AppDateTime: formatDate(new Date()), /// 账户类型 AccountType: 0 } /// loding.... Toast.loading({message: '出金请求中......'}) /// 发送请求 sendMsgToMQ({ data: { isEncrypted: isEncrypted(), funCodeReq: FunCode.T2bBankWithdrawReq, funCodeRsp: FunCode.T2bBankWithdrawRsp, data: JSON.stringify(param) }, success: (res) => { /// 请求失败 if (res.code != 0) { Toast({message: '出金申请请求失败,原因:'+res.msg, duration: 3000}) return } /// 请求成功 Toast.success({message: '出金申请请求成功', onClose: () => { /// 返回上层视图 wx.navigateBack() }}) }, fail: (emsg) => { Toast({message: '出金申请请求失败,原因:'+emsg, duration: 3000}) }, complete: () => { /// 清除Toast Toast.clear() } }) }, /// 合规性校验 check(): boolean { /// 获取账户签约信息失败 if (this.data.bankAccountSign === undefined) { Toast({message: '获取账户签约信息失败!'}) return false } /// 充值 if (this.data.active === 0) { /// 请输入充值金额 if (this.data.inamount === 0.00) { Toast({message: '请输入充值金额!'}) return false } /// 请上传转账凭证 if (this.data.fileList.length === 0) { Toast({message: '请上传转账凭证!'}) return false } } /// 提现 if (this.data.active === 1) { /// 请输入提现金额 if (this.data.outamount === 0.00) { Toast({message: '请输入提现金额!'}) return false } /// 提现金额不能超过可提金额 if (this.data.outamount > this.data.enableOutAmount) { Toast({message: '提现金额不能超过可提金额!'}) return false } } return true }, /** * 生命周期函数--监听页面加载 */ onLoad() { /// 查询账户签约信息 this.queryBankAccountSign() /// 资金账户查询 this.accountFundInfo() /// 开始结束时间 const start = loginQuery().systemParams.filter(obj => { return obj.paramcode === "012" })[0].paramvalue /// 开始结束时间 const end = loginQuery().systemParams.filter(obj => { return obj.paramcode === "013" })[0].paramvalue /// 显示时间 this.setData({ time: start+'-'+end }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })