index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. // pages/deliveryConfirm/index.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. sendRecordNum:0,
  9. str:' ',
  10. loginStatus: wx.getStorageSync('loginStatus') ? wx.getStorageSync('loginStatus') : false,
  11. roleCodeList: wx.getStorageSync('roleCodeList') ? wx.getStorageSync('roleCodeList') : '',
  12. activeIndex:'1',
  13. searchVal: '',
  14. //分页
  15. limit: 10,
  16. requestStatu: '加载中...',
  17. page: 1,
  18. totalPages: 1,
  19. more: false,
  20. nomore: '',
  21. resData:[],
  22. appointmentTypeArray: [{
  23. dictValue: "",
  24. dictLabel: "全部状态"
  25. }],
  26. appointmentTypeIndex: 0,
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad(options) {
  32. if(wx.getStorageSync('loginStatus')){
  33. this.getTree()
  34. }
  35. },
  36. //获取字典数据
  37. getTree:function(){
  38. app.request.GET({
  39. url:app.API.getTree,
  40. page:this,
  41. successFun:true
  42. }).then(res=>{
  43. let treeData = res.data.data
  44. for (const element of treeData) {
  45. let arrStr;
  46. switch (element.dictValue) {
  47. case 'appointment_type':
  48. arrStr = "appointmentTypeArray";
  49. break;
  50. }
  51. let getArray = this.data.appointmentTypeArray
  52. this.setData({
  53. [arrStr]: getArray.concat(element.children)
  54. })
  55. }
  56. })
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady() {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow() {
  67. const roleCodeList = wx.getStorageSync('roleCodeList')
  68. let loginStatus = wx.getStorageSync('loginStatus')
  69. this.setData({
  70. searchVal: '',
  71. roleCodeList: roleCodeList ? roleCodeList : '',
  72. loginStatus: loginStatus ? loginStatus : false
  73. })
  74. //动态tabbar
  75. // if (roleCodeList == 'bizAdmin') {
  76. // this.getTabBar().setData({
  77. // list: app.globalData.allList[0].list2,
  78. // })
  79. // } else if(roleCodeList == 'send') {
  80. // this.getTabBar().setData({
  81. // list: app.globalData.allList[0].list3,
  82. // })
  83. // } else if(roleCodeList == 'sale') {
  84. // this.getTabBar().setData({
  85. // list: app.globalData.allList[0].list4,
  86. // })
  87. // } else if(roleCodeList == 'customer') {
  88. // this.getTabBar().setData({
  89. // list: app.globalData.allList[0].list5,
  90. // })
  91. // } else if (roleCodeList=='driver'||roleCodeList==''){
  92. // this.getTabBar().setData({
  93. // list: app.globalData.allList[0].list1,
  94. // })
  95. // }
  96. // if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  97. // this.getTabBar().setData({
  98. // selected: 0
  99. // })
  100. // }
  101. if(wx.getStorageSync('loginStatus')){
  102. this.getListFun();
  103. }
  104. },
  105. //搜索框请求S
  106. onChange(e) {
  107. this.setData({
  108. searchVal: e.detail,
  109. });
  110. },
  111. onSearch: function (event) {
  112. this.setData({
  113. searchVal: event.detail
  114. })
  115. this.getListFun();
  116. },
  117. onCancel: function () {
  118. this.setData({})
  119. },
  120. toSearch: function (event) {
  121. this.getListFun();
  122. },
  123. //搜索框请求E
  124. //点击选项卡变化
  125. changeTypeFun: function (e) {
  126. this.setData({
  127. activeIndex: e.currentTarget.dataset.type
  128. })
  129. this.getListFun();
  130. },
  131. //列表 appointmentType 1砂石 3起卸
  132. getListFun: function () {
  133. this.setData({
  134. page: 1
  135. })
  136. let params = {
  137. current: this.data.page,
  138. size: this.data.limit,
  139. isFlag:'1',
  140. licensePlate:this.data.searchVal,
  141. sendRecordStatus:this.data.activeIndex
  142. }
  143. app.request.pageFirst({
  144. url: app.API.sendGoodsList,
  145. page: this,
  146. params: params,
  147. })
  148. },
  149. //发货确认操作
  150. comform: function (e) {
  151. let _this = this
  152. let { id, licensePlate } = e.currentTarget.dataset
  153. wx.showModal({
  154. title: '提示!',
  155. content: `【${licensePlate}】发货确认后不可取消。确定现在确认吗?`,
  156. confirmColor: '#FF5B5B',
  157. success: function (res) {
  158. if (res.confirm) {
  159. app.request.POST({
  160. url: app.API.sendGoodsConfirm,
  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. /**
  182. * 生命周期函数--监听页面隐藏
  183. */
  184. onHide() {
  185. },
  186. /**
  187. * 生命周期函数--监听页面卸载
  188. */
  189. onUnload() {
  190. },
  191. /**
  192. * 页面相关事件处理函数--监听用户下拉动作
  193. */
  194. onPullDownRefresh() {
  195. this.setData({
  196. searchVal: ''
  197. })
  198. if (wx.getStorageSync('loginStatus')) {
  199. this.getListFun();
  200. } else {
  201. wx.stopPullDownRefresh();
  202. }
  203. },
  204. /**
  205. * 页面上拉触底事件的处理函数
  206. * appointmentType 1砂石 3起卸
  207. */
  208. onReachBottom() {
  209. this.data.page++;
  210. let params = {
  211. current: this.data.page,
  212. size: this.data.limit,
  213. isFlag:'1',
  214. licensePlate:this.data.searchVal,
  215. sendRecordStatus:this.data.activeIndex
  216. }
  217. app.request.pageOther({
  218. url: app.API.sendGoodsList,
  219. page: this,
  220. params: params,
  221. loadType: true, //加载类型,是否是下拉加载
  222. });
  223. },
  224. /**
  225. * 用户点击右上角分享
  226. */
  227. onShareAppMessage() {
  228. }
  229. })