yyjl.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. // pages/recordPages/yyjl/yyjl.js
  2. import {
  3. xcxqxyy,
  4. xcxyyhh,
  5. xcxsxph
  6. } from "../../../apis/index"
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. infos: {},
  13. nowTime: "",
  14. timer: null,
  15. khh: false
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad(options) {
  21. let that = this
  22. that.init(options)
  23. that.setData({
  24. nowTime: that.getTime()
  25. })
  26. },
  27. init(e) {
  28. let that = this
  29. if (e) {
  30. if (e.infos) {
  31. let infos = JSON.parse(e.infos)
  32. that.setData({
  33. infos: infos
  34. })
  35. if (infos.ztDm == 2 || infos.ztDm == 3) {
  36. that.chageNum()
  37. }
  38. if (infos.ztDm == 0) {
  39. let datetime = {
  40. date: that.data.infos.yybsrq,
  41. time: that.data.infos.yysjd
  42. }
  43. that.setData({
  44. khh: that.timeFormat(datetime)
  45. })
  46. }
  47. }
  48. }
  49. },
  50. getTime() {
  51. let date = new Date()
  52. let y = date.getFullYear()
  53. let m = date.getMonth() + 1 < 10 ? '0' + date.getMonth() + 1 : date.getMonth() + 1
  54. let d = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  55. let h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
  56. let mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  57. let ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  58. return y + '-' + m + '-' + d + ' ' + h + ':' + mm + ':' + ss
  59. },
  60. cansole() {
  61. let that = this
  62. wx.showLoading({
  63. title: '正在取消...',
  64. })
  65. xcxqxyy({
  66. yymxxh: that.data.infos.yymxxh
  67. }).then(res => {
  68. wx.hideLoading()
  69. if (res.code == 200) {
  70. wx.showToast({
  71. title: '取消成功',
  72. duration: 2000
  73. })
  74. setTimeout(() => {
  75. wx.navigateBack()
  76. }, 2000);
  77. } else {
  78. wx.showToast({
  79. title: res.msg || res.message,
  80. icon: "none",
  81. duration: 5000
  82. })
  83. }
  84. })
  85. },
  86. timeFormat(e) {
  87. let date = e.date
  88. let time1 = e.time1
  89. let time2 = e.time2
  90. let date1 = date + 'T' + time1
  91. let date2 = date + 'T' + time2
  92. let timestamp1 = new Date(date1).getTime()
  93. let timestamp2 = new Date(date2).getTime()
  94. let nowstamp = new Date().getTime()
  95. if (nowstamp >= timestamp1 && nowstamp < timestamp2) {
  96. return true
  97. } else {
  98. return false
  99. }
  100. },
  101. chageNum() {
  102. let that = this
  103. let datetime = {
  104. date: that.data.infos.yybsrq,
  105. time1: that.data.infos.yyqpkssj,
  106. time2: that.data.infos.yyqpjssj
  107. }
  108. if (that.timeFormat(datetime)) {
  109. wx.showLoading({
  110. title: '',
  111. })
  112. let form = {
  113. unionid: wx.getStorageSync('PUBLIC_ID').unionid,
  114. yymxxh: that.data.infos.yymxxh
  115. }
  116. xcxyyhh(form).then(res => {
  117. wx.hideLoading()
  118. if (res.code == 200) {
  119. res.data.ztDm = 2
  120. that.setData({
  121. infos: {
  122. ...that.data.infos,
  123. ...res.data
  124. }
  125. })
  126. } else if (res.code == 201) {
  127. res.data.ztDm = 2
  128. that.setData({
  129. infos: {
  130. ...that.data.infos,
  131. ...res.data
  132. }
  133. })
  134. } else {
  135. wx.showToast({
  136. title: res.msg || res.message,
  137. icon: "none",
  138. duration: 5000
  139. })
  140. }
  141. })
  142. }
  143. },
  144. brush() {
  145. let that = this
  146. let infos = that.data.infos
  147. wx.showLoading({
  148. title: '正在刷新...',
  149. })
  150. xcxsxph({
  151. bsfwtDm: infos.bsfwtDm,
  152. phhm: infos.ticketNum,
  153. qpsj: infos.createTime
  154. }).then(res => {
  155. wx.hideLoading()
  156. if (res.code == 200) {
  157. if (res.data.phzt == 0) {
  158. that.setData({
  159. infos: {
  160. ...that.data.infos,
  161. ...res.data
  162. }
  163. })
  164. } else {
  165. that.setData({
  166. infos: {
  167. ...that.data.infos,
  168. ...res.data
  169. }
  170. })
  171. if (res.data.fwztDm == 0) {
  172. wx.showModal({
  173. title: '提示',
  174. content: '当前已叫到您的号码,请立即前往' + res.data.ckhm + "窗口进行办理业务。",
  175. })
  176. } else {
  177. wx.showModal({
  178. title: '提示',
  179. content: '当前号码已经叫过了,请前往' + res.data.ckhm + "窗口进行咨询。"
  180. })
  181. }
  182. }
  183. } else {
  184. wx.showToast({
  185. title: res.msg || res.message,
  186. icon: "none",
  187. duration: 5000
  188. })
  189. }
  190. })
  191. },
  192. /**
  193. * 生命周期函数--监听页面初次渲染完成
  194. */
  195. onReady() {
  196. },
  197. /**
  198. * 生命周期函数--监听页面显示
  199. */
  200. onShow() {
  201. let that = this
  202. let timer = that.data.timer
  203. clearInterval(timer)
  204. timer = setInterval(() => {
  205. that.setData({
  206. nowTime: that.getTime()
  207. })
  208. if (that.data.infos.ztDm == 0) {
  209. let datetime = {
  210. date: that.data.infos.yybsrq,
  211. time: that.data.infos.yysjd
  212. }
  213. that.setData({
  214. khh: that.timeFormat(datetime)
  215. })
  216. }
  217. }, 1000);
  218. that.setData({
  219. timer: timer
  220. })
  221. },
  222. /**
  223. * 生命周期函数--监听页面隐藏
  224. */
  225. onHide() {
  226. let that = this
  227. let timer = that.data.timer
  228. clearInterval(timer)
  229. that.setData({
  230. timer: null
  231. })
  232. },
  233. /**
  234. * 生命周期函数--监听页面卸载
  235. */
  236. onUnload() {
  237. let that = this
  238. let timer = that.data.timer
  239. clearInterval(timer)
  240. that.setData({
  241. timer: null
  242. })
  243. },
  244. /**
  245. * 页面相关事件处理函数--监听用户下拉动作
  246. */
  247. onPullDownRefresh() {
  248. },
  249. /**
  250. * 页面上拉触底事件的处理函数
  251. */
  252. onReachBottom() {
  253. },
  254. /**
  255. * 用户点击右上角分享
  256. */
  257. onShareAppMessage() {
  258. }
  259. })