index-guest.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. // pages/index-guest/index-guest.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. nowTime: util.formatDate(null, 'yyyy.MM.dd'),
  15. nextMeeting: null,
  16. hasNext: false
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. let that = this;
  23. if (!app.globalData.userInfo.usernameShow || !app.globalData.userInfo.nickName || !app.globalData.userInfo.headImgUrl) {
  24. wx.showModal({
  25. title: '提示',
  26. content: '轻应用需要取您的用户信息',
  27. showCancel: false,
  28. confirmText: '确定',
  29. success: (res) => {
  30. if (res.confirm) {
  31. wx.getUserProfile({
  32. desc: '提升用户体验感',
  33. success: (res) => {
  34. app.globalData.userInfo.usernameShow = res.userInfo.nickName;
  35. app.globalData.userInfo.nickName = res.userInfo.nickName;
  36. app.globalData.userInfo.headImgUrl = res.userInfo.avatarUrl;
  37. that.setData({
  38. username: app.globalData.userInfo.usernameShow,
  39. role_name: app.globalData.roleInfo.name
  40. });
  41. util.post({
  42. url: '/sys/user/updateNoAuth',
  43. data: {
  44. id: app.globalData.userInfo.id,
  45. nickName: res.userInfo.nickName,
  46. usernameShow: res.userInfo.nickName,
  47. headImgUrl: res.userInfo.avatarUrl
  48. }
  49. });
  50. },
  51. fail: (res) => {
  52. util.toast('拒绝授权将影响您的体验感');
  53. that.setData({
  54. username: '未知用户',
  55. role_name: app.globalData.roleInfo.name
  56. });
  57. }
  58. });
  59. }
  60. },
  61. });
  62. } else {
  63. that.setData({
  64. username: app.globalData.userInfo.usernameShow,
  65. role_name: app.globalData.roleInfo.name
  66. });
  67. }
  68. // 下一场会议
  69. util.get({
  70. url: '/api/meeting/info/getNextMeeting',
  71. success: (res) => {
  72. wx.hideLoading();
  73. if (res.data.code != 200) {
  74. util.toast(res.data.msg);
  75. } else {
  76. let datas = res.data.data;
  77. if (datas) {
  78. that.setData({
  79. hasNext: true,
  80. nextMeeting: datas,
  81. nextTitle: datas.title,
  82. nextTime: util.formatDate(datas.receptionTime),
  83. nextUnit: datas.receptionObject
  84. });
  85. } else {
  86. util.toast('暂无下一场会议');
  87. }
  88. }
  89. }
  90. });
  91. },
  92. /**
  93. * 生命周期函数--监听页面初次渲染完成
  94. */
  95. onReady: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面显示
  99. */
  100. onShow: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面隐藏
  104. */
  105. onHide: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. },
  117. /**
  118. * 页面上拉触底事件的处理函数
  119. */
  120. onReachBottom: function () {
  121. },
  122. /**
  123. * 用户点击右上角分享
  124. */
  125. onShareAppMessage: function () {
  126. },
  127. /**
  128. * 调试使用:切换角色菜单
  129. */
  130. changeRole: function () {
  131. wx.redirectTo({
  132. url: '../index/index',
  133. });
  134. },
  135. /**
  136. * 点击查看下一场会议详情
  137. */
  138. meetingInfo: function () {
  139. let nextMeeting = this.data.nextMeeting;
  140. if (nextMeeting) {
  141. wx.navigateTo({
  142. url: '../meeting-cover/meeting-cover?item=' + JSON.stringify(nextMeeting),
  143. });
  144. } else {
  145. util.toast('暂无下一场会议');
  146. }
  147. },
  148. /**
  149. * 点击参观议程跳转至会议列表
  150. */
  151. visitAgenda: function () {
  152. wx.navigateTo({
  153. url: '../meeting-list/meeting-list',
  154. });
  155. },
  156. /**
  157. * 图片回传
  158. */
  159. uploadImage: function () {
  160. let that = this;
  161. wx.chooseImage({
  162. count: 1,
  163. success: function (res) {
  164. console.info(res.tempFilePaths);
  165. wx.uploadFile({
  166. filePath: res.tempFilePaths[0],
  167. name: 'file',
  168. url: that.data.path + '/api/upload/record/upload',
  169. header: {
  170. "Content-Type": "multipart/form-data",
  171. "Authorization": app.globalData.Authorization
  172. },
  173. formData: {
  174. fileType: 10
  175. },
  176. success(res) {
  177. console.info(res)
  178. }
  179. });
  180. }
  181. });
  182. },
  183. /**
  184. * 内容投屏
  185. */
  186. contentScreen: function () {
  187. let wifi, pass;
  188. // 打开微信扫一扫
  189. wx.scanCode({
  190. onlyFromCamera: true,
  191. scanType: 'qrCode',
  192. success: (res) => {
  193. console.info(res);
  194. if (res.result.indexOf('WIFI') < 0) {
  195. util.toast('请扫描WIFI二维码');
  196. return;
  197. }
  198. wx.showLoading({
  199. title: '加载中...',
  200. mask: true
  201. });
  202. try {
  203. let a = res.result.split(',');
  204. wifi = a[0].split(':')[1];
  205. pass = a[1].split(':')[1];
  206. } catch (error) {
  207. util.toast('请扫描WIFI二维码');
  208. return;
  209. }
  210. // 获取设备系统类型
  211. wx.getSystemInfo({
  212. success: (res) => {
  213. console.info(res);
  214. if (!res.wifiEnabled) {
  215. wx.hideLoading();
  216. util.toast('请打开WIFI功能');
  217. return;
  218. }
  219. // 1、初始化Wi-Fi模块
  220. wx.startWifi({
  221. success: (res) => {
  222. console.info('startWifi', res)
  223. if (res.errMsg == 'startWifi:ok') {
  224. // 4、连接Wi-Fi
  225. wx.connectWifi({
  226. SSID: wifi,
  227. password: pass,
  228. success: (res) => {
  229. wx.hideLoading();
  230. console.info('connectWifi', res);
  231. if (res.errMsg == 'connectWifi:ok') {
  232. util.toast('WIFI连接成功', 'success');
  233. } else {
  234. util.toast(res.errMsg);
  235. }
  236. },
  237. fail: (e) => {
  238. console.info(e);
  239. util.toast('WIFI连接失败');
  240. }
  241. });
  242. } else {
  243. util.toast(res.errMsg);
  244. }
  245. },
  246. fail: (e) => {
  247. console.info(e);
  248. util.toast('初始化WiFi模块失败');
  249. }
  250. });
  251. },
  252. fail: (e) => {
  253. util.toast('获取设备系统类型失败');
  254. return;
  255. }
  256. });
  257. },
  258. fail: (e) => {
  259. util.toast('扫码失败,请重试');
  260. return;
  261. }
  262. });
  263. },
  264. /**
  265. * 聊天室
  266. * @param {*} e
  267. */
  268. chatRoom: function (e) {
  269. wx.navigateTo({
  270. url: '../chat-room/chat-room',
  271. });
  272. },
  273. /**
  274. * 地图
  275. */
  276. lightMap: function () {
  277. wx.getSetting({
  278. withSubscriptions: true,
  279. success: function (res) {
  280. console.info(res);
  281. if (!res.authSetting['scope.userLocation']) {
  282. wx.authorize({
  283. scope: 'scope.userLocation',
  284. success: function (res) {
  285. console.info(res);
  286. wx.navigateTo({
  287. url: '../light-map/light-map',
  288. });
  289. },
  290. fail: function (e) {
  291. console.info(e);
  292. wx.showToast({
  293. title: '用户拒绝授权',
  294. icon: 'error'
  295. });
  296. }
  297. });
  298. } else {
  299. wx.navigateTo({
  300. url: '../light-map/light-map',
  301. });
  302. }
  303. }
  304. });
  305. },
  306. /**
  307. * 文件浏览
  308. */
  309. fileBrowse: function () {
  310. wx.navigateTo({
  311. url: '../file-browse/file-browse',
  312. })
  313. },
  314. })