index.js 9.7 KB

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