index.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import { sendMsgToMQ } from "../../../../services/api/common/index"
  2. import { FunCode } from "../../../../constants/enum/funcode"
  3. import { accountid, getErrorMsg, isEncrypted, protoHeader } from "../../../../services/utils";
  4. import { hideLoading, showLoading, showToast } from "../../../../utils/message/index";
  5. import { encryptBody } from "../../../../utils/websocket/crypto";
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. /// 单据信息
  12. order: <GuangZuan.MyPerformanc>({}),
  13. /// 联系信息
  14. contract: '',
  15. /// 地址信息
  16. address: '',
  17. /// 发票信息
  18. invoice: ''
  19. },
  20. /**
  21. * 返回上层视图
  22. */
  23. backToParent() {
  24. /// 返回上层视图
  25. wx.navigateBack()
  26. },
  27. /**
  28. * 修改申请
  29. */
  30. doModify() {
  31. // 校验失败
  32. if (!this.check()) { return }
  33. /// loding.....
  34. showLoading(()=>{
  35. /// json
  36. const json = {
  37. ContactInfo: `ContactInfo:${this.data.contract}`+`ReceiveInfo:${this.data.address}`+`ReceiptInfo:${this.data.invoice}`
  38. }
  39. /// 参数信息
  40. const info = JSON.stringify({
  41. PerformancePlanID: this.data.order.performanceplanid,
  42. AccountID: accountid(),
  43. ContactInfo: JSON.stringify(json),
  44. Header: protoHeader(FunCode.PerformanceModifyContactReq)
  45. })
  46. /// 发送请求
  47. sendMsgToMQ({
  48. data: {
  49. data: encryptBody(info),
  50. funCodeReq: FunCode.PerformanceModifyContactReq,
  51. funCodeRsp: FunCode.PerformanceModifyContactRsp,
  52. isEncrypted: isEncrypted()
  53. },
  54. success: (res) => {
  55. /// 解析对象
  56. const data = JSON.parse(res.data.data)
  57. if (data.RetCode != 0) {
  58. hideLoading(() => {}, getErrorMsg(data.RetCode))
  59. return
  60. }
  61. /// 操作成功
  62. hideLoading(()=>{
  63. /// 返回上层视图
  64. wx.navigateBack()
  65. }, '修改申请成功', 'success')
  66. },
  67. fail: (emsg) => {
  68. /// 操作失败
  69. hideLoading(()=>{}, emsg)
  70. }
  71. })
  72. }, '修改申请请求中.....')
  73. },
  74. check(): boolean {
  75. if (this.data.contract === '') {
  76. showToast('请输入联系信息!')
  77. return false
  78. }
  79. if (this.data.address === '') {
  80. showToast('请选择收货地址信息!')
  81. return false
  82. }
  83. if (this.data.invoice === '') {
  84. showToast('请选择发票信息!')
  85. return false
  86. }
  87. return true
  88. },
  89. /**
  90. * 生命周期函数--监听页面加载
  91. */
  92. onLoad(options: any) {
  93. /// 数据解析
  94. const myPerformanc: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '')
  95. if (myPerformanc) {
  96. this.setData({
  97. order: myPerformanc
  98. })
  99. }
  100. },
  101. /**
  102. * 生命周期函数--监听页面初次渲染完成
  103. */
  104. onReady() {
  105. },
  106. /**
  107. * 生命周期函数--监听页面显示
  108. */
  109. onShow() {
  110. },
  111. /**
  112. * 生命周期函数--监听页面隐藏
  113. */
  114. onHide() {
  115. },
  116. /**
  117. * 生命周期函数--监听页面卸载
  118. */
  119. onUnload() {
  120. },
  121. /**
  122. * 页面相关事件处理函数--监听用户下拉动作
  123. */
  124. onPullDownRefresh() {
  125. },
  126. /**
  127. * 页面上拉触底事件的处理函数
  128. */
  129. onReachBottom() {
  130. },
  131. /**
  132. * 用户点击右上角分享
  133. */
  134. onShareAppMessage() {
  135. }
  136. })