index.js 9.4 KB

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