index.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. // pages/reservationPipe/index.js
  2. const app = getApp()
  3. var startPoint
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. str:' ',
  10. str2: ' ',
  11. filterWidth: 0, //获取顶部筛选宽度
  12. filterHeight: 0, //获取顶部筛选高度
  13. safeAreaHeight: 0, //底部安全区域的高度
  14. //按钮位置参数
  15. buttonTop: 0,
  16. buttonLeft: 0,
  17. windowHeight: '',
  18. windowWidth: '',
  19. loginStatus: wx.getStorageSync('loginStatus') ? wx.getStorageSync('loginStatus') : false,
  20. roleCodeList: wx.getStorageSync('roleCodeList') ? wx.getStorageSync('roleCodeList') : '',
  21. searchVal: '',
  22. appointmentStatusArray: [{
  23. dictValue: "",
  24. dictLabel: "全部状态"
  25. }],
  26. appointmentStatusIndex: 0,
  27. //分页
  28. limit: 10,
  29. requestStatu: '加载中...',
  30. page: 1,
  31. totalPages: 1,
  32. more: false,
  33. nomore: '',
  34. type: '5',// 管桩预约类型
  35. resData:[],
  36. requestStatu2: '加载中...',
  37. page2: 1,
  38. totalPages2: 1,
  39. more2: false,
  40. nomore2: '',
  41. },
  42. /**
  43. * 生命周期函数--监听页面加载
  44. */
  45. onLoad(options) {
  46. //预约审核状态
  47. let treeData = app.globalData.treeArr
  48. for (const element of treeData) {
  49. let arrStr;
  50. switch (element.dictValue) {
  51. case 'appointment_status':
  52. arrStr = "appointmentStatusArray";
  53. break;
  54. }
  55. let getArray =[{
  56. dictValue: "",
  57. dictLabel: "全部状态"
  58. }]
  59. this.setData({
  60. [arrStr]: getArray.concat(element.children)
  61. })
  62. }
  63. this.setData({
  64. safeAreaHeight: app.globalData.windowInfo.screenHeight - app.globalData.systemInfo.safeArea.bottom
  65. })
  66. // 使用选择器选择节点
  67. this.getFilterHeight()
  68. //获取页面高度设置新增按钮的初始位置
  69. var that = this;
  70. wx.getSystemInfo({
  71. success: function (res) {
  72. // 高度,宽度 单位为px
  73. that.setData({
  74. windowHeight: res.windowHeight, //屏幕宽度、高度
  75. windowWidth: res.windowWidth,
  76. buttonTop: res.windowHeight * 0.8 - that.data.safeAreaHeight-50, //这里定义按钮的初始位置
  77. buttonLeft: res.windowWidth * 0.80, //这里定义按钮的初始位置
  78. })
  79. }
  80. })
  81. },
  82. //获取顶部筛选区域的高度
  83. getFilterHeight:function(){
  84. let that = this;
  85. // 使用顶部筛选高度选择器选择节点的高度
  86. const query = wx.createSelectorQuery();
  87. query.select('.topSeach').boundingClientRect(function (rect) {
  88. if(rect){
  89. that.setData({
  90. filterWidth: rect.width,
  91. filterHeight: rect.height,
  92. });
  93. }
  94. }).exec();
  95. },
  96. /**
  97. * 生命周期函数--监听页面初次渲染完成
  98. */
  99. onReady() {
  100. },
  101. /**
  102. * 生命周期函数--监听页面显示
  103. */
  104. onShow() {
  105. const roleCodeList = wx.getStorageSync('roleCodeList')
  106. let loginStatus = wx.getStorageSync('loginStatus')
  107. this.setData({
  108. searchVal: '',
  109. roleCodeList: roleCodeList ? roleCodeList : '',
  110. loginStatus: loginStatus ? loginStatus : false
  111. })
  112. this.setData({
  113. requestStatu:'加载中...',
  114. })
  115. if (wx.getStorageSync('loginStatus')) {
  116. this.getListFun();
  117. }
  118. },
  119. //下拉选择
  120. bindPickerChange: function (e) { //下拉菜单
  121. //方法一动态的
  122. let getIndex = e.target.dataset.pickername + 'Index'
  123. app.util.getPickerIndex(this, getIndex, e);
  124. this.getListFun()
  125. },
  126. //搜索框请求S
  127. onChange(e) {
  128. this.setData({
  129. searchVal: e.detail,
  130. });
  131. },
  132. onSearch: function (event) {
  133. this.setData({
  134. searchVal: event.detail
  135. })
  136. this.getListFun();
  137. },
  138. onCancel: function () {
  139. this.setData({})
  140. },
  141. toSearch: function (event) {
  142. this.getListFun();
  143. },
  144. //列表
  145. getListFun: function () {
  146. this.setData({
  147. page: 1
  148. })
  149. let params = {
  150. current : this.data.page,
  151. size : this.data.limit,
  152. type : this.data.type,
  153. searchKey : this.data.searchVal,
  154. status : this.data.appointmentStatusArray[this.data.appointmentStatusIndex].dictValue
  155. }
  156. app.request.pageFirst({
  157. url: app.API.appointmentPipePage,
  158. page: this,
  159. params: params,
  160. })
  161. },
  162. //页面跳转
  163. toLink: function (e) {
  164. let { url } = e.currentTarget.dataset
  165. wx.navigateTo({
  166. url: url
  167. })
  168. },
  169. //删除
  170. delFun: function (e) {
  171. let _this = this
  172. let { id, planNumber } = e.currentTarget.dataset
  173. wx.showModal({
  174. title: '提示!',
  175. content: `删除管桩预约号【${planNumber}】后不可恢复。确定要删除吗?`,
  176. confirmColor: '#FF5B5B',
  177. success: function (res) {
  178. if (res.confirm) {
  179. app.request.POST({
  180. url: app.API.appointmentDelete,
  181. params: [{
  182. id: id
  183. }],
  184. page: _this,
  185. isLoadingTxt: '删除中...',
  186. successFun: true
  187. }).then(res => {
  188. wx.showToast({
  189. title: '删除成功',
  190. icon: 'success',
  191. duration: 1000,
  192. mask: true
  193. })
  194. _this.getListFun(); //刷新列表
  195. })
  196. } else if (res.cancel) {
  197. }
  198. }
  199. })
  200. },
  201. //取消
  202. cancelFun: function (e) {
  203. let _this = this
  204. let { id, planNumber } = e.currentTarget.dataset
  205. wx.showModal({
  206. title: '提示!',
  207. content: `管桩预约号【${planNumber}】,确定取消该预约吗?`,
  208. confirmColor: '#FF5B5B',
  209. success: function (res) {
  210. if (res.confirm) {
  211. app.request.POST({
  212. url: app.API.appointmentCancel,
  213. params: {
  214. id: id
  215. },
  216. page: _this,
  217. isLoadingTxt: '提交中...',
  218. successFun: true
  219. }).then(res => {
  220. wx.showToast({
  221. title: '取消成功',
  222. icon: 'success',
  223. duration: 1000,
  224. mask: true
  225. })
  226. _this.getListFun(); //刷新列表
  227. })
  228. } else if (res.cancel) {
  229. }
  230. }
  231. })
  232. },
  233. // 单选
  234. dangerStatusChange: function (e) {
  235. this.setData({
  236. [e.currentTarget.dataset.radiotype]: e.detail.value
  237. })
  238. },
  239. //申请
  240. changeAdd() {
  241. wx.navigateTo({
  242. url: 'add'
  243. })
  244. },
  245. /**
  246. * 生命周期函数--监听页面隐藏
  247. */
  248. onHide() {
  249. },
  250. /**
  251. * 生命周期函数--监听页面卸载
  252. */
  253. onUnload() {
  254. },
  255. /**
  256. * 页面相关事件处理函数--监听用户下拉动作
  257. */
  258. onPullDownRefresh: function () {
  259. this.setData({
  260. searchVal: ''
  261. })
  262. if (wx.getStorageSync('loginStatus')) {
  263. this.getListFun();
  264. } else {
  265. wx.stopPullDownRefresh();
  266. }
  267. },
  268. /**
  269. * 页面上拉触底事件的处理函数
  270. */
  271. onReachBottom: function () {
  272. this.data.page++;
  273. let params = {
  274. current : this.data.page,
  275. size : this.data.limit,
  276. type : this.data.type,
  277. searchKey : this.data.searchVal,
  278. status : this.data.appointmentStatusArray[this.data.appointmentStatusIndex].dictValue
  279. }
  280. app.request.pageOther({
  281. url: app.API.bizloadarrivePage,
  282. page: this,
  283. params: params,
  284. loadType: true //加载类型,是否是下拉加载
  285. });
  286. },
  287. //以下是按钮拖动事件
  288. buttonStart: function (e) {
  289. startPoint = e.touches[0] //获取拖动开始点
  290. },
  291. buttonMove: function (e) {
  292. var endPoint = e.touches[e.touches.length - 1] //获取拖动结束点
  293. //计算在X轴上拖动的距离和在Y轴上拖动的距离
  294. var translateX = endPoint.clientX - startPoint.clientX
  295. var translateY = endPoint.clientY - startPoint.clientY
  296. startPoint = endPoint //重置开始位置
  297. var buttonTop = this.data.buttonTop + translateY
  298. var buttonLeft = this.data.buttonLeft + translateX
  299. //判断是移动否超出屏幕
  300. if (buttonLeft + 60 >= this.data.windowWidth) {
  301. buttonLeft = this.data.windowWidth - 60;
  302. }
  303. if (buttonLeft <= 0) {
  304. buttonLeft = 0;
  305. }
  306. if (buttonTop <= this.data.filterHeight) {
  307. buttonTop = this.data.filterHeight
  308. }
  309. if (buttonTop + 60 + 48 + this.data.safeAreaHeight >= this.data.windowHeight) {
  310. buttonTop = this.data.windowHeight - 60 - 48 - this.data.safeAreaHeight;
  311. }
  312. this.setData({
  313. buttonTop: buttonTop,
  314. buttonLeft: buttonLeft
  315. })
  316. },
  317. buttonEnd: function (e) {},
  318. /**
  319. * 用户点击右上角分享
  320. */
  321. onShareAppMessage() {
  322. }
  323. })