ticketResult.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // pages/ticketHand/ticketResult.js
  2. const utils = require('../../utils/util.js')
  3. import drawQrcode from '../../utils/weapp.qrcode.esm.js'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. invoiceReqFlowNo: '',
  10. result: '',
  11. qrcodeUrl: ''
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. this.setData({
  18. invoiceReqFlowNo: options.invoiceReqFlowNo
  19. })
  20. /* this.getDetail() */
  21. },
  22. //获取微信卡包详情所需的二维码参数
  23. getDetail() {
  24. let result = wx.getStorageSync('wxCode')
  25. this.setData({
  26. result
  27. })
  28. this.getCode()
  29. },
  30. //获取二维码
  31. getCode() {
  32. let result = this.data.result
  33. let params = {
  34. source: 'wap',
  35. clientOrderNo: result.clientOrderNo,
  36. moeny: result.totalAmountTaxes,
  37. timestamp: new Date().getTime(),
  38. redirectUrl: 'https://app.taxbk.cn:9443/qrcode/#/operateSuccess',
  39. authType: 2
  40. }
  41. utils.axios({
  42. method: 'post',
  43. url: '/sys/wxCollect/collectAuth',
  44. data: params,
  45. sendBefore() {
  46. wx.showLoading({
  47. title: '加载中...',
  48. mask: true
  49. })
  50. },
  51. complete() {
  52. wx.hideLoading()
  53. },
  54. success: res => {
  55. let url = res.data.authUrl
  56. this.drawQrcode('qrcode', url)
  57. }
  58. })
  59. },
  60. //二维码
  61. drawQrcode(canvasId, text) {
  62. wx.showLoading({
  63. title: '二维码加载中...',
  64. mask: true
  65. })
  66. drawQrcode({
  67. width:150,
  68. height: 150,
  69. canvasId: canvasId,
  70. text: text,
  71. callback: () => {
  72. //安卓机上不准确,生成的二维码无法扫描,加延时解决
  73. setTimeout(() => {
  74. wx.canvasToTempFilePath({
  75. canvasId: canvasId,
  76. success: res => {
  77. wx.hideLoading()
  78. this.setData({
  79. qrcodeUrl: res.tempFilePath
  80. })
  81. }
  82. }, this)
  83. }, 500)
  84. }
  85. })
  86. },
  87. //长按保存
  88. save() {
  89. wx.getImageInfo({
  90. src: this.data.qrcodeUrl,
  91. success: res => {
  92. utils.savePhoto(res.path)
  93. }
  94. })
  95. },
  96. //项目详情
  97. toProlist() {
  98. /* wx.redirectTo({
  99. url: '/pages/ticketProdetail/ticketProdetail?invoiceReqFlowNo=' + this.data.invoiceReqFlowNo
  100. }) */
  101. wx.redirectTo({
  102. url: '/pages/ticketQuery/ticketQuery'
  103. })
  104. },
  105. /**
  106. * 生命周期函数--监听页面初次渲染完成
  107. */
  108. onReady: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面显示
  112. */
  113. onShow: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面隐藏
  117. */
  118. onHide: function () {
  119. },
  120. /**
  121. * 生命周期函数--监听页面卸载
  122. */
  123. onUnload: function () {
  124. },
  125. /**
  126. * 页面相关事件处理函数--监听用户下拉动作
  127. */
  128. onPullDownRefresh: function () {
  129. },
  130. /**
  131. * 页面上拉触底事件的处理函数
  132. */
  133. onReachBottom: function () {
  134. },
  135. /**
  136. * 用户点击右上角分享
  137. */
  138. onShareAppMessage: function () {
  139. return {
  140. title: '诺信云',
  141. path: '/pages/index/index'
  142. }
  143. }
  144. })