index.js 9.6 KB

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