index.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. // pages/reservationMan/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. str:' ',
  9. loginStatus: wx.getStorageSync('loginStatus') ? wx.getStorageSync('loginStatus') : false,
  10. roleCodeList: wx.getStorageSync('roleCodeList') ? wx.getStorageSync('roleCodeList') : '',
  11. searchVal: '',
  12. type:'',//预约类型
  13. appointmentClassifyArray: [
  14. { label:'充电预约',value:'1' },
  15. { label:'管桩预约',value:'2' },
  16. { label:'其他预约',value:'3' },
  17. ], //预约类型
  18. //分页
  19. limit: 10,
  20. requestStatu: '加载中...',
  21. page: 1,
  22. totalPages: 1,
  23. more: false,
  24. nomore: '',
  25. resData:[],
  26. show:false,
  27. auditFlag:'false',
  28. appointmentReason:'',//审核备注
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad(options) {
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady() {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow() {
  44. const roleCodeList = wx.getStorageSync('roleCodeList')
  45. let loginStatus = wx.getStorageSync('loginStatus')
  46. this.setData({
  47. searchVal: '',
  48. roleCodeList: roleCodeList ? roleCodeList : '',
  49. loginStatus: loginStatus ? loginStatus : false
  50. })
  51. //动态tabbar
  52. // if (roleCodeList == 'bizAdmin') {
  53. // this.getTabBar().setData({
  54. // list: app.globalData.allList[0].list2,
  55. // })
  56. // } else if(roleCodeList == 'send') {
  57. // this.getTabBar().setData({
  58. // list: app.globalData.allList[0].list3,
  59. // })
  60. // } else if(roleCodeList == 'sale') {
  61. // this.getTabBar().setData({
  62. // list: app.globalData.allList[0].list4,
  63. // })
  64. // }else if(roleCodeList == 'customer') {
  65. // this.getTabBar().setData({
  66. // list: app.globalData.allList[0].list5,
  67. // })
  68. // } else if (roleCodeList=='driver'||roleCodeList==''){
  69. // this.getTabBar().setData({
  70. // list: app.globalData.allList[0].list1,
  71. // })
  72. // }
  73. // if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  74. // this.getTabBar().setData({
  75. // selected: 2
  76. // })
  77. // }
  78. if(wx.getStorageSync('loginStatus')){
  79. this.getListFun();
  80. }
  81. },
  82. //搜索框请求S
  83. onChange(e) {
  84. this.setData({
  85. searchVal: e.detail,
  86. });
  87. },
  88. onSearch: function (event) {
  89. this.setData({
  90. searchVal: event.detail
  91. })
  92. this.getListFun();
  93. },
  94. onCancel: function () {
  95. this.setData({})
  96. },
  97. toSearch: function (event) {
  98. this.getListFun();
  99. },
  100. //列表
  101. getListFun: function () {
  102. this.setData({
  103. page: 1
  104. })
  105. let params = {
  106. current: this.data.page,
  107. size: this.data.limit,
  108. licenseNumber:this.data.searchVal,
  109. //status:1
  110. }
  111. app.request.pageFirst({
  112. url: app.API.appointmentList,
  113. page: this,
  114. params: params,
  115. })
  116. },
  117. //取消预约
  118. cancelFun: function (e) {
  119. let _this = this
  120. let { id, licenseNumber } = e.currentTarget.dataset
  121. wx.showModal({
  122. title: '提示!',
  123. content: `取消【${licenseNumber}】后不可恢复。确定要取消吗?`,
  124. confirmColor: '#FF5B5B',
  125. success: function (res) {
  126. if (res.confirm) {
  127. app.request.POST({
  128. url: app.API.appointmentCancel,
  129. params: {
  130. id: id
  131. },
  132. page: _this,
  133. isLoadingTxt: '取消中...',
  134. successFun: true
  135. }).then(res => {
  136. wx.showToast({
  137. title: '取消成功',
  138. icon: 'success',
  139. duration: 1000,
  140. mask: true
  141. })
  142. _this.getListFun(); //刷新列表
  143. })
  144. } else if (res.cancel) {
  145. }
  146. }
  147. })
  148. },
  149. //授权出场
  150. exitFun: function (e) {
  151. let _this = this
  152. let { id, licenseNumber } = e.currentTarget.dataset
  153. wx.showModal({
  154. title: '提示!',
  155. content: `确定授权【${licenseNumber}】出场?`,
  156. confirmColor: '#FF5B5B',
  157. success: function (res) {
  158. if (res.confirm) {
  159. app.request.POST({
  160. url: app.API.appointmentExit,
  161. params: {
  162. id: id
  163. },
  164. page: _this,
  165. isLoadingTxt: '授权中...',
  166. successFun: true
  167. }).then(res => {
  168. wx.showToast({
  169. title: '授权成功',
  170. icon: 'success',
  171. duration: 1000,
  172. mask: true
  173. })
  174. _this.getListFun(); //刷新列表
  175. })
  176. } else if (res.cancel) {
  177. }
  178. }
  179. })
  180. },
  181. // 审核S
  182. showPopup(e) {
  183. let { id,type } = e.currentTarget.dataset
  184. this.setData({
  185. show: true,
  186. appointmentReason: '',
  187. type:type,
  188. id: id
  189. });
  190. },
  191. onClose() {
  192. this.setData({
  193. show: false,
  194. auditFlag:'false',
  195. appointmentReason:'',
  196. id: ''
  197. });
  198. },
  199. // 单选
  200. dangerStatusChange: function (e) {
  201. this.setData({
  202. [e.currentTarget.dataset.radiotype]: e.detail.value
  203. })
  204. },
  205. //审核
  206. formSubmit: function (e) {
  207. let formData = e.detail.value;
  208. var warn = ""; //弹框时提示的内容
  209. if (formData.auditFlag=='true' && formData.appointmentReason == '') {
  210. warn = "审核不通过时备注不能为空!";
  211. }
  212. formData.auditFlag = formData.auditFlag=='true'
  213. if (warn != '') {
  214. app.util.checkForm(warn);
  215. } else {
  216. let url = app.API.appointmentAudit
  217. if(this.data.type == '2'){
  218. url = app.API.tempAudit
  219. }
  220. app.request.POST({
  221. url: url,
  222. params: formData,
  223. page: this,
  224. isLoadingTxt: '审核中...',
  225. successFun: true
  226. }).then(res => {
  227. wx.showToast({
  228. title: '审核成功',
  229. icon: 'success',
  230. duration: 1000,
  231. mask: true
  232. })
  233. this.onClose()
  234. this.getListFun(); //刷新列表
  235. })
  236. }
  237. },
  238. // 审核E
  239. /**
  240. * 生命周期函数--监听页面隐藏
  241. */
  242. onHide() {
  243. },
  244. /**
  245. * 生命周期函数--监听页面卸载
  246. */
  247. onUnload() {
  248. },
  249. /**
  250. * 页面相关事件处理函数--监听用户下拉动作
  251. */
  252. onPullDownRefresh: function () {
  253. this.setData({
  254. searchVal: ''
  255. })
  256. if (wx.getStorageSync('loginStatus')) {
  257. this.getListFun();
  258. } else {
  259. wx.stopPullDownRefresh();
  260. }
  261. },
  262. /**
  263. * 页面上拉触底事件的处理函数
  264. */
  265. onReachBottom: function () {
  266. this.data.page++;
  267. let params = {
  268. current: this.data.page,
  269. size: this.data.limit,
  270. licenseNumber:this.data.searchVal,
  271. //status:1
  272. }
  273. app.request.pageOther({
  274. url: app.API.appointmentList,
  275. page: this,
  276. params: params,
  277. loadType: true //加载类型,是否是下拉加载
  278. });
  279. },
  280. /**
  281. * 用户点击右上角分享
  282. */
  283. onShareAppMessage() {
  284. }
  285. })