331 lines
11 KiB
JavaScript
331 lines
11 KiB
JavaScript
var app = getApp();
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
randomName: true,
|
|
showPhone: true,
|
|
gotCode: false,
|
|
restTime: 120,
|
|
timer: '',
|
|
indicatorDots: true,
|
|
autoplay: true,
|
|
token: '',
|
|
news: {
|
|
newsUrl: app.newsUrl,
|
|
bannerList: [],
|
|
newsList: []
|
|
},
|
|
venue: {
|
|
venueUrl: app.venueUrl,
|
|
venueList: []
|
|
},
|
|
activity: {
|
|
activityUrl: app.activityUrl,
|
|
activityList: []
|
|
},
|
|
live: {
|
|
liveUrl: app.liveUrl,
|
|
liveList: []
|
|
},
|
|
usercenterUrl: app.usercenterUrl,
|
|
isConfirm: false,
|
|
mainFuncList: [],
|
|
mainNewTab: [],
|
|
},
|
|
doLogin: function () {
|
|
var self = this;
|
|
wx.login({
|
|
success(res) {
|
|
if (res.code) {
|
|
wx.setStorageSync('token', 'aGh2UkUyWTBMbFh5dlV2WXJRci9pT1VPN1JuNkhEQUc5NDF4NmdsUUUxSE91enFBc2VMTmoyTkJscDdlaEhnYW01dEQ1bDFqN1lXLzk2S2l1S1ZEclhTeEFiMEp1Vzk0a1VJWTBlandZSmV6YXVGbjhnaFMzOFN2MkdVdzZsZFA1V0JWcXBYTFFFWWRrREhUTHp0RUJ1YktFWi82N09xTGdjM1UwcFdVdy9WSTQ3U3VrUVdZVklZK0tRV2VQMTZtTElpYTkvandSNFo1cjMzVlRIaGRTVXlEUnBPQy9VV1NlNWZuYThYUzJVRT0');
|
|
app.restAjax.post(app.restAjax.path('{url}/wechat-miniapp/sign/default', [app.loginUrl]), {
|
|
jsCode: res.code
|
|
}, null, function (code, data) {
|
|
console.log(data)
|
|
var tokenArray = data.data.split('_');
|
|
var token = tokenArray[0];
|
|
var isRandomUsername = tokenArray[1];
|
|
self.setData({
|
|
token: token
|
|
})
|
|
wx.setStorageSync('token', token);
|
|
wx.setStorageSync('isRandomUsername', isRandomUsername)
|
|
}, function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
});
|
|
} else {
|
|
console.log(res)
|
|
app.dialog.msg('登录失败!' + res.errMsg);
|
|
}
|
|
}
|
|
})
|
|
},
|
|
//获取首页功能
|
|
getMainFunc() {
|
|
var _self = this;
|
|
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newsdirectories/list/areamenu/release/{areaCode}', [_self.data.news.newsUrl, app.areaCode]),
|
|
null,
|
|
null,
|
|
function (code, data) {
|
|
console.log(data)
|
|
_self.setData({
|
|
mainFuncList: data
|
|
})
|
|
},
|
|
function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
});
|
|
},
|
|
//获取首页新闻动态
|
|
getMainNewsTab() {
|
|
var _self = this;
|
|
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newsdirectories/list/areaplate/release/{areaCode}', [_self.data.news.newsUrl, app.areaCode]),
|
|
null,
|
|
null,
|
|
function (code, data) {
|
|
if (data && data.length > 0) {
|
|
_self.setData({
|
|
mainNewTab: data
|
|
})
|
|
data.forEach(el => {
|
|
_self.doGetNewsList(el.newsDirectoriesId);
|
|
});
|
|
}
|
|
},
|
|
function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
});
|
|
},
|
|
//获取新闻
|
|
doGetNewsList(id) {
|
|
var _self = this;
|
|
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease/{areaCode}', [_self.data.news.newsUrl, app.areaCode]), {
|
|
newsDirectoriesId: id,
|
|
page: 1,
|
|
rows: 5
|
|
}, null, function (code, data) {
|
|
_self.data.mainNewTab.forEach(el => {
|
|
if (el.newsDirectoriesId == id) {
|
|
el.newsList = data.rows
|
|
}
|
|
});
|
|
_self.setData({
|
|
mainNewTab: _self.data.mainNewTab
|
|
})
|
|
}, function (code, data) {
|
|
console.log(data)
|
|
app.dialog.msg(data.msg);
|
|
});
|
|
},
|
|
doGetBanner: function () {
|
|
var self = this;
|
|
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), {
|
|
newsDirectoriesId: 'eab0ca3c-d35d-4c02-9397-ace2bdd10fc1',
|
|
page: 1,
|
|
rows: 5
|
|
}, null, function (code, data) {
|
|
self.setData({
|
|
'news.bannerList': data.rows
|
|
})
|
|
}, function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
});
|
|
},
|
|
doGetVenueList: function () {
|
|
var self = this;
|
|
app.restAjax.get(app.restAjax.path('{venueUrl}/app/venuesinfo/listpagevenuesinforelease', [self.data.venue.venueUrl]), {
|
|
page: 1,
|
|
rows: 3,
|
|
latitude: app.globalData.curLat,
|
|
longitude: app.globalData.curLng,
|
|
orderKey: "",
|
|
}, null, function (code, data) {
|
|
for (var i = 0, item; item = data.rows[i++];) {
|
|
item.venuePanoramaArray = item.venuePanorama.split(',');
|
|
}
|
|
self.setData({
|
|
'venue.venueList': data.rows
|
|
});
|
|
}, function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
});
|
|
},
|
|
doGetActivityList: function () {
|
|
var self = this;
|
|
app.restAjax.get(app.restAjax.path('{activityUrl}/app/activitylibrary/listpageactivitylibraryrelease', [self.data.activity.activityUrl]), {
|
|
page: 1,
|
|
rows: 3
|
|
}, null, function (code, data) {
|
|
console.log(data);
|
|
for (var i = 0, item; item = data.rows[i++];) {
|
|
item.activityImageArray = item.activityImage.split(',');
|
|
}
|
|
self.setData({
|
|
'activity.activityList': data.rows
|
|
});
|
|
}, function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
});
|
|
},
|
|
// doGetNewsList: function () {
|
|
// var self = this;
|
|
// app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), {
|
|
// newsDirectoriesParentId: 'f497904b-7727-4832-891c-604c36ae4167',
|
|
// page: 1,
|
|
// rows: 5
|
|
// }, null, function (code, data) {
|
|
// self.setData({
|
|
// 'news.newsList': data.rows
|
|
// })
|
|
// }, function (code, data) {
|
|
// app.dialog.msg(data.msg);
|
|
// });
|
|
// },
|
|
doGetLiveList: function () {
|
|
var self = this;
|
|
app.restAjax.get(app.restAjax.path('{liveUrl}/app/liveplan/listpageliveplanrelease', [self.data.live.liveUrl]), {
|
|
page: 1,
|
|
rows: 4
|
|
}, null, function (code, data) {
|
|
self.setData({
|
|
'live.liveList': data.rows
|
|
})
|
|
}, function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
});
|
|
},
|
|
|
|
goNewsDetail: function (event) {
|
|
wx.navigateTo({
|
|
url: '../newsDetail/newsDetail?templateRecordUrl=' + event.currentTarget.dataset.templateRecordUrl,
|
|
})
|
|
},
|
|
openNewsDetail(e) {
|
|
console.log(e.currentTarget.dataset.item)
|
|
//判断是跳转到列表 详情 webview
|
|
var item = e.currentTarget.dataset.item;
|
|
if (item.directoriesView == '0') {
|
|
//跳转webview
|
|
wx.navigateTo({
|
|
url: '/subpages/webcontentview/webcontent?url=' + item.directoriesTarget2,
|
|
})
|
|
} else if (item.directoriesView == '1') {
|
|
//跳转列表
|
|
wx.navigateTo({
|
|
url: '/pages/newsList/newsList?id=' + item.newsDirectoriesId,
|
|
})
|
|
} else {
|
|
//跳转无二级页面
|
|
wx.navigateTo({
|
|
url: '/pages/newsList/newsList?id=' + item.newsDirectoriesId,
|
|
})
|
|
}
|
|
},
|
|
goNewsList: function (event) {
|
|
wx.navigateTo({
|
|
url: '../newsList/newsList?type=' + event.currentTarget.dataset.type,
|
|
})
|
|
},
|
|
goVolunteer: function () {
|
|
wx.navigateTo({
|
|
url: '../volunteer/volunteer',
|
|
})
|
|
},
|
|
goBroadcast: function () {
|
|
wx.navigateTo({
|
|
url: '../broadcast/broadcast',
|
|
})
|
|
},
|
|
goVenue: function () {
|
|
wx.switchTab({
|
|
url: '../venue/venue',
|
|
})
|
|
},
|
|
goVenueDetail: function (event) {
|
|
wx.navigateTo({
|
|
url: '../venueDetail/venueDetail?venuesInfoId=' + event.currentTarget.dataset.venuesInfoId,
|
|
})
|
|
},
|
|
goBroadcastDetail: function (event) {
|
|
wx.navigateTo({
|
|
url: '../broadcastDetail/broadcastDetail?livePlanId=' + event.currentTarget.dataset.livePlanId,
|
|
})
|
|
},
|
|
goActivity: function () {
|
|
wx.switchTab({
|
|
url: '../activity/activity',
|
|
})
|
|
},
|
|
goActivityDetail: function (event) {
|
|
wx.navigateTo({
|
|
url: '../activityDetail/activityDetail?id=' + event.currentTarget.dataset.activityLibraryId
|
|
})
|
|
},
|
|
goHeritage: function () {
|
|
wx.switchTab({
|
|
url: '../heritage/heritage',
|
|
})
|
|
},
|
|
goCultureDetail: function (event) {
|
|
wx.navigateTo({
|
|
url: '../cultureDetail/cultureDetail?libraryId=' + event.currentTarget.dataset.libraryId,
|
|
})
|
|
},
|
|
// 获取用户信息
|
|
getUserInfo: function () {
|
|
var self = this
|
|
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/user/getappuser', [app.usercenterUrl]), {}, {
|
|
headers: {
|
|
token: self.data.token
|
|
}
|
|
}, function (code, data) {
|
|
self.setData({
|
|
userInfo: data
|
|
})
|
|
}, function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
})
|
|
},
|
|
goTrain: function () {
|
|
wx.navigateTo({
|
|
url: '../train/train',
|
|
})
|
|
},
|
|
goTravel: function () {
|
|
wx.navigateTo({
|
|
url: '../travel/travel',
|
|
})
|
|
},
|
|
goResource: function () {
|
|
wx.navigateTo({
|
|
url: '../resource/resource',
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
var self = this;
|
|
wx.getLocation({
|
|
type: 'gcj02',
|
|
success(res) {
|
|
// const latitude = res.latitude
|
|
// const longitude = res.longitude
|
|
// const speed = res.speed
|
|
// const accuracy = res.accuracy
|
|
app.globalData.curLng = res.longitude
|
|
app.globalData.curLat = res.latitude
|
|
}
|
|
})
|
|
self.doLogin();
|
|
self.doGetBanner();
|
|
self.doGetLiveList();
|
|
self.doGetVenueList();
|
|
self.doGetActivityList();
|
|
self.getMainFunc();
|
|
self.getMainNewsTab();
|
|
},
|
|
|
|
}) |