index.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. comform: function (e) {
  205. let _this = this
  206. let { id, orderNumber } = e.currentTarget.dataset
  207. wx.showModal({
  208. title: '提示!',
  209. content: `确认【${orderNumber}】后不可取消。确定现在确认订单吗?`,
  210. confirmColor: '#FF5B5B',
  211. success: function (res) {
  212. if (res.confirm) {
  213. app.request.POST({
  214. url: app.API.orderConfirm,
  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. /*wx.navigateTo({
  244. url: '/pages/appointment/review?id='+e.currentTarget.dataset.id
  245. })*/
  246. },
  247. onClose() {
  248. this.setData({
  249. show: false,
  250. auditFlag:'false',
  251. orderReason:'',
  252. id: ''
  253. });
  254. },
  255. // 单选
  256. dangerStatusChange: function (e) {
  257. this.setData({
  258. [e.currentTarget.dataset.radiotype]: e.detail.value
  259. })
  260. if (e.detail.value == '1') {
  261. this.setData({
  262. appointmentReason: ''
  263. })
  264. }
  265. },
  266. //审核
  267. formSubmit: function (e) {
  268. let formData = e.detail.value;
  269. var warn = ""; //弹框时提示的内容
  270. if (formData.auditFlag=='true' && formData.orderReason == '') {
  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. orderSubmit: function (e) {
  298. let _this = this
  299. let { id, orderNumber } = e.currentTarget.dataset
  300. wx.showModal({
  301. title: '提示!',
  302. content: `确认提交【${orderNumber}】订单?`,
  303. confirmColor: '#FF5B5B',
  304. success: function (res) {
  305. if (res.confirm) {
  306. app.request.POST({
  307. url: app.API.orderSubmit,
  308. params: {
  309. id: id
  310. },
  311. page: _this,
  312. isLoadingTxt: '操作中...',
  313. successFun: true
  314. }).then(res => {
  315. wx.showToast({
  316. title: '提交成功',
  317. icon: 'success',
  318. duration: 1000,
  319. mask: true
  320. })
  321. _this.getListFun(); //刷新列表
  322. })
  323. } else if (res.cancel) {
  324. }
  325. }
  326. })
  327. },
  328. //申请
  329. changeAdd() {
  330. wx.navigateTo({
  331. url: 'add'
  332. })
  333. },
  334. /**
  335. * 生命周期函数--监听页面隐藏
  336. */
  337. onHide() {
  338. },
  339. /**
  340. * 生命周期函数--监听页面卸载
  341. */
  342. onUnload() {
  343. },
  344. /**
  345. * 页面相关事件处理函数--监听用户下拉动作
  346. */
  347. onPullDownRefresh: function () {
  348. this.setData({
  349. searchVal: ''
  350. })
  351. if (wx.getStorageSync('loginStatus')) {
  352. this.getListFun();
  353. } else {
  354. wx.stopPullDownRefresh();
  355. }
  356. },
  357. /**
  358. * 页面上拉触底事件的处理函数
  359. */
  360. onReachBottom: function () {
  361. this.data.page++;
  362. let params = {
  363. current: this.data.page,
  364. size: this.data.limit,
  365. searchKey:this.data.searchVal,
  366. arriveStatus:this.data.arriveStatusArray[this.data.arriveStatusIndex].dictValue
  367. }
  368. app.request.pageOther({
  369. url: app.API.bizloadarrivePage,
  370. page: this,
  371. params: params,
  372. loadType: true //加载类型,是否是下拉加载
  373. });
  374. },
  375. //以下是按钮拖动事件
  376. buttonStart: function (e) {
  377. startPoint = e.touches[0] //获取拖动开始点
  378. },
  379. buttonMove: function (e) {
  380. var endPoint = e.touches[e.touches.length - 1] //获取拖动结束点
  381. //计算在X轴上拖动的距离和在Y轴上拖动的距离
  382. var translateX = endPoint.clientX - startPoint.clientX
  383. var translateY = endPoint.clientY - startPoint.clientY
  384. startPoint = endPoint //重置开始位置
  385. var buttonTop = this.data.buttonTop + translateY
  386. var buttonLeft = this.data.buttonLeft + translateX
  387. //判断是移动否超出屏幕
  388. if (buttonLeft + 60 >= this.data.windowWidth) {
  389. buttonLeft = this.data.windowWidth - 60;
  390. }
  391. if (buttonLeft <= 0) {
  392. buttonLeft = 0;
  393. }
  394. if (buttonTop <= this.data.filterHeight) {
  395. buttonTop = this.data.filterHeight
  396. }
  397. if (buttonTop + 60 + 48 + this.data.safeAreaHeight >= this.data.windowHeight) {
  398. buttonTop = this.data.windowHeight - 60 - 48 - this.data.safeAreaHeight;
  399. }
  400. this.setData({
  401. buttonTop: buttonTop,
  402. buttonLeft: buttonLeft
  403. })
  404. },
  405. buttonEnd: function (e) {},
  406. /**
  407. * 用户点击右上角分享
  408. */
  409. onShareAppMessage() {
  410. }
  411. })