tanyanfei 4 лет назад
Родитель
Сommit
9932cdd9ae

+ 1 - 1
app.js

@@ -42,6 +42,6 @@ App({
   globalData: {
     userInfo: null,
     host:'https://test.scxjc.club',
-    openid: ''
+    openid: '',
   }
 })

+ 3 - 2
app.json

@@ -1,11 +1,12 @@
 {
   "pages": [
+    
     "pages/knowledge/knowledge",
     "pages/index/index",
     "pages/list/list",
-    
-    "pages/search/search",
     "pages/actDetail/actDetail",
+    "pages/search/search",
+    
     
     "pages/jInfo/jInfo",
     "pages/eventDetail/eventDetail",

+ 81 - 3
pages/actDetail/actDetail.js

@@ -1,20 +1,98 @@
 // pages/actDetail/actDetail.js
+const app = getApp()
+var host = app.globalData.host;
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    info: {},
+    uid:'',
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    // options.id=89;
+    var that = this;
+    wx.showLoading({
+      title: '加载中',
+    })
+    wx.getStorage({
+      key: 'uid',
+      success: function (res) {
+        that.setData({
+          uid:res.data,
+          id: options.id
+        })
+        that.getData();
+      },
+    })
+    
+  },
+  getData:function(){
+    var that = this;
+    wx.request({
+      url: host + '/api/detail',
+      method: 'GET',
+      data: {
+        type: 'article',
+        id: this.data.id,
+        uid: this.data.uid
+      },
+      success: function (res) {
+        wx.hideLoading();
+        that.setData({
+          info: res.data.data
+        })
+      },
+      fail: function () {
+        wx.hideLoading();
+        wx.showToast({
+          title: '服务器开小差啦!',
+          icon: 'none'
+        })
+      }
+    })
+  },
+  collect:function(e){
+    var that=this,info=this.data.info;
+    var data={
+      type: 'article',
+      id: this.data.info.id,
+      uid: this.data.uid
+    }
+    if(e.target.dataset.id){
+      data.action='cancel'
+    }
+    wx.request({
+      url: host+'/api/collect',
+      data:data,
+      success:function(res){
+        if(res.data.code == 0){
+          if(data.action){
+            wx.showToast({
+              title: '已取消',
+              icon: 'none'
+            })
+            info.is_collected = 0
+          }else{
+            wx.showToast({
+              title: '已收藏',
+              icon:'none'
+            })
+            info.is_collected = 1
+          }
+            
+            that.setData({
+              info: info
+            })
+        }
+      }
+    })
   },
-
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

Разница между файлами не показана из-за своего большого размера
+ 14 - 11
pages/actDetail/actDetail.wxml


+ 13 - 2
pages/actDetail/actDetail.wxss

@@ -14,9 +14,12 @@ page{
 }
 .faceimg{
   width: 20%;
+  height: 180rpx;
+  /* padding-right: 20rpx; */
 }
 .faceimg image{
   width: 100%;
+  /* height: 200rpx; */
 }
 .tweo{
   width: 80%;
@@ -24,14 +27,19 @@ page{
 .tweo view{
   color: #999;
   font-size: 26rpx;
-  padding-left: 20rpx;
+  padding-left: 30rpx;
   margin-bottom: 10rpx;
 }
 .intro text{
-  color: #333;
+  color: #666;
   display: block;
   margin-bottom: 10rpx;
 }
+.intro view{
+  color: #333;
+  margin-bottom: 20rpx;
+  font-weight: bolder;
+}
 .content{
   line-height: 50rpx;
 }
@@ -41,4 +49,7 @@ page{
   font-size: 24rpx;
   padding:10rpx 20rpx;
   border-radius: 8rpx;
+}
+rich-text{
+  font-size: 28rpx;
 }

+ 5 - 2
pages/index/index.js

@@ -25,7 +25,7 @@ Page({
       openid: app.globalData.openid
     })
     wx.getStorage({
-      key: 'userInfo',
+      key: 'uid',
       success: res => {
         if (res.data) {
           this.setData({ show: 0 })
@@ -49,7 +49,10 @@ Page({
       },
       success: res => {
         console.log(res)
-        app.globalData.uid=res.data.data.uid
+        wx.setStorage({
+          key: 'uid',
+          data: res.data.data.uid,
+        })
         this.setData({
           show: 0
         })

+ 15 - 5
pages/knowledge/knowledge.js

@@ -11,7 +11,8 @@ Page({
     index:0,
     act:0,
     list:[],
-    show:0
+    show:0,
+    keyword:''
   },
 
   /**
@@ -20,6 +21,13 @@ Page({
   onLoad: function (options) {
     this.getData()
   },
+  search:function(e){
+    console.log(e.detail)
+    this.setData({
+      keyword: e.detail.value
+    })
+    this.getData();
+  },
   showmenu:function(){
     this.setData({
       show:!this.data.show
@@ -34,9 +42,11 @@ Page({
   },
   //获取所有数据
   getData: function () {
-    wx.showLoading({
-      title: '加载中',
-    })
+    if(this.data.keyword == ''){
+      wx.showLoading({
+        title: '加载中',
+      })
+    }
     var that = this;
     var index=this.data.index;
     wx.request({
@@ -44,7 +54,7 @@ Page({
       method: 'GET',
       data:{
         order_by:this.data.val[index],
-        keyword:''
+        keyword:this.data.keyword
       },
       success: function (res) {
         wx.hideLoading();

+ 2 - 2
pages/knowledge/knowledge.wxml

@@ -1,6 +1,6 @@
 <!--pages/knowledge/knowledge.wxml-->
 <view class="search">
-    <input placeholder-style='color:#C8C8C8;' placeholder="输入名称/关键字搜索"></input>
+    <input bindinput='search' placeholder-style='color:#C8C8C8;' placeholder="输入名称/关键字搜索"></input>
     <image  mode="widthFix" src="../images/search.png"></image>
 </view>
 
@@ -25,7 +25,7 @@
 <swiper circular="{{true}}" style="height:83vh;" bindchange='swchange' current='{{act}}' autoplay="{{false}}">
   <swiper-item>
       <scroll-view scroll-y="true" scroll-into-view="{{scroll}}" class="content">
-          <navigator url="../journalDetail/journalDetail" class="list" wx:for='{{list}}' wx:key="journals{{index}}">
+          <navigator url="../actDetail/actDetail?id={{item.id}}" class="list" wx:for='{{list}}' wx:key="journals{{index}}">
               <image   src="{{item.img}}"></image>
               <view>
                   <view class="title">{{item.name}}</view>