index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { orderVerific } from "../../../api/admin";
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. 'navbar': '1',
  10. 'return': '1',
  11. 'title': '订单核销',
  12. 'color': false
  13. },
  14. verify_code:'',
  15. orderInfo: {},
  16. iShidden: false,
  17. },
  18. close: function () {
  19. },
  20. /**
  21. * 去订单详情
  22. */
  23. goOrderDetails: function (e) {
  24. var order_id = e.currentTarget.dataset.order_id;
  25. wx.navigateTo({ url: '/pages/admin/order_details/index?order_id=' + order_id + '&goname=look'});
  26. },
  27. /**
  28. * 核销码
  29. */
  30. bindCode: function (e) {
  31. this.setData({ verify_code: e.detail.value });
  32. },
  33. /**
  34. * 立即销码
  35. */
  36. codeChange: function () {
  37. let ref = /[0-9]{12}/;
  38. if (!this.data.verify_code) return app.Tips({ title: '请输入核销码' });
  39. if (!ref.test(this.data.verify_code)) return app.Tips({ title: '请输入正确的核销码' });
  40. app.Tips({ title: '查询中' });
  41. setTimeout(() => {
  42. orderVerific(this.data.verify_code, 0)
  43. .then(res => {
  44. this.setData({
  45. orderInfo: res.data,
  46. iShidden: true
  47. });
  48. })
  49. .catch(res => {
  50. this.setData({
  51. verify_code: ''
  52. });
  53. return app.Tips({ title: res });
  54. });
  55. }, 800);
  56. },
  57. /**
  58. * 扫码核销
  59. */
  60. scanCode: function () {
  61. var myThis = this;
  62. wx.scanCode({
  63. scanType: ["qrCode", "barCode"],
  64. success(res) {
  65. myThis.setData({
  66. verify_code: res.result
  67. })
  68. myThis.codeChange();
  69. },
  70. fail(res) {
  71. console.log(res);
  72. // app.Tips({ title: res });
  73. // if (res.errMsg == "scanQRCode:permission denied") {
  74. // app.Tips({ title: "没有权限"});
  75. // }
  76. },
  77. // complete(res){
  78. // console.log(res);
  79. // }
  80. })
  81. },
  82. /**
  83. * 确定销码
  84. */
  85. confirm: function () {
  86. orderVerific(this.data.verify_code, 1)
  87. .then(res => {
  88. this.setData({
  89. verify_code: '',
  90. iShidden:false
  91. });
  92. app.Tips({ title: res.msg });
  93. })
  94. .catch(res => {
  95. app.Tips({ title: res });
  96. });
  97. },
  98. /**
  99. * 取消
  100. */
  101. cancel: function () {
  102. this.setData({
  103. iShidden: false
  104. });
  105. },
  106. /**
  107. * 授权回调
  108. */
  109. onLoadFun: function (e) {
  110. },
  111. Setting: function () {
  112. },
  113. })