index.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import { sendMsgToMQ } from "../../../../services/api/common/index"
  2. import { FunCode } from "../../../../constants/enum/funcode"
  3. import { accountid, deleteUserRecevieInfo, deleteWrUserReceiptInfo, getErrorMsg, getUserRecevieInfo, getWrUserReceiptInfo, 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. onIconClick(e: any) {
  28. switch (e.target.id) {
  29. case "address":
  30. wx.navigateTo({
  31. url: '/mMine/pages/address/list/index?isMine=false'
  32. })
  33. break;
  34. default:
  35. wx.navigateTo({
  36. url: '/mMine/pages/invoice/list/index?isMine=false'
  37. })
  38. break;
  39. }
  40. },
  41. /**
  42. * 修改申请
  43. */
  44. doModify() {
  45. // 校验失败
  46. if (!this.check()) { return }
  47. /// loding.....
  48. showLoading(()=>{
  49. /// json
  50. const json = {
  51. ContactInfo: `${this.data.contract}`,
  52. ReceiveInfo: `${this.data.address}`,
  53. ReceiptInfo: `${this.data.invoice}`
  54. }
  55. /// 参数信息
  56. const info = JSON.stringify({
  57. PerformancePlanID: this.data.order.performanceplanid,
  58. AccountID: accountid(),
  59. ContactInfo: JSON.stringify(json),
  60. Header: protoHeader(FunCode.PerformanceModifyContactReq)
  61. })
  62. /// 发送请求
  63. sendMsgToMQ({
  64. data: {
  65. data: encryptBody(info),
  66. funCodeReq: FunCode.PerformanceModifyContactReq,
  67. funCodeRsp: FunCode.PerformanceModifyContactRsp,
  68. isEncrypted: isEncrypted()
  69. },
  70. success: (res) => {
  71. /// 解析对象
  72. const data = JSON.parse(res.data.data)
  73. if (data.RetCode != 0) {
  74. hideLoading(() => {}, getErrorMsg(data.RetCode))
  75. return
  76. }
  77. /// 操作成功
  78. hideLoading(()=>{
  79. /// 返回上层视图
  80. wx.navigateBack()
  81. }, '修改申请成功', 'success')
  82. },
  83. fail: (emsg) => {
  84. /// 操作失败
  85. hideLoading(()=>{}, emsg)
  86. }
  87. })
  88. }, '修改申请请求中.....')
  89. },
  90. check(): boolean {
  91. if (this.data.contract === '') {
  92. showToast('请输入联系信息!')
  93. return false
  94. }
  95. if (this.data.address === '' && this.data.order.buyorsell === 0) {
  96. showToast('请选择收货地址信息!')
  97. return false
  98. }
  99. if (this.data.invoice === '' && this.data.order.buyorsell === 0) {
  100. showToast('请选择发票信息!')
  101. return false
  102. }
  103. return true
  104. },
  105. /**
  106. * 生命周期函数--监听页面加载
  107. */
  108. onLoad(options: any) {
  109. /// 数据解析
  110. const obj: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '')
  111. if (obj) {
  112. const infos = JSON.parse(obj.buyorsell === 0 ? obj.buyerinfo : obj.sellerinfo)
  113. /// 买方信息
  114. if (infos) {
  115. const { ContactInfo, ReceiptInfo, ReceiveInfo } = infos
  116. this.setData({
  117. contract: ContactInfo,
  118. address: ReceiveInfo,
  119. invoice: ReceiptInfo
  120. })
  121. }
  122. this.setData({ order: obj })
  123. }
  124. },
  125. /**
  126. * 生命周期函数--监听页面初次渲染完成
  127. */
  128. onReady() {
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow() {
  134. const receipt = getWrUserReceiptInfo()
  135. const receive = getUserRecevieInfo()
  136. if (receipt) {
  137. const {receipttype, username, taxpayerid, receiptbank, receiptaccount, address, contactinfo} = receipt
  138. if (receipttype === 1) {
  139. this.setData({ invoice: `发票抬头:${ username }` })
  140. } else {
  141. this.setData({
  142. invoice: `发票抬头:${ username }\n税号:${ taxpayerid }\n开户银行:${ receiptbank }\n银行账号:${ receiptaccount }\n企业地址:${ address }\n企业电话:${ contactinfo }`
  143. })
  144. }
  145. deleteWrUserReceiptInfo()
  146. }
  147. if (receive) {
  148. const { receivername, phonenum, provincename, cityname, districtname, address } = receive
  149. this.setData({
  150. address: `姓名:${receivername}\n电话:${phonenum}\n地址:${provincename+cityname+districtname+address}`
  151. })
  152. deleteUserRecevieInfo()
  153. }
  154. },
  155. /**
  156. * 生命周期函数--监听页面隐藏
  157. */
  158. onHide() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面卸载
  162. */
  163. onUnload() {
  164. },
  165. /**
  166. * 页面相关事件处理函数--监听用户下拉动作
  167. */
  168. onPullDownRefresh() {
  169. },
  170. /**
  171. * 页面上拉触底事件的处理函数
  172. */
  173. onReachBottom() {
  174. },
  175. /**
  176. * 用户点击右上角分享
  177. */
  178. onShareAppMessage() {
  179. }
  180. })