zcmx.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // pages/zcmx/zcmx.js
  2. import {
  3. emptyAreaList,
  4. contactList
  5. } from "../../../pages/api/gzw-api"
  6. import {
  7. imgUrl
  8. } from "../../../pages/api/request"
  9. import{
  10. js_date_time
  11. }from "../../../utils/util"
  12. Page({
  13. /**
  14. * 页面的初始数据
  15. */
  16. data: {
  17. imgUrl,
  18. contactList:[],
  19. emptyAreaList:[],
  20. emptyAreaIndex:1,
  21. emptyAreaTotalPage:0,
  22. contactIndex:1,
  23. contactTotalPage:0
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad(options) {
  29. this.loadHotline(1,10);
  30. this.loadDetail(1,10);
  31. },
  32. /**
  33. * 生命周期函数--监听页面初次渲染完成
  34. */
  35. onReady() {
  36. },
  37. /**
  38. * 生命周期函数--监听页面显示
  39. */
  40. onShow() {
  41. },
  42. /**
  43. * 生命周期函数--监听页面隐藏
  44. */
  45. onHide() {
  46. },
  47. /**
  48. * 生命周期函数--监听页面卸载
  49. */
  50. onUnload() {
  51. },
  52. /**
  53. * 页面相关事件处理函数--监听用户下拉动作
  54. */
  55. onPullDownRefresh() {
  56. },
  57. /**
  58. * 页面上拉触底事件的处理函数
  59. */
  60. onReachBottom() {
  61. },
  62. /**
  63. * 用户点击右上角分享
  64. */
  65. onShareAppMessage() {
  66. },
  67. prevLoadDetail(){
  68. let a = this.data.emptyAreaIndex - 1
  69. this.setData({
  70. emptyAreaIndex: a
  71. })
  72. this.loadDetail(a,10);
  73. },
  74. nextLoadDetail(){
  75. let a = this.data.emptyAreaIndex + 1
  76. this.setData({
  77. emptyAreaIndex: a
  78. })
  79. this.loadDetail(a,10);
  80. },
  81. loadDetail(page,size){
  82. emptyAreaList(page,size,{}).then(res=>{
  83. if (res.success) {
  84. if(res.data.size>0){
  85. let emptyAreaList = res.data.records
  86. this.setData({
  87. emptyAreaList,
  88. emptyAreaTotalPage: res.data.pages
  89. })
  90. }
  91. }
  92. })
  93. },
  94. prevLoadHotline(){
  95. let a = this.data.contactIndex - 1
  96. this.setData({
  97. contactIndex: a
  98. })
  99. this.loadHotline(a,10);
  100. },
  101. nextLoadHotline(){
  102. let a = this.data.contactIndex + 1
  103. this.setData({
  104. contactIndex: a
  105. })
  106. this.loadHotline(a,10);
  107. },
  108. loadHotline(page,size){
  109. contactList(page,size,{}).then(res=>{
  110. if (res.success) {
  111. if(res.data.size>0){
  112. let contactList = res.data.records
  113. this.setData({
  114. contactList,
  115. contactTotalPage: res.data.pages
  116. })
  117. }
  118. }
  119. })
  120. }
  121. })