index.ts 5.2 KB

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