index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // pages/detailsonthereceipt/index.js
  2. // pages/index/index.js
  3. import {
  4. Home
  5. } from '../../utils/home.js';
  6. let home = new Home(); //实例化 首页 对象
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. index:0,
  13. data:[],
  14. toast:true,
  15. },
  16. inputNum:function(e){
  17. let that=this
  18. that.setData({
  19. num:e.detail.value
  20. })
  21. },
  22. /**
  23. * 交付
  24. */
  25. delivery: function() {
  26. let that = this
  27. if(!that.data.num){
  28. that.setData({
  29. toast:false
  30. })
  31. wx.showToast({
  32. title: '请输入数量',
  33. icon: 'none',
  34. duration: 1500,
  35. mask: true,
  36. success: function(res) {},
  37. fail: function(res) {},
  38. complete: function(res) {},
  39. })
  40. return
  41. }
  42. var param = {
  43. id: that.data.data[that.data.index].id,
  44. num:that.data.num
  45. }
  46. home.delivery(param, (res) => {
  47. (res.code == 1) ? wx.showToast({ title: res.msg, icon: 'success' }) : wx.showToast({ title: res.msg, icon: 'none' });
  48. that.setData({ toast: true})
  49. setTimeout(function () { wx.navigateBack({}) }, 1000);
  50. })
  51. },
  52. /**
  53. * 生命周期函数--监听页面加载
  54. */
  55. onLoad: function(options) {
  56. let that = this
  57. console.log(JSON.parse(options.data))
  58. var data = JSON.parse(options.data)
  59. var index = options.index
  60. var type = options.type
  61. that.setData({
  62. data: data,
  63. index: index,
  64. type: type
  65. })
  66. },
  67. /**
  68. * 生命周期函数--监听页面初次渲染完成
  69. */
  70. onReady: function() {
  71. },
  72. /**
  73. * 生命周期函数--监听页面显示
  74. */
  75. onShow: function() {
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function() {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function() {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function() {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function() {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function() {
  101. }
  102. })