quick.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. const util = require("../../../utils/util");
  2. const api = require('../../../api/api.js');
  3. var app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. today: '',
  10. orderList: [],
  11. showType: 0,
  12. page: 1,
  13. limit: 10,
  14. totalPages: 1,
  15. addressInfo: {}
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. let that = this
  22. try {
  23. var tab = wx.getStorageSync('tabQuick');
  24. if (tab) {
  25. this.setData({
  26. showType: tab == 3 ? 0 : tab
  27. });
  28. }
  29. } catch (e) {}
  30. },
  31. getOrderList() {
  32. let that = this;
  33. wx.showLoading();
  34. util.request(api.BookHmList, {
  35. showType: that.data.showType,
  36. page: that.data.page,
  37. limit: that.data.limit
  38. }).then(function (res) {
  39. wx.hideLoading();
  40. if (res.errno === 0) {
  41. console.log(res.data);
  42. that.setData({
  43. orderList: that.data.orderList.concat(res.data.list),
  44. totalPages: res.data.pages
  45. });
  46. }
  47. });
  48. },
  49. switchTab: function (event) {
  50. let showType = event.currentTarget.dataset.index;
  51. wx.setStorageSync('tabQuick', showType);
  52. this.setData({
  53. orderList: [],
  54. showType: showType,
  55. page: 1,
  56. limit: 10,
  57. totalPages: 1
  58. });
  59. this.getOrderList();
  60. },
  61. onReachBottom() {
  62. if (this.data.totalPages > this.data.page) {
  63. this.setData({
  64. page: this.data.page + 1
  65. });
  66. this.getOrderList();
  67. } else {
  68. wx.showToast({
  69. title: '没有更多预检单了',
  70. icon: 'none',
  71. duration: 2000
  72. });
  73. return false;
  74. }
  75. },
  76. makeCall(e) {
  77. let mobile = e.currentTarget.dataset.mobile;
  78. wx.makePhoneCall({
  79. phoneNumber: mobile,
  80. })
  81. },
  82. goProblemAdd(e) {
  83. let id = e.currentTarget.dataset.id;
  84. if (id) {
  85. wx.navigateTo({
  86. url: '/pages/problem/list/list?bookTradeNo=' + id,
  87. })
  88. } else {
  89. wx.navigateTo({
  90. url: '/pages/problem/list/list',
  91. })
  92. }
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady: function () {
  98. },
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow: function () {
  103. if (app.globalData.hasLogin == false) {
  104. wx.navigateTo({
  105. url: '/pages/index/index',
  106. })
  107. return;
  108. }
  109. this.setData({
  110. orderList: [],
  111. showType: this.data.showType,
  112. page: 1,
  113. limit: 10,
  114. totalPages: 1,
  115. today: util.formatDate(new Date()),
  116. });
  117. this.getOrderList();
  118. },
  119. openMap(e) { //打开地图
  120. let address = e.currentTarget.dataset.address;
  121. let lng = e.currentTarget.dataset.lng;
  122. let lat = e.currentTarget.dataset.lat;
  123. // console.info(lng)
  124. // console.info(lat)
  125. // console.info(address)
  126. wx.openLocation({
  127. latitude: lat,
  128. longitude: lng,
  129. name: address,
  130. address: address,
  131. scale: 28
  132. })
  133. },
  134. /**
  135. * 生命周期函数--监听页面隐藏
  136. */
  137. onHide: function () {
  138. },
  139. /**
  140. * 生命周期函数--监听页面卸载
  141. */
  142. onUnload: function () {
  143. },
  144. /**
  145. * 页面相关事件处理函数--监听用户下拉动作
  146. */
  147. onPullDownRefresh: function () {
  148. },
  149. /**
  150. * 用户点击右上角分享
  151. */
  152. onShareAppMessage: function () {
  153. }
  154. })