index.ts 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. import { FunCode } from "../../../constants/enum/funcode"
  2. import Toast from "../../../miniprogram_npm/@vant/weapp/toast/toast"
  3. import { queryBankAccountSign, queryCusBankSignBank } from "../../../services/api/account/index"
  4. import { sendMsgToMQ } from "../../../services/api/common/index"
  5. import { accountid, isEncrypted, loginQuery, protoHeader, timetample, userid } from "../../../services/utils"
  6. import { hideLoading, showLoading } from "../../../utils/message/index"
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. /// 开户银行
  13. bankName: '',
  14. /// 银行卡号
  15. bankNo: '',
  16. /// 姓名
  17. accountName: '',
  18. /// 支行名称
  19. branchBankName: '',
  20. /// 开户行信息
  21. bankInfos: <GuangZuan.BankInfo[]>[],
  22. /// 显示的开户行信息
  23. bankNames: <string[]>[],
  24. /// 选中的银行信息
  25. bankInfo: <GuangZuan.BankInfo>{},
  26. /// 是否显示银行
  27. showBank: false,
  28. /// 托管银行信息
  29. cusBankInfo: <GuangZuan.CusBankInfo>{},
  30. /// 签约账户信息
  31. bankAccountSign: <GuangZuan.BankAccountSign>{}
  32. },
  33. /**
  34. * 返回上层视图
  35. */
  36. backToParent() {
  37. /// 返回上层视图
  38. wx.navigateBack()
  39. },
  40. /**
  41. * onCancel
  42. */
  43. onCancel() {
  44. this.setData({ showBank: false })
  45. },
  46. /**
  47. * onConfirm
  48. */
  49. onConfirm(e: any) {
  50. const { index } = e.detail;
  51. /// 赋值
  52. this.setData({
  53. showBank: false,
  54. bankInfo: this.data.bankInfos[index],
  55. bankName: this.data.bankInfos[index].bankname
  56. })
  57. },
  58. /**
  59. * showBankInfos
  60. */
  61. showBankInfos() {
  62. this.setData({ showBank: true })
  63. },
  64. /**
  65. * 查询托管银行信息
  66. */
  67. queryCusBankInfo() {
  68. /// showLoading
  69. showLoading(()=>{
  70. /// 发送请求
  71. queryCusBankSignBank({
  72. success: (res) => {
  73. /// 请求失败
  74. if (res.code != 200) {
  75. hideLoading(()=>{}, '托管银行请求失败,原因:'+res.msg, 'error')
  76. return
  77. }
  78. hideLoading(()=>{
  79. /// 数据赋值
  80. this.setData({
  81. cusBankInfo: res.data[0],
  82. /// 银行信息
  83. bankInfos: res.data[0].Banklst,
  84. /// 银行名称信息
  85. bankNames: res.data[0].Banklst.map(obj => { return obj.bankname })
  86. })
  87. })
  88. },
  89. fail: (emsg) => {
  90. hideLoading(()=>{}, '托管银行请求失败,原因:'+emsg, 'error')
  91. }
  92. })
  93. })
  94. },
  95. /**
  96. * 查询用户已签约信息
  97. */
  98. queryBankAccountSign() {
  99. /// showLoading
  100. showLoading(()=>{
  101. /// 发送请求
  102. queryBankAccountSign({
  103. data: {
  104. userid: userid()
  105. },
  106. success: (res) => {
  107. /// 请求失败
  108. if (res.code != 200) {
  109. hideLoading(()=>{}, '用户签约信息请求失败,原因:'+res.msg, 'error')
  110. return
  111. }
  112. /// hideLoading
  113. hideLoading(()=>{
  114. /// 数据赋值
  115. this.setData({ bankAccountSign: res.data[0] })
  116. })
  117. },
  118. fail: (emsg) => {
  119. hideLoading(()=>{}, '用户签约信息请求失败,原因:'+emsg, 'error')
  120. }
  121. })
  122. })
  123. },
  124. /**
  125. * 按钮点击响应事件
  126. */
  127. onButtonPressed(e: any) {
  128. switch (e.currentTarget.id) {
  129. case 'submit': /// 签约提交
  130. this.doBankAccountSign()
  131. break;
  132. case 'cancel': /// 解约请求
  133. this.doCancelBankAccountSign()
  134. break
  135. default:
  136. break;
  137. }
  138. },
  139. /**
  140. * 签约请求
  141. */
  142. doBankAccountSign() {
  143. /// 合规性校验
  144. if (!this.check()) { return }
  145. /// loading
  146. showLoading(()=>{
  147. /// 用户信息
  148. const userinfo = loginQuery().userInfo
  149. /// 参数信息
  150. const param = {
  151. /// 扩展信息(JSON串,参考配置要求进行填充)
  152. extend_info: JSON.stringify({ "sex" : 1 }),
  153. /// 交易所业务日期
  154. TradeDate: this.data.cusBankInfo.tradedate,
  155. /// 账户类型[1-对私;2-对公]
  156. AccountType: 1,
  157. /// 币种
  158. Currency: this.data.cusBankInfo.currency,
  159. /// 是否强制[0-否;1-是]强制,只更新中心签约信息,不发送银行。用于银行信息不一致的情况
  160. IsForce: 0,
  161. /// 授权代理人证件类型
  162. AgentCertType: 0,
  163. /// 变更类型[1-增加;2-修改;4-绑卡;
  164. OperateType: 1,
  165. /// 银行卡类型
  166. BankCardType: 0,
  167. /// 银行账户类型
  168. BankAccountType: 1,
  169. /// 客户名称
  170. AccountName: this.data.accountName,
  171. /// 银行账户名称
  172. BankAccountName: this.data.accountName,
  173. /// 银行账户
  174. BankAccountNo: this.data.bankNo,
  175. /// 开户支行名称
  176. OpenBankName: this.data.branchBankName,
  177. /// 银行卡行号
  178. OpenBankAccId: this.data.bankInfo.bankid,
  179. /// 托管银行编号
  180. CusBankID: this.data.cusBankInfo.cusbankid,
  181. /// 开户行名称
  182. ExBankName: this.data.bankInfo.bankname,
  183. /// 账户
  184. AccountCode: accountid().toString(),
  185. /// 外部操作流水号
  186. ExtOperatorID: timetample(),
  187. /// 证件号码
  188. CertID: userinfo.cardnum,
  189. /// 证件类型
  190. CertType: userinfo.cardtypeid.toString(),
  191. /// 头部
  192. Header: protoHeader(FunCode.T2bBankSignReq)
  193. }
  194. /// 发送请求
  195. sendMsgToMQ({
  196. data: {
  197. funCodeReq: FunCode.T2bBankSignReq,
  198. funCodeRsp: FunCode.T2bBankSignReq,
  199. isEncrypted: isEncrypted(),
  200. data: JSON.stringify(param)
  201. },
  202. success: (res) => {
  203. /// 请求失败
  204. if (res.code != 0) {
  205. hideLoading(()=>{}, '签约请求请求失败,原因:'+res.msg, 'error')
  206. return
  207. }
  208. /// 请求成功
  209. hideLoading(()=>{
  210. /// 返回上层视图
  211. wx.navigateBack()
  212. }, '签约请求成功', 'success')
  213. },
  214. fail: (emsg) => {
  215. hideLoading(()=>{}, '签约请求请求失败,原因:'+emsg, 'error')
  216. }
  217. })
  218. }, '签约请求中.....')
  219. },
  220. /**
  221. * 解约请求
  222. */
  223. doCancelBankAccountSign() {
  224. /// loading
  225. showLoading(()=>{
  226. /// 参数信息
  227. const param = {
  228. /// 头部
  229. Header: protoHeader(FunCode.T2bBankCancelSignReq),
  230. /// 外部操作流水号
  231. ExtOperatorID: timetample(),
  232. /// 账户
  233. AccountCode: this.data.bankAccountSign.accountcode,
  234. /// 托管银行编号
  235. CusBankID: this.data.bankAccountSign.cusbankid,
  236. /// 币种
  237. Currency: this.data.bankAccountSign.currency,
  238. /// 交易所业务日期
  239. TradeDate: this.data.cusBankInfo.tradedate,
  240. /// 是否强制
  241. isForce: 0,
  242. /// 银行子账号
  243. BankChildAcc: this.data.bankAccountSign.bankaccountno,
  244. /// 银行子账号名
  245. BankChildAccName: this.data.bankAccountSign.bankaccountname
  246. }
  247. /// 发送请求
  248. sendMsgToMQ({
  249. data: {
  250. isEncrypted: isEncrypted(),
  251. funCodeReq: FunCode.T2bBankCancelSignReq,
  252. funCodeRsp: FunCode.T2bBankCancelSignRsp,
  253. data: JSON.stringify(param)
  254. },
  255. success: (res) => {
  256. /// 请求失败
  257. if (res.code != 0) {
  258. hideLoading(()=>{}, '解约请求失败,原因:'+res.msg, 'error')
  259. return
  260. }
  261. /// 请求成功
  262. hideLoading(()=>{
  263. /// 返回上层视图
  264. wx.navigateBack()
  265. }, '解约请求成功', 'success')
  266. },
  267. fail: (emsg) => {
  268. hideLoading(()=>{}, '解约请求失败,原因:'+emsg, 'error')
  269. }
  270. })
  271. }, '解约请求中.....')
  272. },
  273. /**
  274. * 合规性校验
  275. */
  276. check(): boolean {
  277. /// 请选择开户行
  278. if (this.data.bankName.length === 0) {
  279. Toast({message: '请选择开户行!'})
  280. return false
  281. }
  282. /// 请输入银行卡号!
  283. if (this.data.bankNo.length === 0) {
  284. Toast({message: '请输入银行卡号!'})
  285. return false
  286. }
  287. /// 请输入姓名!
  288. if (this.data.accountName.length === 0) {
  289. Toast({message: '请输入姓名!'})
  290. return false
  291. }
  292. /// 请输入支行名称!
  293. if (this.data.branchBankName.length === 0) {
  294. Toast({message: '请输入支行名称!'})
  295. return false
  296. }
  297. return true
  298. },
  299. /**
  300. * 生命周期函数--监听页面加载
  301. */
  302. onLoad() {
  303. /// 查询托管银行信息
  304. this.queryCusBankInfo()
  305. /// 查询账户已签约信息
  306. this.queryBankAccountSign()
  307. },
  308. /**
  309. * 生命周期函数--监听页面初次渲染完成
  310. */
  311. onReady() {
  312. },
  313. /**
  314. * 生命周期函数--监听页面显示
  315. */
  316. onShow() {
  317. },
  318. /**
  319. * 生命周期函数--监听页面隐藏
  320. */
  321. onHide() {
  322. },
  323. /**
  324. * 生命周期函数--监听页面卸载
  325. */
  326. onUnload() {
  327. },
  328. /**
  329. * 页面相关事件处理函数--监听用户下拉动作
  330. */
  331. onPullDownRefresh() {
  332. },
  333. /**
  334. * 页面上拉触底事件的处理函数
  335. */
  336. onReachBottom() {
  337. },
  338. /**
  339. * 用户点击右上角分享
  340. */
  341. onShareAppMessage() {
  342. }
  343. })