diff --git a/scr/lt2/app.json b/scr/lt2/app.json
index b2ea63c..a126f73 100644
--- a/scr/lt2/app.json
+++ b/scr/lt2/app.json
@@ -4,15 +4,14 @@
"pages/index/index",
"pages/submit/submit",
"pages/notify/notify",
-
-
- "pages/answer/answer",
- "pages/question/question"
+ "pages/searchShow/searchShow",
+ "pages/change/change",
+ "pages/answer/answer"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#0068C4",
- "navigationBarTitleText": "知乎",
+ "navigationBarTitleText": "论坛",
"navigationBarTextStyle":"white",
"enablePullDownRefresh":true
},
@@ -31,7 +30,9 @@
"text": "",
"iconPath": "images/ring.png",
"selectedIconPath": "images/ring_focus.png"
- }]
+ }
+
+ ]
},
"networkTimeout": {
"request": 10000,
diff --git a/scr/lt2/images/amend.PNG b/scr/lt2/images/amend.PNG
new file mode 100644
index 0000000..28c87f8
Binary files /dev/null and b/scr/lt2/images/amend.PNG differ
diff --git a/scr/lt2/images/delete.PNG b/scr/lt2/images/delete.PNG
new file mode 100644
index 0000000..24d507e
Binary files /dev/null and b/scr/lt2/images/delete.PNG differ
diff --git a/scr/lt2/images/heart1.png b/scr/lt2/images/heart1.png
new file mode 100644
index 0000000..3e43d33
Binary files /dev/null and b/scr/lt2/images/heart1.png differ
diff --git a/scr/lt2/pages/answer/answer.js b/scr/lt2/pages/answer/answer.js
index 6a47837..ce7fdab 100644
--- a/scr/lt2/pages/answer/answer.js
+++ b/scr/lt2/pages/answer/answer.js
@@ -1,50 +1,145 @@
//answer.js
-
+let dianzan=false
var app = getApp()
Page({
data: {
motto: '知乎--微信小程序版',
userInfo: {},
feed: [],
+ //修改
+ pinglun:[], //评论数组
+ content:'',
+ detail: '',
+ dianzanUrl: "../../images/heart2.png",
+ comment_num:0
},
//事件处理函数
- toQuestion: function() {
- wx.navigateTo({
- url: '../question/question'
- })
- },
+ // toQuestion: function() {
+ // wx.navigateTo({
+ // url: '../question/question'
+ // })
+ // },
onLoad: function (options) {
var aid=options.aid
console.log(options);
console.log(options.aid);
console.log('onLoad')
- var that = this
- //调用应用实例的方法获取全局数据
- /*app.getUserInfo(function(userInfo){
- //更新数据
- that.setData({
- userInfo:userInfo
+ wx.setStorageSync('aid', aid)
+
+
+ //修改
+ wx.cloud.database().collection("tiezi")
+ .doc(aid)
+ .get()
+ .then(res => {
+ console.log("详情页成功", res);
+ //将收藏添加到数据库
+ //shoucang = res.data.shoucang
+ //dianzan = res.data.dianzan
+ //console.log(shoucang, dianzan);
+ //再次显示数据
+ this.setData({
+ detail: res.data,
+
+ pinglun:res.data.pinglun
+ })
})
- })*/
- wx.cloud.database().collection('tiezi')
- .where({
- _id:aid
- })
- .get({
- success(res) {
- console.log("请求成功", res)
- that.setData({
- feed:res.data
- }),
- console.log(res.data)
- },
- fail(res) {
- console.log("请求失败", res)
- }
+ .catch(err => {
+ console.log("详情页失败", err);
})
-
+
+
+
+ var getId = options.aid;
+ // 让接收到的id值传递到data:{}里面
+ this.setData({
+ currentId: getId
+ });
+ // 读取所有的文章列表点赞缓存状态
+ var cache = wx.getStorageSync('cache_key');
+ // 如果缓存状态存在
+ if (cache) {
+ // 拿到所有缓存状态中的1个
+ var currentCache = cache[getId];
+ // 把拿到的缓存状态中的1个赋值给data中的collection,如果当前文章没有缓存状态,currentCache 的值就是 false,如果当前文章的缓存存在,那么 currentCache 就是有值的,有值的说明 currentCache 的值是 true
+ this.setData({
+ collection: currentCache
+ })
+ } else {
+ // 如果所有的缓存状态都不存在 就让不存在的缓存存在
+ var cache = {};
+ // 既然所有的缓存都不存在,那么当前这个文章点赞的缓存也不存在,我们可以把当前这个文章点赞的缓存值设置为 false
+ cache[getId] = false;
+ // 把设置的当前文章点赞放在整体的缓存中
+ wx.setStorageSync('cache_key',cache);
+ }
},
+
+ // 点击图片的点赞事件 这里使用的是同步的方式
+ toCollect: function(options) {
+ let aid= wx.getStorageSync ("aid")
+ console.log(aid);
+ // 获取所有的缓存
+ var cache = wx.getStorageSync('cache_key');
+ // 获取当前文章是否被点赞的缓存
+ var currentCache = cache[this.data.currentId];
+ // 取反,点赞的变成未点赞 未点赞的变成点赞
+ currentCache = !currentCache;
+ // 更新cache中的对应的1个的缓存值,使其等于当前取反的缓存值
+ cache[this.data.currentId] = currentCache;
+ // 重新设置缓存
+ wx.setStorageSync('cache_key',cache);
+ // 更新数据绑定,从而切换图片
+ this.setData({
+ // collection 默认的是 false
+ collection: currentCache
+ });
+ // 交互反馈
+ wx.showToast({
+ title: currentCache?'点赞':'取消',
+ icon: 'success',
+ duration: 2000
+ });
+ if(currentCache==true){
+ wx.cloud.database().collection("tiezi")
+ .doc(aid)
+ .update({
+ data: {
+ // 前面为数据库字段,后面为修改之后的值
+ good_num: wx.cloud.database().command.inc(1),
+ }
+ })
+ .then(res => {
+ console.log("添加评论成功", res);
+ return res
+
+ })
+ .catch(err => {
+ console.log("添加评论失败", err);
+ return err
+
+ })
+ }
+ else{
+ wx.cloud.database().collection("tiezi")
+ .doc(aid)
+ .update({
+ data: {
+ // 前面为数据库字段,后面为修改之后的值
+ good_num: wx.cloud.database().command.inc(-1),
+ }
+ })
+ .then(res => {
+ console.log("成功", res);
+ return res
+ })
+ .catch(err => {
+ console.log("失败", err);
+ return err
+ })
+ }
+ },
/*
onLoad: function (options) {
@@ -52,5 +147,151 @@ Page({
tapName: function(event){
console.log(event)
},
-
+
+
+//获取输入的值
+getContent(event){
+ this.setData({
+ content:event.detail.value
+ })
+},
+//发表评论
+fabiao(options){
+ let content=this.data.content
+ if(content.length<4){
+ wx.showLoading({
+ icon:"none",
+ title: '评论太短了',
+ })
+ return
+ }
+ let pinglunItem={}
+ pinglunItem.nickName=wx.getStorageSync ("nickName")
+ pinglunItem.avatarUrl=wx.getStorageSync ("avatarUrl")
+ pinglunItem.content=content
+ let pinglunArr=this.data.pinglun
+ pinglunArr.push(pinglunItem)
+ let l= pinglunArr.length
+ console.log("评论数",l)
+ console.log("添加后的评论数组",pinglunArr)
+ wx.showLoading({
+ title: '发表中',
+ })
+
+wx.cloud.init({
+ env:"cloud1-8g5wmepxce8a3b8a",
})
+let aid= wx.getStorageSync ("aid")
+console.log(aid);
+ //异步操作
+ wx.cloud.database().collection("tiezi")
+ .doc(aid)
+ .update({
+ data: {
+ // 前面为数据库字段,后面为修改之后的值
+ pinglun: pinglunArr,
+ comment_num:pinglunArr.length
+ }
+ })
+ .then(res => {
+ console.log("添加评论成功", res);
+ return res
+
+ })
+ .catch(err => {
+ console.log("添加评论失败", err);
+ return err
+
+ })
+ let that = this;
+ wx.hideLoading({
+ success: (res) => {
+ that.setData({
+ pinglun:pinglunArr,
+ content:''
+ })
+ wx.showToast({
+ title: '发布成功',
+ })}})
+
+},
+//点赞切换
+clickDianzan() {
+ this.setData({
+ dianzanUrl: dianzan ? "../../images/heart2.png" : "../../images/heart1.png"
+ })
+ dianzan = !dianzan
+ wx.setStorageSync ("dianzan",dianzan)
+ console.log("改变点赞状态", dianzan)
+},
+
+amend: function(e) {
+ let aid= wx.getStorageSync ("aid")
+ console.log(aid);
+ wx.showModal({
+ title: '编辑',
+ content: '确定要修改已发布的信息吗?',
+ success(res) {
+ if(res.confirm) {
+ wx.redirectTo({
+ url: '../change/change?aid='+aid,
+ })
+ console.log('用户点击了确定')
+ }else if(res.cancel) {
+ console.log('用户点击了取消')
+ }
+ }
+ })
+},
+delete(event){
+ let aid= wx.getStorageSync ("aid")
+ console.log(aid);
+ wx.cloud.database().collection('tiezi')
+ .doc(aid)
+ .remove()
+ .then(res => {
+ console.log(res);
+ }).catch(res => {
+ console.log(res);
+ })
+ wx.switchTab({
+ url: '../index/index'
+ })
+},
+delete_p: function(event) {
+ /*wx.navigateTo({
+ url: '../answer/answer'
+ })*/
+ let aid= wx.getStorageSync ("aid")
+ console.log(aid);
+ var aidc=event.currentTarget.dataset.aidc;
+ console.log(aidc)
+ //console.log("1")
+ wx.cloud.database().collection('tiezi')
+ .where({
+ '_id':aid,
+ 'pinglun.content':aidc
+ })
+ .update({
+ data:{
+ pinglun:wx.cloud.database().command.pull({
+ content:aidc
+ }),
+ comment_num:wx.cloud.database().command.inc(-1)
+ }
+ })
+ .then(res => {
+ console.log(res);
+ console.log(res);
+ wx.showLoading({
+ title: '删除成功...',
+ })
+ wx.redirectTo({
+ url: '../answer/answer?aid='+aid,
+ })
+ wx.hideLoading()
+ }).catch(res => {
+ console.log(res);
+ })
+}
+})
\ No newline at end of file
diff --git a/scr/lt2/pages/answer/answer.wxml b/scr/lt2/pages/answer/answer.wxml
index 2151cc9..9d4f5e4 100644
--- a/scr/lt2/pages/answer/answer.wxml
+++ b/scr/lt2/pages/answer/answer.wxml
@@ -1,94 +1,93 @@
-
+
+
- {{item.title}}
+ {{detail.title}}
-
+
- {{item.feed_source_name}}
- 快来关注我吧~
+ {{detail.feed_source_name}}
+ 喜欢就点个赞吧~
+
+
+
+
+
+ 删除
+
+
+
+
+
+ 编辑
+
- 十 关注
+
+
+
+
+
+
+
+
+ 点赞
+
- {{item.content}}
-
- 碎片时间阅读总不能天天背着一本书吧,那么占地方。
- 看到描述最后一段,感觉有骗答案的嫌疑
-
-
-
- 难道不明白纸质书更贵啊!!!
- 若觉得kindle更贵,我觉得要么阅读量太少,那确实没有买kindle的必要。要么买的都是盗版的纸质书?我不清楚不加以评论。。。
+
+
+
+
+
+
+
+ {{item.nickName}}:{{item.content}}
+
+
+
+
+
+
+
+
+
- 另外,用kindle看小说的怎么真心不懂了。题主不看小说么?难道题主拿来看教科书还是技术文档?还是题主觉得小说就是小时代内样的?(对小时代没偏见,尊重多样性)
- 而且纸质书搬起来真心困难啊!当初毕业带不回来,忍痛卖了不少好桑心!
+
+
+
+
+
+
+ 发表
+
+
- 碎片时间阅读总不能天天背着一本书吧,那么占地方。
- 看到描述最后一段,感觉有骗答案的嫌疑
+
-
- -->
-
-
-
-
\ No newline at end of file
diff --git a/scr/lt2/pages/answer/answer.wxss b/scr/lt2/pages/answer/answer.wxss
index fc07e38..7f92b3a 100644
--- a/scr/lt2/pages/answer/answer.wxss
+++ b/scr/lt2/pages/answer/answer.wxss
@@ -1,4 +1,7 @@
/**answer.wxss**/
+.mycontainer{
+ margin-bottom: 200rpx;
+}
.a {
padding: 0;
@@ -69,21 +72,47 @@
color: #808080;
line-height: 28rpx;
}
-.answerer .follow{
- flex: 2;
+
+.answerer .follow image{
+ /* flex: 2;
padding: 15rpx 0;
- font-size: 22rpx;
+ font-size: 22rpx; */
+
+ display: block;
+ margin: 0 auto;
+ width: 40rpx;
+ height: 40rpx;
}
.answerer .follow text{
- display: inline-block;
+ /* display: inline-block;
padding: 15rpx 20rpx;
color: #40bcd0;
border: solid 2px #40bcd0;
- border-radius: 6rpx;
+ border-radius: 6rpx; */
+ display: block;
+ font-size: 14rpx;
+ color: #bebebe;
+}
+.answerer .follow .a3{
+ /* flex: 2;
+ padding: 15rpx 0;
+ font-size: 22rpx; */
+
+ display: block;
+ margin: 0 auto;
+ width: 30rpx;
+ height: 35rpx;
+ margin-top: 9rpx;
}
+
+
+
+
+
.answer-content{
padding: 30rpx 40rpx;
background: #ffffff;
+
}
.answer-content text{
font-size: 32rpx;
@@ -96,56 +125,176 @@
margin: 20rpx 0;
}
.answer-footer{
- position: fixed;
- bottom: 0;
- height: 70rpx;
- border-top: solid 1px #ebebeb;
- background: #ffffff;
- width: 670rpx;
- padding: 20rpx 40rpx;
+ width: 750rpx;
+ height: 70rpx;
+
+ font-size: 28rpx;
+
+ box-shadow: 0 100px 7px #bebebe;
+ margin: 0 200rpx 0 0;
+
+ position: sticky ;
+ bottom: 0;
+ z-index: 9999;
+}
+.answer-footer{
+ position: fixed;
+ bottom: 0;
+ height: 70rpx;
+ border-top: solid 1px #ebebeb;
+ background: #ffffff;
+ width: 670rpx;
+ padding: 20rpx 40rpx;
}
.answer-footer .good{
- flex: 1;
- /*display: inline-block;*/
- height: 40rpx;
- border: solid 1px #d1d1d1;
- border-radius: 3px;
- padding: 10rpx 8rpx;
- margin: 10rpx 0;
+ flex: 1;
+ /*display: inline-block;*/
+ height: 40rpx;
+ border: solid 1px #d1d1d1;
+ border-radius: 3px;
+ padding: 10rpx 8rpx;
+ margin: 10rpx 0;
}
.answer-footer .good .good-bad{
- display: inline-block;
+ display: inline-block;
}
.answer-footer .good image{
- display: inline-block;
- width: 38rpx;
- height: 38rpx;
- vertical-align: middle;
+ display: inline-block;
+ width: 38rpx;
+ height: 38rpx;
+ vertical-align: middle;
}
.answer-footer .good .good-num{
- display: inline-block;
- padding: 10rpx 4rpx;
- /*font-size: 24rpx;*/
+ display: inline-block;
+ padding: 10rpx 4rpx;
+ /*font-size: 24rpx;*/
}
.answer-footer .operation-wrp{
- flex: 5;
+ flex: 5;
}
.answer-footer .operation{
- justify-content: space-between;
- padding: 0 0 0 60rpx;
+ justify-content: space-between;
+ padding: 0 0 0 60rpx;
}
.answer-footer .operation-btn{
- flex: 1;
- text-align: center;
+ flex: 1;
+ text-align: center;
}
.answer-footer .operation image{
- display: block;
- margin: 0 auto;
- width: 50rpx;
- height: 50rpx;
+ display: block;
+ margin: 0 auto;
+ width: 50rpx;
+ height: 50rpx;
}
.answer-footer .operation-btn text{
- display: block;
- font-size: 14rpx;
- color: #bebebe;
+ display: block;
+ font-size: 14rpx;
+ color: #bebebe;
+}
+
+
+
+
+
+
+/* .tip{
+ position: relative;
+ width: 650rpx;
+ padding: 30rpx 50rpx 30rpx;
+ /*background: #298DE5;*/
+ /* color: rgb(0, 0, 0);
+ font-size: 38rpx;
+ line-height: 48rpx;
+
+} */
+
+.input{
+ display:block;
+ border:2px solid gainsboro;
+ margin-top: 60rpx;
+ margin-bottom: 60rpx;
+}
+.pinglunItem{
+
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: flex-start;
+ border-top: 2px solid gainsboro;
+ margin-left: 0rpx;
+ margin-top: 0rpx;
+
+}
+
+.pinglunItem .a1{
+ margin-left: 30rpx;
+ margin-right: 30rpx;
+ margin-top: 20rpx;
+ margin-bottom: 20rpx;
+ width: 60rpx;
+ height: 60rpx;
+ border-radius: 90rpx;
+}
+.pinglunItem .desc{
+ font-size: 30rpx;
+ height: 40rpx;
+}
+.pinglunItem .a2 {
+ margin-left: 100rpx;
+ margin-right: 30rpx;
+ margin-top: -20rpx;
+ width: 30rpx;
+ height: 35rpx;
+position: absolute; /* 要约束所在位置的子元素的位置要设置成绝对 */
+right: 0;
+}
+
+
+
+.search{
+ position: fixed;
+ bottom: 0;
+ width: 735rpx;
+ height: 65rpx;
+ padding: 12.5rpx 0 12.5rpx 15rpx;
+ background: #2A8CE5;
+}
+.search-left{
+ flex: 8;
+ background: #4EA3E7;
+ text-align: left;
+}
+.search-left input{
+ display: inline-block;
+ height: 65rpx;
+ font-size: 26rpx;
+}
+.search-placeholder{
+ color: #8CCEFD;
+ line-height: 20rpx;
+}
+.search .search-left image{
+ display: inline-block;
+ width: 35rpx;
+ height: 35rpx;
+ padding: 15rpx 15rpx 15rpx 20rpx;
+}
+.search .search-right{
+ flex: 1;
+}
+.search .search-right .desc{
+ font-size: 25rpx;
+ color: #ffffff;
+ margin:15rpx
+}
+
+
+
+
+
+/* 解决底部导航栏遮挡的占位view的样式 */
+.standView{
+ width: 100%;
+ height: 100rpx; /* 自定义一下需要的高度 */
+ /* background-color: black; */
}
diff --git a/scr/lt2/pages/change/change.js b/scr/lt2/pages/change/change.js
new file mode 100644
index 0000000..88c7867
--- /dev/null
+++ b/scr/lt2/pages/change/change.js
@@ -0,0 +1,241 @@
+// pages/change/change.js
+var app = getApp()
+Page({
+ data: {
+ feed: [],
+ change1: '',
+ change2: '',
+ tempFilePaths: [],
+ t:'',
+ c:'',
+ nowCount:0,//当前的图片上传个数
+ index:0,
+ url:[]
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+ var that = this
+ var aid=options.aid
+ console.log(options);
+ console.log(options.aid);
+
+ wx.cloud.database().collection('tiezi')
+ .doc(aid)
+ .get({
+ success(res) {
+ console.log("请求成功", res.data)
+ console.log("请求成功", res.data.url.length)
+ // 将查询返回的结果赋值给本地数组
+ that.setData({
+ feed: res.data,
+ nowCount:res.data.url.length,
+ tempFilePaths: res.data.url,
+ url:res.data.url,
+ t:res.data.title,
+ c:res.data.content
+ })
+ },
+ fail(res) {
+ console.log("请求失败", res)
+ }
+ })
+ },
+
+ // 获取修改后的内容
+ change1: function(e) {
+ this.setData({
+ change1: e.detail.value
+ })
+ },
+ change: function(e) {
+ this.setData({
+ change2: e.detail.value
+ })
+ },
+ //图片的上传
+ chooseImage:function(e){
+ let that = this;
+ wx.chooseImage({
+ count: 3, // 默认最多3张图片,可自行更改
+ sizeType: ['original', 'compressed'],// 可以指定是原图还是压缩图,默认二者都有
+ sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
+ success: res => {
+ wx.showToast({
+ title: '正在上传...',
+ icon: 'loading',
+ mask: true,
+ duration: 1000
+ })
+ // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
+ let tempFilePath = res.tempFilePaths;
+ console.log(tempFilePath);
+ let nowCount = that.data.nowCount;
+ let tempFilePaths = that.data.tempFilePaths;
+
+ if(that.data.nowCount + tempFilePath.length >=3){
+ let i = 0;
+ while(nowCount<3){//还可以继续上传图片
+ tempFilePaths.push(tempFilePath[i]);
+ i++;
+ nowCount++;
+ }
+ that.setData({
+ nowCount:3,
+ tempFilePaths:tempFilePaths
+ })
+ }else{
+ let i = 0;
+ while(i{
+ console.log(res);
+ wx.showLoading({
+ title: '修改成功...',
+ })
+ wx.redirectTo({
+ url: '../answer/answer?aid='+aid,
+ })
+ wx.hideLoading()
+ }).catch(res=>{
+ console.log(res);
+ })
+ }else{
+ //将所有的内容上传到云端去
+ for(i=l;i {
+ count++;
+ url.push(res.fileID);
+ console.log('上传图片');
+ console.log(i,url);
+ if(count==that.data.nowCount){
+ console.log(url);
+ }
+ },fail:res=>{
+ console.log(res);
+ }
+ })
+
+ }
+ wx.cloud.init({
+ env:"cloud1-8g5wmepxce8a3b8a",
+ })
+ let aid=wx.getStorageSync ("aid")
+ console.log(aid);
+ wx.cloud.database().collection('tiezi')
+ .doc(aid)
+ .update({
+ data:{
+ title:content1,
+ content: content,
+ url:url
+ }
+ }).then(res=>{
+ console.log(res);
+ wx.showLoading({
+ title: '修改成功...',
+ })
+ wx.redirectTo({
+ url: '../answer/answer?aid='+aid,
+ })
+ wx.hideLoading()
+ }).catch(res=>{
+ console.log(res);
+})
+ }
+
+
+
+
+ },
+
+
+})
diff --git a/scr/lt2/pages/change/change.json b/scr/lt2/pages/change/change.json
new file mode 100644
index 0000000..e8cfaaf
--- /dev/null
+++ b/scr/lt2/pages/change/change.json
@@ -0,0 +1,4 @@
+{
+ "component": true,
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/scr/lt2/pages/change/change.wxml b/scr/lt2/pages/change/change.wxml
new file mode 100644
index 0000000..1cffe11
--- /dev/null
+++ b/scr/lt2/pages/change/change.wxml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scr/lt2/pages/change/change.wxss b/scr/lt2/pages/change/change.wxss
new file mode 100644
index 0000000..817f782
--- /dev/null
+++ b/scr/lt2/pages/change/change.wxss
@@ -0,0 +1,73 @@
+/* pages/change/change.wxss */
+.title{
+ font-size: 38rpx;
+ display: flex;
+ margin-top: 25rpx;
+
+ padding: 13px 0;
+ margin-bottom: 30rpx;
+ border-bottom: 1px solid #ccc;
+}
+.content{
+ margin-bottom: 30rpx;
+ border-bottom: 1px solid #ccc;
+ padding-right: 50rpx;
+ margin-top: 30rpx;
+ display: block;
+ width: 100%;
+ height: 550rpx !important;
+ box-sizing: border-box;
+ font-size: 32rpx;
+ color: #454545;
+ line-height: 44rpx;
+ /*word-break: break-all;*/
+}
+.picker{
+
+ display: flex;
+ padding: 13px 0;
+ margin-bottom: 35rpx;
+ border-bottom: 1px solid #ccc;
+
+}
+.img_box{
+ position:relative;
+ display: flex;
+ flex-wrap: wrap;
+ margin:0 auto;
+}
+.imgs{
+ width:33.33333333%;
+ display: flex;
+ justify-content: center;
+ margin-bottom:20rpx;
+}
+.imgs image{
+ width:90%;
+ max-height:212rpx;
+ border:1px solid rgba(214, 212, 212, 0.1);
+ /* box-shadow: 5rpx 5rpx 1rpx 3rpx #e2e0e0; */
+}
+.imgs .images{
+ position:relative;
+}
+.images button{
+ width:100%;
+ height:100%;
+ position:absolute;
+ top:0;
+ left:0;
+}
+.img_box .images{
+ width:90%;
+ height: 212rpx;
+ border:1px solid #E8E8E8;
+ border-radius:4rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+.img_box .images>image{
+ width:60rpx;
+ height:60rpx;
+}
\ No newline at end of file
diff --git a/scr/lt2/pages/index/index.js b/scr/lt2/pages/index/index.js
index 7739010..4e93110 100644
--- a/scr/lt2/pages/index/index.js
+++ b/scr/lt2/pages/index/index.js
@@ -1,10 +1,12 @@
//index.js
let currentPage = 0 // 当前第几页,0代表第一页
-let pageSize = 1
+let pageSize = 6
var util = require('../../utils/util.js')
var app = getApp()
Page({
data: {
+ search:'',
+ re:[],
feed: [],
feed_length: 0,
loadMore: false, //"上拉加载"的变量,默认false,隐藏
@@ -24,23 +26,27 @@ bindItemTap: function(event) {
})
},
-bindQueTap: function() {//跳转que 可不用此函数
-
- },
+
onLoad: function () {
console.log('onLoad')
+ this.clearCache();
let that = this
//调用应用实例的方法获取全局数据
this.getData();
+ this.refresh()
},
+onShow: function (){
+ console.log('onshow')
+ this.upper()
+},
- upper: function () {
+ upper: function () {//下滑刷新
wx.showNavigationBarLoading()
this.refresh();
console.log("upper");
- setTimeout(function(){wx.hideNavigationBarLoading();wx.stopPullDownRefresh();}, 2000);
+ setTimeout(function(){wx.hideNavigationBarLoading();wx.stopPullDownRefresh();}, 1000);
},
- lower: function (e) {
+ lower: function (e) {//触底加载
wx.showNavigationBarLoading();
var that = this;
setTimeout(function(){wx.hideNavigationBarLoading();that.nextLoad();}, 1000);
@@ -112,19 +118,22 @@ onLoad: function () {
})
},
refresh: function(){
- wx.showToast({
- title: '刷新中',
- icon: 'loading',
- duration: 3000
- });
+
+ this.clearCache();
this.getData()
-
+ let that = this
+ if (!that.data.loadMore) {
+ that.setData({
+ loadMore: true, //加载中
+ loadAll: false //是否加载完所有数据
+ });}
},
//使用本地 fake 数据实现继续加载效果
nextLoad: function(){
console.log("上拉触底事件")
+
let that = this
if (!that.data.loadMore) {
that.setData({
@@ -139,13 +148,6 @@ onLoad: function () {
}
},
- // 清缓存
- clearCache:function(){
- currentPage = 0;//分页标识归零
- this.setData({
- feed: [] //列表数组清空
- });
- },
goto(){
wx.navigateTo({
@@ -153,6 +155,97 @@ onLoad: function () {
})
},
+// 清缓存
+clearCache:function(){
+ currentPage = 0;//分页标识归零
+ this.setData({
+ feed: [] //文章列表数组清空
+ });
+},
+
+
+
+
+GetSearchInput: function(e) {
+ this.setData({
+ search: e.detail.value
+ })
+
+},
+ToSearch: function(e) {
+ //let search = e.detail.value;
+ var that = this;
+
+ if(this.data.search == '') {
+ wx.showToast({
+ title: '请输入',
+ icon: 'none'
+ })
+ return
+ }
+
+ wx.showLoading({
+ title: '搜索中',
+ })
+ const _ = wx.cloud.database().command
+ wx.cloud.database().collection('tiezi').where(_.or([
+ {
+ content: wx.cloud.database().RegExp({
+ regexp: this.data.search,
+ options: 'i',
+ }),
+ },
+ {
+ title: wx.cloud.database().RegExp({
+ regexp: this.data.search,
+ options: 'i',
+ }),
+ }
+]))
+
+// wx.cloud.database().collection('tiezi').where({
+// content: wx.cloud.database().RegExp({
+// regexp: this.data.search,
+// options: 'i',
+// }),
+
+// })
+.get()
+.then(res => {
+ if (res.data.length != 0) {
+ this.setData({
+ re: res.data,
+ })
+ wx.setStorageSync('re', res.data)
+ let re= wx.getStorageSync('re')
+ console.log(re)
+ let that = this;
+ wx.hideLoading({
+ success: (res) => {
+ that.setData({
+ search: '',
+ })
+ }})
+ wx.navigateTo({
+ url: '../searchShow/searchShow?re='+JSON.stringify(re),//要跳转到的页面路径
+
+ })
+
+
+ } else {
+ wx.showToast({
+ title: '未找到',
+ icon: 'none'
+ })
+ }
+ console.log(res.data)
+
+
+})
+.catch(res => {
+ console.log("查询失败",res)
+})
+},
})
diff --git a/scr/lt2/pages/index/index.wxml b/scr/lt2/pages/index/index.wxml
index b559bf7..0e3ec16 100644
--- a/scr/lt2/pages/index/index.wxml
+++ b/scr/lt2/pages/index/index.wxml
@@ -2,13 +2,29 @@
-
-
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+
+
+
+
+
+
@@ -22,10 +38,10 @@
{{item.feed_source_name}}
-
+
-
+
{{item.title}}
@@ -38,15 +54,18 @@
{{item.good_num}} 赞同
+
+
+
-
- 关注问题
-
+
+ 正在载入更多...
+ 已加载全部
diff --git a/scr/lt2/pages/index/index.wxss b/scr/lt2/pages/index/index.wxss
index 10439be..2551e0f 100644
--- a/scr/lt2/pages/index/index.wxss
+++ b/scr/lt2/pages/index/index.wxss
@@ -54,4 +54,56 @@
display:-webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
-}
\ No newline at end of file
+}
+.loading {
+ font-size: 32rpx;
+ position: relative;
+ bottom: 5rpx;
+ padding: 10rpx;
+ text-align: center;
+}
+
+
+
+
+
+.sousuokuang {
+ width: 100%;
+ height: 100rpx;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ background-color: white;
+}
+.sousuo {
+ width: 92%;
+ height: 100rpx;
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-items: center;
+}
+.shurukuang {
+ width: 80%;
+ height: 64rpx;
+ border-radius: 32rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #f6f6f6;
+}
+.shurukuang input {
+ width: 90%;
+ height: 100%;
+ font-size: 32rpx;
+}
+.sousuo_anniu {
+ width: 20%;
+ height: 64rpx;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+.sousuo_anniu text {
+ font-size: 30rpx;
+}
diff --git a/scr/lt2/pages/login/login.js b/scr/lt2/pages/login/login.js
index 8638f1a..47d4c41 100644
--- a/scr/lt2/pages/login/login.js
+++ b/scr/lt2/pages/login/login.js
@@ -17,6 +17,7 @@ Page({
*/
},
login(){
+ let that = this;
console.log('点击事件执行了')
wx.getUserProfile({
desc: '必须授权才能使用',
@@ -24,6 +25,7 @@ Page({
let user=res.userInfo
let avatarUrl=res.userInfo.avatarUrl
let nickName=res.userInfo.nickName
+
wx.setStorageSync('user', user)
wx.setStorageSync('avatarUrl', avatarUrl)
wx.setStorageSync('nickName', nickName)
diff --git a/scr/lt2/pages/searchShow/searchShow.js b/scr/lt2/pages/searchShow/searchShow.js
new file mode 100644
index 0000000..79793ad
--- /dev/null
+++ b/scr/lt2/pages/searchShow/searchShow.js
@@ -0,0 +1,33 @@
+// pages/searchShow/searchShow.js
+Page({
+
+ /**
+ * 组件的初始数据
+ */
+ data: {
+
+ },
+
+ onLoad: function(options) {
+ console.log("1")
+ console.log(JSON.parse(options.re),"1")
+ let re = JSON.parse(options.re);
+ let that = this
+ that.setData({
+ re: re
+ })
+ console.log(re)
+ },
+ bindItemTap: function(event) {
+ /*wx.navigateTo({
+ url: '../answer/answer'
+ })*/
+ var aid=event.currentTarget.dataset.aid;
+ console.log(aid)
+ //console.log("1")
+ wx.navigateTo({
+ url: '../answer/answer?aid='+aid,//要跳转到的页面路径
+ })
+}
+
+})
diff --git a/scr/lt2/pages/searchShow/searchShow.json b/scr/lt2/pages/searchShow/searchShow.json
new file mode 100644
index 0000000..e8cfaaf
--- /dev/null
+++ b/scr/lt2/pages/searchShow/searchShow.json
@@ -0,0 +1,4 @@
+{
+ "component": true,
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/scr/lt2/pages/searchShow/searchShow.wxml b/scr/lt2/pages/searchShow/searchShow.wxml
new file mode 100644
index 0000000..528f720
--- /dev/null
+++ b/scr/lt2/pages/searchShow/searchShow.wxml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.feed_source_name}}
+
+
+
+
+
+
+
+ {{item.title}}
+
+
+
+
+ {{item.content}}
+
+
+
+ {{item.good_num}} 赞同
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/scr/lt2/pages/searchShow/searchShow.wxss b/scr/lt2/pages/searchShow/searchShow.wxss
new file mode 100644
index 0000000..52980fa
--- /dev/null
+++ b/scr/lt2/pages/searchShow/searchShow.wxss
@@ -0,0 +1,10 @@
+.answer-txt{
+ width:700rpx;
+ height:49rpx;
+ font-size:25rpx;
+ overflow:hidden;
+ text-overflow: ellipsis;
+ display:-webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+}
\ No newline at end of file
diff --git a/scr/lt2/pages/submit/submit.js b/scr/lt2/pages/submit/submit.js
index 640d56c..093cdd0 100644
--- a/scr/lt2/pages/submit/submit.js
+++ b/scr/lt2/pages/submit/submit.js
@@ -16,7 +16,10 @@ Page({
index:0,
nickName:"",
avatarUrl:"",
- feed:[]
+ feed:[],
+ pinglun:[],
+ comment_num:0,
+ good_num:0
},
bindPickerChange:function(e){
console.log(e)
@@ -105,6 +108,7 @@ Page({
let count=0;
let that = this;
let url = [];
+ let pl=[];
console.log(e);
let title = e.detail.value.name;
let content = e.detail.value.content;
@@ -180,7 +184,10 @@ Page({
url:url,
createTime: wx.cloud.database().serverDate(),
feed_source_img:b,
- feed_source_name:a
+ feed_source_name:a,
+ pinglun:pl,
+ comment_num:0,
+ good_num:0
}
})
wx.hideLoading({
@@ -201,6 +208,7 @@ Page({
//将所有的内容上传到云端去
for(i=0;i