index.js 8.0 KB

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