index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad(options) {
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady() {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow() {
  37. const roleCodeList = wx.getStorageSync('roleCodeList')
  38. let loginStatus = wx.getStorageSync('loginStatus')
  39. this.setData({
  40. searchVal: '',
  41. roleCodeList: roleCodeList ? roleCodeList : '',
  42. loginStatus: loginStatus ? loginStatus : false
  43. })
  44. //动态tabbar
  45. // if (roleCodeList == 'bizAdmin') {
  46. // this.getTabBar().setData({
  47. // list: app.globalData.allList[0].list2,
  48. // })
  49. // } else if(roleCodeList == 'send') {
  50. // this.getTabBar().setData({
  51. // list: app.globalData.allList[0].list3,
  52. // })
  53. // } else if(roleCodeList == 'sale') {
  54. // this.getTabBar().setData({
  55. // list: app.globalData.allList[0].list4,
  56. // })
  57. // } else if(roleCodeList == 'customer') {
  58. // this.getTabBar().setData({
  59. // list: app.globalData.allList[0].list5,
  60. // })
  61. // } else if (roleCodeList=='driver'||roleCodeList==''){
  62. // this.getTabBar().setData({
  63. // list: app.globalData.allList[0].list1,
  64. // })
  65. // }
  66. // if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  67. // this.getTabBar().setData({
  68. // selected: 0
  69. // })
  70. // }
  71. if(wx.getStorageSync('loginStatus')){
  72. this.getListFun();
  73. }
  74. },
  75. //搜索框请求S
  76. onChange(e) {
  77. this.setData({
  78. searchVal: e.detail,
  79. });
  80. },
  81. onSearch: function (event) {
  82. this.setData({
  83. searchVal: event.detail
  84. })
  85. this.getListFun();
  86. },
  87. onCancel: function () {
  88. this.setData({})
  89. },
  90. toSearch: function (event) {
  91. this.getListFun();
  92. },
  93. //搜索框请求E
  94. //点击选项卡变化
  95. changeTypeFun: function (e) {
  96. this.setData({
  97. activeIndex: e.currentTarget.dataset.type
  98. })
  99. this.getListFun();
  100. },
  101. //列表
  102. getListFun: function () {
  103. this.setData({
  104. page: 1
  105. })
  106. let params = {
  107. current: this.data.page,
  108. size: this.data.limit,
  109. isFlag:'1',
  110. licensePlate:this.data.searchVal,
  111. sendRecordStatus:this.data.activeIndex
  112. }
  113. app.request.pageFirst({
  114. url: app.API.sendGoodsList,
  115. page: this,
  116. params: params,
  117. })
  118. },
  119. //发货确认操作
  120. comform: function (e) {
  121. let _this = this
  122. let { id, licensePlate } = e.currentTarget.dataset
  123. wx.showModal({
  124. title: '提示!',
  125. content: `【${licensePlate}】发货确认后不可取消。确定现在确认吗?`,
  126. confirmColor: '#FF5B5B',
  127. success: function (res) {
  128. if (res.confirm) {
  129. app.request.POST({
  130. url: app.API.sendGoodsConfirm,
  131. params: {
  132. id: id
  133. },
  134. page: _this,
  135. isLoadingTxt: '确认中...',
  136. successFun: true
  137. }).then(res => {
  138. wx.showToast({
  139. title: '确认成功',
  140. icon: 'success',
  141. duration: 1000,
  142. mask: true
  143. })
  144. _this.getListFun(); //刷新列表
  145. })
  146. } else if (res.cancel) {
  147. }
  148. }
  149. })
  150. },
  151. /**
  152. * 生命周期函数--监听页面隐藏
  153. */
  154. onHide() {
  155. },
  156. /**
  157. * 生命周期函数--监听页面卸载
  158. */
  159. onUnload() {
  160. },
  161. /**
  162. * 页面相关事件处理函数--监听用户下拉动作
  163. */
  164. onPullDownRefresh() {
  165. this.setData({
  166. searchVal: ''
  167. })
  168. if (wx.getStorageSync('loginStatus')) {
  169. this.getListFun();
  170. } else {
  171. wx.stopPullDownRefresh();
  172. }
  173. },
  174. /**
  175. * 页面上拉触底事件的处理函数
  176. */
  177. onReachBottom() {
  178. this.data.page++;
  179. let params = {
  180. current: this.data.page,
  181. size: this.data.limit,
  182. isFlag:'1',
  183. licensePlate:this.data.searchVal,
  184. sendRecordStatus:this.data.activeIndex
  185. }
  186. app.request.pageOther({
  187. url: app.API.sendGoodsList,
  188. page: this,
  189. params: params,
  190. loadType: true, //加载类型,是否是下拉加载
  191. });
  192. },
  193. /**
  194. * 用户点击右上角分享
  195. */
  196. onShareAppMessage() {
  197. }
  198. })