index-work.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. changeRole: function () {
  129. wx.redirectTo({
  130. url: '../index-admin/index-admin',
  131. });
  132. },
  133. /**
  134. * 点击查看下一场会议详情
  135. */
  136. meetingInfo: function () {
  137. let nextMeeting = this.data.nextMeeting;
  138. if (nextMeeting) {
  139. wx.navigateTo({
  140. url: '../meeting-cover/meeting-cover?item=' + JSON.stringify(nextMeeting),
  141. });
  142. } else {
  143. util.toast('暂无下一场会议');
  144. }
  145. },
  146. /**
  147. * 日常巡检
  148. */
  149. dailyInspection: function () {
  150. wx.navigateTo({
  151. url: '../daily-inspection/daily-inspection',
  152. });
  153. },
  154. /**
  155. * 会议巡检
  156. */
  157. meetingInspection: function () {
  158. wx.navigateTo({
  159. url: '../meeting-list/meeting-list?type=INSPECTION',
  160. });
  161. },
  162. /**
  163. * 点击参观议程跳转至会议列表
  164. */
  165. visitAgenda: function () {
  166. wx.navigateTo({
  167. url: '../meeting-list/meeting-list',
  168. });
  169. },
  170. /**
  171. * 图片回传
  172. */
  173. uploadImage: function () {
  174. let that = this;
  175. wx.chooseImage({
  176. count: 1,
  177. success: function (res) {
  178. console.info(res.tempFilePaths);
  179. wx.uploadFile({
  180. filePath: res.tempFilePaths[0],
  181. name: 'file',
  182. url: that.data.path + '/api/upload/record/upload',
  183. header: {
  184. "Content-Type": "multipart/form-data",
  185. "Authorization": app.globalData.Authorization
  186. },
  187. formData: {
  188. fileType: 10
  189. },
  190. success(res) {
  191. console.info(res)
  192. }
  193. });
  194. }
  195. });
  196. },
  197. /**
  198. * 内容投屏
  199. */
  200. contentScreen: function () {
  201. let wifi, pass;
  202. // 打开微信扫一扫
  203. wx.scanCode({
  204. onlyFromCamera: true,
  205. scanType: 'qrCode',
  206. success: (res) => {
  207. console.info(res);
  208. if (res.result.indexOf('WIFI') < 0) {
  209. util.toast('请扫描WIFI二维码');
  210. return;
  211. }
  212. wx.showLoading({
  213. title: '加载中...',
  214. mask: true
  215. });
  216. try {
  217. let a = res.result.split(',');
  218. wifi = a[0].split(':')[1];
  219. pass = a[1].split(':')[1];
  220. } catch (error) {
  221. util.toast('请扫描WIFI二维码');
  222. return;
  223. }
  224. // 获取设备系统类型
  225. wx.getSystemInfo({
  226. success: (res) => {
  227. console.info(res);
  228. if (!res.wifiEnabled) {
  229. wx.hideLoading();
  230. util.toast('请打开WIFI功能');
  231. return;
  232. }
  233. // 1、初始化Wi-Fi模块
  234. wx.startWifi({
  235. success: (res) => {
  236. console.info(res)
  237. if (res.errMsg == 'startWifi:ok') {
  238. // 4、连接Wi-Fi
  239. wx.connectWifi({
  240. SSID: wifi,
  241. password: pass,
  242. success: (res) => {
  243. wx.hideLoading();
  244. console.info('connectWifi', res);
  245. if (res.errMsg == 'connectWifi:ok') {
  246. util.toast('WIFI连接成功', 'success');
  247. } else {
  248. util.toast(res.errMsg);
  249. }
  250. },
  251. fail: (e) => {
  252. console.info(e);
  253. util.toast('WIFI连接失败');
  254. }
  255. });
  256. } else {
  257. util.toast(res.errMsg);
  258. }
  259. },
  260. fail: (e) => {
  261. console.info(e);
  262. util.toast('初始化WiFi模块失败');
  263. }
  264. });
  265. },
  266. fail: (e) => {
  267. util.toast('获取设备系统类型失败');
  268. return;
  269. }
  270. });
  271. },
  272. fail: (e) => {
  273. util.toast('扫码失败,请重试');
  274. return;
  275. }
  276. });
  277. },
  278. /**
  279. * 聊天室
  280. * @param {*} e
  281. */
  282. chatRoom: function (e) {
  283. wx.navigateTo({
  284. url: '../chat-room/chat-room',
  285. });
  286. },
  287. /**
  288. * 地图
  289. */
  290. lightMap: function () {
  291. wx.getSetting({
  292. withSubscriptions: true,
  293. success: function (res) {
  294. console.info(res);
  295. if (!res.authSetting['scope.userLocation']) {
  296. wx.authorize({
  297. scope: 'scope.userLocation',
  298. success: function (res) {
  299. console.info(res);
  300. wx.navigateTo({
  301. url: '../light-map/light-map',
  302. });
  303. },
  304. fail: function (e) {
  305. console.info(e);
  306. wx.showToast({
  307. title: '用户拒绝授权',
  308. icon: 'error'
  309. });
  310. }
  311. });
  312. } else {
  313. wx.navigateTo({
  314. url: '../light-map/light-map',
  315. });
  316. }
  317. }
  318. });
  319. }
  320. })