Skip to content

Commit 2b93329

Browse files
committed
集成吐槽功能
1 parent ab35a34 commit 2b93329

File tree

8 files changed

+88
-108
lines changed

8 files changed

+88
-108
lines changed

app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"downloadFile": 10000
5555
},
5656
"navigateToMiniProgramAppIdList": [
57-
"wxb6bde4eeb2d43820"
57+
"wxb6bde4eeb2d43820",
58+
"wx8abaf00ee8c3202e"
5859
]
5960
}

app.wxss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
@import "vendor/ZanUI/index.wxss";
1313
@import "vendor/dist/index.wxss";
14+
@import "pages/index/index.wxss";
1415

1516
.container {
1617
padding: 0 28rpx;

pages/index/index.js

Lines changed: 53 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ var app = getApp();
2727
Page({
2828
data: {
2929
postsList: [],
30-
postsList1: [],
31-
//postsList2: [],
32-
postsList3: [],
30+
recommendPostsList: [],
31+
selectionPostsList: [],
3332
postsShowSwiperList: [],
3433
isLastPage: false,
3534
page: 1,
@@ -46,8 +45,17 @@ Page({
4645
currentIndex: 0,
4746
topNav: [],
4847
userInfo: app.globalData.userInfo,
49-
isLoginPopup: false
50-
48+
isLoginPopup: false,
49+
appId: "wx8abaf00ee8c3202e",
50+
extraData: {
51+
// 把1221数字换成你的产品ID,否则会跳到别的产品
52+
id: "45980",
53+
// 自定义参数,具体参考文档
54+
customData: {
55+
clientInfo: `iPhone OS 10.3.1 / 3.2.0.43 / 0`,
56+
imei: '7280BECE2FC29544172A2B858E9E90D0'
57+
}
58+
}
5159

5260
},
5361
formSubmit: function(e) {
@@ -173,7 +181,7 @@ Page({
173181
},
174182
fetchTopFivePosts: function() {
175183
var self = this;
176-
//取置顶的文章
184+
//获取幻灯片的文章
177185
var getPostsRequest = wxRequest.getRequest(Api.getSwiperPosts());
178186
getPostsRequest.then(response => {
179187
if (response.data.status == '200' && response.data.posts.length > 0) {
@@ -323,7 +331,7 @@ Page({
323331
getPostsRequest.then(response => {
324332
if (response.statusCode === 200) {
325333
self.setData({
326-
postsList1: self.data.postsList1.concat(response.data.map(function(item) {
334+
recommendPostsList: self.data.recommendPostsList.concat(response.data.map(function(item) {
327335

328336
var strdate = item.date
329337
if (item.category_name != null) {
@@ -350,7 +358,7 @@ Page({
350358
getPostsRequest.then(response => {
351359
if (response.statusCode === 200) {
352360
self.setData({
353-
postsList3: self.data.postsList3.concat(response.data.map(function(item) {
361+
selectionPostsList: self.data.selectionPostsList.concat(response.data.map(function(item) {
354362

355363
var strdate = item.date
356364
if (item.category_name != null) {
@@ -371,44 +379,6 @@ Page({
371379
})
372380
},
373381

374-
375-
//获取浏览排行
376-
fetchPostsHostData: function(tab) {
377-
var self = this;
378-
self.setData({
379-
postsList2: []
380-
});
381-
wx.showLoading({
382-
title: '正在加载',
383-
mask: true
384-
});
385-
var getTopHotPostsRequest = wxRequest.getRequest(Api.getTopHotPosts(tab));
386-
getTopHotPostsRequest.then(response => {
387-
if (response.statusCode === 200) {
388-
self.setData({
389-
postsList2: self.data.postsList2.concat(response.data.map(function(item) {
390-
var strdate = item.post_date
391-
if (item.post_thumbnail_image == null || item.post_thumbnail_image == '') {
392-
item.post_thumbnail_image = '../../images/logo700.png';
393-
}
394-
item.post_date = util.cutstr(strdate, 10, 1);
395-
return item;
396-
})),
397-
});
398-
} else if (response.statusCode === 404) {
399-
console.log('加载数据失败,可能缺少相应的数据');
400-
}
401-
})
402-
.catch(function() {
403-
wx.hideLoading();
404-
})
405-
.finally(function() {
406-
setTimeout(function() {
407-
wx.hideLoading();
408-
}, 1500);
409-
});
410-
},
411-
412382
//加载分页
413383
loadMore: function(e) {
414384

@@ -519,7 +489,7 @@ Page({
519489
});
520490
},
521491

522-
userAuthorization: function () {
492+
userAuthorization: function() {
523493
var self = this;
524494
// 判断是否是第一次授权,非第一次授权且授权失败则进行提醒
525495
wx.getSetting({
@@ -544,7 +514,7 @@ Page({
544514
cancelColor: '#296fd0',
545515
confirmColor: '#296fd0',
546516
confirmText: '设置权限',
547-
success: function (res) {
517+
success: function(res) {
548518
if (res.confirm) {
549519
console.log('用户点击确定')
550520
wx.openSetting({
@@ -566,7 +536,7 @@ Page({
566536
}
567537
});
568538
},
569-
agreeGetUser: function (e) {
539+
agreeGetUser: function(e) {
570540
var userInfo = e.detail.userInfo;
571541
var self = this;
572542
if (userInfo) {
@@ -575,7 +545,7 @@ Page({
575545
userInfo: userInfo
576546
})
577547
}
578-
setTimeout(function () {
548+
setTimeout(function() {
579549
self.setData({
580550
isLoginPopup: false
581551
})
@@ -592,14 +562,14 @@ Page({
592562
isLoginPopup: true
593563
});
594564
},
595-
confirm: function () {
565+
confirm: function() {
596566
this.setData({
597567
'dialog.hidden': true,
598568
'dialog.title': '',
599569
'dialog.content': ''
600570
})
601571
},
602-
getUsreInfo: function () {
572+
getUsreInfo: function() {
603573
var self = this;
604574
var wxLogin = wxApi.wxLogin();
605575
var jscode = '';
@@ -608,43 +578,43 @@ Page({
608578
var wxGetUserInfo = wxApi.wxGetUserInfo()
609579
return wxGetUserInfo()
610580
}).
611-
//获取用户信息
612-
then(response => {
613-
console.log(response.userInfo);
614-
console.log("成功获取用户信息(公开信息)");
615-
app.globalData.userInfo = response.userInfo;
616-
app.globalData.isGetUserInfo = true;
617-
self.setData({
618-
userInfo: response.userInfo
619-
});
581+
//获取用户信息
582+
then(response => {
583+
console.log(response.userInfo);
584+
console.log("成功获取用户信息(公开信息)");
585+
app.globalData.userInfo = response.userInfo;
586+
app.globalData.isGetUserInfo = true;
587+
self.setData({
588+
userInfo: response.userInfo
589+
});
620590

621-
var url = Api.getOpenidUrl();
622-
var data = {
623-
js_code: jscode,
624-
encryptedData: response.encryptedData,
625-
iv: response.iv,
626-
avatarUrl: response.userInfo.avatarUrl
591+
var url = Api.getOpenidUrl();
592+
var data = {
593+
js_code: jscode,
594+
encryptedData: response.encryptedData,
595+
iv: response.iv,
596+
avatarUrl: response.userInfo.avatarUrl
597+
}
598+
var postOpenidRequest = wxRequest.postRequest(url, data);
599+
//获取openid
600+
postOpenidRequest.then(response => {
601+
if (response.data.status == '200') {
602+
//console.log(response.data.openid)
603+
console.log("openid 获取成功");
604+
app.globalData.openid = response.data.openid;
605+
app.globalData.isGetOpenid = true;
606+
} else {
607+
console.log(response.data.message);
627608
}
628-
var postOpenidRequest = wxRequest.postRequest(url, data);
629-
//获取openid
630-
postOpenidRequest.then(response => {
631-
if (response.data.status == '200') {
632-
//console.log(response.data.openid)
633-
console.log("openid 获取成功");
634-
app.globalData.openid = response.data.openid;
635-
app.globalData.isGetOpenid = true;
636-
} else {
637-
console.log(response.data.message);
638-
}
639-
})
640-
}).catch(function (error) {
641-
console.log('error: ' + error.errMsg);
642-
self.userAuthorization();
643609
})
610+
}).catch(function(error) {
611+
console.log('error: ' + error.errMsg);
612+
self.userAuthorization();
613+
})
644614
},
645615

646616
//设置首页咨询按钮点击事件:当用户点击咨询按钮时,自动推送一条消息给管理员
647-
notifyAdmin: function () {
617+
notifyAdmin: function() {
648618
console.log(' 用户咨询,开始通知管理员。');
649619
wx.request({
650620
url: 'https://cloud.safedog.cc/vpush/functions/PUSH_API',

pages/index/index.wxml

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
<swiper class="index-swiper" indicator-dots="" interval="10000" autoplay="true" indicator-color="rgba(255, 255, 255, .2)" indicator-active-color="rgba(255, 255, 255, .7)" previous-margin="30rpx" next-margin="50rpx" circular="true" bindchange="handleChange">
3131
<block wx:key="id" wx:for="{{postsShowSwiperList}}">
3232
<swiper-item id="{{item.id}}" index="{{index}}" data-redicttype="{{item.type}}" data-appid="{{item.appid}}" data-url="{{item.url}}" bindtap="redictAppDetail" style="">
33-
34-
<view wx:if="{{item.post_thumbnail_image}}"><!-- 默认调取文章内容的特色图片 -->
35-
<image class="itemImg {{currentIndex == index ? 'active': ''}}" mode="aspectFill" src="{{item.post_thumbnail_image}}" style="width:96%;margin:0 24rpx;border-radius:8rpx" />
33+
34+
<view wx:if="{{item.post_thumbnail_image}}">
35+
<!-- 默认调取文章内容的特色图片 -->
36+
<image class="itemImg {{currentIndex == index ? 'active': ''}}" mode="aspectFill" src="{{item.post_thumbnail_image}}" style="width:96%;margin:0 24rpx;border-radius:8rpx" />
3637
</view>
37-
<view wx:else><!-- 如果没有特色图片时,这里调取文章内容里面的第一张图像 -->
38-
<image class="itemImg {{currentIndex == index ? 'active': ''}}" mode="aspectFill" src="{{item.content_first_image}}" style="width:96%;margin:0 24rpx;border-radius:8rpx" />
38+
<view wx:else>
39+
<!-- 如果没有特色图片时,这里调取文章内容里面的第一张图像 -->
40+
<image class="itemImg {{currentIndex == index ? 'active': ''}}" mode="aspectFill" src="{{item.content_first_image}}" style="width:96%;margin:0 24rpx;border-radius:8rpx" />
3941
</view>
4042

4143
</swiper-item>
@@ -95,18 +97,20 @@
9597
</view>
9698
</navigator>
9799
</view>
98-
<!-- 绑定同<vpush-view>一公众号关联的其他小程序 end -->
100+
<!-- 绑定同一公众号关联的其他小程序 end -->
101+
102+
<!-- 绑定吐槽社区功能 -->
99103
<view class="top-item" style='width:10%; position: relative; float:left; text-align:center'>
100-
<view>
101-
<image src="../../images/kefu.svg"></image>
102-
</view>
103-
<view>
104-
<vpush-view>
105-
<text>咨询</text>
106-
</vpush-view>
107-
</view>
108-
<button class="share-button" open-type="contact" bindtap="notifyAdmin">
109-
</button>
104+
<navigator target="miniProgram" open-type="navigate" app-id="{{ appId }}" extra-data="{{ extraData }}" hover-class="none" version="release">
105+
<view>
106+
<image src="../../images/kefu.svg"></image>
107+
</view>
108+
<view>
109+
<vpush-view>
110+
<text>吐槽</text>
111+
</vpush-view>
112+
</view>
113+
</navigator>
110114
</view>
111115
</view>
112116
<!-- 图标导航 end -->
@@ -124,12 +128,12 @@
124128
</view>
125129

126130
<view class="cms-cont mstTwoPicsPerRow">
127-
<block wx:key="id" wx:for="{{postsList1}}">
131+
<block wx:key="id" wx:for="{{recommendPostsList}}">
128132
<view class="mstTwoPicsPerRow-item" index="{{index}}" id="{{item.id}}" bindtap="redictDetail">
129133
<image class="mstTwoPicsPerRow-img" mode="aspectFill" src="{{item.post_thumbnail_image}}"></image>
130134
<!--view class="bg-shadow"></view-->
131135
<view class="img-text">
132-
<!--text class="img-text-large">{{item.title.rendered}}</text-->
136+
<!--text class="img-text-large">{{item.title.rendered}} </text-->
133137
<text class="img-text-small">{{item.pageviews}} 位网友推荐</text>
134138
</view>
135139
</view>
@@ -147,7 +151,7 @@
147151
</view>
148152
</view>
149153
<scroll-view scroll-x="true" scroll-with-animation="true" style="display:flex;white-space:nowrap;padding:4rpx 0 24rpx;">
150-
<view class="cms-cont" wx:key="id" wx:for="{{postsList3}}" style='width:93%'>
154+
<view class="cms-cont" wx:key="id" wx:for="{{selectionPostsList}}" style='width:93%'>
151155
<view index="{{index}}" id="{{item.id}}" bindtap="redictDetail">
152156
<image class="mstOnePic-img" mode="aspectFill" src="{{item.post_thumbnail_image}}"></image>
153157
<text class="new_icon">广告</text>

pages/index/index.wxss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Copyright (c) 2017 https://www.yeehee.cn All rights reserved.
99
*
1010
*/
11+
1112
.scroll-view {
1213
width: 100%;
1314
white-space: normal;

pages/usercenter/usercenter.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</view>
2222

2323
<template is="login-popup" data="{{show: isLoginPopup, userInfo: userInfo}}"></template>
24-
24+
2525
<zan-panel title="" style="width:100vw;border-top:20rpx solid #eee;">
2626
<zan-cell-group>
2727
<zan-cell title="热门排行" is-link url="../hot/hot"></zan-cell>

utils/api.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,12 @@ module.exports = {
287287
return url;
288288
},
289289
//获取随机文章
290-
getRandomPosts() {
290+
getPostsByRandom() {
291+
//var url = 'https://' + domain + "/wp-json/watch-life-net/v1/post/random";
292+
//return url;
293+
291294
var url = HOST_URI_WATCH_LIFE_JSON;
292-
url += "post/random";
295+
url += 'post/random';
293296
return url;
294297
}
295298
};

utils/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ var DOWNLOADFILEDOMAIN = [
3838
// 'appid' 当redirecttype为miniapp时,这个值为其他微信小程序的appid,如果redirecttype为apppage,webpage时,这个值设置为空。
3939
// 'extraData'当redirecttype为miniapp时,这个值为提交到其他微信小程序的参数,如果redirecttype为apppage,webpage时,这个值设置为空。
4040
var INDEXNAV = [
41-
{ id: '1', name: '热门教程', image: '../../images/qddesign.svg', url: '../list/list?categoryID=4', redirecttype: 'apppage', appid: '', extraData:'' },
41+
{ id: '1', name: '教程', image: '../../images/qddesign.svg', url: '../list/list?categoryID=4', redirecttype: 'apppage', appid: '', extraData:'' },
4242
{ id: '2', name: '随笔', image: '../../images/sbnote.svg', url: '../list/list?categoryID=1', redirecttype: 'apppage', appid: '', extraData:''},
43-
{ id: '3', name: '排行榜', image: '../../images/ranking.svg', url: '../hot/hot', redirecttype: 'apppage', appid: '', extraData: '' },
43+
{ id: '3', name: '排行', image: '../../images/ranking.svg', url: '../hot/hot', redirecttype: 'apppage', appid: '', extraData: '' },
4444
]
4545

4646
export default {

0 commit comments

Comments
 (0)