index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. const util = require('../../../utils/util');
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. // 修改开票信息图片
  8. editInvoicImg: 'https://img.bbztx.com/image_test/upload/thumbs/20230211/logo/1676108882272014866.png',
  9. editDetail: {},
  10. orderPassword: [],
  11. company: '',
  12. dutyNumber: '', //税号
  13. email: '',
  14. attendantNamesList: [], //多个名字存放数组
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad(options) {
  20. console.log(options);
  21. let detail = JSON.parse(options.detail)
  22. console.log(detail);
  23. this.setData({
  24. editDetail: detail.data,
  25. company: detail.data.company,
  26. dutyNumber: detail.data.dutyNumber,
  27. email: detail.data.email,
  28. orderPassword: JSON.parse(detail.data.orderPassword),
  29. attendantNamesList: detail.info
  30. })
  31. // console.log(detail);
  32. },
  33. //输入框
  34. bindinput(e) {
  35. let type = e.currentTarget.dataset.type
  36. let value = e.detail.value
  37. console.log(value);
  38. if (type == 'company') {
  39. this.setData({
  40. company: value
  41. })
  42. }
  43. if (type == 'dutyNumber') {
  44. this.setData({
  45. dutyNumber: value
  46. })
  47. }
  48. if (type == 'email') {
  49. this.setData({
  50. email: value
  51. })
  52. }
  53. },
  54. //提交
  55. submit() {
  56. // console.log(this.data.orderPassword, this.data.editDetail);
  57. let that = this
  58. // console.log(that.data.editDetail.company, that.data.editDetail.dutyNumber, that.data.editDetail.email);
  59. if (util.isEmpty(that.data.company)) {
  60. util.showTips('公司名称不能为空')
  61. } else if (util.isEmpty(that.data.dutyNumber)) {
  62. util.showTips('税号不能为空')
  63. } else if (util.isEmpty(that.data.email)) {
  64. util.showTips('邮箱不能为空')
  65. } else {
  66. // console.log(that.data.editDetail);
  67. let data = {}
  68. data.passwords = [that.data.orderPassword[0].password]
  69. data.type = 0
  70. data.company = that.data.company
  71. data.dutyNumber = that.data.dutyNumber
  72. data.email = that.data.email
  73. data.isUpdate = true
  74. data.status = that.data.editDetail.status
  75. data.price = that.data.editDetail.price
  76. data.id = that.data.editDetail.id
  77. util.ajax({
  78. func: "articleInvoice/save",
  79. data,
  80. method: 'POST',
  81. load:false,
  82. }, ({
  83. data,
  84. code,
  85. reason
  86. }) => {
  87. if (code == 0) {
  88. console.log(data);
  89. var pages = getCurrentPages(); //当前页面
  90. var beforePage = pages; //前一页
  91. // console.log(pages);
  92. wx.navigateBack({
  93. delta: 1,
  94. })
  95. } else if (code == -1) {
  96. util.showTips(reason)
  97. } else if(code==-14) {
  98. // this.setData({
  99. // showconsumptionCode: true
  100. // })
  101. util.showTips(reason+',请返回上一页')
  102. }
  103. })
  104. }
  105. },
  106. /**
  107. * 生命周期函数--监听页面初次渲染完成
  108. */
  109. onReady() {
  110. },
  111. /**
  112. * 生命周期函数--监听页面显示
  113. */
  114. onShow() {
  115. },
  116. /**
  117. * 生命周期函数--监听页面隐藏
  118. */
  119. onHide() {
  120. },
  121. /**
  122. * 生命周期函数--监听页面卸载
  123. */
  124. onUnload() {
  125. },
  126. /**
  127. * 页面相关事件处理函数--监听用户下拉动作
  128. */
  129. onPullDownRefresh() {
  130. },
  131. /**
  132. * 页面上拉触底事件的处理函数
  133. */
  134. onReachBottom() {
  135. },
  136. /**
  137. * 用户点击右上角分享
  138. */
  139. onShareAppMessage() {
  140. }
  141. })