index.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. // pages/index/index.js
  2. const app = getApp();
  3. const util = require('../../utils/util.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. imgPath: app.globalData.imgPath,
  10. path: app.globalData.path,
  11. username: app.globalData.userInfo.usernameShow,
  12. role_name: app.globalData.roleInfo.name,
  13. app_bottom: '大城细管·大城众管·大城智管',
  14. nextMeeting: null
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. let that = this;
  21. if (!app.globalData.userInfo.usernameShow || !app.globalData.userInfo.nickName || !app.globalData.userInfo.headImgUrl) {
  22. wx.showModal({
  23. title: '提示',
  24. content: '轻应用需要取您的用户信息',
  25. showCancel: false,
  26. confirmText: '确定',
  27. success: (res) => {
  28. if (res.confirm) {
  29. wx.getUserProfile({
  30. desc: '提升用户体验感',
  31. success: (res) => {
  32. app.globalData.userInfo.usernameShow = res.userInfo.nickName;
  33. app.globalData.userInfo.nickName = res.userInfo.nickName;
  34. app.globalData.userInfo.headImgUrl = res.userInfo.avatarUrl;
  35. that.setData({
  36. username: app.globalData.userInfo.usernameShow,
  37. role_name: app.globalData.roleInfo.name
  38. });
  39. util.post({
  40. url: '/sys/user/updateNoAuth',
  41. data: {
  42. id: app.globalData.userInfo.id,
  43. nickName: res.userInfo.nickName,
  44. usernameShow: res.userInfo.nickName,
  45. headImgUrl: res.userInfo.avatarUrl
  46. }
  47. });
  48. },
  49. fail: (res) => {
  50. util.toast('拒绝授权将影响您的体验感');
  51. that.setData({
  52. username: '未知用户',
  53. role_name: app.globalData.roleInfo.name
  54. });
  55. }
  56. });
  57. }
  58. },
  59. });
  60. } else {
  61. that.setData({
  62. username: app.globalData.userInfo.usernameShow,
  63. role_name: app.globalData.roleInfo.name
  64. });
  65. }
  66. // 下一场会议
  67. util.get({
  68. url: '/api/meeting/info/getNextMeeting',
  69. success: (res) => {
  70. wx.hideLoading();
  71. console.info(res)
  72. if (res.data.code != 200) {
  73. util.toast(res.data.msg);
  74. } else {
  75. let datas = res.data.data;
  76. if (datas) {
  77. that.setData({
  78. nextMeeting: datas,
  79. nextTitle: datas.title,
  80. nextTime: util.formatDate(datas.receptionTime),
  81. nextUnit: datas.receptionObject
  82. });
  83. } else {
  84. util.toast('暂无下一场会议');
  85. }
  86. }
  87. }
  88. });
  89. },
  90. /**
  91. * 生命周期函数--监听页面初次渲染完成
  92. */
  93. onReady: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面显示
  97. */
  98. onShow: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload: function () {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh: function () {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom: function () {
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage: function () {
  124. },
  125. /**
  126. * 点击查看下一场会议详情
  127. */
  128. meetingInfo: function () {
  129. let nextMeeting = this.data.nextMeeting;
  130. if (nextMeeting) {
  131. wx.navigateTo({
  132. url: '../meeting-cover/meeting-cover?item=' + JSON.stringify(nextMeeting),
  133. });
  134. } else {
  135. util.toast('暂无下一场会议');
  136. }
  137. },
  138. /**
  139. * 日常巡检
  140. */
  141. dailyInspection: function () {
  142. },
  143. /**
  144. * 会议巡检
  145. */
  146. meetingInspection: function () {
  147. wx.navigateTo({
  148. url: '../meeting-list/meeting-list?type=INSPECTION',
  149. });
  150. },
  151. /**
  152. * 点击参观议程跳转至会议列表
  153. */
  154. visitAgenda: function () {
  155. wx.navigateTo({
  156. url: '../meeting-list/meeting-list',
  157. });
  158. },
  159. /**
  160. * 图片回传
  161. */
  162. uploadImage: function () {
  163. let that = this;
  164. wx.chooseImage({
  165. count: 1,
  166. success: function (res) {
  167. console.info(res.tempFilePaths);
  168. wx.uploadFile({
  169. filePath: res.tempFilePaths[0],
  170. name: 'file',
  171. url: that.data.path + '/api/upload/record/upload',
  172. header: {
  173. "Content-Type": "multipart/form-data",
  174. "Authorization": app.globalData.Authorization
  175. },
  176. formData: {
  177. fileType: 10
  178. },
  179. success(res) {
  180. console.info(res)
  181. }
  182. });
  183. }
  184. });
  185. },
  186. changeRole: function () {
  187. wx.redirectTo({
  188. url: '../index-admin/index-admin',
  189. });
  190. },
  191. /**
  192. * 聊天室
  193. * @param {*} e
  194. */
  195. chatRoom: function (e) {
  196. wx.navigateTo({
  197. url: '../chat-room/chat-room',
  198. });
  199. },
  200. /**
  201. * 地图
  202. */
  203. lightMap: function () {
  204. wx.getSetting({
  205. withSubscriptions: true,
  206. success: function (res) {
  207. console.info(res);
  208. if (!res.authSetting['scope.userLocation']) {
  209. wx.authorize({
  210. scope: 'scope.userLocation',
  211. success: function (res) {
  212. console.info(res);
  213. wx.navigateTo({
  214. url: '../light-map/light-map',
  215. });
  216. },
  217. fail: function (e) {
  218. console.info(e);
  219. wx.showToast({
  220. title: '用户拒绝授权',
  221. icon: 'error'
  222. });
  223. }
  224. });
  225. } else {
  226. wx.navigateTo({
  227. url: '../light-map/light-map',
  228. });
  229. }
  230. }
  231. });
  232. }
  233. })