verify.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // pages/verify/verify.js
  2. const app = getApp();
  3. const api = require('../../api/api');
  4. let innerAudioContext = wx.createInnerAudioContext();
  5. innerAudioContext.src = 'https://down.ear0.com:3321/index/preview?soundid=35314&type=mp3&audio=sound.mp3'
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. card_number: '', //卡券号
  12. },
  13. //扫描二维码成功回调
  14. sao(res) {
  15. innerAudioContext.play();
  16. let result = res.detail.result;
  17. // console.log(result);
  18. var pages = getCurrentPages();
  19. var prevPage = pages[pages.length - 2]; //上一个页面
  20. prevPage.setData({
  21. code_result: result
  22. })
  23. wx.navigateBack({
  24. delta: 1,
  25. })
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad: function (options) {
  31. },
  32. /**
  33. * 生命周期函数--监听页面初次渲染完成
  34. */
  35. onReady: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面显示
  39. */
  40. onShow: function () {
  41. },
  42. /**
  43. * 生命周期函数--监听页面隐藏
  44. */
  45. onHide: function () {
  46. },
  47. /**
  48. * 生命周期函数--监听页面卸载
  49. */
  50. onUnload: function () {
  51. },
  52. /**
  53. * 页面相关事件处理函数--监听用户下拉动作
  54. */
  55. onPullDownRefresh: function () {
  56. },
  57. /**
  58. * 页面上拉触底事件的处理函数
  59. */
  60. onReachBottom: function () {
  61. },
  62. /**
  63. * 用户点击右上角分享
  64. */
  65. onShareAppMessage: function () {
  66. },
  67. navToPage() {
  68. wx.navigateBack({
  69. delta: 1,
  70. })
  71. },
  72. submit() {
  73. let that = this;
  74. console.log(111);
  75. return
  76. if (that.data.card_number == '') {
  77. wx.showToast({
  78. title: '订单核销码未录入',
  79. mask: true,
  80. icon: 'none'
  81. })
  82. return
  83. }
  84. wx.showLoading({
  85. title: '提交中',
  86. mask: true
  87. })
  88. wx.request({
  89. url: api.Orderwrite,
  90. header: {
  91. 'Authorization': wx.getStorageSync('token')
  92. },
  93. data: {
  94. card_number: that.data.card_number,
  95. write_method: 0
  96. },
  97. method: 'POST',
  98. success(res) {
  99. wx.hideLoading()
  100. console.log(res);
  101. if (res.data.code === 1) {
  102. wx.showToast({
  103. title: '核销成功',
  104. mask: true,
  105. success() {
  106. setTimeout(() => {
  107. wx.navigateBack({
  108. delta: 1
  109. })
  110. }, 1500)
  111. }
  112. })
  113. } else {
  114. wx.showToast({
  115. title: res.data.msg,
  116. mask: true,
  117. icon: 'none'
  118. })
  119. }
  120. },
  121. fail(err) {
  122. wx.hideLoading()
  123. wx.showToast({
  124. title: '发起网络请求失败',
  125. icon: 'none',
  126. mask: true
  127. })
  128. },
  129. complete() {
  130. // wx.hideLoading()
  131. }
  132. })
  133. }
  134. })