home.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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: '11',
  81. name: '已约会议',
  82. img: '/static/home/home-10.png',
  83. url: '/pages/meeting/index/index?type=meeting-detail&statusItem=1',
  84. jurisdiction: [3],
  85. },
  86. {
  87. id: '12',
  88. name: '会议记录',
  89. img: '/static/home/home-2.png',
  90. url: '/pages/meetingRecord/index/index?type=meeting-record',
  91. jurisdiction: [3],
  92. },
  93. {
  94. id: '9',
  95. name: '会议服务',
  96. img: '/static/home/home-9.png',
  97. url: '/pages/orderMeal/index/index?type=order-audit',
  98. jurisdiction: [3],
  99. },
  100. ],
  101. // accountId: null,
  102. // accountName: null,
  103. },
  104. // getVal(e) {
  105. // console.log(e);
  106. // this.setData({
  107. // accountName: this.data.accountList[e.detail.value].name,
  108. // accountId: this.data.accountList[e.detail.value].id
  109. // })
  110. // },
  111. gotomy() {
  112. wx.switchTab({
  113. url: '/pages/mine/index/index',
  114. })
  115. },
  116. // 我的会议室-数据
  117. myMeeting() {
  118. let data = {
  119. data: {
  120. appointmentStatus: null
  121. },
  122. pageNum: 1,
  123. pageSize: 3,
  124. }
  125. myMeeting(data).then(res => {
  126. this.setData({
  127. myMeetingList: res.data.records
  128. })
  129. })
  130. },
  131. // 会议室-数据
  132. meetingGetList() {
  133. let data = {
  134. pageNum: 1,
  135. pageSize: 8,
  136. }
  137. meetingGetPageList(data).then(res => {
  138. this.setData({
  139. meetingList: res.data.records
  140. })
  141. })
  142. },
  143. // 我的会议-详情
  144. myMeetingFun(e) {
  145. let item = e.currentTarget.dataset.item
  146. item.status = item.appointmentStatus
  147. item = JSON.stringify(e.currentTarget.dataset.item)
  148. wx.navigateTo({
  149. url: '/pages/meeting/appointmentDetail/index?item=' + item + '&type=' + e.currentTarget.dataset.type
  150. })
  151. },
  152. // 会议室-详情
  153. goRoomFun(e) {
  154. let type = 'meeting-detail'
  155. if (e.currentTarget.dataset.item) {
  156. let item = JSON.stringify(e.currentTarget.dataset.item)
  157. wx.navigateTo({
  158. url: '/pages/meeting/detail/index?item=' + item + '&type=' + type
  159. })
  160. } else {
  161. wx.navigateTo({
  162. url: '/pages/meeting/index/index?' + '&type=' + type
  163. })
  164. }
  165. },
  166. // 功能区
  167. goFun(e) {
  168. let item = e.currentTarget.dataset.item
  169. if (item.id == 6 || item.id == 4 || item.id == 7 || item.id == 9) {
  170. wx.requestSubscribeMessage({
  171. tmplIds: ['w7cy1am3DS8BF31uUDoMKfruKWQXT0ckhALzyUdvweg', 'mJs6TXjIFuwgPu2JOEIpu3lO9ym9rnai-schUPuLuok'],
  172. success(res) {
  173. wx.navigateTo({
  174. url: item.url
  175. })
  176. }
  177. })
  178. } else {
  179. wx.navigateTo({
  180. url: item.url
  181. })
  182. }
  183. },
  184. doGetInfo() {
  185. let userInfo = wx.getStorageSync('userInfo')
  186. if (userInfo) {
  187. doGetInfo().then(res => {
  188. if (res.code == 200) {
  189. userInfo = Object.assign(userInfo, res.data);
  190. this.setData({
  191. userInfo
  192. })
  193. wx.setStorageSync('userInfo', userInfo)
  194. this.meetingGetList()
  195. // 预约权限
  196. if(!userInfo.appointmentAuth&&(userInfo.serivceAuth||userInfo.checkAuth)){
  197. this.setData({
  198. myMeetingList: [],
  199. })
  200. }
  201. if (userInfo.appointmentAuth) {
  202. this.myMeeting()
  203. }
  204. } else {
  205. this.removeData()
  206. }
  207. }).catch((err) => {
  208. this.removeData()
  209. })
  210. } else {
  211. this.removeData()
  212. }
  213. },
  214. removeData() {
  215. wx.removeStorageSync('userInfo')
  216. this.setData({
  217. userInfo: {},
  218. myMeetingList: [],
  219. meetingList: [],
  220. })
  221. },
  222. // 审核人消息订阅
  223. subscriptionFun() {
  224. wx.showModal({
  225. title: '感谢您使用!',
  226. content: '',
  227. success(res) {
  228. wx.requestSubscribeMessage({
  229. tmplIds: ['w7cy1am3DS8BF31uUDoMKfruKWQXT0ckhALzyUdvweg'],
  230. success(res) {}
  231. })
  232. }
  233. })
  234. },
  235. /**
  236. * 生命周期函数--监听页面加载
  237. */
  238. onLoad(options) {
  239. let json = {};
  240. if (options.q) {
  241. var url = decodeURIComponent(options.q);
  242. json = GetQueryJson(url);
  243. if ('adminId' in json) {
  244. // console.log(111, json.adminId);
  245. let adminId = wx.getStorageSync('adminId')
  246. if (adminId != json.adminId) {
  247. this.removeData()
  248. }
  249. wx.setStorageSync('adminId', json.adminId)
  250. }
  251. }
  252. },
  253. /**
  254. * 生命周期函数--监听页面初次渲染完成
  255. */
  256. onReady() {
  257. },
  258. /**
  259. * 生命周期函数--监听页面显示
  260. */
  261. onShow() {
  262. this.doGetInfo()
  263. },
  264. /**
  265. * 生命周期函数--监听页面隐藏
  266. */
  267. onHide() {
  268. },
  269. /**
  270. * 生命周期函数--监听页面卸载
  271. */
  272. onUnload() {
  273. },
  274. /**
  275. * 页面相关事件处理函数--监听用户下拉动作
  276. */
  277. onPullDownRefresh() {
  278. },
  279. /**
  280. * 页面上拉触底事件的处理函数
  281. */
  282. onReachBottom() {
  283. },
  284. /**
  285. * 用户点击右上角分享
  286. */
  287. onShareAppMessage() {
  288. }
  289. })