| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- 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, isnullstr } from "../../../utils/util"
- import { hideLoading, showLoading } from "../../../utils/message/index"
- // mMine/pages/inoutgold/index.ts
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// tab激活索引
- active: 0,
- /// tabs
- tabs: [{id: 0, name: '充值'}, {id: 1, name: '提现'}],
- /// 签约账户信息
- bankAccountSign: <GuangZuan.BankAccountSign>{},
- /// 入金金额
- inamount: 0.0,
- /// 出金金额
- outamount: 0.0,
- /// 当前可出金额
- enableOutAmount: 0.0,
- /// 出入金时间
- time: '',
- /// 文件上传列表
- fileList: [],
- /// 上传的文件路径
- filePath: '',
- /// 显示信息
- sign: {}
- },
- /**
- * 返回上层视图
- */
- 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.....
- showLoading(() => {
- /// 发送请求
- queryBankAccountSign({
- data: {
- userid: userid()
- },
- success: (res) => {
- /// 请求失败
- if (res.code != 200) {
- hideLoading(() => {}, '用户签约信息请求失败,原因:'+res.msg)
- return
- }
- hideLoading(() => {
- /// 数据赋值
- this.setData({
- bankAccountSign: res.data[0],
- sign: res.data.map(obj=>{
- return {
- bankname: obj.bankname,
- cardno: isnullstr(obj.cardno),
- bankaccountname: isnullstr(obj.bankaccountname),
- branchbankname: isnullstr(obj.branchbankname)
- }
- })[0]
- })
- })
- },
- fail: (emsg) => {
- hideLoading(() => {}, '托管银行请求失败,原因:'+emsg)
- },
- complete: () => {}
- })
- })
- },
- /// 账户资金信息请求
- accountFundInfo() {
- /// loding....
- showLoading(()=>{
- /// 参数信息
- const param = {
- /// 头部
- Header: protoHeader(FunCode.AccountFundInfoReq),
- /// uint32 查询位掩码
- QueryBitMask: 2,
- /// uint64 查询资金账号
- AccountId: accountid(),
- }
- /// 发送请求
- sendMsgToMQ({
- data: {
- isEncrypted: isEncrypted(),
- funCodeReq: FunCode.AccountFundInfoReq,
- funCodeRsp: FunCode.AccountFundInfoReq,
- data: JSON.stringify(param)
- },
- success: (res) => {
- /// 请求失败
- if (res.code != 0) {
- hideLoading(()=>{}, '账户资金信息请求失败,原因:'+res.msg, 'error')
- return
- }
- },
- fail: (emsg) => {
- hideLoading(()=>{}, '账户资金信息请求失败,原因:'+emsg, 'error')
- }
- })
- }, '账户资金信息请求中......')
- },
- /// 入金申请请求
- doInMoneyApply() {
- /// 合规性校验
- if (!this.check()) { return }
- /// showLoading
- showLoading(()=>{
- /// 参数信息
- 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},
- }
- /// 发送请求
- sendMsgToMQ({
- data: {
- isEncrypted: isEncrypted(),
- funCodeReq: FunCode.T2bBankDepositReq,
- funCodeRsp: FunCode.T2bBankDepositRsp,
- data: JSON.stringify(param)
- },
- success: (res) => {
- /// 请求失败
- if (res.code != 0) {
- hideLoading(()=>{}, '入金申请请求失败,原因:'+res.msg, 'error')
- return
- }
- /// 请求成功
- hideLoading(()=>{
- /// 返回上层视图
- wx.navigateBack()
- }, '入金申请请求成功', 'success')
- },
- fail: (emsg) => {
- hideLoading(()=>{}, '入金申请请求失败,原因:'+emsg, 'error')
- }
- })
- }, '入金请求中......')
- },
- /// 出金申请请求
- doOutMoneyApply() {
- /// 合规性校验
- if (!this.check()) { return }
- /// loding....
- showLoading(()=>{
- /// 参数信息
- 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
- }
- /// 发送请求
- sendMsgToMQ({
- data: {
- isEncrypted: isEncrypted(),
- funCodeReq: FunCode.T2bBankWithdrawReq,
- funCodeRsp: FunCode.T2bBankWithdrawRsp,
- data: JSON.stringify(param)
- },
- success: (res) => {
- /// 请求失败
- if (res.code != 0) {
- hideLoading(()=>{}, '出金申请请求失败,原因:'+res.msg, 'error')
- return
- }
- /// 请求成功
- hideLoading(()=>{
- /// 返回上层视图
- wx.navigateBack()
- }, '出金申请请求成功', 'success')
- },
- fail: (emsg) => {
- hideLoading(()=>{}, '出金申请请求失败,原因:'+emsg, 'error')
- }
- })
- }, '出金请求中......')
- },
- /// 合规性校验
- 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() {
- }
- })
|