From fb920b2ff8b0e1980d736c3e23a67ffc70724ae5 Mon Sep 17 00:00:00 2001 From: itgaojian Date: Thu, 27 Jul 2023 14:28:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=85=AC=E4=BC=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 125 ++--- app.json | 3 +- images/app_logo.png | Bin 0 -> 7466 bytes pages/center/center.js | 7 +- pages/center/center.wxml | 2 +- pages/commonQrCode/commonQrCode.js | 98 ++++ pages/commonQrCode/commonQrCode.json | 3 + pages/commonQrCode/commonQrCode.wxml | 15 + pages/commonQrCode/commonQrCode.wxss | 80 +++ pages/index/index.js | 780 ++++++++++++++------------- pages/index/index.wxml | 82 +-- pages/index/index.wxss | 22 +- pages/newsDetail/newsDetail.js | 503 +++++++++-------- pages/newsDetail/newsDetail.wxml | 165 +++--- pages/newsDetail/newsDetail.wxss | 261 +++++---- pages/newsList/newsList.js | 9 +- utils/restAjax.js | 1 + 17 files changed, 1246 insertions(+), 910 deletions(-) create mode 100644 images/app_logo.png create mode 100644 pages/commonQrCode/commonQrCode.js create mode 100644 pages/commonQrCode/commonQrCode.json create mode 100644 pages/commonQrCode/commonQrCode.wxml create mode 100644 pages/commonQrCode/commonQrCode.wxss diff --git a/app.js b/app.js index adf56dc..2b053e6 100644 --- a/app.js +++ b/app.js @@ -4,67 +4,70 @@ var dialog = require('utils/dialog.js'); var utils = require('utils/util.js'); // + 'https://www.xzszwhy.cn/usercenter' App({ - loginUrl: restAjax.baseUrl, - usercenterUrl: restAjax.baseUrl, - newsUrl: restAjax.baseUrl, - newsContentUrl: restAjax.url, - libraryUrl: restAjax.baseUrl, - venueUrl: restAjax.baseUrl, - activityUrl: restAjax.baseUrl, - volunteerUrl: restAjax.baseUrl, - activityUrl: restAjax.baseUrl, - volunteerUrl: restAjax.baseUrl, - liveUrl: restAjax.url + 'live', - liveRecordUrl: restAjax.baseUrl, - socialUrl: restAjax.baseUrl, - areaCode: '540200000000', - areaName: '日喀则市', - areaId: '640675', - shopUrl: restAjax.url + "xzshop", - bigDataUrl: restAjax.url + "module", - restAjax: restAjax, - shopImgUrl: restAjax.url + "xzshop/route/file/download/true/", - imgUrl: restAjax.baseUrl + "/route/file/download/true/", - liveImgUrl: restAjax.url + "live/route/file/download/true/", - dialog: dialog, - utils: utils, - onLaunch: function () { - // 展示本地存储能力 - var logs = wx.getStorageSync('logs') || [] - logs.unshift(Date.now()) - wx.setStorageSync('logs', logs) + loginUrl: restAjax.baseUrl, + usercenterUrl: restAjax.baseUrl, + newsUrl: restAjax.baseUrl, + newsContentUrl: restAjax.url, + libraryUrl: restAjax.baseUrl, + venueUrl: restAjax.baseUrl, + activityUrl: restAjax.baseUrl, + volunteerUrl: restAjax.baseUrl, + activityUrl: restAjax.baseUrl, + volunteerUrl: restAjax.baseUrl, + liveUrl: restAjax.url + 'live', + liveRecordUrl: restAjax.baseUrl, + socialUrl: restAjax.baseUrl, + areaCode: '540200000000', + areaName: '日喀则市', + areaId: '640675', + appId: 'wxa5c5246b283713de', + shopUrl: restAjax.url + "xzshop", + bigDataUrl: restAjax.url + "module", + restAjax: restAjax, + shopImgUrl: restAjax.url + "xzshop/route/file/download/true/", + imgUrl: restAjax.baseUrl + "/route/file/download/true/", + liveImgUrl: restAjax.url + "live/route/file/download/true/", + dialog: dialog, + utils: utils, + wssUrl: restAjax.wssUrl, + onLaunch: function () { + // 展示本地存储能力 + var logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) - // 登录 - wx.login({ - success: res => { - // 发送 res.code 到后台换取 openId, sessionKey, unionId - } - }) - // 获取用户信息 - wx.getSetting({ - success: res => { - if (res.authSetting['scope.userInfo']) { - // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 - wx.getUserInfo({ - success: res => { - // 可以将 res 发送给后台解码出 unionId - this.globalData.userInfo = res.userInfo + // 登录 + wx.login({ + success: res => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + } + }) + // 获取用户信息 + wx.getSetting({ + success: res => { + if (res.authSetting['scope.userInfo']) { + // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 + wx.getUserInfo({ + success: res => { + // 可以将 res 发送给后台解码出 unionId + this.globalData.userInfo = res.userInfo - // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 - // 所以此处加入 callback 以防止这种情况 - if (this.userInfoReadyCallback) { - this.userInfoReadyCallback(res) - } - } - }) - } - } - }) - }, - globalData: { - userInfo: null, - curLat: -1, - curLng: -1, - carList: [] - } + // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 + // 所以此处加入 callback 以防止这种情况 + if (this.userInfoReadyCallback) { + this.userInfoReadyCallback(res) + } + } + }) + } + } + }) + }, + globalData: { + userInfo: null, + curLat: -1, + curLng: -1, + carList: [], + isPublic: false,//是否关注了公众号 + } }) \ No newline at end of file diff --git a/app.json b/app.json index 20ef3a9..4ec760c 100644 --- a/app.json +++ b/app.json @@ -38,7 +38,8 @@ "pages/myVolunteerTeam/myVolunteerTeam", "pages/myVolunteerActivity/myVolunteerActivity", "pages/serviceActivityDetail/serviceActivityDetail", - "pages/shop/shopcategory" + "pages/shop/shopcategory", + "pages/commonQrCode/commonQrCode" ], "subPackages": [ { diff --git a/images/app_logo.png b/images/app_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..eff4db2aa0dfc48d2c61114756d55872076a1e91 GIT binary patch literal 7466 zcmV+_9o6EAP)P^rVio|u|J`rC>3{s+|N5qX{q@)1{M&x_-+%wJZ~DLf&5y&qyHW{ba#ZEvEel2#ic!UAm8!^l z+iTiutDt0$Ckx9_l!vtp7+L!?nqvqQxSifMaNnx1M6K6|4LhLRyj8%+28{$x77P!< z3?L(xu6<5rAP_JQC=YF!Jfmu(s&*=(P8C2#K&cK4S^IVJlg;f)FtV!AY*6&`MgYN{ zv0fu;B0U1iN#r-RtH2OAR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@h`lI#xT75xe@vTz_EUPZIlH8{4ZM+A~c5{A;Mt}4r;Nv-t?c9478<(u}wbhiwn;&}w9MUYS70E}iih&~tL*gZR zpH|_z+Cp)!OG$8U#e!tjO5m$iWv5DT z*X{(2E+4^L9C&RW7jEQtJemABIHb*(A7M}s5|m&qp|c>lV&+|LcOAJOL;7xY$f`zm zZIxEF(sB>ZLvA_Wk!@Z+l7$3)DBn1vC3HPddfz{Iy4@|+Xm+PM_~8vuY^AkrJ|-#e zwHZk}jx_i)gTf_Z?7P(DO}(NTR)FKcC$AAeP*JjQJPwf7EUT4)1ZUJa-{4ZAHOXXE zxeh3GFsu?T=8LWOl!d{_!g1*;-Pz5{N1|Wr#wUv{6+h)7bMw^!r3OZ%;1Vg%BCu~x2GF$)sUc6}Ns zJurH3c4R<-IQ;E>i+lIZBAm4F$XOm2eP?&TnTa~g5lye&vt3s*Oos-RYe2l3TWhWGC)+-!aCo) zsMM-l@qmTD_vSf14i0G^B$c&Wa*;4M;eWaErM;Jv|EvY`tQo?S?d`o$t5ku4RXM64 zoQL!VAzl)6;BZd*s#K^N z2arUIK*DMgslaHj;Td|&OITHKSw*GlbH{E0!jr8PRcY7gSgJ*>2MMc5G@*{XhV2F? z^_cW?)8| z4NXR)m7rwQ1^~RVxl9I#Oisa2956ntjevr{SkUx>dLV`W(Z%&v|(#R22ADecL?93W2H(ioUKfP?#SU^wk| o4M%AWo>72!Tl{&ukN<7$&+EO8TRb3;m;e9(07*qoM6N<$f*LLXW&i*H literal 0 HcmV?d00001 diff --git a/pages/center/center.js b/pages/center/center.js index b77a26e..a7b4005 100644 --- a/pages/center/center.js +++ b/pages/center/center.js @@ -64,7 +64,7 @@ Page({ // 上传 uploadAvatar: function (avatarId) { 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 }, { headers: { @@ -246,6 +246,11 @@ Page({ }) self.getUserInfo() app.dialog.msg('绑定成功'); + },function(code,error){ + self.setData({ + isLoading: false + }) + app.dialog.msg(error.msg) }) } else { self.setData({ diff --git a/pages/center/center.wxml b/pages/center/center.wxml index fd29c68..3dc4711 100644 --- a/pages/center/center.wxml +++ b/pages/center/center.wxml @@ -3,7 +3,7 @@ - + {{userInfo.name}} diff --git a/pages/commonQrCode/commonQrCode.js b/pages/commonQrCode/commonQrCode.js new file mode 100644 index 0000000..bebae40 --- /dev/null +++ b/pages/commonQrCode/commonQrCode.js @@ -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() { + + }, +}) \ No newline at end of file diff --git a/pages/commonQrCode/commonQrCode.json b/pages/commonQrCode/commonQrCode.json new file mode 100644 index 0000000..3928faa --- /dev/null +++ b/pages/commonQrCode/commonQrCode.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/commonQrCode/commonQrCode.wxml b/pages/commonQrCode/commonQrCode.wxml new file mode 100644 index 0000000..00f171b --- /dev/null +++ b/pages/commonQrCode/commonQrCode.wxml @@ -0,0 +1,15 @@ + + + + + + {{title}} + {{desc}} + + + + {{hint}} + + + + \ No newline at end of file diff --git a/pages/commonQrCode/commonQrCode.wxss b/pages/commonQrCode/commonQrCode.wxss new file mode 100644 index 0000000..eae47db --- /dev/null +++ b/pages/commonQrCode/commonQrCode.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index ef34150..9b1c62a 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1,382 +1,410 @@ 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, - bigDataUrl: app.bigDataUrl, - isConfirm: false, - mainFuncList: [], - mainNewTab: [], - isHide: true - }, - doLogin: function () { - var self = this; - wx.login({ - success(res) { - if (res.code) { - wx.setStorageSync('token', 'REQ5NW5IZTZjS2ZyQU9QQmFKZ1FIRmVhbjNFZmV4dEx3emdob2g5UjVXaForWGdpOHFIRWgyTWRIelJFWkhNS28wN1hUV2Uwb0FKSUEra2wzYVhXdnI4aG9odkxLd3ZFUGkrTTQwQTkzdyt3cnN3NkY4OE9aaGw0aUJPTUNSaENKbGxTdm8xR3Z5WTJBV0NDcWRpbEd3OW0zUzA3US8xMmUyaTU2a0N4YmN5d1FjTXd6aTZIZkhhdmpsSDlqYSt0OUJVUHRSbTJqSVd6eHlYc1M5WTlkK015MVR2R083T3crU2wrdVFmVGk4N3NHWmZNY1A3SGNNbm8xMDFMTy9tcTN2K0NuQTZJbk9YZGJqK3drQkxlMXNUVjZZNkZyRE9LMGdYdUQzSE9lbDQ9'); - 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/listsub/areaauth/release/{newsDirectoriesId}/{areaCode}', [_self.data.news.newsUrl, '0', 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: "", - newsDirectoriesParentId: 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/{areaCode}', [self.data.news.newsUrl, app.areaCode]), { - 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/{areaCode}', [self.data.venue.venueUrl, app.areaCode]), { - 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); - }); - }, - //加载活动图片错误 - loadImgErr(e) { - console.log(e) - var index = e.currentTarget.dataset.index - this.data.activity.activityList[index].activityImageArray.unshift("03c2ea0d-87ad-43db-bba0-ae6b4f827dba") - this.setData({ - activity: this.data.activity - }) - }, - //加载轮播图错误 - loadBannerErr(e) { - var index = e.currentTarget.dataset.index - this.data.news.bannerList[index].newsContentCoverList.unshift('03c2ea0d-87ad-43db-bba0-ae6b4f827dba') - this.setData({ - news: this.data.news - }) - }, - doGetActivityList: function () { - var self = this; - app.restAjax.get(app.restAjax.path('{activityUrl}/app/activitylibrary/listpageactivitylibraryfornetrelease/{areaCode}', [self.data.activity.activityUrl, app.areaCode]), { - 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); - }); - }, + /** + * 页面的初始数据 + */ + 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, + bigDataUrl: app.bigDataUrl, + isConfirm: false, + mainFuncList: [], + mainNewTab: [], + isHide: true + }, + doLogin: function () { + var self = this; + wx.login({ + success(res) { + if (res.code) { + app.restAjax.post(app.restAjax.path('{url}/wechat-miniapp/sign/default-multi', [app.loginUrl]), { + jsCode: res.code, + appKey: app.appId + }, 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) + //获取UserID + self.getUserInfo(); + }, function (code, data) { + app.dialog.msg(data.msg); + }); + } else { + console.log(res) + app.dialog.msg('登录失败!' + res.errMsg); + } + } + }) + }, + // getUserInfo(){ + // var _self= this; + // // app/wxopen/qrcoderelease/{userId} + // app.restAjax.get(app.restAjax.path('{newsUrl}/app/user/get-app-user'),[_self.data.news.newsUrl]), + // null, + // null, + // function(code,data){ + // console.log(data) + // }, + // function(code,error){ + // app.dialog.msg(error.msg); + // } + // }, + //获取首页功能 + 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/listsub/areaauth/release/{newsDirectoriesId}/{areaCode}', [_self.data.news.newsUrl, '0', 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: "", + newsDirectoriesParentId: 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/{areaCode}', [self.data.news.newsUrl, app.areaCode]), { + 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/{areaCode}', [self.data.venue.venueUrl, app.areaCode]), { + 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); + }); + }, + //加载活动图片错误 + loadImgErr(e) { + console.log(e) + var index = e.currentTarget.dataset.index + this.data.activity.activityList[index].activityImageArray.unshift("03c2ea0d-87ad-43db-bba0-ae6b4f827dba") + this.setData({ + activity: this.data.activity + }) + }, + //加载轮播图错误 + loadBannerErr(e) { + var index = e.currentTarget.dataset.index + this.data.news.bannerList[index].newsContentCoverList.unshift('03c2ea0d-87ad-43db-bba0-ae6b4f827dba') + this.setData({ + news: this.data.news + }) + }, + doGetActivityList: function () { + var self = this; + app.restAjax.get(app.restAjax.path('{activityUrl}/app/activitylibrary/listpageactivitylibraryfornetrelease/{areaCode}', [self.data.activity.activityUrl, app.areaCode]), { + 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?id=' + event.currentTarget.dataset.item.newsContentId - }) - }, - 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.navigateTo({ - url: '/pages/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 - }) - self.doSaveLoginInfo(data.userId) - }, 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, { + goNewsDetail: function (event) { + wx.navigateTo({ + url: '../newsDetail/newsDetail?id=' + event.currentTarget.dataset.item.newsContentId + }) + }, + 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.navigateTo({ + url: '/pages/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/get-app-user', [app.usercenterUrl]), {}, { + headers: { + token: self.data.token + } + }, function (code, data) { + console.log(data); + app.globalData.userInfo = data; + self.setData({ + userInfo: data + }); + self.doSaveLoginInfo(data.userId); + self.getIsPublic(); + }, function (code, data) { + app.dialog.msg(data.msg); + }) + }, + //是否关注公众号 + getIsPublic() { + 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) { - }) - }, - 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(); - }, - onPageScroll(e) { - var _self = this; - if (e.scrollTop <= 96) { - //显示 - _self.setData({ - isHide: true - }) - } else { - //隐藏 - _self.setData({ - isHide: false - }) - } - }, - openSearch() { - wx.navigateTo({ - url: '/subpages/search/commonSearch', - }) - } + }, function (code, data) { + }) + }, + 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(); + }, + onPageScroll(e) { + var _self = this; + if (e.scrollTop <= 96) { + //显示 + _self.setData({ + isHide: true + }) + } else { + //隐藏 + _self.setData({ + isHide: false + }) + } + }, + openSearch() { + wx.navigateTo({ + url: '/subpages/search/commonSearch', + }) + } }) \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 20e3f79..c393f82 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -5,35 +5,37 @@ - - - - - - {{item.directoriesName}} + + + + + + {{item.directoriesName}} + + + + + 志愿者服务 + + + + 精彩活动 + + + + 场馆导航 + + + + 非遗文化 + + + + 直播点播 - - - - 志愿者服务 - - - 精彩活动 - - - - 场馆导航 - - - - 非遗文化 - - - - 直播点播 - - + + @@ -42,20 +44,22 @@ - - - - 场馆导航 - {{item.venueName}} - + + + + 场馆导航 + {{item.venueName}} + + + + 精彩活动 + {{item.activityTitle}} + + - - 精彩活动 - {{item.activityTitle}} - - - + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index 89e8ef7..768c5e8 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -34,9 +34,18 @@ swiper { .tab { padding: 30rpx; display: flex; - border-bottom: 5px solid #FBFBFB; 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 { @@ -56,14 +65,11 @@ swiper { .recommend { padding: 0rpx 30rpx 30rpx 30rpx; - border-bottom: 5px solid #FBFBFB; } .recommend-container { width: 100%; display: flex; - overflow-x: auto; - margin-top: 10rpx; } .line { @@ -72,6 +78,12 @@ swiper { background: #f2f2f2; } +.line-thick { + width: 100%; + height: 10rpx; + background: #f2f2f2; +} + .recommend-box { flex-shrink: 0; width: 220rpx; diff --git a/pages/newsDetail/newsDetail.js b/pages/newsDetail/newsDetail.js index f6ca00d..9f4ac38 100644 --- a/pages/newsDetail/newsDetail.js +++ b/pages/newsDetail/newsDetail.js @@ -3,243 +3,282 @@ var app = getApp(); var audioContentx = null; Page({ - /** - * 页面的初始数据 - */ - data: { - newsId: '', - newsBean: null, - imgUrl: app.imgUrl, - pageHeight: 500, - currentVideoUrl: '', - currentDesc: '', - currentVideoIndex: 0, - sliderValue: 0, - currentTime: 0, - duration: 0, - currentAudioIndex: 0, - currentAudioDesc: '', - canPlay: false, - isPlaying: false, - totalValue: 0, - }, + /** + * 页面的初始数据 + */ + data: { + newsId: '', + newsBean: null, + imgUrl: app.imgUrl, + pageHeight: 500, + currentVideoUrl: '', + currentDesc: '', + currentVideoIndex: 0, + sliderValue: 0, + currentTime: 0, + duration: 0, + currentAudioIndex: 0, + currentAudioDesc: '', + canPlay: false, + isPlaying: false, + totalValue: 0, + isPublicCode: false, + isPublic: false + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - this.setData({ - newsId: options.id, - pageHeight: wx.getSystemInfoSync().windowHeight - }) - 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) { + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + newsId: options.id, + pageHeight: wx.getSystemInfoSync().windowHeight, + isPublic: app.globalData.isPublic + }) - }, 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) { - }) - }, - 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(); + }, function (code, err) { - audioContentx.src = _self.data.currentAudioUrl; - // 准备好歌曲流,可以播放 - audioContentx.onCanplay(() => { - _self.setData({ - canPlay: true, - duration: audioContentx.duration * 1000 - }) - console.log(audioContentx.duration) + }) + }, + 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() + } + //判断是否需要关注公众号 + 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(); + }); + }, - }) - audioContentx.onTimeUpdate(function () { - const currentTime = audioContentx.currentTime * 1000 - _self.setData({ - duration: audioContentx.duration * 1000, - currentTime: currentTime, - sliderValue: audioContentx.currentTime, - totalValue: audioContentx.duration - }) + 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.onStop(() => { - _self.setData({ - isPlaying: false, - sliderValue: 0, - }) - }); - audioContentx.onEnded(() => { - _self.setData({ - isPlaying: false, - sliderValue: 0, - }) - }); - audioContentx.onPlay(() => { - _self.setData({ - isPlaying: true, - }) - }); - audioContentx.onError((res) => { - console.log(res.errMsg) - console.log(res.errCode) - }) + audioContentx.src = _self.data.currentAudioUrl; + // 准备好歌曲流,可以播放 + audioContentx.onCanplay(() => { + _self.setData({ + canPlay: true, + duration: audioContentx.duration * 1000 + }) + console.log(audioContentx.duration) - }, - playAudio() { - if (audioContentx && audioContentx.paused) { - audioContentx.stop(); - audioContentx.play(); - this.setData({ - isPlaying: true - }) - } else { - audioContentx.pause(); - this.setData({ - isPlaying: false - }) - } - }, - //下一个音频 - nextAudio() { - var _self = this; - var index = _self.data.currentAudioIndex + 1 - if (index >= _self.data.newsBean.fileList.length) { - index = _self.data.newsBean.fileList.length - 1 - 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() - } - } - }, - setAudioUrl(e) { - var _self = this; - var item = e.currentTarget.dataset.item - var index = e.currentTarget.dataset.index - if (audioContentx) { - audioContentx.stop() - audioContentx.src = _self.data.imgUrl + item.contentFileFileId; - audioContentx.play() - this.setData({ - currentAudioIndex: index, - sliderValue: 0 - }) - } - }, - //上一个音频 - 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(); - } - } + }) + audioContentx.onTimeUpdate(function () { + const currentTime = audioContentx.currentTime * 1000 + _self.setData({ + duration: audioContentx.duration * 1000, + currentTime: currentTime, + sliderValue: audioContentx.currentTime, + totalValue: audioContentx.duration + }) + + }); + audioContentx.onStop(() => { + _self.setData({ + isPlaying: false, + sliderValue: 0, + }) + }); + audioContentx.onEnded(() => { + _self.setData({ + isPlaying: false, + sliderValue: 0, + }) + }); + audioContentx.onPlay(() => { + _self.setData({ + isPlaying: true, + }) + }); + audioContentx.onError((res) => { + console.log(res.errMsg) + console.log(res.errCode) + }) + + }, + move() { + + }, + + goAttention() { + wx.navigateTo({ + url: '/pages/commonQrCode/commonQrCode', + }) + }, + playAudio() { + if (audioContentx && audioContentx.paused) { + audioContentx.stop(); + audioContentx.play(); + this.setData({ + isPlaying: true + }) + } else { + audioContentx.pause(); + this.setData({ + isPlaying: false + }) + } + }, + //下一个音频 + nextAudio() { + var _self = this; + var index = _self.data.currentAudioIndex + 1 + if (index >= _self.data.newsBean.fileList.length) { + index = _self.data.newsBean.fileList.length - 1 + 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() + } + } + }, + setAudioUrl(e) { + var _self = this; + var item = e.currentTarget.dataset.item + var index = e.currentTarget.dataset.index + if (audioContentx) { + audioContentx.stop() + audioContentx.src = _self.data.imgUrl + item.contentFileFileId; + audioContentx.play() + this.setData({ + currentAudioIndex: index, + sliderValue: 0 + }) + } + }, + //上一个音频 + 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(); + } + } }) \ No newline at end of file diff --git a/pages/newsDetail/newsDetail.wxml b/pages/newsDetail/newsDetail.wxml index dda1eb8..5cc0780 100644 --- a/pages/newsDetail/newsDetail.wxml +++ b/pages/newsDetail/newsDetail.wxml @@ -1,84 +1,89 @@ + + + 关注公众号即可阅读 + 去关注 + - - - - {{newsBean.newsContentTitle}} - - 新闻来源:{{newsBean.newsContentResource}} - 发布时间:{{newsBean.newsContentPublishTime}} - - - - - - - - - - - - - - - - - - - - - - - - - - - {{format.formatDuration(currentTime)}} - - {{format.formatDuration(duration)}} - - - - - - - 目录 - - - {{index+1}} - - - - - | - 详情 - - {{currentAudioDesc}} - - - - - - 目录 - - - {{index+1}} - - - - - | - 详情 - - {{currentDesc}} - - - - - - - - - + + + + {{newsBean.newsContentTitle}} + + 新闻来源:{{newsBean.newsContentResource}} + 发布时间:{{newsBean.newsContentPublishTime}} + + + + + + + + + + + + + + + + + + + + + + + + + + + {{format.formatDuration(currentTime)}} + + {{format.formatDuration(duration)}} + + + + + + + 目录 + + + {{index+1}} + + + + + | + 详情 + + {{currentAudioDesc}} + + + + + + 目录 + + + {{index+1}} + + + + + | + 详情 + + {{currentDesc}} + + + + + + + + + \ No newline at end of file diff --git a/pages/newsDetail/newsDetail.wxss b/pages/newsDetail/newsDetail.wxss index 92023be..6138bac 100644 --- a/pages/newsDetail/newsDetail.wxss +++ b/pages/newsDetail/newsDetail.wxss @@ -1,201 +1,238 @@ -/* page{ - background: #d2e0f6; -} */ +page { + width: 100%; + height: 100%; +} + .news-title { - padding: 20rpx 30rpx; - font-size: 34rpx; - font-weight: bold; - color: #242424; - text-align: center; + padding: 20rpx 30rpx; + font-size: 34rpx; + font-weight: bold; + color: #242424; + text-align: center; } .news-attr-box { - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; } .news-attr { - font-size: 24rpx; - color: #949494; + font-size: 24rpx; + color: #949494; } .news-attr:nth-of-type(n+2) { - margin-left: 20rpx; + margin-left: 20rpx; } .news-content { - padding: 20rpx 20rpx; - font-size: 34rpx; - color: #242424; + padding: 20rpx 20rpx; + font-size: 34rpx; + color: #242424; } .img-box { - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - background: black; + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + background: black; } .swiper-item { - width: 100%; - height: 100%; - position: absolute; - transform: translate(0%, 0px) translateZ(0px); - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; + width: 100%; + height: 100%; + position: absolute; + transform: translate(0%, 0px) translateZ(0px); + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; } .item-txt { - position: absolute; - color: white; - font-size: 24rpx; - bottom: 0rpx; + position: absolute; + color: white; + font-size: 24rpx; + bottom: 0rpx; } .video-box { - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - background: #242424; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + background: #242424; } .video-box video { - width: 100%; + width: 100%; } .video-category { - display: flex; - flex-direction: row; - justify-content: flex-start; - align-items: flex-start; - padding-bottom: 30rpx; - margin: 20rpx; - flex-wrap: wrap; + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: flex-start; + padding-bottom: 30rpx; + margin: 20rpx; + flex-wrap: wrap; } .category-title { - font-size: 34rpx; - color: white; - align-self: center; - margin-top: 20rpx; + font-size: 34rpx; + color: white; + align-self: center; + margin-top: 20rpx; } .category-item { - font-size: 30rpx; - color: white; - border: 1rpx solid #949494; - padding: 20rpx; - margin: 5rpx; + font-size: 30rpx; + color: white; + border: 1rpx solid #949494; + padding: 20rpx; + margin: 5rpx; } .category-item-sel { - border: 1rpx solid #f30000; - color: #f30000; - background: #97979741; + border: 1rpx solid #f30000; + color: #f30000; + background: #97979741; } .desc-box { - color: #f30000; - margin-top: 40rpx; - padding-left: 20rpx; + color: #f30000; + margin-top: 40rpx; + padding-left: 20rpx; } .desc { - font-size: 28rpx; - color: #242424; - padding: 30rpx 40rpx; + font-size: 28rpx; + color: #242424; + padding: 30rpx 40rpx; } .audio-box { - display: flex; - flex-direction: column; - justify-content: center; - align-items: flex-start; - background: black; - color: white; + display: flex; + flex-direction: column; + justify-content: center; + align-items: flex-start; + background: black; + color: white; } .audio-img { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: 400rpx; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + height: 400rpx; } .img-bg { - width: 100%; - height: 400rpx; + width: 100%; + height: 400rpx; } .img-loading { - width: 200rpx; - height: 200rpx; - position: absolute; - top: calc(50%-50rpx); - left: calc(50%-50rpx); + width: 200rpx; + height: 200rpx; + position: absolute; + top: calc(50%-50rpx); + left: calc(50%-50rpx); } .progress { - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - width: 100%; + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + width: 100%; } .slider { - margin: 10rpx; - width: 50%; + margin: 10rpx; + width: 50%; } .option { - display: flex; - flex: 1; - justify-content: space-between; - align-items: center; - padding-bottom: 20rpx; - width: 70%; - align-self: center; - margin-top: 20rpx; + display: flex; + flex: 1; + justify-content: space-between; + align-items: center; + padding-bottom: 20rpx; + width: 70%; + align-self: center; + margin-top: 20rpx; } .btn-mode, .btn-music { - width: 70rpx; - height: 70rpx; + width: 70rpx; + height: 70rpx; } .btn-prev, .btn-next { - width: 70rpx; - height: 70rpx; + width: 70rpx; + height: 70rpx; } .btn-pause { - width: 140rpx; - height: 140rpx; + width: 140rpx; + height: 140rpx; } .current { - font-size: 28rpx; - margin-right: 30rpx; + font-size: 28rpx; + margin-right: 30rpx; } .duration { - font-size: 28rpx; - margin-left: 30rpx; + font-size: 28rpx; + margin-left: 30rpx; } .btn { - width: 64rpx; - height: 64rpx; + width: 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; } \ No newline at end of file diff --git a/pages/newsList/newsList.js b/pages/newsList/newsList.js index 62f35b5..74f1e29 100644 --- a/pages/newsList/newsList.js +++ b/pages/newsList/newsList.js @@ -34,7 +34,7 @@ Page({ function (code, data) { app.dialog.msg(data.msg); }, - function () {}); + function () { }); }, doClickDictionaries: function (event) { var self = this; @@ -73,7 +73,6 @@ Page({ currentPage: page, 'news.newsList': newsArray }) - console.log(self.data.news.newsList) if (data.rows.length == 0) { app.dialog.msg('暂无数据'); return; @@ -137,5 +136,11 @@ Page({ self.doGetNewsDictionariesList(); self.getAreaList(); }, + onReachBottom() { + this.setData({ + currentPage: this.data.currentPage + 1 + }) + this.doGetNewsList(this.data.currentPage) + } }) \ No newline at end of file diff --git a/utils/restAjax.js b/utils/restAjax.js index 8b19796..b882982 100644 --- a/utils/restAjax.js +++ b/utils/restAjax.js @@ -229,6 +229,7 @@ module.exports.file = postFile; // module.exports.url="http://v3.xzszwhy.cn/"; module.exports.baseUrl = 'https://www.xzszwhy.cn/xzszwhy'; 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.url = "http://192.168.0.120:8081/"; \ No newline at end of file