preview.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // pages/invoice/preview/preview.js
  2. const app = getApp();
  3. const api = app.api;
  4. import WxValidate from '../../../utils/WxValidate'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. invoiceId:16,
  11. invoiceOrderId:20,
  12. invoiceInfo:null,
  13. isShowInvoiceDetail:false,
  14. isShowInvoiceSure:false,
  15. isSubmit:false
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. this.setData({
  22. invoiceId:options.invoiceId,
  23. invoiceOrderId:options.invoiceOrderId
  24. })
  25. },
  26. /**
  27. * 生命周期函数--监听页面初次渲染完成
  28. */
  29. onReady: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow: function () {
  35. this.getData()
  36. },
  37. showInvoiceDetail(){
  38. this.setData({
  39. isShowInvoiceDetail:true
  40. })
  41. },
  42. hideInvoiceDetail(){
  43. this.setData({
  44. isShowInvoiceDetail:false
  45. })
  46. },
  47. hideInvoiceSure(){
  48. this.setData({
  49. isShowInvoiceSure:false
  50. })
  51. },
  52. sureInvoice(){
  53. /*'EuqOzIPHw16p-4A4x2rFf-t0khWIiv_rP_lAi-Zjvrk',*/
  54. wx.requestSubscribeMessage({
  55. tmplIds: [
  56. 'MiZ76kP6vQ7akw04b1bWOrZMrXqMw8hrdCEHZNHPK-A',
  57. 'TL7rAlbCWIWtr7A0lW-v5qR2MDH4UQk0YkkxOZuq-Bc',
  58. 'bXJEBQtWtoF3VhSg4t-JtU2kdECo9uSFEllHDUDoKak'
  59. ],
  60. success: (res)=> {
  61. this.setData({
  62. isShowInvoiceSure:true
  63. })
  64. }
  65. })
  66. },
  67. /**
  68. * get data
  69. * **/
  70. getData(){
  71. const {invoiceId,invoiceOrderId}=this.data;
  72. app.post(api.queryOrderInvoiceInfo,{
  73. id:invoiceId,
  74. invoiceOrderId
  75. }).then(res=>{
  76. this.setData({
  77. invoiceInfo:res.data
  78. })
  79. })
  80. },
  81. /**
  82. * 提交发票
  83. * **/
  84. saveData(){
  85. const {invoiceOrderId,isSubmit}=this.data;
  86. if(isSubmit){
  87. return
  88. }
  89. this.setData({
  90. isSubmit:true
  91. })
  92. app.post(api.updateInvoiceOrder,{
  93. invoiceOrderId:invoiceOrderId,
  94. orderStatus:2, // 2已提交 3已支付
  95. }).then(res=>{
  96. console.log(res);
  97. this.setData({
  98. isSubmit:false,
  99. });
  100. wx.reLaunch({
  101. url:"/pages/invoice/myInvoice/myInvoice"
  102. })
  103. }).catch(()=>{
  104. this.setData({
  105. isSubmit:false
  106. })
  107. })
  108. },
  109. /**
  110. * 生命周期函数--监听页面隐藏
  111. */
  112. onHide: function () {
  113. },
  114. /**
  115. * 生命周期函数--监听页面卸载
  116. */
  117. onUnload: function () {
  118. },
  119. /**
  120. * 页面相关事件处理函数--监听用户下拉动作
  121. */
  122. onPullDownRefresh: function () {
  123. },
  124. /**
  125. * 页面上拉触底事件的处理函数
  126. */
  127. onReachBottom: function () {
  128. },
  129. /**
  130. * 用户点击右上角分享
  131. */
  132. onShareAppMessage: function () {
  133. },
  134. viewInvoice: function(){
  135. app.base64src(this.data.invoiceInfo.invoiceFileBase64, res => {
  136. console.log(res) // 返回图片地址,直接赋值到image标签即可
  137. wx.previewImage({
  138. current: res,
  139. urls: [res]
  140. })
  141. });
  142. }
  143. })