index.js 9.6 KB

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