完成公众号

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

5
app.js
View File

@ -20,6 +20,7 @@ App({
areaCode: '540200000000',
areaName: '日喀则市',
areaId: '640675',
appId: 'wxa5c5246b283713de',
shopUrl: restAjax.url + "xzshop",
bigDataUrl: restAjax.url + "module",
restAjax: restAjax,
@ -28,6 +29,7 @@ App({
liveImgUrl: restAjax.url + "live/route/file/download/true/",
dialog: dialog,
utils: utils,
wssUrl: restAjax.wssUrl,
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
@ -65,6 +67,7 @@ App({
userInfo: null,
curLat: -1,
curLng: -1,
carList: []
carList: [],
isPublic: false,//是否关注了公众号
}
})

View File

@ -38,7 +38,8 @@
"pages/myVolunteerTeam/myVolunteerTeam",
"pages/myVolunteerActivity/myVolunteerActivity",
"pages/serviceActivityDetail/serviceActivityDetail",
"pages/shop/shopcategory"
"pages/shop/shopcategory",
"pages/commonQrCode/commonQrCode"
],
"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) {
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({

View File

@ -3,7 +3,7 @@
</view>
<view class="page-container">
<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>
</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

@ -41,9 +41,9 @@ Page({
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
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('_');
@ -54,6 +54,8 @@ Page({
})
wx.setStorageSync('token', token);
wx.setStorageSync('isRandomUsername', isRandomUsername)
//获取UserID
self.getUserInfo();
}, function (code, data) {
app.dialog.msg(data.msg);
});
@ -64,6 +66,19 @@ Page({
}
})
},
// 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;
@ -296,19 +311,32 @@ Page({
// 获取用户信息
getUserInfo: function () {
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: {
token: self.data.token
}
}, function (code, data) {
console.log(data);
app.globalData.userInfo = data;
self.setData({
userInfo: data
})
self.doSaveLoginInfo(data.userId)
});
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 = {

View File

@ -5,7 +5,7 @@
</swiper-item>
</swiper>
</view>
<scroll-view scroll-x="true">
<view class="tab">
<block wx:for="{{mainFuncList}}" wx:key="index">
<view class="tab-box" bindtap="openNewsDetail" data-item="{{item}}">
@ -34,6 +34,8 @@
<view class="tab-title">直播点播</view>
</view>
</view>
</scroll-view>
<view class="line-thick"></view>
<view class="recommend">
<view class="public-title">
<view class="title-text">
@ -42,7 +44,7 @@
<image src="../../images/selected-r.png" class="selected-r"></image>
</view>
</view>
<view class="line"></view>
<scroll-view scroll-x="true" style="margin-top: 10rpx;">
<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-status">场馆导航</view>
@ -55,7 +57,9 @@
<image src="{{activity.activityUrl}}/route/file/download/true/{{item.activityImageArray[0]}}" data-index="{{index}}" binderror="loadImgErr"></image>
</view>
</view>
</scroll-view>
</view>
<view class="line-thick"></view>
<view class="news" wx:if="{{mainNewTab.length>0}}">
<block wx:for="{{mainNewTab}}" wx:key="i" wx:for-item="it" wx:for-index="i">
<view class="public-title">

View File

@ -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;

View File

@ -22,6 +22,8 @@ Page({
canPlay: false,
isPlaying: false,
totalValue: 0,
isPublicCode: false,
isPublic: false
},
/**
@ -30,10 +32,22 @@ Page({
onLoad: function (options) {
this.setData({
newsId: options.id,
pageHeight: wx.getSystemInfoSync().windowHeight
pageHeight: wx.getSystemInfoSync().windowHeight,
isPublic: app.globalData.isPublic
})
this.saveBigdata(options.id);
},
onShow() {
if (this.data.isPublic) {
this.setData({
isPublicCode: false
})
}
this.setData({
newsBean: null
})
this.getNewsDetail();
this.saveBigdata(options.id);
},
saveBigdata(id) {
var params = "小程序" + id + "新闻";
@ -70,6 +84,21 @@ Page({
})
_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);
@ -79,6 +108,7 @@ Page({
// wx.hideLoading();
});
},
setVideoUrl(e) {
var _self = this;
var item = e.currentTarget.dataset.item
@ -137,6 +167,15 @@ Page({
})
},
move() {
},
goAttention() {
wx.navigateTo({
url: '/pages/commonQrCode/commonQrCode',
})
},
playAudio() {
if (audioContentx && audioContentx.paused) {
audioContentx.stop();

View File

@ -1,4 +1,9 @@
<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}}">
<!-- newsContentType 1 文章 2图片 3音频 4视频 5PDF 6链接 -->
<!-- 文章 -->

View File

@ -1,6 +1,8 @@
/* page{
background: #d2e0f6;
} */
page {
width: 100%;
height: 100%;
}
.news-title {
padding: 20rpx 30rpx;
font-size: 34rpx;
@ -199,3 +201,38 @@
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;
}

View File

@ -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)
}
})

View File

@ -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/";