api接口baseUrl通过全局变量引入;代码格式化
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
// pages/home/home.js
|
||||
const app = getApp()
|
||||
const baseUrl = app.globalData.baseUrl
|
||||
// console.log("baseUrl", baseUrl)
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
isManager:false,
|
||||
isStudent:false,
|
||||
notice:''
|
||||
isManager: false,
|
||||
isStudent: false,
|
||||
notice: ''
|
||||
},
|
||||
|
||||
goWebPage: function (event) {
|
||||
wx.navigateTo({
|
||||
url: '../webPage/'+event.target.dataset.web,
|
||||
url: '../webPage/' + event.target.dataset.web,
|
||||
})
|
||||
},
|
||||
toRedList: function (event) {
|
||||
@@ -20,7 +23,7 @@ Page({
|
||||
url: '../other/redList'
|
||||
})
|
||||
},
|
||||
goCode:function() {
|
||||
goCode: function () {
|
||||
wx.navigateTo({
|
||||
url: '../other/redList2'
|
||||
})
|
||||
@@ -30,12 +33,12 @@ Page({
|
||||
url: '../person/count'
|
||||
})
|
||||
},
|
||||
goNotice:function () {
|
||||
goNotice: function () {
|
||||
wx.navigateTo({
|
||||
url: '../notice/notice'
|
||||
})
|
||||
},
|
||||
goVisitor:function () {
|
||||
goVisitor: function () {
|
||||
wx.navigateTo({
|
||||
url: '../visitor/visitorReplay'
|
||||
})
|
||||
@@ -80,7 +83,7 @@ Page({
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -94,17 +97,17 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
if(!wx.getStorageSync("username")){
|
||||
if (!wx.getStorageSync("username")) {
|
||||
wx.navigateTo({
|
||||
url: '../login/login'
|
||||
})
|
||||
}
|
||||
if(wx.getStorageSync("role") == 2){
|
||||
if (wx.getStorageSync("role") == 2) {
|
||||
this.setData({
|
||||
isManager: false,
|
||||
isStudent: true,
|
||||
})
|
||||
}else if(wx.getStorageSync("role") == 1){
|
||||
} else if (wx.getStorageSync("role") == 1) {
|
||||
this.setData({
|
||||
isManager: true,
|
||||
isStudent: false,
|
||||
@@ -112,8 +115,10 @@ Page({
|
||||
}
|
||||
var that = this;
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8080/notice/noticeList',
|
||||
data:{limit:3},
|
||||
url: `${baseUrl}/notice/noticeList`,
|
||||
data: {
|
||||
limit: 3
|
||||
},
|
||||
success: function (d) {
|
||||
that.setData({
|
||||
notice: d.data.data
|
||||
@@ -156,4 +161,4 @@ Page({
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user