BF-202210271038\Administrator 2 lat temu
rodzic
commit
e0c0eba719

+ 1 - 1
components/dgex-tantan/dgex-tantan.vue

@@ -72,7 +72,7 @@
                 </view>
               </view>
               <view class="user-content">
-                <user-content></user-content>
+                <user-content :user-id="item.userId"></user-content>
               </view>
               </scroll-view>
             </view>

+ 68 - 33
pages/common/dynamic/dynamic-items.vue

@@ -19,12 +19,14 @@
           </view>
       </view>
     </view>
-    <view class="dynamic-item" v-for="(item,itemIndex) in list">
+    {{dynamicList.length}}
+    <view class="dynamic-item" v-for="(item,itemIndex) in dynamicList">
+      12121
       <view class="dynamic-title">
         <view class="dynamic-title-left">
-          <text class="dynamic-title-text  sys-weight-600" :style="{'color':textColor}">12</text>
-          <text class="dynamic-title-text  sys-weight-400" :style="{'color':textColor}">04月</text>
-          <text class="dynamic-title-text  sys-weight-400" :style="{'color':textColor}">2020年</text>
+          <text class="dynamic-title-text  sys-weight-600" :style="{'color':textColor}">item.dateArr[2]</text>
+          <text class="dynamic-title-text  sys-weight-400" :style="{'color':textColor}">item.dateArr[1]月</text>
+          <text class="dynamic-title-text  sys-weight-400" :style="{'color':textColor}">item.dateArr[0]年</text>
         </view>
         <view class="dynamic-title-right">
           <image  class="dynamic-right-img"   mode="aspectFill" src="/static/img/index/dynamic-all.png" ></image>
@@ -32,22 +34,22 @@
       </view>
       <view class="dynamic-data" :style="{'border-left':' 1rpx solid '+divisionColor}">
         <view class="data-text">
-          <text class="text-item" :style="{'color':textColor}">{{item.text}}</text>
+          <text class="text-item" :style="{'color':textColor}">{{item.content}}</text>
         </view>
 
-        <view class="data-img" v-if="item.img.length>0">
-          <view class="one-img" v-if="item.img.length===1">
-            <img-one :file-list="item.img"></img-one>
+        <view class="data-img" v-if="item.galleryUrls.length>0">
+          <view class="one-img" v-if="item.galleryUrls.length===1">
+            <img-one :file-list="item.galleryUrls"></img-one>
           </view>
-          <view class="two-img" v-else-if="item.img.length===2 || item.img.length===4">
-            <img-two :file-list="item.img"></img-two>
+          <view class="two-img" v-else-if="item.galleryUrls.length===2 || item.galleryUrls.length===4">
+            <img-two :file-list="item.galleryUrls"></img-two>
           </view>
           <view class="three-img" v-else>
-            <img-three :file-list="item.img"></img-three>
+            <img-three :file-list="item.galleryUrls"></img-three>
           </view>
 
         </view>
-        <view class="data-tag-list" 	>
+        <view class="data-tag-list" v-if="false"	>
           <dynamic-tag :list="item.tag" :tag-bg="tagBg" :tag-color="tagColor"></dynamic-tag>
 
         </view>
@@ -55,15 +57,15 @@
           <view class="operation-item" @click="setLike(itemIndex)">
 <!--            <image  class="operation-img"   mode="aspectFill" :src="'/static/img/index/like-'+(item.isLike?'ok':'no')+'.png'" ></image>-->
             <view class="operation-icon">
-              <text class="iconfont icon-dianzan" v-if="!item.isLike"  :style="{'color':operateColor}"> &#xe8ad;</text>
+              <text class="iconfont icon-dianzan" v-if="!item.liked"  :style="{'color':operateColor}"> &#xe8ad;</text>
               <text class="iconfont icon-dianzan1" v-else  :style="{'color':'#ED301D'}"> &#xe8c3;</text>
             </view>
-            <view class="operation-text sys-weight-400" :style="{'color':operateColor}">{{item.likeNum>0?item.likeNum:'点赞'}}</view>
+            <view class="operation-text sys-weight-400" :style="{'color':operateColor}">{{item.likeCount>0?item.likeCount:'点赞'}}</view>
           </view>
           <view class="operation-item">
 <!--            <image  class="operation-img"   mode="aspectFill" src="/static/img/index/evaluate.png" ></image>-->
             <view class="operation-icon"><text class="iconfont icon-pinglun"  :style="{'color':operateColor}">&#xe891;</text></view>
-            <view class="operation-text sys-weight-400" :style="{'color':operateColor}">{{item.evaluateNum>0?item.evaluateNum:'评论'}}</view>
+            <view class="operation-text sys-weight-400" :style="{'color':operateColor}">{{item.commentCount>0?item.commentCount:'评论'}}</view>
           </view>
         </view>
 
@@ -78,10 +80,15 @@ import ImgOne from "@/pages/common/img/img-one";
 import ImgTwo from "@/pages/common/img/img-two";
 import ImgThree from "@/pages/common/img/img-three";
 import DynamicTag from "@/pages/common/tag/dynamic-tag";
+import {getMoments} from "@/api/discovery";
+import tools from "@/service/tools";
 export default {
   name: "dynamic-items",
   components: {DynamicTag, ImgThree, ImgTwo, ImgOne},
   props: {
+    'userId':{
+      default:0
+    },
       textColor:{
         type:String,
         default:'#fff'
@@ -109,31 +116,59 @@ export default {
   },
   data() {
     return {
-      list:[
-        {'text':'我是阳光大男孩我','img':['/static/img/temporary/1.png'],'tag':[{'text':'南亭新都会商场','icon':'1'},{'text':'你好认识一哈','icon':'2'}],'likeNum':1,'evaluateNum':0,'isLike':true},
-        {'text':'我是阳光大男孩我','img':['/static/img/temporary/1.png','/static/img/temporary/2.png','/static/img/temporary/3.png','/static/img/temporary/2.png'],'tag':[{'text':'南亭新都会商场','icon':'1'},{'text':'你好认识一哈','icon':'2'}],'likeNum':0,'evaluateNum':20,'isLike':false},
-        {'text':'我是阳光大男孩我','img':[
-            '/static/img/temporary/1.png',
-            '/static/img/temporary/3.png',
-            '/static/img/temporary/2.png',
-            '/static/img/temporary/1.png',
-            '/static/img/temporary/3.png',
-            '/static/img/temporary/2.png',
-          ],'tag':[{'text':'南亭新都会商场','icon':'1'},{'text':'你好认识一哈','icon':'2'}],'likeNum':10,'evaluateNum':20,'isLike':true},
-      ]
+      page:1,
+      total:undefined,
+      isAjax:false,
+      dynamicList:[]
+    }
+  },
+  watch: {
+    'userId':function () {
+      // this.startList()
     }
   },
-  watch: {},
   mounted() {
-
+    this.startList()
   },
   methods: {
+    startList(){
+      if(this.userId<=0){
+        return false
+      }
+      // this.dynamicList=[]
+      this.isAjax=false
+      this.total=undefined
+      this.page=1
+      this.getMoments()
+    },
+    getMoments(){
+      if(this.isAjax){
+        return
+      }
+      this.isAjax=true
+      let that=this
+      getMoments({'userId':this.userId,'pageNo':this.page,'pageSize':20}).then((res)=>{
+        this.isAjax=false
+        if(res.code===0){
+          // console.log(this.dynamicList)
+          res.data.data.forEach((item)=>{
+            item.dateArr=tools.getDateArr(item.createdAt)
+            console.log(that.dynamicList)
+            that.dynamicList.push(item)
+          })
+          // console.log( this.dynamicList)
+          // console.log( this.dynamicList.length)
+          ++that.page
+          that.total=res.data.total
+        }
+      })
+    },
     setLike(index){
-      this.list[index].isLike=!this.list[index].isLike
-      if(this.list[index].isLike){
-        ++this.list[index].likeNum
+      this.dynamicList[index].liked=!this.dynamicList[index].liked
+      if(this.dynamicListdynamicList[index].liked){
+        ++this.dynamicList[index].likeCount
       }else {
-        --this.list[index].likeNum
+        --this.dynamicList[index].likeCount
       }
     }
   }

+ 13 - 3
pages/index/model/user-content.vue

@@ -37,7 +37,7 @@
     </view>
 
     <view class="dynamic-list">
-      <dynamic-item ></dynamic-item>
+      <dynamic-item :user-id="userId"></dynamic-item>
 
     </view>
 
@@ -49,10 +49,15 @@ import ImgOne from "@/pages/common/img/img-one";
 import ImgTwo from "@/pages/common/img/img-two";
 import ImgThree from "@/pages/common/img/img-three";
 import DynamicItem from "@/pages/common/dynamic/dynamic-items";
+import {getMoments} from "@/api/discovery";
 export default {
   name: "user-content",
   components: {DynamicItem, ImgThree, ImgTwo, ImgOne},
-  props: {},
+  props: {
+    'userId':{
+      default:0
+    }
+  },
   data() {
     return {
       giftList:[
@@ -66,11 +71,16 @@ export default {
 
     }
   },
-  watch: {},
+  watch: {
+    'userId':function () {
+
+    }
+  },
   mounted() {
 
   },
   methods: {
+
     stopTouche(){
       // console.log('滑动事件阻止触发')
       return false

+ 5 - 7
service/ajax.js

@@ -28,26 +28,24 @@ export const request = (url, method, data, show = false) => {
     token= 'Bearer '+token
   }
   header.Authorization=token
-  console.log(header)
+  // console.log(header)
   // data.token = token;
   // data.m_id = uni.getStorageSync('m_id')
   if (show) {
     tools.showLoading();
   }
-  if (data === undefined) {
-    data = {};
-  }
+
   return new Promise((resolve, reject) => {
     // 封装主体:网络请求
-    console.log(BASE_URL+  url)
-    console.log(data)
+    // console.log(BASE_URL+  url)
+    // console.log(data)
     uni.request({
       url:BASE_URL+  url,
       data: data,
       method: method || 'post',
       header: header,
       success: (res) => {
-        console.log(res); // 控制台显示数据信息
+        // console.log(res); // 控制台显示数据信息
         if (res.statusCode === 200) {
           // console.log('应答信息-----------------------')
           tools.hideLoading();

+ 11 - 1
service/tools.js

@@ -278,7 +278,8 @@ tools.leftClick = function () {
     }
 }
 
-tools.getDate = function () {
+tools.getDate = function (date) {
+
     let myDate = new Date();
     // let myYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
     // let myMonth = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
@@ -290,6 +291,15 @@ tools.getDate = function () {
     return myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate()
 }
 
+tools.getDateArr = function (date) {
+
+    let myDate = new Date(date);
+    let myYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
+    let myMonth = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
+    let myToday = myDate.getDate(); //获取当前日(1-31)
+    return [myYear, myMonth>9?myMonth:'0'+myMonth , myToday>9?myToday:'0'+myToday]
+}
+
 tools.getRandFileName = function (filePath)
 {
     let extIndex = filePath.lastIndexOf('.');