orderNum.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // pages/tabber/news/index.js
  2. const app=getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. selectInfo: {},
  9. id:0
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. this.setData({
  16. id:options.id,
  17. })
  18. },
  19. /**
  20. * 生命周期函数--监听页面初次渲染完成
  21. */
  22. onReady: function () {
  23. },
  24. saoma:function(e){
  25. var that=this;
  26. wx.scanCode({
  27. onlyFromCamera: true,
  28. success (res) {
  29. console.log(res)
  30. var reg = new RegExp('(^|&|/?)orde_num=([^&|/?]*)(&|/?|$)', 'i');
  31. var r = res.result.substr(1).match(reg);
  32. var order_num=r[2];
  33. that.settask(order_num);
  34. }
  35. })
  36. },
  37. settask(order_num){
  38. var that=this
  39. app.api.useApi(app.globalData.baseAppUrl + "api/admin/bindQr", {
  40. device_id:this.data.id,
  41. order_num:order_num,
  42. }, "post").then(function (res) {
  43. console.log(res);
  44. if (res.code != 200) {
  45. wx.showLoading({
  46. title: res.message.msg,
  47. })
  48. setTimeout(function () {
  49. wx.hideLoading();
  50. }, 1000);
  51. } else {
  52. wx.hideLoading();
  53. wx.showModal({
  54. title: '提示',
  55. content: res.message.msg,
  56. showCancel:false,
  57. success (res) {
  58. if (res.confirm) {
  59. console.log('用户点击确定')
  60. wx.navigateBack()
  61. } else if (res.cancel) {
  62. console.log('用户点击取消')
  63. }
  64. }
  65. })
  66. }
  67. }).catch(function (err) {
  68. console.log(err);
  69. })
  70. }
  71. })