123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- // pages/index/index.js
- const app = getApp();
- const util = require('../../utils/util.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgPath: app.globalData.imgPath,
- path: app.globalData.path,
- username: app.globalData.userInfo.usernameShow,
- role_name: app.globalData.roleInfo.name,
- app_bottom: '大城细管·大城众管·大城智管',
- nextMeeting: null
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this;
- if (!app.globalData.userInfo.usernameShow || !app.globalData.userInfo.nickName || !app.globalData.userInfo.headImgUrl) {
- wx.showModal({
- title: '提示',
- content: '轻应用需要取您的用户信息',
- showCancel: false,
- confirmText: '确定',
- success: (res) => {
- if (res.confirm) {
- wx.getUserProfile({
- desc: '提升用户体验感',
- success: (res) => {
- app.globalData.userInfo.usernameShow = res.userInfo.nickName;
- app.globalData.userInfo.nickName = res.userInfo.nickName;
- app.globalData.userInfo.headImgUrl = res.userInfo.avatarUrl;
- that.setData({
- username: app.globalData.userInfo.usernameShow,
- role_name: app.globalData.roleInfo.name
- });
- util.post({
- url: '/sys/user/updateNoAuth',
- data: {
- id: app.globalData.userInfo.id,
- nickName: res.userInfo.nickName,
- usernameShow: res.userInfo.nickName,
- headImgUrl: res.userInfo.avatarUrl
- }
- });
- },
- fail: (res) => {
- util.toast('拒绝授权将影响您的体验感');
- that.setData({
- username: '未知用户',
- role_name: app.globalData.roleInfo.name
- });
- }
- });
- }
- },
- });
- } else {
- that.setData({
- username: app.globalData.userInfo.usernameShow,
- role_name: app.globalData.roleInfo.name
- });
- }
- // 下一场会议
- util.get({
- url: '/api/meeting/info/getNextMeeting',
- success: (res) => {
- wx.hideLoading();
- console.info(res)
- if (res.data.code != 200) {
- util.toast(res.data.msg);
- } else {
- let datas = res.data.data;
- if (datas) {
- that.setData({
- nextMeeting: datas,
- nextTitle: datas.title,
- nextTime: util.formatDate(datas.receptionTime),
- nextUnit: datas.receptionObject
- });
- } else {
- util.toast('暂无下一场会议');
- }
- }
- }
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- /**
- * 点击查看下一场会议详情
- */
- meetingInfo: function () {
- let nextMeeting = this.data.nextMeeting;
- if (nextMeeting) {
- wx.navigateTo({
- url: '../meeting-cover/meeting-cover?item=' + JSON.stringify(nextMeeting),
- });
- } else {
- util.toast('暂无下一场会议');
- }
- },
- /**
- * 日常巡检
- */
- dailyInspection: function () {
- },
- /**
- * 会议巡检
- */
- meetingInspection: function () {
- wx.navigateTo({
- url: '../meeting-list/meeting-list?type=INSPECTION',
- });
- },
- /**
- * 点击参观议程跳转至会议列表
- */
- visitAgenda: function () {
- wx.navigateTo({
- url: '../meeting-list/meeting-list',
- });
- },
- /**
- * 图片回传
- */
- uploadImage: function () {
- let that = this;
- wx.chooseImage({
- count: 1,
- success: function (res) {
- console.info(res.tempFilePaths);
- wx.uploadFile({
- filePath: res.tempFilePaths[0],
- name: 'file',
- url: that.data.path + '/api/upload/record/upload',
- header: {
- "Content-Type": "multipart/form-data",
- "Authorization": app.globalData.Authorization
- },
- formData: {
- fileType: 10
- },
- success(res) {
- console.info(res)
- }
- });
- }
- });
- },
- changeRole: function () {
- wx.redirectTo({
- url: '../index-admin/index-admin',
- });
- },
- /**
- * 聊天室
- * @param {*} e
- */
- chatRoom: function (e) {
- wx.navigateTo({
- url: '../chat-room/chat-room',
- });
- },
- /**
- * 地图
- */
- lightMap: function () {
- wx.getSetting({
- withSubscriptions: true,
- success: function (res) {
- console.info(res);
- if (!res.authSetting['scope.userLocation']) {
- wx.authorize({
- scope: 'scope.userLocation',
- success: function (res) {
- console.info(res);
- wx.navigateTo({
- url: '../light-map/light-map',
- });
- },
- fail: function (e) {
- console.info(e);
- wx.showToast({
- title: '用户拒绝授权',
- icon: 'error'
- });
- }
- });
- } else {
- wx.navigateTo({
- url: '../light-map/light-map',
- });
- }
- }
- });
- }
- })
|