完成公众号

This commit is contained in:
itgaojian 2023-07-27 14:28:57 +08:00
parent 859d40a127
commit fb920b2ff8
17 changed files with 1246 additions and 910 deletions

125
app.js
View File

@ -4,67 +4,70 @@ var dialog = require('utils/dialog.js');
var utils = require('utils/util.js'); var utils = require('utils/util.js');
// + 'https://www.xzszwhy.cn/usercenter' // + 'https://www.xzszwhy.cn/usercenter'
App({ App({
loginUrl: restAjax.baseUrl, loginUrl: restAjax.baseUrl,
usercenterUrl: restAjax.baseUrl, usercenterUrl: restAjax.baseUrl,
newsUrl: restAjax.baseUrl, newsUrl: restAjax.baseUrl,
newsContentUrl: restAjax.url, newsContentUrl: restAjax.url,
libraryUrl: restAjax.baseUrl, libraryUrl: restAjax.baseUrl,
venueUrl: restAjax.baseUrl, venueUrl: restAjax.baseUrl,
activityUrl: restAjax.baseUrl, activityUrl: restAjax.baseUrl,
volunteerUrl: restAjax.baseUrl, volunteerUrl: restAjax.baseUrl,
activityUrl: restAjax.baseUrl, activityUrl: restAjax.baseUrl,
volunteerUrl: restAjax.baseUrl, volunteerUrl: restAjax.baseUrl,
liveUrl: restAjax.url + 'live', liveUrl: restAjax.url + 'live',
liveRecordUrl: restAjax.baseUrl, liveRecordUrl: restAjax.baseUrl,
socialUrl: restAjax.baseUrl, socialUrl: restAjax.baseUrl,
areaCode: '540200000000', areaCode: '540200000000',
areaName: '日喀则市', areaName: '日喀则市',
areaId: '640675', areaId: '640675',
shopUrl: restAjax.url + "xzshop", appId: 'wxa5c5246b283713de',
bigDataUrl: restAjax.url + "module", shopUrl: restAjax.url + "xzshop",
restAjax: restAjax, bigDataUrl: restAjax.url + "module",
shopImgUrl: restAjax.url + "xzshop/route/file/download/true/", restAjax: restAjax,
imgUrl: restAjax.baseUrl + "/route/file/download/true/", shopImgUrl: restAjax.url + "xzshop/route/file/download/true/",
liveImgUrl: restAjax.url + "live/route/file/download/true/", imgUrl: restAjax.baseUrl + "/route/file/download/true/",
dialog: dialog, liveImgUrl: restAjax.url + "live/route/file/download/true/",
utils: utils, dialog: dialog,
onLaunch: function () { utils: utils,
// 展示本地存储能力 wssUrl: restAjax.wssUrl,
var logs = wx.getStorageSync('logs') || [] onLaunch: function () {
logs.unshift(Date.now()) // 展示本地存储能力
wx.setStorageSync('logs', logs) var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录 // 登录
wx.login({ wx.login({
success: res => { success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId // 发送 res.code 到后台换取 openId, sessionKey, unionId
} }
}) })
// 获取用户信息 // 获取用户信息
wx.getSetting({ wx.getSetting({
success: res => { success: res => {
if (res.authSetting['scope.userInfo']) { if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({ wx.getUserInfo({
success: res => { success: res => {
// 可以将 res 发送给后台解码出 unionId // 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况 // 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) { if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res) this.userInfoReadyCallback(res)
} }
} }
}) })
} }
} }
}) })
}, },
globalData: { globalData: {
userInfo: null, userInfo: null,
curLat: -1, curLat: -1,
curLng: -1, curLng: -1,
carList: [] carList: [],
} isPublic: false,//是否关注了公众号
}
}) })

View File

@ -38,7 +38,8 @@
"pages/myVolunteerTeam/myVolunteerTeam", "pages/myVolunteerTeam/myVolunteerTeam",
"pages/myVolunteerActivity/myVolunteerActivity", "pages/myVolunteerActivity/myVolunteerActivity",
"pages/serviceActivityDetail/serviceActivityDetail", "pages/serviceActivityDetail/serviceActivityDetail",
"pages/shop/shopcategory" "pages/shop/shopcategory",
"pages/commonQrCode/commonQrCode"
], ],
"subPackages": [ "subPackages": [
{ {

BIN
images/app_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -64,7 +64,7 @@ Page({
// 上传 // 上传
uploadAvatar: function (avatarId) { uploadAvatar: function (avatarId) {
var self = this var self = this
app.restAjax.put(app.restAjax.path('{usercenterUrl}/app/user/updateuseravatar', [app.usercenterUrl]), { app.restAjax.put(app.restAjax.path('{usercenterUrl}/app/user/update-avatar', [app.usercenterUrl]), {
avatar: avatarId avatar: avatarId
}, { }, {
headers: { headers: {
@ -246,6 +246,11 @@ Page({
}) })
self.getUserInfo() self.getUserInfo()
app.dialog.msg('绑定成功'); app.dialog.msg('绑定成功');
},function(code,error){
self.setData({
isLoading: false
})
app.dialog.msg(error.msg)
}) })
} else { } else {
self.setData({ self.setData({

View File

@ -3,7 +3,7 @@
</view> </view>
<view class="page-container"> <view class="page-container">
<view class="person"> <view class="person">
<view class="user-avatar" bindtap="changeAvatar" wx:if="{{userInfo.avatar}}"> <view class="user-avatar" bindtap="changeAvatar" >
<image src="{{usercenterUrl}}{{sourcePath}}{{userInfo.avatar}}"></image> <image src="{{usercenterUrl}}{{sourcePath}}{{userInfo.avatar}}"></image>
</view> </view>
<view class="user-name">{{userInfo.name}}</view> <view class="user-name">{{userInfo.name}}</view>

View File

@ -0,0 +1,98 @@
// subpages/commonQrCode.js
const app = getApp();
var socket = null;
Page({
/**
* 页面的初始数据
*/
data: {
title: '日喀则市公共数字文化云',
desc: '开展新闻资讯、场馆导航、场馆预定、活动预约、艺术普及、在线培训、电子图书、文化点单、直播活动等。',
hint: '扫描或长按识别上面二维码进行关注公众号',
imgSrc: '',
userId: '',
urls: app.wssUrl,
userName: '码',
hideloading: false,
},
onLoad(options) {
console.log(options)
wx.setNavigationBarTitle({
title: '公众号关注',
});
wx.setNavigationBarColor({
backgroundColor: '#ededed',
frontColor: '#000000',
})
var userId = "";
if (options && JSON.stringify(options) !== '{}') {
var keys = Object.keys(options)
var values = keys[0].split("=");
userId = values[1];
this.setData({
userId: userId
})
} else {
userId = app.globalData.userInfo.userId;
this.setData({
userId: userId
})
this.startWebSocket();
}
this.getCodeImg(userId);
},
startWebSocket() {
var _self = this;
socket = wx.connectSocket({
url: _self.data.urls + '/app/wxeventrelease/' + _self.data.userId,
success(res) {
console.log(res)
}
});
socket.onMessage(function (e) {
console.log(e)
if (e.data) {
var data = JSON.parse(e.data);
_self.prePage(data.attention)
}
});
},
prePage(e) {
console.log(e)
app.globalData.isPublic = e
var pages = getCurrentPages();
var prePage = pages[pages.length - 2]
prePage.setData({
isPublic: e
});
wx.navigateBack()
},
onUnload() {
if (socket != null) {
socket.close({
code: 1000
});
}
},
getCodeImg(id) {
var _self = this;
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/wxopen/qrcoderelease/{userId}', [app.usercenterUrl, id]), {}, {
}, function (code, data) {
_self.setData({
imgSrc: data,
hideloading: true
})
}, function (code, data) {
_self.setData({
hideloading: true
})
app.dialog.msg(data.msg);
})
},
onShow() {
},
})

View File

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

View File

@ -0,0 +1,15 @@
<view class="page" wx:if="{{hideloading}}">
<view class="box">
<view class="title-box">
<image class="title-icon" src="/images/app_logo.png" mode="scaleToFill"></image>
<view class="title-content">
<view class="title-txt">{{title}}</view>
<view class="title-des">{{desc}}</view>
</view>
</view>
<image class="img" src="{{imgSrc}}" mode="scaleToFill" show-menu-by-longpress="{{true}}"></image>
<view class="hint">{{hint}}</view>
</view>
</view>
<page-loading wx:else></page-loading>

View File

@ -0,0 +1,80 @@
/* subpages/commonQrCode.wxss */
page {
width: 100%;
height: 100%;
background-color: #ededed;
}
.page {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
/* justify-content: center; */
}
.box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 200rpx;
width: 80%;
background-color: white;
border-radius: 20rpx;
height: auto;
padding: 20rpx;
box-shadow: 3rpx 3rpx 30rpx #e7e7e7;
}
.title-box {
width: 100%;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.title-icon {
width: 120rpx;
height: 120rpx;
}
.title-content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
width: 75%;
margin-left: 20rpx;
}
.title-txt {
font-size: 35rpx;
color: black;
font-weight: bold;
}
.title-des {
font-size: 20rpx;
color: #6b6b6b;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
margin-top: 10rpx;
}
.img {
margin-top: 20rpx;
width: 500rpx;
height: 500rpx;
}
.hint {
margin-top: 20rpx;
font-size: 24rpx;
color: #858585;
margin-bottom: 20rpx;
}

View File

@ -1,382 +1,410 @@
var app = getApp(); var app = getApp();
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
randomName: true, randomName: true,
showPhone: true, showPhone: true,
gotCode: false, gotCode: false,
restTime: 120, restTime: 120,
timer: '', timer: '',
indicatorDots: true, indicatorDots: true,
autoplay: true, autoplay: true,
token: '', token: '',
news: { news: {
newsUrl: app.newsUrl, newsUrl: app.newsUrl,
bannerList: [], bannerList: [],
newsList: [] newsList: []
}, },
venue: { venue: {
venueUrl: app.venueUrl, venueUrl: app.venueUrl,
venueList: [] venueList: []
}, },
activity: { activity: {
activityUrl: app.activityUrl, activityUrl: app.activityUrl,
activityList: [] activityList: []
}, },
live: { live: {
liveUrl: app.liveUrl, liveUrl: app.liveUrl,
liveList: [] liveList: []
}, },
usercenterUrl: app.usercenterUrl, usercenterUrl: app.usercenterUrl,
bigDataUrl: app.bigDataUrl, bigDataUrl: app.bigDataUrl,
isConfirm: false, isConfirm: false,
mainFuncList: [], mainFuncList: [],
mainNewTab: [], mainNewTab: [],
isHide: true isHide: true
}, },
doLogin: function () { doLogin: function () {
var self = this; var self = this;
wx.login({ wx.login({
success(res) { success(res) {
if (res.code) { if (res.code) {
wx.setStorageSync('token', 'REQ5NW5IZTZjS2ZyQU9QQmFKZ1FIRmVhbjNFZmV4dEx3emdob2g5UjVXaForWGdpOHFIRWgyTWRIelJFWkhNS28wN1hUV2Uwb0FKSUEra2wzYVhXdnI4aG9odkxLd3ZFUGkrTTQwQTkzdyt3cnN3NkY4OE9aaGw0aUJPTUNSaENKbGxTdm8xR3Z5WTJBV0NDcWRpbEd3OW0zUzA3US8xMmUyaTU2a0N4YmN5d1FjTXd6aTZIZkhhdmpsSDlqYSt0OUJVUHRSbTJqSVd6eHlYc1M5WTlkK015MVR2R083T3crU2wrdVFmVGk4N3NHWmZNY1A3SGNNbm8xMDFMTy9tcTN2K0NuQTZJbk9YZGJqK3drQkxlMXNUVjZZNkZyRE9LMGdYdUQzSE9lbDQ9'); app.restAjax.post(app.restAjax.path('{url}/wechat-miniapp/sign/default-multi', [app.loginUrl]), {
app.restAjax.post(app.restAjax.path('{url}/wechat-miniapp/sign/default', [app.loginUrl]), { jsCode: res.code,
jsCode: res.code appKey: app.appId
}, null, function (code, data) { }, null, function (code, data) {
console.log(data) console.log(data)
var tokenArray = data.data.split('_'); var tokenArray = data.data.split('_');
var token = tokenArray[0]; var token = tokenArray[0];
var isRandomUsername = tokenArray[1]; var isRandomUsername = tokenArray[1];
self.setData({ self.setData({
token: token token: token
}) })
wx.setStorageSync('token', token); wx.setStorageSync('token', token);
wx.setStorageSync('isRandomUsername', isRandomUsername) wx.setStorageSync('isRandomUsername', isRandomUsername)
}, function (code, data) { //获取UserID
app.dialog.msg(data.msg); self.getUserInfo();
}); }, function (code, data) {
} else { app.dialog.msg(data.msg);
console.log(res) });
app.dialog.msg('登录失败!' + res.errMsg); } else {
} console.log(res)
} app.dialog.msg('登录失败!' + res.errMsg);
}) }
}, }
//获取首页功能 })
getMainFunc() { },
var _self = this; // getUserInfo(){
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newsdirectories/list/areamenu/release/{areaCode}', [_self.data.news.newsUrl, app.areaCode]), // var _self= this;
null, // // app/wxopen/qrcoderelease/{userId}
null, // app.restAjax.get(app.restAjax.path('{newsUrl}/app/user/get-app-user'),[_self.data.news.newsUrl]),
function (code, data) { // null,
console.log(data) // null,
_self.setData({ // function(code,data){
mainFuncList: data // console.log(data)
}) // },
}, // function(code,error){
function (code, data) { // app.dialog.msg(error.msg);
app.dialog.msg(data.msg); // }
}); // },
}, //获取首页功能
//获取首页新闻动态 getMainFunc() {
getMainNewsTab() { var _self = this;
var _self = this; app.restAjax.get(app.restAjax.path('{newsUrl}/app/newsdirectories/list/areamenu/release/{areaCode}', [_self.data.news.newsUrl, app.areaCode]),
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newsdirectories/listsub/areaauth/release/{newsDirectoriesId}/{areaCode}', [_self.data.news.newsUrl, '0', app.areaCode]), null,
null, null,
null, function (code, data) {
function (code, data) { console.log(data)
if (data && data.length > 0) { _self.setData({
_self.setData({ mainFuncList: data
mainNewTab: data })
}) },
data.forEach(el => { function (code, data) {
_self.doGetNewsList(el.newsDirectoriesId); app.dialog.msg(data.msg);
}); });
} },
}, //获取首页新闻动态
function (code, data) { getMainNewsTab() {
app.dialog.msg(data.msg); var _self = this;
}); app.restAjax.get(app.restAjax.path('{newsUrl}/app/newsdirectories/listsub/areaauth/release/{newsDirectoriesId}/{areaCode}', [_self.data.news.newsUrl, '0', app.areaCode]),
}, null,
//获取新闻 null,
doGetNewsList(id) { function (code, data) {
var _self = this; if (data && data.length > 0) {
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease/{areaCode}', [_self.data.news.newsUrl, app.areaCode]), { _self.setData({
newsDirectoriesId: "", mainNewTab: data
newsDirectoriesParentId: id, })
page: 1, data.forEach(el => {
rows: 5 _self.doGetNewsList(el.newsDirectoriesId);
}, null, function (code, data) { });
_self.data.mainNewTab.forEach(el => { }
if (el.newsDirectoriesId == id) { },
el.newsList = data.rows function (code, data) {
} app.dialog.msg(data.msg);
}); });
_self.setData({ },
mainNewTab: _self.data.mainNewTab //获取新闻
}) doGetNewsList(id) {
}, function (code, data) { var _self = this;
console.log(data) app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease/{areaCode}', [_self.data.news.newsUrl, app.areaCode]), {
app.dialog.msg(data.msg); newsDirectoriesId: "",
}); newsDirectoriesParentId: id,
}, page: 1,
doGetBanner: function () { rows: 5
var self = this; }, null, function (code, data) {
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease/{areaCode}', [self.data.news.newsUrl, app.areaCode]), { _self.data.mainNewTab.forEach(el => {
newsDirectoriesId: 'eab0ca3c-d35d-4c02-9397-ace2bdd10fc1', if (el.newsDirectoriesId == id) {
page: 1, el.newsList = data.rows
rows: 5 }
}, null, function (code, data) { });
self.setData({ _self.setData({
'news.bannerList': data.rows mainNewTab: _self.data.mainNewTab
}) })
}, function (code, data) { }, function (code, data) {
app.dialog.msg(data.msg); console.log(data)
}); app.dialog.msg(data.msg);
}, });
doGetVenueList: function () { },
var self = this; doGetBanner: function () {
app.restAjax.get(app.restAjax.path('{venueUrl}/app/venuesinfo/listpagevenuesinforelease/{areaCode}', [self.data.venue.venueUrl, app.areaCode]), { var self = this;
page: 1, app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease/{areaCode}', [self.data.news.newsUrl, app.areaCode]), {
rows: 3, newsDirectoriesId: 'eab0ca3c-d35d-4c02-9397-ace2bdd10fc1',
latitude: app.globalData.curLat, page: 1,
longitude: app.globalData.curLng, rows: 5
orderKey: "", }, null, function (code, data) {
}, null, function (code, data) { self.setData({
for (var i = 0, item; item = data.rows[i++];) { 'news.bannerList': data.rows
item.venuePanoramaArray = item.venuePanorama.split(','); })
} }, function (code, data) {
self.setData({ app.dialog.msg(data.msg);
'venue.venueList': data.rows });
}); },
}, function (code, data) { doGetVenueList: function () {
app.dialog.msg(data.msg); var self = this;
}); app.restAjax.get(app.restAjax.path('{venueUrl}/app/venuesinfo/listpagevenuesinforelease/{areaCode}', [self.data.venue.venueUrl, app.areaCode]), {
}, page: 1,
//加载活动图片错误 rows: 3,
loadImgErr(e) { latitude: app.globalData.curLat,
console.log(e) longitude: app.globalData.curLng,
var index = e.currentTarget.dataset.index orderKey: "",
this.data.activity.activityList[index].activityImageArray.unshift("03c2ea0d-87ad-43db-bba0-ae6b4f827dba") }, null, function (code, data) {
this.setData({ for (var i = 0, item; item = data.rows[i++];) {
activity: this.data.activity item.venuePanoramaArray = item.venuePanorama.split(',');
}) }
}, self.setData({
//加载轮播图错误 'venue.venueList': data.rows
loadBannerErr(e) { });
var index = e.currentTarget.dataset.index }, function (code, data) {
this.data.news.bannerList[index].newsContentCoverList.unshift('03c2ea0d-87ad-43db-bba0-ae6b4f827dba') app.dialog.msg(data.msg);
this.setData({ });
news: this.data.news },
}) //加载活动图片错误
}, loadImgErr(e) {
doGetActivityList: function () { console.log(e)
var self = this; var index = e.currentTarget.dataset.index
app.restAjax.get(app.restAjax.path('{activityUrl}/app/activitylibrary/listpageactivitylibraryfornetrelease/{areaCode}', [self.data.activity.activityUrl, app.areaCode]), { this.data.activity.activityList[index].activityImageArray.unshift("03c2ea0d-87ad-43db-bba0-ae6b4f827dba")
page: 1, this.setData({
rows: 3 activity: this.data.activity
}, null, function (code, data) { })
console.log(data); },
for (var i = 0, item; item = data.rows[i++];) { //加载轮播图错误
item.activityImageArray = item.activityImage.split(','); loadBannerErr(e) {
} var index = e.currentTarget.dataset.index
self.setData({ this.data.news.bannerList[index].newsContentCoverList.unshift('03c2ea0d-87ad-43db-bba0-ae6b4f827dba')
'activity.activityList': data.rows this.setData({
}); news: this.data.news
}, function (code, data) { })
app.dialog.msg(data.msg); },
}); doGetActivityList: function () {
}, var self = this;
// doGetNewsList: function () { app.restAjax.get(app.restAjax.path('{activityUrl}/app/activitylibrary/listpageactivitylibraryfornetrelease/{areaCode}', [self.data.activity.activityUrl, app.areaCode]), {
// var self = this; page: 1,
// app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), { rows: 3
// newsDirectoriesParentId: 'f497904b-7727-4832-891c-604c36ae4167', }, null, function (code, data) {
// page: 1, console.log(data);
// rows: 5 for (var i = 0, item; item = data.rows[i++];) {
// }, null, function (code, data) { item.activityImageArray = item.activityImage.split(',');
// self.setData({ }
// 'news.newsList': data.rows self.setData({
// }) 'activity.activityList': data.rows
// }, function (code, data) { });
// app.dialog.msg(data.msg); }, function (code, data) {
// }); app.dialog.msg(data.msg);
// }, });
doGetLiveList: function () { },
var self = this; // doGetNewsList: function () {
app.restAjax.get(app.restAjax.path('{liveUrl}/app/liveplan/listpageliveplanrelease', [self.data.live.liveUrl]), { // var self = this;
page: 1, // app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), {
rows: 4 // newsDirectoriesParentId: 'f497904b-7727-4832-891c-604c36ae4167',
}, null, function (code, data) { // page: 1,
self.setData({ // rows: 5
'live.liveList': data.rows // }, null, function (code, data) {
}) // self.setData({
}, function (code, data) { // 'news.newsList': data.rows
app.dialog.msg(data.msg); // })
}); // }, 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) { goNewsDetail: function (event) {
wx.navigateTo({ wx.navigateTo({
url: '../newsDetail/newsDetail?id=' + event.currentTarget.dataset.item.newsContentId url: '../newsDetail/newsDetail?id=' + event.currentTarget.dataset.item.newsContentId
}) })
}, },
openNewsDetail(e) { openNewsDetail(e) {
console.log(e.currentTarget.dataset.item) console.log(e.currentTarget.dataset.item)
//判断是跳转到列表 详情 webview //判断是跳转到列表 详情 webview
var item = e.currentTarget.dataset.item; var item = e.currentTarget.dataset.item;
if (item.directoriesView == '0') { if (item.directoriesView == '0') {
//跳转webview //跳转webview
wx.navigateTo({ wx.navigateTo({
url: '/subpages/webcontentview/webcontent?url=' + item.directoriesTarget2, url: '/subpages/webcontentview/webcontent?url=' + item.directoriesTarget2,
}) })
} else if (item.directoriesView == '1') { } else if (item.directoriesView == '1') {
//跳转列表 //跳转列表
wx.navigateTo({ wx.navigateTo({
url: '/pages/newsList/newsList?id=' + item.newsDirectoriesId, url: '/pages/newsList/newsList?id=' + item.newsDirectoriesId,
}) })
} else { } else {
//跳转无二级页面 //跳转无二级页面
wx.navigateTo({ wx.navigateTo({
url: '/pages/newsList/newsList?id=' + item.newsDirectoriesId, url: '/pages/newsList/newsList?id=' + item.newsDirectoriesId,
}) })
} }
}, },
goNewsList: function (event) { goNewsList: function (event) {
wx.navigateTo({ wx.navigateTo({
url: '../newsList/newsList?type=' + event.currentTarget.dataset.type, url: '../newsList/newsList?type=' + event.currentTarget.dataset.type,
}) })
}, },
goVolunteer: function () { goVolunteer: function () {
wx.navigateTo({ wx.navigateTo({
url: '../volunteer/volunteer', url: '../volunteer/volunteer',
}) })
}, },
goBroadcast: function () { goBroadcast: function () {
wx.navigateTo({ wx.navigateTo({
url: '../broadcast/broadcast', url: '../broadcast/broadcast',
}) })
}, },
goVenue: function () { goVenue: function () {
wx.switchTab({ wx.switchTab({
url: '../venue/venue', url: '../venue/venue',
}) })
}, },
goVenueDetail: function (event) { goVenueDetail: function (event) {
wx.navigateTo({ wx.navigateTo({
url: '../venueDetail/venueDetail?venuesInfoId=' + event.currentTarget.dataset.venuesInfoId, url: '../venueDetail/venueDetail?venuesInfoId=' + event.currentTarget.dataset.venuesInfoId,
}) })
}, },
goBroadcastDetail: function (event) { goBroadcastDetail: function (event) {
wx.navigateTo({ wx.navigateTo({
url: '../broadcastDetail/broadcastDetail?livePlanId=' + event.currentTarget.dataset.livePlanId, url: '../broadcastDetail/broadcastDetail?livePlanId=' + event.currentTarget.dataset.livePlanId,
}) })
}, },
goActivity: function () { goActivity: function () {
wx.switchTab({ wx.switchTab({
url: '../activity/activity', url: '../activity/activity',
}) })
}, },
goActivityDetail: function (event) { goActivityDetail: function (event) {
wx.navigateTo({ wx.navigateTo({
url: '../activityDetail/activityDetail?id=' + event.currentTarget.dataset.activityLibraryId url: '../activityDetail/activityDetail?id=' + event.currentTarget.dataset.activityLibraryId
}) })
}, },
goHeritage: function () { goHeritage: function () {
wx.navigateTo({ wx.navigateTo({
url: '/pages/heritage/heritage', url: '/pages/heritage/heritage',
}) })
}, },
goCultureDetail: function (event) { goCultureDetail: function (event) {
wx.navigateTo({ wx.navigateTo({
url: '../cultureDetail/cultureDetail?libraryId=' + event.currentTarget.dataset.libraryId, url: '../cultureDetail/cultureDetail?libraryId=' + event.currentTarget.dataset.libraryId,
}) })
}, },
// 获取用户信息 // 获取用户信息
getUserInfo: function () { getUserInfo: function () {
var self = this var self = this
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/user/getappuser', [app.usercenterUrl]), {}, { app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/user/get-app-user', [app.usercenterUrl]), {}, {
headers: { headers: {
token: self.data.token token: self.data.token
} }
}, function (code, data) { }, function (code, data) {
self.setData({ console.log(data);
userInfo: data app.globalData.userInfo = data;
}) self.setData({
self.doSaveLoginInfo(data.userId) userInfo: data
}, function (code, data) { });
app.dialog.msg(data.msg); self.doSaveLoginInfo(data.userId);
}) self.getIsPublic();
}, }, function (code, data) {
doSaveLoginInfo(id) { app.dialog.msg(data.msg);
var params = "小程序USER" + id; })
var info = { },
requestUrl: params //是否关注公众号
} getIsPublic() {
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/contentcensusrelease/log', [app.bigDataUrl]), info, { var _self = this;
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/wxopen/attentionrelease/{userId}', [app.usercenterUrl, _self.data.userInfo.userId]), {}, {
}, function (code, data) {
app.globalData.isPublic = data
}, function (code, data) {
app.dialog.msg(data.msg)
})
},
doSaveLoginInfo(id) {
var params = "小程序USER" + id;
var info = {
requestUrl: params
}
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/contentcensusrelease/log', [app.bigDataUrl]), info, {
}, function (code, data) { }, function (code, data) {
}, function (code, data) { }, function (code, data) {
}) })
}, },
goTrain: function () { goTrain: function () {
wx.navigateTo({ wx.navigateTo({
url: '../train/train', url: '../train/train',
}) })
}, },
goTravel: function () { goTravel: function () {
wx.navigateTo({ wx.navigateTo({
url: '../travel/travel', url: '../travel/travel',
}) })
}, },
goResource: function () { goResource: function () {
wx.navigateTo({ wx.navigateTo({
url: '../resource/resource', url: '../resource/resource',
}) })
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
var self = this; var self = this;
wx.getLocation({ wx.getLocation({
type: 'gcj02', type: 'gcj02',
success(res) { success(res) {
// const latitude = res.latitude // const latitude = res.latitude
// const longitude = res.longitude // const longitude = res.longitude
// const speed = res.speed // const speed = res.speed
// const accuracy = res.accuracy // const accuracy = res.accuracy
app.globalData.curLng = res.longitude app.globalData.curLng = res.longitude
app.globalData.curLat = res.latitude app.globalData.curLat = res.latitude
} }
}) })
self.doLogin(); self.doLogin();
self.doGetBanner(); self.doGetBanner();
self.doGetLiveList(); self.doGetLiveList();
self.doGetVenueList(); self.doGetVenueList();
self.doGetActivityList(); self.doGetActivityList();
self.getMainFunc(); self.getMainFunc();
self.getMainNewsTab(); self.getMainNewsTab();
}, },
onPageScroll(e) { onPageScroll(e) {
var _self = this; var _self = this;
if (e.scrollTop <= 96) { if (e.scrollTop <= 96) {
//显示 //显示
_self.setData({ _self.setData({
isHide: true isHide: true
}) })
} else { } else {
//隐藏 //隐藏
_self.setData({ _self.setData({
isHide: false isHide: false
}) })
} }
}, },
openSearch() { openSearch() {
wx.navigateTo({ wx.navigateTo({
url: '/subpages/search/commonSearch', url: '/subpages/search/commonSearch',
}) })
} }
}) })

View File

@ -5,35 +5,37 @@
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
<scroll-view scroll-x="true">
<view class="tab"> <view class="tab">
<block wx:for="{{mainFuncList}}" wx:key="index"> <block wx:for="{{mainFuncList}}" wx:key="index">
<view class="tab-box" bindtap="openNewsDetail" data-item="{{item}}"> <view class="tab-box" bindtap="openNewsDetail" data-item="{{item}}">
<image src="{{item.directoriesPhoto==''? '../../images/tab6.png':news.newsUrl+'/route/file/download/true/'+item.directoriesPhoto}}"></image> <image src="{{item.directoriesPhoto==''? '../../images/tab6.png':news.newsUrl+'/route/file/download/true/'+item.directoriesPhoto}}"></image>
<view class="tab-title">{{item.directoriesName}}</view> <view class="tab-title">{{item.directoriesName}}</view>
</view>
</block>
<view class="tab-box" bindtap="goVolunteer">
<image src="../../images/tab1.png"></image>
<view class="tab-title">志愿者服务</view>
</view>
<view class="tab-box" bindtap="goActivity">
<image src="../../images/tab2.png"></image>
<view class="tab-title">精彩活动</view>
</view>
<view class="tab-box" bindtap="goVenue">
<image src="../../images/tab3.png"></image>
<view class="tab-title">场馆导航</view>
</view>
<view class="tab-box" bindtap="goHeritage">
<image src="../../images/tab4.png"></image>
<view class="tab-title">非遗文化</view>
</view>
<view class="tab-box" bindtap="goBroadcast">
<image src="../../images/tab5.png"></image>
<view class="tab-title">直播点播</view>
</view> </view>
</block>
<view class="tab-box" bindtap="goVolunteer">
<image src="../../images/tab1.png"></image>
<view class="tab-title">志愿者服务</view>
</view> </view>
<view class="tab-box" bindtap="goActivity"> </scroll-view>
<image src="../../images/tab2.png"></image> <view class="line-thick"></view>
<view class="tab-title">精彩活动</view>
</view>
<view class="tab-box" bindtap="goVenue">
<image src="../../images/tab3.png"></image>
<view class="tab-title">场馆导航</view>
</view>
<view class="tab-box" bindtap="goHeritage">
<image src="../../images/tab4.png"></image>
<view class="tab-title">非遗文化</view>
</view>
<view class="tab-box" bindtap="goBroadcast">
<image src="../../images/tab5.png"></image>
<view class="tab-title">直播点播</view>
</view>
</view>
<view class="recommend"> <view class="recommend">
<view class="public-title"> <view class="public-title">
<view class="title-text"> <view class="title-text">
@ -42,20 +44,22 @@
<image src="../../images/selected-r.png" class="selected-r"></image> <image src="../../images/selected-r.png" class="selected-r"></image>
</view> </view>
</view> </view>
<view class="line"></view> <scroll-view scroll-x="true" style="margin-top: 10rpx;">
<view class="recommend-container"> <view class="recommend-container">
<view class="recommend-box" wx:for="{{venue.venueList}}" bindtap="goVenueDetail" data-venues-info-Id="{{item.venuesInfoId}}" wx:for-index="index" wx:for-item="item" wx:key="venueList"> <view class="recommend-box" wx:for="{{venue.venueList}}" bindtap="goVenueDetail" data-venues-info-Id="{{item.venuesInfoId}}" wx:for-index="index" wx:for-item="item" wx:key="venueList">
<view class="recommend-status">场馆导航</view> <view class="recommend-status">场馆导航</view>
<view class="recommend-name">{{item.venueName}}</view> <view class="recommend-name">{{item.venueName}}</view>
<image src="{{venue.venueUrl}}/route/file/download/true/{{item.venuePanoramaArray[0]}}"></image> <image src="{{venue.venueUrl}}/route/file/download/true/{{item.venuePanoramaArray[0]}}"></image>
</view>
<view class="recommend-box" wx:for="{{activity.activityList}}" bindtap="goActivityDetail" data-activity-library-id="{{item.activityLibraryId}}" wx:for-index="index" wx:for-item="item" wx:key="activityList">
<view class="recommend-status">精彩活动</view>
<view class="recommend-name">{{item.activityTitle}}</view>
<image src="{{activity.activityUrl}}/route/file/download/true/{{item.activityImageArray[0]}}" data-index="{{index}}" binderror="loadImgErr"></image>
</view>
</view> </view>
<view class="recommend-box" wx:for="{{activity.activityList}}" bindtap="goActivityDetail" data-activity-library-id="{{item.activityLibraryId}}" wx:for-index="index" wx:for-item="item" wx:key="activityList"> </scroll-view>
<view class="recommend-status">精彩活动</view>
<view class="recommend-name">{{item.activityTitle}}</view>
<image src="{{activity.activityUrl}}/route/file/download/true/{{item.activityImageArray[0]}}" data-index="{{index}}" binderror="loadImgErr"></image>
</view>
</view>
</view> </view>
<view class="line-thick"></view>
<view class="news" wx:if="{{mainNewTab.length>0}}"> <view class="news" wx:if="{{mainNewTab.length>0}}">
<block wx:for="{{mainNewTab}}" wx:key="i" wx:for-item="it" wx:for-index="i"> <block wx:for="{{mainNewTab}}" wx:key="i" wx:for-item="it" wx:for-index="i">
<view class="public-title"> <view class="public-title">

View File

@ -34,9 +34,18 @@ swiper {
.tab { .tab {
padding: 30rpx; padding: 30rpx;
display: flex; display: flex;
border-bottom: 5px solid #FBFBFB;
flex-wrap: nowrap; flex-wrap: nowrap;
overflow-x: scroll; }
.tab-arrow {
font-size: 28rpx;
background: #242424;
text-align: center;
justify-content: center;
align-items: center;
position: absolute;
right: 0rpx;
padding: 20rpx;
} }
.tab-box { .tab-box {
@ -56,14 +65,11 @@ swiper {
.recommend { .recommend {
padding: 0rpx 30rpx 30rpx 30rpx; padding: 0rpx 30rpx 30rpx 30rpx;
border-bottom: 5px solid #FBFBFB;
} }
.recommend-container { .recommend-container {
width: 100%; width: 100%;
display: flex; display: flex;
overflow-x: auto;
margin-top: 10rpx;
} }
.line { .line {
@ -72,6 +78,12 @@ swiper {
background: #f2f2f2; background: #f2f2f2;
} }
.line-thick {
width: 100%;
height: 10rpx;
background: #f2f2f2;
}
.recommend-box { .recommend-box {
flex-shrink: 0; flex-shrink: 0;
width: 220rpx; width: 220rpx;

View File

@ -3,243 +3,282 @@ var app = getApp();
var audioContentx = null; var audioContentx = null;
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
newsId: '', newsId: '',
newsBean: null, newsBean: null,
imgUrl: app.imgUrl, imgUrl: app.imgUrl,
pageHeight: 500, pageHeight: 500,
currentVideoUrl: '', currentVideoUrl: '',
currentDesc: '', currentDesc: '',
currentVideoIndex: 0, currentVideoIndex: 0,
sliderValue: 0, sliderValue: 0,
currentTime: 0, currentTime: 0,
duration: 0, duration: 0,
currentAudioIndex: 0, currentAudioIndex: 0,
currentAudioDesc: '', currentAudioDesc: '',
canPlay: false, canPlay: false,
isPlaying: false, isPlaying: false,
totalValue: 0, totalValue: 0,
}, isPublicCode: false,
isPublic: false
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.setData({ this.setData({
newsId: options.id, newsId: options.id,
pageHeight: wx.getSystemInfoSync().windowHeight pageHeight: wx.getSystemInfoSync().windowHeight,
}) isPublic: app.globalData.isPublic
this.getNewsDetail(); })
this.saveBigdata(options.id);
},
saveBigdata(id) {
var params = "小程序" + id + "新闻";
var info = {
requestUrl: params
}
app.restAjax.get(app.restAjax.path(app.bigDataUrl + '/app/contentcensusrelease/log', []), info, null,
function (code, data) {
}, function (code, err) { this.saveBigdata(options.id);
},
onShow() {
if (this.data.isPublic) {
this.setData({
isPublicCode: false
})
}
this.setData({
newsBean: null
})
this.getNewsDetail();
},
saveBigdata(id) {
var params = "小程序" + id + "新闻";
var info = {
requestUrl: params
}
app.restAjax.get(app.restAjax.path(app.bigDataUrl + '/app/contentcensusrelease/log', []), info, null,
function (code, data) {
}) }, function (code, err) {
},
getNewsDetail() {
var _self = this;
// app.dialog.loading('正在加载');
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/getnewscontentbyidrelease/{id}', [app.newsUrl, _self.data.newsId]), null, null,
function (code, data) {
_self.setData({
newsBean: data
})
//视频
if (_self.data.newsBean.newsContentType == '4') {
_self.setData({
currentVideoUrl: _self.data.imgUrl + _self.data.newsBean.fileList[0].contentFileFileId,
currentDesc: _self.data.newsBean.fileList[0].contentFileText
})
}
//音频
if (_self.data.newsBean.newsContentType == '3') {
_self.setData({
currentAudioUrl: _self.data.imgUrl + _self.data.newsBean.fileList[0].contentFileFileId,
currentAudioDesc: _self.data.newsBean.fileList[0].contentFileText,
})
_self.initAudio()
}
},
function (code, data) {
app.dialog.msg(data.msg);
},
function () {
wx.stopPullDownRefresh();
// wx.hideLoading();
});
},
setVideoUrl(e) {
var _self = this;
var item = e.currentTarget.dataset.item
var index = e.currentTarget.dataset.index
this.setData({
currentVideoUrl: _self.data.imgUrl + item.contentFileFileId,
currentDesc: item.contentFileText,
currentVideoIndex: index
})
},
//初始化音频播放器
initAudio() {
var _self = this;
audioContentx = wx.createInnerAudioContext();
audioContentx.src = _self.data.currentAudioUrl; })
// 准备好歌曲流,可以播放 },
audioContentx.onCanplay(() => { getNewsDetail() {
_self.setData({ var _self = this;
canPlay: true, // app.dialog.loading('正在加载');
duration: audioContentx.duration * 1000 app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/getnewscontentbyidrelease/{id}', [app.newsUrl, _self.data.newsId]), null, null,
}) function (code, data) {
console.log(audioContentx.duration) _self.setData({
newsBean: data
})
//视频
if (_self.data.newsBean.newsContentType == '4') {
_self.setData({
currentVideoUrl: _self.data.imgUrl + _self.data.newsBean.fileList[0].contentFileFileId,
currentDesc: _self.data.newsBean.fileList[0].contentFileText
})
}
//音频
if (_self.data.newsBean.newsContentType == '3') {
_self.setData({
currentAudioUrl: _self.data.imgUrl + _self.data.newsBean.fileList[0].contentFileFileId,
currentAudioDesc: _self.data.newsBean.fileList[0].contentFileText,
})
_self.initAudio()
}
//判断是否需要关注公众号
if (data.newsViewAuth && data.newsViewAuth.indexOf('2')) {
//需要关注
//判断是否已经关注
if (!_self.data.isPublic) {
_self.setData({
isPublicCode: true
})
}
} else {
//无需关注
_self.setData({
isPublicCode: false
})
}
},
function (code, data) {
app.dialog.msg(data.msg);
},
function () {
wx.stopPullDownRefresh();
// wx.hideLoading();
});
},
}) setVideoUrl(e) {
audioContentx.onTimeUpdate(function () { var _self = this;
const currentTime = audioContentx.currentTime * 1000 var item = e.currentTarget.dataset.item
_self.setData({ var index = e.currentTarget.dataset.index
duration: audioContentx.duration * 1000, this.setData({
currentTime: currentTime, currentVideoUrl: _self.data.imgUrl + item.contentFileFileId,
sliderValue: audioContentx.currentTime, currentDesc: item.contentFileText,
totalValue: audioContentx.duration currentVideoIndex: index
}) })
},
//初始化音频播放器
initAudio() {
var _self = this;
audioContentx = wx.createInnerAudioContext();
}); audioContentx.src = _self.data.currentAudioUrl;
audioContentx.onStop(() => { // 准备好歌曲流,可以播放
_self.setData({ audioContentx.onCanplay(() => {
isPlaying: false, _self.setData({
sliderValue: 0, canPlay: true,
}) duration: audioContentx.duration * 1000
}); })
audioContentx.onEnded(() => { console.log(audioContentx.duration)
_self.setData({
isPlaying: false,
sliderValue: 0,
})
});
audioContentx.onPlay(() => {
_self.setData({
isPlaying: true,
})
});
audioContentx.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
}, })
playAudio() { audioContentx.onTimeUpdate(function () {
if (audioContentx && audioContentx.paused) { const currentTime = audioContentx.currentTime * 1000
audioContentx.stop(); _self.setData({
audioContentx.play(); duration: audioContentx.duration * 1000,
this.setData({ currentTime: currentTime,
isPlaying: true sliderValue: audioContentx.currentTime,
}) totalValue: audioContentx.duration
} else { })
audioContentx.pause();
this.setData({ });
isPlaying: false audioContentx.onStop(() => {
}) _self.setData({
} isPlaying: false,
}, sliderValue: 0,
//下一个音频 })
nextAudio() { });
var _self = this; audioContentx.onEnded(() => {
var index = _self.data.currentAudioIndex + 1 _self.setData({
if (index >= _self.data.newsBean.fileList.length) { isPlaying: false,
index = _self.data.newsBean.fileList.length - 1 sliderValue: 0,
var item = _self.data.newsBean.fileList[index] })
_self.setData({ });
currentAudioIndex: index, audioContentx.onPlay(() => {
sliderValue: 0, _self.setData({
currentAudioDesc: item.contentFileText isPlaying: true,
}) })
if (audioContentx) { });
audioContentx.stop() audioContentx.onError((res) => {
audioContentx.src = _self.data.imgUrl + item.contentFileFileId console.log(res.errMsg)
audioContentx.play() console.log(res.errCode)
} })
} else {
var item = _self.data.newsBean.fileList[index] },
_self.setData({ move() {
currentAudioIndex: index,
sliderValue: 0, },
currentAudioDesc: item.contentFileText
}) goAttention() {
if (audioContentx) { wx.navigateTo({
audioContentx.stop() url: '/pages/commonQrCode/commonQrCode',
audioContentx.src = _self.data.imgUrl + item.contentFileFileId })
audioContentx.play() },
} playAudio() {
} if (audioContentx && audioContentx.paused) {
}, audioContentx.stop();
setAudioUrl(e) { audioContentx.play();
var _self = this; this.setData({
var item = e.currentTarget.dataset.item isPlaying: true
var index = e.currentTarget.dataset.index })
if (audioContentx) { } else {
audioContentx.stop() audioContentx.pause();
audioContentx.src = _self.data.imgUrl + item.contentFileFileId; this.setData({
audioContentx.play() isPlaying: false
this.setData({ })
currentAudioIndex: index, }
sliderValue: 0 },
}) //下一个音频
} nextAudio() {
}, var _self = this;
//上一个音频 var index = _self.data.currentAudioIndex + 1
preAudio() { if (index >= _self.data.newsBean.fileList.length) {
var _self = this; index = _self.data.newsBean.fileList.length - 1
var index = _self.data.currentAudioIndex - 1 var item = _self.data.newsBean.fileList[index]
if (index <= 0) { _self.setData({
index = 0 currentAudioIndex: index,
var item = _self.data.newsBean.fileList[index] sliderValue: 0,
_self.setData({ currentAudioDesc: item.contentFileText
currentAudioIndex: index, })
sliderValue: 0, if (audioContentx) {
currentAudioDesc: item.contentFileText audioContentx.stop()
}) audioContentx.src = _self.data.imgUrl + item.contentFileFileId
if (audioContentx) { audioContentx.play()
audioContentx.stop() }
audioContentx.src = _self.data.imgUrl + item.contentFileFileId } else {
audioContentx.play() var item = _self.data.newsBean.fileList[index]
} _self.setData({
} else { currentAudioIndex: index,
var item = _self.data.newsBean.fileList[index] sliderValue: 0,
_self.setData({ currentAudioDesc: item.contentFileText
currentAudioIndex: index, })
sliderValue: 0, if (audioContentx) {
currentAudioDesc: item.contentFileText audioContentx.stop()
}) audioContentx.src = _self.data.imgUrl + item.contentFileFileId
if (audioContentx) { audioContentx.play()
audioContentx.stop() }
audioContentx.src = _self.data.imgUrl + item.contentFileFileId }
audioContentx.play() },
} setAudioUrl(e) {
} var _self = this;
}, var item = e.currentTarget.dataset.item
//slider进度调整 var index = e.currentTarget.dataset.index
handleSliderChange(event) { if (audioContentx) {
this.setData({ audioContentx.stop()
currentTime: event.detail.value * 1000 audioContentx.src = _self.data.imgUrl + item.contentFileFileId;
}) audioContentx.play()
audioContentx.pause() this.setData({
audioContentx.seek(event.detail.value) currentAudioIndex: index,
audioContentx.play() sliderValue: 0
}, })
onUnload() { }
if (audioContentx) { },
audioContentx.stop(); //上一个音频
audioContentx.destroy(); preAudio() {
} var _self = this;
} var index = _self.data.currentAudioIndex - 1
if (index <= 0) {
index = 0
var item = _self.data.newsBean.fileList[index]
_self.setData({
currentAudioIndex: index,
sliderValue: 0,
currentAudioDesc: item.contentFileText
})
if (audioContentx) {
audioContentx.stop()
audioContentx.src = _self.data.imgUrl + item.contentFileFileId
audioContentx.play()
}
} else {
var item = _self.data.newsBean.fileList[index]
_self.setData({
currentAudioIndex: index,
sliderValue: 0,
currentAudioDesc: item.contentFileText
})
if (audioContentx) {
audioContentx.stop()
audioContentx.src = _self.data.imgUrl + item.contentFileFileId
audioContentx.play()
}
}
},
//slider进度调整
handleSliderChange(event) {
this.setData({
currentTime: event.detail.value * 1000
})
audioContentx.pause()
audioContentx.seek(event.detail.value)
audioContentx.play()
},
onUnload() {
if (audioContentx) {
audioContentx.stop();
audioContentx.destroy();
}
}
}) })

View File

@ -1,84 +1,89 @@
<wxs src="/utils/utils.wxs" module="format"></wxs> <wxs src="/utils/utils.wxs" module="format"></wxs>
<!-- 是否需要关注公众号 -->
<view wx:if="{{isPublicCode}}" class="page-mask" catch:touchmove="move">
<view class="mask-hint">关注公众号即可阅读</view>
<view class="mask-btn" bind:tap="goAttention">去关注</view>
</view>
<view wx:if="{{newsBean}}"> <view wx:if="{{newsBean}}">
<!-- newsContentType 1 文章 2图片 3音频 4视频 5PDF 6链接 --> <!-- newsContentType 1 文章 2图片 3音频 4视频 5PDF 6链接 -->
<!-- 文章 --> <!-- 文章 -->
<view wx:if="{{newsBean.newsContentType=='1'}}"> <view wx:if="{{newsBean.newsContentType=='1'}}">
<view class="news-title">{{newsBean.newsContentTitle}}</view> <view class="news-title">{{newsBean.newsContentTitle}}</view>
<view class="news-attr-box"> <view class="news-attr-box">
<view class="news-attr">新闻来源:{{newsBean.newsContentResource}}</view> <view class="news-attr">新闻来源:{{newsBean.newsContentResource}}</view>
<view class="news-attr">发布时间:{{newsBean.newsContentPublishTime}}</view> <view class="news-attr">发布时间:{{newsBean.newsContentPublishTime}}</view>
</view> </view>
<view class="news-content"> <view class="news-content">
<rich-text nodes="{{newsBean.newsContentContent}}"></rich-text> <rich-text nodes="{{newsBean.newsContentContent}}"></rich-text>
</view> </view>
</view> </view>
<!-- 图片 --> <!-- 图片 -->
<view wx:elif="{{newsBean.newsContentType=='2'}}"> <view wx:elif="{{newsBean.newsContentType=='2'}}">
<view class="img-box" style="height: {{pageHeight}}px;"> <view class="img-box" style="height: {{pageHeight}}px;">
<swiper autoplay="true" interval="10000" style="width: 100%;height: {{pageHeight}}px;"> <swiper autoplay="true" interval="10000" style="width: 100%;height: {{pageHeight}}px;">
<swiper-item class="swiper-item" wx:for="{{newsBean.fileList}}" wx:for-item="item" wx:key="index"> <swiper-item class="swiper-item" wx:for="{{newsBean.fileList}}" wx:for-item="item" wx:key="index">
<image style="width: 100%;height: 500rpx;" src="{{imgUrl+item.contentFileFileId}}" mode="aspectFit"></image> <image style="width: 100%;height: 500rpx;" src="{{imgUrl+item.contentFileFileId}}" mode="aspectFit"></image>
<view class="item-txt"> <view class="item-txt">
<custom-content content="{{item.contentFileText}}" maxline="2" position="right" foldable="true"></custom-content> <custom-content content="{{item.contentFileText}}" maxline="2" position="right" foldable="true"></custom-content>
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
</view> </view>
<!-- 音频 --> <!-- 音频 -->
<view wx:elif="{{newsBean.newsContentType=='3'}}"> <view wx:elif="{{newsBean.newsContentType=='3'}}">
<view class="audio-box"> <view class="audio-box">
<view class="audio-img"> <view class="audio-img">
<image class="img-bg" src="/images/ic_audio_bg.png" mode="scaleToFill"></image> <image class="img-bg" src="/images/ic_audio_bg.png" mode="scaleToFill"></image>
<image class="img-loading" wx:if="{{!canPlay}}" src="/images/loading-small.gif" mode="scaleToFill"></image> <image class="img-loading" wx:if="{{!canPlay}}" src="/images/loading-small.gif" mode="scaleToFill"></image>
</view> </view>
<view class="progress"> <view class="progress">
<view class="current">{{format.formatDuration(currentTime)}}</view> <view class="current">{{format.formatDuration(currentTime)}}</view>
<slider class="slider" block-size="{{16}}" value="{{sliderValue}}" bindchange="handleSliderChange" max="{{totalValue}}"></slider> <slider class="slider" block-size="{{16}}" value="{{sliderValue}}" bindchange="handleSliderChange" max="{{totalValue}}"></slider>
<view class="duration">{{format.formatDuration(duration)}}</view> <view class="duration">{{format.formatDuration(duration)}}</view>
</view> </view>
<view class="option"> <view class="option">
<image class="btn btn-prev" src="/images/play_prev.png" bindtap="preAudio"> </image> <image class="btn btn-prev" src="/images/play_prev.png" bindtap="preAudio"> </image>
<image class="btn btn-pause" src="{{isPlaying?'/images/play_pause.png':'/images/play_resume.png'}}" bindtap="playAudio"> </image> <image class="btn btn-pause" src="{{isPlaying?'/images/play_pause.png':'/images/play_resume.png'}}" bindtap="playAudio"> </image>
<image class="btn btn-next" src="/images/play_next.png" bindtap="nextAudio"> </image> <image class="btn btn-next" src="/images/play_next.png" bindtap="nextAudio"> </image>
</view> </view>
<view class="category-title">目录</view> <view class="category-title">目录</view>
<view class="video-category"> <view class="video-category">
<view class="category-item {{index==currentAudioIndex? 'category-item-sel':''}}" wx:for="{{newsBean.fileList}}" wx:for-item="item" wx:key="index" bindtap="setAudioUrl" data-index="{{index}}" data-item="{{item}}"> <view class="category-item {{index==currentAudioIndex? 'category-item-sel':''}}" wx:for="{{newsBean.fileList}}" wx:for-item="item" wx:key="index" bindtap="setAudioUrl" data-index="{{index}}" data-item="{{item}}">
<view>{{index+1}}</view> <view>{{index+1}}</view>
</view> </view>
</view> </view>
</view> </view>
<view class="flex desc-box"> <view class="flex desc-box">
<view>|</view> <view>|</view>
<view style="margin-left: 10rpx;color: #242424;">详情</view> <view style="margin-left: 10rpx;color: #242424;">详情</view>
</view> </view>
<view class="desc">{{currentAudioDesc}}</view> <view class="desc">{{currentAudioDesc}}</view>
</view> </view>
<!-- 视频 --> <!-- 视频 -->
<view wx:elif="{{newsBean.newsContentType=='4'}}"> <view wx:elif="{{newsBean.newsContentType=='4'}}">
<view class="video-box"> <view class="video-box">
<video src="{{currentVideoUrl}}"></video> <video src="{{currentVideoUrl}}"></video>
<view class="category-title">目录</view> <view class="category-title">目录</view>
<view class="video-category"> <view class="video-category">
<view class="category-item {{index==currentVideoIndex? 'category-item-sel':''}}" wx:for="{{newsBean.fileList}}" wx:for-item="item" wx:key="index" bindtap="setVideoUrl" data-index="{{index}}" data-item="{{item}}"> <view class="category-item {{index==currentVideoIndex? 'category-item-sel':''}}" wx:for="{{newsBean.fileList}}" wx:for-item="item" wx:key="index" bindtap="setVideoUrl" data-index="{{index}}" data-item="{{item}}">
<view>{{index+1}}</view> <view>{{index+1}}</view>
</view> </view>
</view> </view>
</view> </view>
<view class="flex desc-box"> <view class="flex desc-box">
<view>|</view> <view>|</view>
<view style="margin-left: 10rpx;color: #242424;">详情</view> <view style="margin-left: 10rpx;color: #242424;">详情</view>
</view> </view>
<view class="desc">{{currentDesc}}</view> <view class="desc">{{currentDesc}}</view>
</view> </view>
<!-- PDF --> <!-- PDF -->
<view wx:elif="{{newsBean.newsContentType=='5'}}"> <view wx:elif="{{newsBean.newsContentType=='5'}}">
<web-view src="{{newsBean.newsContentLink}}"></web-view> <web-view src="{{newsBean.newsContentLink}}"></web-view>
</view> </view>
<!-- 链接 --> <!-- 链接 -->
<view wx:elif="{{newsBean.newsContentType=='6'}}"> <view wx:elif="{{newsBean.newsContentType=='6'}}">
<web-view src="{{newsBean.newsContentContent}}"></web-view> <web-view src="{{newsBean.newsContentContent}}"></web-view>
</view> </view>
</view> </view>
<page-loading wx:else></page-loading> <page-loading wx:else></page-loading>

View File

@ -1,201 +1,238 @@
/* page{ page {
background: #d2e0f6; width: 100%;
} */ height: 100%;
}
.news-title { .news-title {
padding: 20rpx 30rpx; padding: 20rpx 30rpx;
font-size: 34rpx; font-size: 34rpx;
font-weight: bold; font-weight: bold;
color: #242424; color: #242424;
text-align: center; text-align: center;
} }
.news-attr-box { .news-attr-box {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.news-attr { .news-attr {
font-size: 24rpx; font-size: 24rpx;
color: #949494; color: #949494;
} }
.news-attr:nth-of-type(n+2) { .news-attr:nth-of-type(n+2) {
margin-left: 20rpx; margin-left: 20rpx;
} }
.news-content { .news-content {
padding: 20rpx 20rpx; padding: 20rpx 20rpx;
font-size: 34rpx; font-size: 34rpx;
color: #242424; color: #242424;
} }
.img-box { .img-box {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background: black; background: black;
} }
.swiper-item { .swiper-item {
width: 100%; width: 100%;
height: 100%; height: 100%;
position: absolute; position: absolute;
transform: translate(0%, 0px) translateZ(0px); transform: translate(0%, 0px) translateZ(0px);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.item-txt { .item-txt {
position: absolute; position: absolute;
color: white; color: white;
font-size: 24rpx; font-size: 24rpx;
bottom: 0rpx; bottom: 0rpx;
} }
.video-box { .video-box {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: flex-start;
align-items: flex-start; align-items: flex-start;
background: #242424; background: #242424;
} }
.video-box video { .video-box video {
width: 100%; width: 100%;
} }
.video-category { .video-category {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: flex-start; justify-content: flex-start;
align-items: flex-start; align-items: flex-start;
padding-bottom: 30rpx; padding-bottom: 30rpx;
margin: 20rpx; margin: 20rpx;
flex-wrap: wrap; flex-wrap: wrap;
} }
.category-title { .category-title {
font-size: 34rpx; font-size: 34rpx;
color: white; color: white;
align-self: center; align-self: center;
margin-top: 20rpx; margin-top: 20rpx;
} }
.category-item { .category-item {
font-size: 30rpx; font-size: 30rpx;
color: white; color: white;
border: 1rpx solid #949494; border: 1rpx solid #949494;
padding: 20rpx; padding: 20rpx;
margin: 5rpx; margin: 5rpx;
} }
.category-item-sel { .category-item-sel {
border: 1rpx solid #f30000; border: 1rpx solid #f30000;
color: #f30000; color: #f30000;
background: #97979741; background: #97979741;
} }
.desc-box { .desc-box {
color: #f30000; color: #f30000;
margin-top: 40rpx; margin-top: 40rpx;
padding-left: 20rpx; padding-left: 20rpx;
} }
.desc { .desc {
font-size: 28rpx; font-size: 28rpx;
color: #242424; color: #242424;
padding: 30rpx 40rpx; padding: 30rpx 40rpx;
} }
.audio-box { .audio-box {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: flex-start; align-items: flex-start;
background: black; background: black;
color: white; color: white;
} }
.audio-img { .audio-img {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: 100%; width: 100%;
height: 400rpx; height: 400rpx;
} }
.img-bg { .img-bg {
width: 100%; width: 100%;
height: 400rpx; height: 400rpx;
} }
.img-loading { .img-loading {
width: 200rpx; width: 200rpx;
height: 200rpx; height: 200rpx;
position: absolute; position: absolute;
top: calc(50%-50rpx); top: calc(50%-50rpx);
left: calc(50%-50rpx); left: calc(50%-50rpx);
} }
.progress { .progress {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: 100%; width: 100%;
} }
.slider { .slider {
margin: 10rpx; margin: 10rpx;
width: 50%; width: 50%;
} }
.option { .option {
display: flex; display: flex;
flex: 1; flex: 1;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding-bottom: 20rpx; padding-bottom: 20rpx;
width: 70%; width: 70%;
align-self: center; align-self: center;
margin-top: 20rpx; margin-top: 20rpx;
} }
.btn-mode, .btn-mode,
.btn-music { .btn-music {
width: 70rpx; width: 70rpx;
height: 70rpx; height: 70rpx;
} }
.btn-prev, .btn-prev,
.btn-next { .btn-next {
width: 70rpx; width: 70rpx;
height: 70rpx; height: 70rpx;
} }
.btn-pause { .btn-pause {
width: 140rpx; width: 140rpx;
height: 140rpx; height: 140rpx;
} }
.current { .current {
font-size: 28rpx; font-size: 28rpx;
margin-right: 30rpx; margin-right: 30rpx;
} }
.duration { .duration {
font-size: 28rpx; font-size: 28rpx;
margin-left: 30rpx; margin-left: 30rpx;
} }
.btn { .btn {
width: 64rpx; width: 64rpx;
height: 64rpx; height: 64rpx;
}
.page-mask {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
position: fixed;
top: 0;
left: 0;
z-index: 99999999;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
backdrop-filter: blur(10rpx);
}
.mask-btn {
background-color: #4CAF50;
border: none;
color: white;
padding: 10rpx 80rpx;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 26rpx;
margin-top: 30rpx;
border-radius: 10rpx;
}
.mask-hint {
font-size: 40rpx;
color: #ffffff;
font-weight: bold;
text-align: center;
} }

View File

@ -34,7 +34,7 @@ Page({
function (code, data) { function (code, data) {
app.dialog.msg(data.msg); app.dialog.msg(data.msg);
}, },
function () {}); function () { });
}, },
doClickDictionaries: function (event) { doClickDictionaries: function (event) {
var self = this; var self = this;
@ -73,7 +73,6 @@ Page({
currentPage: page, currentPage: page,
'news.newsList': newsArray 'news.newsList': newsArray
}) })
console.log(self.data.news.newsList)
if (data.rows.length == 0) { if (data.rows.length == 0) {
app.dialog.msg('暂无数据'); app.dialog.msg('暂无数据');
return; return;
@ -137,5 +136,11 @@ Page({
self.doGetNewsDictionariesList(); self.doGetNewsDictionariesList();
self.getAreaList(); self.getAreaList();
}, },
onReachBottom() {
this.setData({
currentPage: this.data.currentPage + 1
})
this.doGetNewsList(this.data.currentPage)
}
}) })

View File

@ -229,6 +229,7 @@ module.exports.file = postFile;
// module.exports.url="http://v3.xzszwhy.cn/"; // module.exports.url="http://v3.xzszwhy.cn/";
module.exports.baseUrl = 'https://www.xzszwhy.cn/xzszwhy'; module.exports.baseUrl = 'https://www.xzszwhy.cn/xzszwhy';
module.exports.url = "https://www.xzszwhy.cn/"; module.exports.url = "https://www.xzszwhy.cn/";
module.exports.wssUrl="wss://www.xzszwhy.cn/xzszwhy";
// module.exports.baseUrl = 'http://192.168.0.120:8081/xzszwhy'; // module.exports.baseUrl = 'http://192.168.0.120:8081/xzszwhy';
// module.exports.url = "http://192.168.0.120:8081/"; // module.exports.url = "http://192.168.0.120:8081/";