siginIn.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // pages/signIn/siginIn.js
  2. const app=getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. checked: false,
  9. result:null,
  10. title:""
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. this.setData({
  17. title:wx.getStorageSync('title')
  18. })
  19. },
  20. toHand(){
  21. wx.navigateTo({
  22. url: '/pages/signIn/hand/hand',
  23. })
  24. },
  25. toRecode(){
  26. wx.navigateTo({
  27. url: '/pages/signIn/recode/recode',
  28. })
  29. },
  30. onChange({ detail }) {
  31. // 需要手动对 checked 状态进行更新
  32. this.setData({ checked: detail });
  33. },
  34. getScancode: function () {
  35. var _this = this;
  36. // 允许从相机和相册扫码
  37. wx.scanCode({
  38. onlyFromCamera: true,
  39. scanType:['barCode', 'qrCode','datamatrix','pdf417'],
  40. success: (res) => {
  41. console.log(res);
  42. var result = res.result;
  43. _this.sign(result);
  44. _this.setData({
  45. result: result,
  46. })
  47. },
  48. fail:(err)=>{
  49. console.log(err);
  50. }
  51. })
  52. },
  53. sign: function (seal_no) {
  54. var that=this;
  55. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/sign", {
  56. seal_no:seal_no
  57. }, "post").then(function (res) {
  58. console.log(res);
  59. if (res.code != 200) {
  60. wx.showLoading({
  61. title:res.message.msg,
  62. })
  63. setTimeout(function () {
  64. wx.hideLoading();
  65. }, 1000);
  66. } else {
  67. wx.hideLoading();
  68. var data=res.message.data
  69. wx.showLoading({
  70. title: res.message.msg,
  71. })
  72. setTimeout(function () {
  73. wx.hideLoading();
  74. }, 1000);
  75. }
  76. }).catch(function (err) {
  77. console.log(222);
  78. })
  79. },
  80. })