index.js 3.1 KB

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