index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. const util = require('../../../utils/util.js');
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. //开票中图
  8. invoicingImg: 'https://img.bbztx.com/miniProgram/challengeFamily/invoicingDetail/pedding.png',
  9. //已拒绝图
  10. rejectedImg: 'https://img.bbztx.com/miniProgram/challengeFamily/invoicingDetail/refuse.png',
  11. //已开票图
  12. invoicedImg: 'https://img.bbztx.com/miniProgram/challengeFamily/invoicingDetail/success.png',
  13. invoiceDetail: {}, //开票详情
  14. invoiceOneDetail: {}, //当前发票详情
  15. orderPassword: [], //消费码详情
  16. attendantNamesList: [], //多个名字存放数组
  17. scene: 0
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad(options) {
  23. // console.log(options);
  24. this.setData({
  25. invoiceDetail: {
  26. id: options.id,
  27. status: options.status
  28. }
  29. })
  30. console.log(this.data.invoiceDetail.status);
  31. this.getInvoiceDetail()
  32. },
  33. //获取发票详情
  34. getInvoiceDetail() {
  35. let that = this
  36. let data = that.data.invoiceDetail
  37. // console.log(data);
  38. util.ajax({
  39. func: "articleInvoice/getArticleInvoice",
  40. data,
  41. load: false
  42. }, ({
  43. data,
  44. code,
  45. reason
  46. }) => {
  47. if (code == 0) {
  48. // console.log(data[0].status);
  49. // if (data.length == 1) {
  50. // let orderPassword = JSON.parse(data[0].orderPassword)
  51. // console.log(orderPassword);
  52. // let arr = []
  53. // data.forEach(vl => {
  54. // // console.log(data, orderPassword[0].password);
  55. // arr.push({
  56. // attendantNames: vl.attendantNames,
  57. // password: orderPassword[0].password
  58. // })
  59. // })
  60. // that.setData({
  61. // invoiceOneDetail: data[0],
  62. // attendantNamesList: arr,
  63. // 'invoiceDetail.status':data[0].status
  64. // // orderPassword: JSON.parse(data[0].orderPassword)
  65. // })
  66. // }
  67. console.log(data.orderPassword);
  68. let orderPassword = JSON.parse(data.orderPassword)
  69. console.log(orderPassword);
  70. let nameList = data.attendantNames
  71. let psWord = []
  72. // console.log(orderPassword);
  73. // data.forEach(vl => {
  74. // nameList.push(vl.attendantNames)
  75. // })
  76. // console.log(nameList);
  77. orderPassword.forEach(el => {
  78. psWord.push(el.password)
  79. })
  80. console.log(nameList, psWord);
  81. let arr = []
  82. nameList.forEach((val, i) => {
  83. arr.push({
  84. attendantNames: val,
  85. password: orderPassword[i].password
  86. })
  87. })
  88. that.setData({
  89. invoiceOneDetail: data,
  90. attendantNamesList: arr,
  91. 'invoiceDetail.status': data.status
  92. })
  93. console.log(that.data.attendantNamesList);
  94. } else {
  95. util.showTips(reason)
  96. }
  97. })
  98. },
  99. /**
  100. * 生命周期函数--监听页面初次渲染完成
  101. */
  102. onReady() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面显示
  106. */
  107. onShow() {
  108. this.getInvoiceDetail()
  109. let query = wx.getLaunchOptionsSync()
  110. console.log(query);
  111. this.setData({
  112. scene: query.scene
  113. })
  114. console.log(this.data.scene);
  115. },
  116. //修改信息
  117. editInfo(e) {
  118. let that = this
  119. let data = {}
  120. data.id = that.data.invoiceDetail.id
  121. data.status = that.data.invoiceDetail.status
  122. console.log(data);
  123. // console.log(that.data.invoiceDetail);
  124. util.ajax({
  125. func: "articleInvoice/submitUpdateMessage",
  126. data,
  127. method: 'POST',
  128. load: false
  129. }, ({
  130. code,
  131. data,
  132. reason
  133. }) => {
  134. if (code == 0) {
  135. let detail = {}
  136. detail.status = that.data.invoiceDetail.status
  137. detail.info = that.data.attendantNamesList
  138. detail.data = e.currentTarget.dataset.item
  139. detail = JSON.stringify(detail)
  140. // console.log(detail);
  141. wx.navigateTo({
  142. url: '/pages/order/invoicingEdit/index?detail=' + detail, //跳转修改信息页面
  143. })
  144. } else if (code == -14) {
  145. util.showTips('申请状态发生变更')
  146. that.getInvoiceDetail(that.data.invoiceDetail)
  147. console.log(that.data.invoiceDetail.status);
  148. that.setData({
  149. 'invoiceDetail.status': Number(reason)
  150. })
  151. }
  152. })
  153. },
  154. resubmit() {
  155. // wx.reLaunch({
  156. // url: 'pages/order/invoicing/index',
  157. // })
  158. let scene = this.data.scene
  159. if (scene == 1001) {
  160. console.log(2);
  161. wx.navigateBack({
  162. delta: 2,
  163. })
  164. } else if (sene == 1157) {
  165. console.log(1);
  166. wx.reLaunch({
  167. url: 'pages/order/invoicing/index',
  168. })
  169. }
  170. },
  171. /**
  172. * 生命周期函数--监听页面隐藏
  173. */
  174. onHide() {
  175. },
  176. /**
  177. * 生命周期函数--监听页面卸载
  178. */
  179. onUnload() {
  180. },
  181. /**
  182. * 页面相关事件处理函数--监听用户下拉动作
  183. */
  184. onPullDownRefresh() {
  185. },
  186. /**
  187. * 页面上拉触底事件的处理函数
  188. */
  189. onReachBottom() {
  190. },
  191. /**
  192. * 用户点击右上角分享
  193. */
  194. onShareAppMessage() {
  195. }
  196. })