carDetails.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. var app = getApp()
  2. Page({
  3. data: {
  4. carList: [
  5. //详情列表
  6. {
  7. id: 1,
  8. img_url: "http://resource.weilaibike.com/bike_yunwei/position.png",
  9. text: "车辆位置"
  10. },
  11. {
  12. id: 2,
  13. img_url: "http://resource.weilaibike.com/bike_yunwei/scan.png",
  14. text: "扫码位置"
  15. },
  16. {
  17. id: 3,
  18. img_url: "http://resource.weilaibike.com/bike_yunwei/order.png",
  19. text: "最近订单"
  20. },
  21. {
  22. id: 4,
  23. img_url: "http://resource.weilaibike.com/bike_yunwei/lock.png",
  24. text: "开关锁记录"
  25. },
  26. {
  27. id: 4,
  28. img_url: "http://resource.weilaibike.com/bike_yunwei/line.png",
  29. text: "上下线记录"
  30. }
  31. ],
  32. id: '',
  33. bike_no: '',
  34. detail: [],
  35. isDisabled: false, //备注是否修改
  36. textVal: '', //输入框内容
  37. },
  38. //点击跳转
  39. skip(e) {
  40. let that = this;
  41. let idx = parseInt(e.currentTarget.dataset.idx);
  42. let url = ''
  43. switch (idx) {
  44. case 0:
  45. url = '/pages/carPosition/carPosition';
  46. break;
  47. case 1:
  48. url = '/pages/scanRecord/scanRecord';
  49. break;
  50. case 2:
  51. url = '/pages/recentOrder/recentOrder';
  52. break;
  53. case 3:
  54. url = '/pages/lockRecord/lockRecord';
  55. break;
  56. case 4:
  57. url = '/pages/lineRecord/lineRecord';
  58. break;
  59. default:
  60. ;
  61. }
  62. wx.navigateTo({
  63. url: url + '?bike_no=' + that.data.bike_no + '&&id=' + that.data.id,
  64. })
  65. },
  66. onLoad: function (options) {
  67. wx.showLoading({
  68. title: '加载中...',
  69. })
  70. let that = this;
  71. that.setData({
  72. bike_no: options.bike_no,
  73. id: options.id
  74. })
  75. app.request('bike/getBikeInfo?bike_no=' + options.bike_no, '', 'GET').then(res => {
  76. wx.hideLoading();
  77. that.setData({
  78. detail: res.data.bike_info
  79. })
  80. if (res.data.bike_info.remark) {
  81. that.setData({
  82. isDisabled: true
  83. })
  84. }
  85. })
  86. },
  87. getText(e) {
  88. this.setData({
  89. textVal: e.detail.value
  90. })
  91. },
  92. operate() {
  93. wx.showLoading({
  94. title: '加载中...',
  95. })
  96. let that = this;
  97. let dis = that.data.isDisabled;
  98. if (dis) {
  99. that.setData({
  100. isDisabled: false
  101. })
  102. } else {
  103. let data = {
  104. remark: this.data.textVal
  105. }
  106. app.request('bike/updateRemark/' + this.data.id, data, 'PUT').then(res => {
  107. wx.hideLoading();
  108. console.log(res);
  109. if (res.statusCode == 200) {
  110. wx.showToast({
  111. title: '提交成功~',
  112. icon: 'none'
  113. })
  114. that.setData({
  115. isDisabled: true
  116. })
  117. }
  118. })
  119. }
  120. },
  121. })