zhanw.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. // pages/ucenter/zhanw/zhanw.js
  2. let Util = require("../../../utils/util");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. searchIndex:-1,
  9. occupyFeeOrderList: [],
  10. pagesize:10,
  11. pagenum:1,
  12. total:-1,
  13. loadTotal: 0,
  14. dataLoading: false,
  15. finishedLoadTap: 0,
  16. finishedLoadShowTimes: 0,
  17. chongdianzhuangmingcheng: false,
  18. chongdianzhuangbianhao: false,
  19. chongdianshichang: false,
  20. chongdiankaishijieshu: false,
  21. customerServiceFlag: false,
  22. cancleBtnFlag: false,
  23. servicetel: getApp().globalData.helpPhoneNum,
  24. },
  25. switchBar(e){
  26. let searchIndex = e.currentTarget.dataset.idx;
  27. this.setData({
  28. searchIndex
  29. })
  30. this.resetListZero();
  31. this.getPage();
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function(options) {
  37. let userInfo = wx.getStorageSync('userInfo');
  38. let isLogin = wx.getStorageSync('isLogin');
  39. let that = this;
  40. // 页面显示
  41. if (userInfo && isLogin) {
  42. this.resetListZero();
  43. this.getPage();
  44. }
  45. },
  46. resetListZero(){
  47. let occupyFeeOrderList = []
  48. let pagesize = 10
  49. let pagenum = 1
  50. let total = -1
  51. let loadTotal = 0
  52. let dataLoading = false
  53. let finishedLoadTap = 0
  54. let finishedLoadShowTimes = 0
  55. this.setData({
  56. occupyFeeOrderList,
  57. pagesize,
  58. pagenum,
  59. total,
  60. loadTotal,
  61. dataLoading,
  62. finishedLoadTap,
  63. finishedLoadShowTimes,
  64. })
  65. },
  66. getPage(){
  67. // console.info(this.data.occupyFeeOrderList.length + " MMM " + this.data.total)
  68. if(this.data.occupyFeeOrderList.length == this.data.total){
  69. this.setData({
  70. finishedLoadTap:this.data.finishedLoadTap+1
  71. })
  72. if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
  73. this.setData({
  74. finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
  75. })
  76. wx.showToast({
  77. title: '全部加载完毕',
  78. icon: 'success',
  79. duration: 2000
  80. })
  81. }
  82. return
  83. }
  84. if(this.data.dataLoading){
  85. return
  86. }
  87. this.setData({
  88. dataLoading: true
  89. })
  90. wx.showLoading({
  91. title: '数据加载中....',
  92. })
  93. let that = this;
  94. wx.request({
  95. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
  96. data: {
  97. userId: wx.getStorageSync('userInfo').userId,
  98. searchIndex: that.data.searchIndex<0?null:that.data.searchIndex,
  99. pagenum: this.data.pagenum++,
  100. pagesize: 10,
  101. },
  102. method: 'POST',
  103. success(res) {
  104. console.log("占位费",res);
  105. if (res.data.result.rows) {
  106. let {
  107. rows: occupyFeeOrderList
  108. } = res.data.result;
  109. // that.startTimeOrder(charginglogs);
  110. that.formatCharginglogs(occupyFeeOrderList);
  111. wx.hideLoading()
  112. that.setData({
  113. occupyFeeOrderList: that.data.occupyFeeOrderList.concat(occupyFeeOrderList),
  114. total: res.data.result.total,
  115. dataLoading: false
  116. });
  117. }
  118. }
  119. });
  120. },
  121. formatCharginglogs(formatCharginglogs) {
  122. formatCharginglogs.forEach((item, index) => {
  123. try {
  124. console.log("item",item);
  125. // 时间截取
  126. item.occupyBeginTime = item.occupyBeginTime.substr(0,16)
  127. item.occupyEndTime = item.occupyEndTime.substr(0,16)
  128. // 状态翻译
  129. if(item.status==3){
  130. item.occupyStatusCN = '未支付'
  131. }else if(item.status==4){
  132. item.occupyStatusCN = '已支付'
  133. }else if(item.status==6){
  134. item.occupyStatusCN = '已取消'
  135. }else if(item.status==7){
  136. item.occupyStatusCN = '已退款'
  137. };
  138. // 判断标记为 chongdianzhuangmingcheng chongdianzhuangbianhao chongdianshichang chongdiankaishijieshu
  139. // let chongdianzhuangmingcheng = false
  140. // let chongdianzhuangbianhao = false
  141. // let chongdianshichang = false
  142. // let chongdiankaishijieshu = false
  143. // let chongdianfeiyong = false
  144. let customerServiceFlag = false;
  145. let cancleBtnFlag= false;
  146. let height= 'h3';
  147. if(item.status==3){
  148. customerServiceFlag = true;
  149. }
  150. if(item.status==3 || item.status == 4){
  151. cancleBtnFlag = true;
  152. }
  153. // item.chongdianzhuangmingcheng = chongdianzhuangmingcheng;
  154. // item.chongdianzhuangbianhao = chongdianzhuangbianhao;
  155. // item.chongdianshichang = chongdianshichang;
  156. // item.chongdiankaishijieshu = chongdiankaishijieshu;
  157. // item.chongdianfeiyong = chongdianfeiyong;
  158. item.customerServiceFlag = customerServiceFlag;
  159. item.cancleBtnFlag = cancleBtnFlag;
  160. item.height = height;
  161. //console.log(item.chargPile);
  162. } catch (err) {
  163. //在这里处理错误
  164. }
  165. try {
  166. let chargePile = item.pileLog;
  167. console.info(chargePile)
  168. let startDate = Util.parseDate(chargePile.chargstarttime);
  169. let endDate = Util.parseDate(chargePile.chargendtime)
  170. let totalTime = Math.round((endDate.getTime() - startDate.getTime()) / 60000);
  171. let totalTimeHour = Math.floor(totalTime / 60);
  172. let totalTimeMinute = totalTime % 60;
  173. let startTime = startDate.getFullYear() + "年" + Util.formatNumber(startDate.getMonth() + 1) + '月' + Util.formatNumber(startDate.getDate()) + '日 ' + Util.formatNumber(startDate.getHours()) + ':' + Util.formatNumber(startDate.getMinutes()) + ':' + Util.formatNumber(startDate.getSeconds());
  174. let endTime = endDate.getFullYear() + "年" + Util.formatNumber(endDate.getMonth() + 1) + '月' + Util.formatNumber(endDate.getDate()) + '日 ' + Util.formatNumber(endDate.getHours()) + ':' + Util.formatNumber(endDate.getMinutes()) + ':' + Util.formatNumber(endDate.getSeconds());
  175. totalTime = Util.formatNumber(totalTimeHour) + "时" + Util.formatNumber(totalTimeMinute) + "分";
  176. chargePile.startTime = startTime;
  177. chargePile.endTime = endTime;
  178. chargePile.totalTime = totalTime;
  179. chargePile.chargallmoney = chargePile.chargallmoney.toFixed(2);
  180. chargePile.chargservice = chargePile.chargservice.toFixed(2);
  181. chargePile.chargmoney = chargePile.chargmoney.toFixed(2);
  182. //console.log(chargePile.chargPile);
  183. } catch (err) {
  184. //在这里处理错误
  185. }
  186. });
  187. },
  188. startTimeOrder(charginglogs) {
  189. if (charginglogs && 0 != charginglogs.length) {
  190. charginglogs.sort(function(ma, mb) {
  191. return mb.chargstarttime.localeCompare(ma.chargstarttime);
  192. });
  193. }
  194. },
  195. customerServiceBtn(){
  196. wx.makePhoneCall({
  197. phoneNumber: this.data.servicetel
  198. })
  199. },
  200. cancleBtn(e){
  201. let that = this
  202. let reservId = e.currentTarget.dataset.idx;
  203. let userInfo = wx.getStorageSync('userInfo');
  204. let isLogin = wx.getStorageSync('isLogin');
  205. wx.showModal({
  206. title: '提示',
  207. confirmColor: '#00AADD',
  208. content: '若对当前占位费订单有疑问,请拨打客服电话4009608068,工作时间:08:00-18:00',
  209. complete: (res) => {
  210. // 可以在这里添加回调逻辑
  211. if (res.confirm) {
  212. console.log('用户点击了确认按钮');
  213. }else{
  214. console.log('用户点击了取消按钮');
  215. }
  216. }
  217. });
  218. },
  219. cancelM:function(e){
  220. this.setData({
  221. hiddenmodalput: true,
  222. })
  223. },
  224. confirmM: function (e) {
  225. console.log("姓名:" + this.data.name + " 电话:" + this.data.phoneNum);
  226. },
  227. iName: function (e) {
  228. this.setData({
  229. name:e.detail.value
  230. })
  231. },
  232. iPhoneNum: function (e) {
  233. this.setData({
  234. phoneNum: e.detail.value
  235. })
  236. },
  237. /**
  238. * 生命周期函数--监听页面初次渲染完成
  239. */
  240. onReady: function() {
  241. },
  242. /**
  243. * 生命周期函数--监听页面显示
  244. */
  245. onShow: function() {
  246. },
  247. /**
  248. * 生命周期函数--监听页面隐藏
  249. */
  250. onHide: function() {
  251. },
  252. /**
  253. * 生命周期函数--监听页面卸载
  254. */
  255. onUnload: function() {
  256. },
  257. /**
  258. * 页面相关事件处理函数--监听用户下拉动作
  259. */
  260. onPullDownRefresh: function() {
  261. },
  262. /**
  263. * 页面上拉触底事件的处理函数
  264. */
  265. onReachBottom: function() {
  266. },
  267. bindScrollTolowerEvent: function(){
  268. this.getPage();
  269. },
  270. /**
  271. * 用户点击右上角分享
  272. */
  273. onShareAppMessage: function() {
  274. }
  275. })