index.js 9.5 KB

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