ticketScan.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // pages/ticketScan/ticketScan.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. qrcodeUrl: ''
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. this.getCompany()
  16. },
  17. //详情
  18. toDetail() {
  19. /* wx.redirectTo({
  20. url: '/pages/ticketScan/detail?belongEntTaxId=' + this.data.belongEntTaxId
  21. }) */
  22. },
  23. //销方公司
  24. getCompany() {
  25. let result = utils.getCurrEntInfo()
  26. this.drawQrcode('qrcode',`https://app.taxbk.cn:9443/qrcode/#/titleTodo?entTaxId=${result.entTaxId}&entName=${result.entName}`)
  27. // utils.getCompany().then(res => {
  28. // let result = res.data
  29. // this.drawQrcode('qrcode',`https://app.taxbk.cn:9443/qrcode/#/titleTodo?entTaxId=${result.entTaxId}&entName=${result.entName}`)
  30. // })
  31. },
  32. //二维码
  33. drawQrcode(canvasId,text) {
  34. wx.showLoading({
  35. title: '二维码加载中...',
  36. mask: true
  37. })
  38. drawQrcode({
  39. width: 232,
  40. height: 232,
  41. canvasId: canvasId,
  42. text: text,
  43. callback: () => {
  44. //安卓机上不准确,生成的二维码无法扫描,加延时解决
  45. setTimeout(() => {
  46. wx.canvasToTempFilePath({
  47. canvasId: canvasId,
  48. success: res => {
  49. wx.hideLoading()
  50. this.setData({
  51. qrcodeUrl: res.tempFilePath
  52. })
  53. }
  54. }, this)
  55. }, 500)
  56. }
  57. })
  58. },
  59. //长按保存
  60. save() {
  61. wx.getImageInfo({
  62. src: this.data.qrcodeUrl,
  63. success: res => {
  64. utils.savePhoto(res.path)
  65. }
  66. })
  67. },
  68. /**
  69. * 生命周期函数--监听页面初次渲染完成
  70. */
  71. onReady: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面显示
  75. */
  76. onShow: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面隐藏
  80. */
  81. onHide: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面卸载
  85. */
  86. onUnload: function () {
  87. },
  88. /**
  89. * 页面相关事件处理函数--监听用户下拉动作
  90. */
  91. onPullDownRefresh: function () {
  92. },
  93. /**
  94. * 页面上拉触底事件的处理函数
  95. */
  96. onReachBottom: function () {
  97. },
  98. /**
  99. * 用户点击右上角分享
  100. */
  101. onShareAppMessage: function () {
  102. return {
  103. title: '诺信云',
  104. path: '/pages/index/index'
  105. }
  106. }
  107. })