index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // pages/writeoff/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. height: app.globalData.height * 2 + 25,
  9. windowHeight: app.globalData.windowHeight,
  10. navbarData: {
  11. name: '核销餐券',
  12. },
  13. },
  14. back: function () {
  15. wx.switchTab({
  16. url: '/pages/my/index',
  17. });
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad(options) {
  23. },
  24. async toUse(){
  25. console.log(1)
  26. wx.scanCode({
  27. onlyFromCamera: true,
  28. scanType:['qrCode'],
  29. success: async (res)=> {
  30. console.log(res)
  31. const uri = res.result;
  32. const result = await app.$get(uri);
  33. if(result) wx.showToast({ title: '核销完成', icon: 'success' });
  34. },
  35. fail:async(e)=>{}
  36. })
  37. },
  38. /**
  39. * 生命周期函数--监听页面初次渲染完成
  40. */
  41. onReady() {
  42. },
  43. /**
  44. * 生命周期函数--监听页面显示
  45. */
  46. onShow() {
  47. },
  48. /**
  49. * 生命周期函数--监听页面隐藏
  50. */
  51. onHide() {
  52. },
  53. /**
  54. * 生命周期函数--监听页面卸载
  55. */
  56. onUnload() {
  57. },
  58. /**
  59. * 页面相关事件处理函数--监听用户下拉动作
  60. */
  61. onPullDownRefresh() {
  62. },
  63. /**
  64. * 页面上拉触底事件的处理函数
  65. */
  66. onReachBottom() {
  67. },
  68. /**
  69. * 用户点击右上角分享
  70. */
  71. onShareAppMessage() {
  72. }
  73. })