index.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 === '' && this.data.order.buyorsell === 0) {
  80. showToast('请选择收货地址信息!')
  81. return false
  82. }
  83. if (this.data.invoice === '' && this.data.order.buyorsell === 0) {
  84. showToast('请选择发票信息!')
  85. return false
  86. }
  87. return true
  88. },
  89. /**
  90. * 生命周期函数--监听页面加载
  91. */
  92. onLoad(options: any) {
  93. /// 数据解析
  94. const obj: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '')
  95. if (obj) {
  96. const infos = JSON.parse(obj.buyorsell === 0 ? obj.buyerinfo : obj.sellerinfo)
  97. /// 买方信息
  98. if (infos) {
  99. const { ContactInfo, ReceiptInfo, ReceiveInfo } = infos
  100. this.setData({
  101. contract: ContactInfo,
  102. address: ReceiveInfo,
  103. invoice: ReceiptInfo
  104. })
  105. }
  106. this.setData({ order: obj })
  107. }
  108. },
  109. /**
  110. * 生命周期函数--监听页面初次渲染完成
  111. */
  112. onReady() {
  113. },
  114. /**
  115. * 生命周期函数--监听页面显示
  116. */
  117. onShow() {
  118. },
  119. /**
  120. * 生命周期函数--监听页面隐藏
  121. */
  122. onHide() {
  123. },
  124. /**
  125. * 生命周期函数--监听页面卸载
  126. */
  127. onUnload() {
  128. },
  129. /**
  130. * 页面相关事件处理函数--监听用户下拉动作
  131. */
  132. onPullDownRefresh() {
  133. },
  134. /**
  135. * 页面上拉触底事件的处理函数
  136. */
  137. onReachBottom() {
  138. },
  139. /**
  140. * 用户点击右上角分享
  141. */
  142. onShareAppMessage() {
  143. }
  144. })