zhanw.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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. orderid: null,
  25. userId: null,
  26. order: null,
  27. },
  28. switchBar(e){
  29. let searchIndex = e.currentTarget.dataset.idx;
  30. this.setData({
  31. searchIndex
  32. })
  33. this.resetListZero();
  34. this.getPage();
  35. },
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad: function(options) {
  40. let userInfo = wx.getStorageSync('userInfo');
  41. let isLogin = wx.getStorageSync('isLogin');
  42. let that = this;
  43. // 页面显示
  44. if (userInfo && isLogin) {
  45. this.resetListZero();
  46. this.getPage();
  47. }
  48. },
  49. resetListZero(){
  50. let occupyFeeOrderList = []
  51. let pagesize = 10
  52. let pagenum = 1
  53. let total = -1
  54. let loadTotal = 0
  55. let dataLoading = false
  56. let finishedLoadTap = 0
  57. let finishedLoadShowTimes = 0
  58. this.setData({
  59. occupyFeeOrderList,
  60. pagesize,
  61. pagenum,
  62. total,
  63. loadTotal,
  64. dataLoading,
  65. finishedLoadTap,
  66. finishedLoadShowTimes,
  67. })
  68. },
  69. getPage(){
  70. // console.info(this.data.occupyFeeOrderList.length + " MMM " + this.data.total)
  71. if(this.data.occupyFeeOrderList.length == this.data.total){
  72. this.setData({
  73. finishedLoadTap:this.data.finishedLoadTap+1
  74. })
  75. if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
  76. this.setData({
  77. finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
  78. })
  79. wx.showToast({
  80. title: '全部加载完毕',
  81. icon: 'success',
  82. duration: 2000
  83. })
  84. }
  85. return
  86. }
  87. if(this.data.dataLoading){
  88. return
  89. }
  90. this.setData({
  91. dataLoading: true
  92. })
  93. wx.showLoading({
  94. title: '数据加载中....',
  95. })
  96. let that = this;
  97. wx.request({
  98. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
  99. data: {
  100. userId: wx.getStorageSync('userInfo').userId,
  101. searchIndex: that.data.searchIndex<0?-1:that.data.searchIndex,
  102. pagenum: this.data.pagenum++,
  103. pagesize: 10,
  104. },
  105. method: 'POST',
  106. success(res) {
  107. console.log("占位费",res);
  108. if (res.data.code == 200) {
  109. let {
  110. rows: occupyFeeOrderList
  111. } = res.data.result;
  112. // that.startTimeOrder(charginglogs);
  113. that.formatCharginglogs(occupyFeeOrderList);
  114. wx.hideLoading()
  115. that.setData({
  116. occupyFeeOrderList: that.data.occupyFeeOrderList.concat(occupyFeeOrderList),
  117. total: res.data.result.total,
  118. dataLoading: false
  119. });
  120. }else{
  121. wx.hideLoading()
  122. }
  123. }
  124. });
  125. },
  126. formatCharginglogs(formatCharginglogs) {
  127. formatCharginglogs.forEach((item, index) => {
  128. try {
  129. console.log("item",item);
  130. // 时间截取
  131. item.occupyBeginTime = item.occupyBeginTime.substr(0,16)
  132. item.occupyEndTime = item.occupyEndTime.substr(0,16)
  133. // 状态翻译
  134. if(item.status==3){
  135. item.occupyStatusCN = '未支付'
  136. }else if(item.status==4){
  137. item.occupyStatusCN = '已支付'
  138. }else if(item.status==6){
  139. item.occupyStatusCN = '已取消'
  140. }else if(item.status==7){
  141. item.occupyStatusCN = '已退款'
  142. };
  143. // 判断标记为 chongdianzhuangmingcheng chongdianzhuangbianhao chongdianshichang chongdiankaishijieshu
  144. // let chongdianzhuangmingcheng = false
  145. // let chongdianzhuangbianhao = false
  146. // let chongdianshichang = false
  147. // let chongdiankaishijieshu = false
  148. // let chongdianfeiyong = false
  149. let customerServiceFlag = false;
  150. let cancleBtnFlag= false;
  151. let height= 'h3';
  152. if(item.status==3){
  153. customerServiceFlag = true;
  154. }
  155. if(item.status==3 || item.status == 4){
  156. cancleBtnFlag = true;
  157. }
  158. // item.chongdianzhuangmingcheng = chongdianzhuangmingcheng;
  159. // item.chongdianzhuangbianhao = chongdianzhuangbianhao;
  160. // item.chongdianshichang = chongdianshichang;
  161. // item.chongdiankaishijieshu = chongdiankaishijieshu;
  162. // item.chongdianfeiyong = chongdianfeiyong;
  163. item.customerServiceFlag = customerServiceFlag;
  164. item.cancleBtnFlag = cancleBtnFlag;
  165. item.height = height;
  166. //console.log(item.chargPile);
  167. } catch (err) {
  168. //在这里处理错误
  169. }
  170. try {
  171. let chargePile = item.pileLog;
  172. console.info(chargePile)
  173. let startDate = Util.parseDate(chargePile.chargstarttime);
  174. let endDate = Util.parseDate(chargePile.chargendtime)
  175. let totalTime = Math.round((endDate.getTime() - startDate.getTime()) / 60000);
  176. let totalTimeHour = Math.floor(totalTime / 60);
  177. let totalTimeMinute = totalTime % 60;
  178. 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());
  179. 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());
  180. totalTime = Util.formatNumber(totalTimeHour) + "时" + Util.formatNumber(totalTimeMinute) + "分";
  181. chargePile.startTime = startTime;
  182. chargePile.endTime = endTime;
  183. chargePile.totalTime = totalTime;
  184. chargePile.chargallmoney = chargePile.chargallmoney.toFixed(2);
  185. chargePile.chargservice = chargePile.chargservice.toFixed(2);
  186. chargePile.chargmoney = chargePile.chargmoney.toFixed(2);
  187. //console.log(chargePile.chargPile);
  188. } catch (err) {
  189. //在这里处理错误
  190. }
  191. });
  192. },
  193. startTimeOrder(charginglogs) {
  194. if (charginglogs && 0 != charginglogs.length) {
  195. charginglogs.sort(function(ma, mb) {
  196. return mb.chargstarttime.localeCompare(ma.chargstarttime);
  197. });
  198. }
  199. },
  200. customerServiceBtn(e){
  201. console.log("拿纸",e.currentTarget.dataset.idx);
  202. let parkId = e.currentTarget.dataset.idx;
  203. wx.makePhoneCall({
  204. phoneNumber: this.data.servicetel
  205. })
  206. },
  207. payOrder(e) {
  208. // log.info('[订单支付]', '[用户触发支付订单]');
  209. // wx.showLoading({
  210. // title: '支付中...',
  211. // mask: true
  212. // });
  213. let parkId = e.currentTarget.dataset.idx;
  214. let that = this;
  215. let userId = wx.getStorageSync('userInfo').userId
  216. wx.request({
  217. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/queryOccupyFeeOrder',
  218. data: {
  219. userId: userId,
  220. orderId:parkId,
  221. searchIndex: null,
  222. pagenum: that.data.pagenum++,
  223. pagesize: 10,
  224. },
  225. method: 'POST',
  226. success(res) {
  227. console.log("更具订单号插叙",res);
  228. // this.setData({
  229. // order:res.data
  230. // })
  231. }
  232. });
  233. // let {
  234. // order,
  235. // } = this.data;
  236. // log.info('[订单支付]', '[用户触发支付订单]', '[wx.login请求]');
  237. // wx.login({
  238. // success(res) {
  239. // console.log(res);
  240. // log.info('[订单支付]', '[用户触发支付订单]', '[wx.login响应]',res);
  241. // if (res.code) {
  242. // // 发起网络请求
  243. // log.info('[订单支付]', '[服务端订单支付]', '[请求]', {
  244. // outTradeNo: order.orderid, //订单号
  245. // totalFee: order.chargallmoney, //钱
  246. // code: res.code,
  247. // user_id: userId
  248. // });
  249. // wx.request({
  250. // url: getApp().globalData.postHeadAgreement +'/restapi/wechatpay/chargpayfor',
  251. // data: {
  252. // outTradeNo: order.orderid, //订单号
  253. // totalFee: order.chargallmoney, //钱
  254. // code: res.code,
  255. // user_id: userId
  256. // },
  257. // method: 'POST',
  258. // header: {
  259. // 'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
  260. // },
  261. // success(res1) {
  262. // let {
  263. // data
  264. // } = res1;
  265. // log.info('[订单支付]', '[服务端订单支付]', '[响应]', data);
  266. // console.log(res1);
  267. // if (data && data.code == 200) {
  268. // if (data.result) {
  269. // //wx.showModal({
  270. // // showCancel: false,
  271. // // content: '请微信支付'
  272. // // });
  273. // log.info('[订单支付]', '[余额不足微信支付]','[请求]',{
  274. // timeStamp: data.result.timeStamp,
  275. // nonceStr: data.result.nonceStr,
  276. // package: data.result.package,
  277. // signType: data.result.signType,
  278. // paySign: data.result.paySign});
  279. // wx.requestPayment({
  280. // timeStamp: data.result.timeStamp,
  281. // nonceStr: data.result.nonceStr,
  282. // package: data.result.package,
  283. // signType: data.result.signType,
  284. // paySign: data.result.paySign,
  285. // success(res2) {
  286. // log.info('[订单支付]', '[余额不足微信支付成功]', '[响应]', res2);
  287. // log.info('[订单支付]', '[微信支付成功回调服务端]', '[请求]', {
  288. // //chargPileId,
  289. // //userId,
  290. // orderid: order.orderid
  291. // });
  292. // wx.hideLoading();
  293. // wx.showModal({
  294. // showCancel: false,
  295. // content: '支付订单成功',
  296. // confirmColor:'#00AADD',
  297. // });
  298. // that.setData({
  299. // orderFlag:true
  300. // });
  301. // },
  302. // fail(res3) {
  303. // wx.hideLoading();
  304. // log.info('[订单支付]', '[余额不足微信支付]', '[fail]', res3);
  305. // console.log(res3);
  306. // }
  307. // });
  308. // } else {
  309. // wx.hideLoading();
  310. // that.setData({
  311. // orderFlag: true
  312. // });
  313. // wx.showModal({
  314. // showCancel: false,
  315. // content: data.msg,
  316. // confirmColor:'#00AADD',
  317. // });
  318. // }
  319. // log.info('[订单支付]', '[服务端订单支付]', '[余额支付成功]', data);
  320. // } else {
  321. // wx.hideLoading();
  322. // wx.showModal({
  323. // showCancel: false,
  324. // content: data.msg,
  325. // confirmColor:'#00AADD',
  326. // });
  327. // log.info('[订单支付]', '[服务端订单支付]', '[失败data null||data.code<>200]', data);
  328. // }
  329. // }
  330. // });
  331. // } else {
  332. // wx.hideLoading();
  333. // console.log('登录失败!' + res.errMsg);
  334. // log.info('[订单支付]', '[用户触发支付订单]', '[wx.login响应失败code null]', res);
  335. // }
  336. // }
  337. // });
  338. },
  339. cancleBtn(e){
  340. let that = this
  341. let reservId = e.currentTarget.dataset.idx;
  342. let userInfo = wx.getStorageSync('userInfo');
  343. let isLogin = wx.getStorageSync('isLogin');
  344. wx.showModal({
  345. title: '提示',
  346. confirmColor: '#00AADD',
  347. content: '若对当前占位费订单有疑问,请拨打客服电话4009608068,工作时间:08:00-18:00',
  348. complete: (res) => {
  349. // 可以在这里添加回调逻辑
  350. if (res.confirm) {
  351. console.log('用户点击了确认按钮');
  352. }else{
  353. console.log('用户点击了取消按钮');
  354. }
  355. }
  356. });
  357. },
  358. cancelM:function(e){
  359. this.setData({
  360. hiddenmodalput: true,
  361. })
  362. },
  363. confirmM: function (e) {
  364. console.log("姓名:" + this.data.name + " 电话:" + this.data.phoneNum);
  365. },
  366. iName: function (e) {
  367. this.setData({
  368. name:e.detail.value
  369. })
  370. },
  371. iPhoneNum: function (e) {
  372. this.setData({
  373. phoneNum: e.detail.value
  374. })
  375. },
  376. /**
  377. * 生命周期函数--监听页面初次渲染完成
  378. */
  379. onReady: function() {
  380. },
  381. /**
  382. * 生命周期函数--监听页面显示
  383. */
  384. onShow: function() {
  385. },
  386. /**
  387. * 生命周期函数--监听页面隐藏
  388. */
  389. onHide: function() {
  390. },
  391. /**
  392. * 生命周期函数--监听页面卸载
  393. */
  394. onUnload: function() {
  395. },
  396. /**
  397. * 页面相关事件处理函数--监听用户下拉动作
  398. */
  399. onPullDownRefresh: function() {
  400. },
  401. /**
  402. * 页面上拉触底事件的处理函数
  403. */
  404. onReachBottom: function() {
  405. },
  406. bindScrollTolowerEvent: function(){
  407. this.getPage();
  408. },
  409. /**
  410. * 用户点击右上角分享
  411. */
  412. onShareAppMessage: function() {
  413. }
  414. })