index.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. import { FunCode } from "../../../../constants/enum/funcode"
  2. import { protoHeader, userid, isEncrypted, timetample, getErrorMsg } from "../../../../services/utils"
  3. import { sendMsgToMQ } from "../../../../services/api/common/index"
  4. import { hideLoading, showLoading, showToast } from "../../../../utils/message/index"
  5. import { encryptBody } from "../../../../utils/websocket/crypto"
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. /// 1个人 2企业
  12. type: 1,
  13. /// 发票抬头
  14. inname: '',
  15. /// 税号
  16. inno: '',
  17. /// 开户银行
  18. bankname: '',
  19. /// 银行账号
  20. bankno: '',
  21. /// 企业地址
  22. inaddress: '',
  23. /// 企业电话
  24. inmobile: '',
  25. /// 自增id
  26. autoid: 0,
  27. /// 发票类型
  28. intypes: ["个人", "企业"],
  29. /// 是否发票类型
  30. show: false
  31. },
  32. /**
  33. * 返回上层视图
  34. */
  35. backToParent() {
  36. /// 返回上层视图
  37. wx.navigateBack()
  38. },
  39. /// 关闭地址选择组件
  40. onCancel(event: any) {
  41. const { index } = event.detail
  42. /// 关闭
  43. this.setData({ show: false, type: index+1 })
  44. },
  45. /// 合规性校验
  46. check(): boolean {
  47. /// 请输入发票抬头
  48. if (this.data.inname.length == 0) {
  49. showToast('请输入发票抬头!')
  50. return false
  51. }
  52. /// 请输入纳税人识别号
  53. if (this.data.inno.length == 0 && this.data.type != 1) {
  54. showToast('请输入纳税人识别号!')
  55. return false
  56. }
  57. return true
  58. },
  59. /**
  60. * 业务操作
  61. */
  62. userReceiptInfoReq() {
  63. /// 合规性校验
  64. if (!this.check()) { return }
  65. /// loding.....
  66. showLoading(()=>{
  67. /// 参数信息
  68. const info = JSON.stringify({
  69. ClientSerialID: timetample(),
  70. UserID: userid(),
  71. UserName: this.data.inname,
  72. ReceiptType: this.data.type,
  73. TaxpayerID: this.data.inno,
  74. Address: this.data.inaddress,
  75. ReceiptBank: this.data.bankname,
  76. ReceiptAccount: this.data.bankno,
  77. ReceiptInfoId: this.data.autoid,
  78. ContactInfo: this.data.inmobile,
  79. Header: protoHeader(FunCode.UserReceiptInfoReq)
  80. })
  81. /// 发送请求
  82. sendMsgToMQ({
  83. data: {
  84. data: encryptBody(info),
  85. funCodeReq: FunCode.UserReceiptInfoReq,
  86. funCodeRsp: FunCode.UserReceiptInfoRsp,
  87. isEncrypted: isEncrypted()
  88. },
  89. success: (res) => {
  90. /// 请求失败
  91. if (res.code ! = 0) {
  92. hideLoading(() => {}, res.msg)
  93. return
  94. }
  95. /// 解析对象
  96. const data = JSON.parse(res.data.data)
  97. if (data.RetCode != 0) {
  98. hideLoading(() => {}, getErrorMsg(data.RetCode))
  99. return
  100. }
  101. /// 操作成功
  102. hideLoading(()=>{
  103. /// 返回上层视图
  104. wx.navigateBack()
  105. }, '操作成功', 'success')
  106. },
  107. fail: (emsg) => {
  108. /// 操作失败
  109. hideLoading(()=>{}, emsg)
  110. },
  111. })
  112. }, '操作请求中......')
  113. },
  114. /**
  115. * 删除发票信息
  116. */
  117. deleteUserReceiptInfoReqReq() {
  118. /// loding.....
  119. showLoading(()=>{
  120. /// 参数信息
  121. const info = JSON.stringify({
  122. ReceiptInfoId: this.data.autoid,
  123. Header: protoHeader(FunCode.DelUserReceiptInfoReq)
  124. })
  125. /// 发送请求
  126. sendMsgToMQ({
  127. data: {
  128. data: encryptBody(info),
  129. funCodeReq: FunCode.DelUserReceiptInfoReq,
  130. funCodeRsp: FunCode.DelUserReceiptInfoRsp,
  131. isEncrypted: isEncrypted()
  132. },
  133. success: (res) => {
  134. /// 请求失败
  135. if (res.code ! = 0) {
  136. hideLoading(() => {}, res.msg)
  137. return
  138. }
  139. /// 解析对象
  140. const data = JSON.parse(res.data.data)
  141. if (data.RetCode != 0) {
  142. hideLoading(() => {}, getErrorMsg(data.RetCode))
  143. return
  144. }
  145. /// 操作成功
  146. hideLoading(()=>{
  147. /// 返回上层视图
  148. wx.navigateBack()
  149. }, '操作成功', 'success')
  150. },
  151. fail: (emsg) => {
  152. /// 操作失败
  153. hideLoading(()=>{}, emsg)
  154. }
  155. })
  156. }, '删除操作请求中......')
  157. },
  158. /**
  159. * 按钮点击响应事件
  160. */
  161. onButtonPressed(e: any) {
  162. switch (e.target.id) {
  163. case "type-selsct": /// 类型选择
  164. /// 显示
  165. this.setData({ show: true })
  166. break;
  167. case 'delete': /// 删除
  168. this.deleteUserReceiptInfoReqReq()
  169. break;
  170. default:
  171. /// 发送业务操作
  172. this.userReceiptInfoReq()
  173. break;
  174. }
  175. },
  176. /**
  177. * 生命周期函数--监听页面加载
  178. */
  179. onLoad(options: any) {
  180. /// 传参信息
  181. const d: GuangZuan.WrUserReceiptInfo = JSON.parse(options.id ?? '')
  182. this.setData({
  183. inname: d.username,
  184. inmobile: d.contactinfo,
  185. inno: d.taxpayerid,
  186. autoid: d.autoid,
  187. inaddress: d.address,
  188. bankno: d.receiptaccount,
  189. bankname: d.receiptbank,
  190. type: d.receipttype
  191. })
  192. },
  193. /**
  194. * 生命周期函数--监听页面初次渲染完成
  195. */
  196. onReady() {
  197. },
  198. /**
  199. * 生命周期函数--监听页面显示
  200. */
  201. onShow() {
  202. },
  203. /**
  204. * 生命周期函数--监听页面隐藏
  205. */
  206. onHide() {
  207. },
  208. /**
  209. * 生命周期函数--监听页面卸载
  210. */
  211. onUnload() {
  212. },
  213. /**
  214. * 页面相关事件处理函数--监听用户下拉动作
  215. */
  216. onPullDownRefresh() {
  217. },
  218. /**
  219. * 页面上拉触底事件的处理函数
  220. */
  221. onReachBottom() {
  222. },
  223. /**
  224. * 用户点击右上角分享
  225. */
  226. onShareAppMessage() {
  227. }
  228. })