preList.js 3.7 KB

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