index.ts 3.1 KB

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