home.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. // pages/home/home.js
  2. import {
  3. meetingGetPageList,
  4. myMeeting
  5. } from '../../utils/api/meeting'
  6. import {
  7. doGetInfo
  8. } from '../../utils/api/api'
  9. import {
  10. GetQueryJson
  11. } from '../../utils/util'
  12. const app = getApp();
  13. Page({
  14. /**
  15. * 页面的初始数据
  16. */
  17. data: {
  18. StatusBar: app.globalData.StatusBar, //胶囊按钮位置
  19. CustomBar: app.globalData.CustomBar,
  20. userInfo: wx.getStorageSync('userInfo'),
  21. myMeetingList: [],
  22. meetingList: [],
  23. funList: [{
  24. id: '1',
  25. name: '会议室预约',
  26. img: '/static/home/home-1.png',
  27. url: '/pages/meeting/index/index?type=meeting-detail',
  28. jurisdiction: [1, 2],
  29. },
  30. {
  31. id: '2',
  32. name: '我的会议',
  33. img: '/static/home/home-2.png',
  34. url: '/pages/myMeeting/index/index?type=my-meeting',
  35. jurisdiction: [1],
  36. },
  37. {
  38. id: '3',
  39. name: '我的预约',
  40. img: '/static/home/home-3.png',
  41. url: '/pages/mySubscribe/index/index?type=my-subscribe',
  42. jurisdiction: [1],
  43. },
  44. {
  45. id: '10',
  46. name: '我的续约',
  47. img: '/static/home/home-4.png',
  48. url: '/pages/myRenewalContract/index/index?type=my-renewalContract',
  49. jurisdiction: [1],
  50. },
  51. {
  52. id: '5',
  53. name: '我的转让',
  54. img: '/static/home/home-5.png',
  55. url: '/pages/myTransfer/index/index?type=my-transfer',
  56. jurisdiction: [1],
  57. },
  58. {
  59. id: '6',
  60. name: '转让审核',
  61. img: '/static/home/home-6.png',
  62. url: '/pages/myTransfer/index/index?type=transfer-audit',
  63. jurisdiction: [1],
  64. },
  65. {
  66. id: '4',
  67. name: '预约审核',
  68. img: '/static/home/home-7.png',
  69. url: '/pages/mySubscribe/index/index?type=subscribe-audit',
  70. jurisdiction: [2],
  71. },
  72. {
  73. id: '7',
  74. name: '续约审核',
  75. img: '/static/home/home-8.png',
  76. url: '/pages/myRenewalContract/index/index?type=renewalContract-audit',
  77. jurisdiction: [2],
  78. },
  79. {
  80. id: '9',
  81. name: '会议服务',
  82. img: '/static/home/home-9.png',
  83. url: '/pages/orderMeal/index/index?type=order-audit',
  84. jurisdiction: [2],
  85. },
  86. ],
  87. // accountId: null,
  88. // accountName: null,
  89. },
  90. // getVal(e) {
  91. // console.log(e);
  92. // this.setData({
  93. // accountName: this.data.accountList[e.detail.value].name,
  94. // accountId: this.data.accountList[e.detail.value].id
  95. // })
  96. // },
  97. gotomy(){
  98. wx.switchTab({
  99. url: '/pages/mine/index/index',
  100. })
  101. },
  102. // 我的会议室-数据
  103. myMeeting() {
  104. let data = {
  105. data: {
  106. appointmentStatus: null
  107. },
  108. pageNum: 1,
  109. pageSize: 3,
  110. }
  111. myMeeting(data).then(res => {
  112. this.setData({
  113. myMeetingList: res.data.records
  114. })
  115. })
  116. },
  117. // 会议室-数据
  118. meetingGetList() {
  119. let data = {
  120. pageNum: 1,
  121. pageSize: 8,
  122. }
  123. meetingGetPageList(data).then(res => {
  124. this.setData({
  125. meetingList: res.data.records
  126. })
  127. })
  128. },
  129. // 我的会议-详情
  130. myMeetingFun(e) {
  131. let item = e.currentTarget.dataset.item
  132. item.status = item.appointmentStatus
  133. item = JSON.stringify(e.currentTarget.dataset.item)
  134. wx.navigateTo({
  135. url: '/pages/meeting/appointmentDetail/index?item=' + item + '&type=' + e.currentTarget.dataset.type
  136. })
  137. },
  138. // 会议室-详情
  139. goRoomFun(e) {
  140. let type = 'meeting-detail'
  141. if (e.currentTarget.dataset.item) {
  142. let item = JSON.stringify(e.currentTarget.dataset.item)
  143. wx.navigateTo({
  144. url: '/pages/meeting/detail/index?item=' + item + '&type=' + type
  145. })
  146. } else {
  147. wx.navigateTo({
  148. url: '/pages/meeting/index/index?' + '&type=' + type
  149. })
  150. }
  151. },
  152. // 功能区
  153. goFun(e) {
  154. let item = e.currentTarget.dataset.item
  155. if (item.id == 6 || item.id == 4 || item.id == 7 || item.id == 9) {
  156. wx.requestSubscribeMessage({
  157. tmplIds: ['w7cy1am3DS8BF31uUDoMKfruKWQXT0ckhALzyUdvweg', 'mJs6TXjIFuwgPu2JOEIpu3lO9ym9rnai-schUPuLuok'],
  158. success(res) {
  159. wx.navigateTo({
  160. url: item.url
  161. })
  162. }
  163. })
  164. } else {
  165. wx.navigateTo({
  166. url: item.url
  167. })
  168. }
  169. },
  170. doGetInfo() {
  171. let userInfo = wx.getStorageSync('userInfo')
  172. if (userInfo) {
  173. doGetInfo().then(res => {
  174. if (res.code == 200) {
  175. userInfo = Object.assign(userInfo, res.data);
  176. this.setData({
  177. userInfo
  178. })
  179. wx.setStorageSync('userInfo', userInfo)
  180. this.meetingGetList()
  181. // 预约权限
  182. if (userInfo.appointmentAuth) {
  183. this.myMeeting()
  184. }
  185. } else {
  186. wx.removeStorageSync('userInfo')
  187. this.setData({
  188. userInfo: {}
  189. })
  190. }
  191. }).catch((err) => {
  192. wx.removeStorageSync('userInfo')
  193. this.setData({
  194. userInfo: {}
  195. })
  196. })
  197. }
  198. },
  199. // 审核人消息订阅
  200. subscriptionFun() {
  201. wx.showModal({
  202. title: '感谢您使用!',
  203. content: '',
  204. success(res) {
  205. wx.requestSubscribeMessage({
  206. tmplIds: ['w7cy1am3DS8BF31uUDoMKfruKWQXT0ckhALzyUdvweg'],
  207. success(res) {}
  208. })
  209. }
  210. })
  211. },
  212. /**
  213. * 生命周期函数--监听页面加载
  214. */
  215. onLoad(options) {
  216. console.log(options);
  217. let json = {};
  218. if (options.q) {
  219. var url = decodeURIComponent(options.q);
  220. json = GetQueryJson(url);
  221. if ('adminId' in json) {
  222. console.log(111, json.adminId);
  223. wx.setStorageSync('adminId', json.adminId)
  224. let adminId = wx.getStorageSync('adminId')
  225. }
  226. }
  227. },
  228. /**
  229. * 生命周期函数--监听页面初次渲染完成
  230. */
  231. onReady() {
  232. },
  233. /**
  234. * 生命周期函数--监听页面显示
  235. */
  236. onShow() {
  237. this.doGetInfo()
  238. },
  239. /**
  240. * 生命周期函数--监听页面隐藏
  241. */
  242. onHide() {
  243. },
  244. /**
  245. * 生命周期函数--监听页面卸载
  246. */
  247. onUnload() {
  248. },
  249. /**
  250. * 页面相关事件处理函数--监听用户下拉动作
  251. */
  252. onPullDownRefresh() {
  253. },
  254. /**
  255. * 页面上拉触底事件的处理函数
  256. */
  257. onReachBottom() {
  258. },
  259. /**
  260. * 用户点击右上角分享
  261. */
  262. onShareAppMessage() {
  263. }
  264. })