Browse Source

Merge branch 'master' of http://git.lcpcp.cc/root/lcoco

sys 2 years ago
parent
commit
bf2f2e7f8c

+ 2 - 0
api/discovery.js

@@ -4,4 +4,6 @@ const goodsUrl = '/admin/discovery/'
 // 猜你喜欢
 export const getMoments = (data) => request(goodsUrl + 'moments', 'get', { ...data })
 export const getDiscoverList = (data) => request(goodsUrl + 'list', 'get', { ...data })
+export const setLike = (data) => request(goodsUrl + 'right/'+data, 'get', {  })
+export const setDislike = (data) => request(goodsUrl + 'left/'+data, 'get', {  })
 

+ 23 - 10
components/dgex-tantan/dgex-tantan.vue

@@ -67,12 +67,12 @@
                 </view>
                 <view class="open-wechat">
                   <image  class="open-wechat-img"     mode="aspectFill" src="/static/img/index/wechat.png" ></image>
-                  <view class="open-wechat-text sys-color-white sys-weight-400">yxk********</view>
+                  <view class="open-wechat-text sys-color-white sys-weight-400">{{item.weChat}}</view>
                   <image  class="lock-wechat-img"     mode="aspectFill" src="/static/img/index/lock.png" ></image>
                 </view>
               </view>
-              <view class="user-content">
-                <user-content></user-content>
+              <view class="user-content" v-if="currentIndex===index">
+                <user-content :user-item="item"></user-content>
               </view>
               </scroll-view>
             </view>
@@ -103,6 +103,7 @@
 <script>
 	import tools from "@/service/tools";
   import UserContent from "@/pages/index/model/user-content";
+  import {setDislike, setLike} from "@/api/discovery";
   export default {
 		name: "slide",
     components: {UserContent},
@@ -198,10 +199,6 @@
         if(this.animationData){
           return false
         }
-
-        // this.touchEndNext(this.currentIndex)
-        // return;
-        console.log('type:'+type)
         if( this.overturnType<=0){
           let imgNum=item.images.length-1
           if(type===0){
@@ -222,7 +219,6 @@
           setTimeout(()=>{
             this.animationData=null
           },300)
-          console.log('item.imgIndex:'+item.imgIndex)
         }
       },
       setOverturnImg(item){
@@ -308,8 +304,6 @@
 				}
         this.x.move = e.touches[0].pageX;
         this.y.move = e.touches[0].pageY;
-        // console.log('this.x.start:'+this.x.start+'this.x.move:'+this.x.move)
-        // console.log('this.y.start:'+this.y.start+'this.y.move:'+this.y.move)
         this.list[index].x = this.x.move - this.x.start
         this.list[index].y = this.y.move - this.y.start
         let moveX= Math.abs(this.list[index].x)
@@ -368,6 +362,16 @@
           this.setBox(index+1,3)
 				}
 			},
+      setLike(userId){
+        setLike(userId).then((res)=>{
+          console.log(res)
+        })
+      },
+      setDislike(userId){
+        setDislike(userId).then((res)=>{
+          console.log(res)
+        })
+      },
 			touchEndNext(index) {
 				this.slideing = true;
 				this.list[index].x = this.list[index].x * 5;
@@ -375,6 +379,14 @@
         this.list[index].moveX *= 5 ;
         this.list[index].angleNum *= 5;
         this.setBox(this.currentIndex+1,1)
+        console.log(this.list[this.currentIndex])
+        if(this.love !== 0){
+          //选择了喜欢
+          this.setLike(this.list[this.currentIndex].userId)
+        }else {
+          //选择了不喜欢
+          this.setDislike(this.list[this.currentIndex].userId)
+        }
 				this.touchEndDone()
 			},
 			touchEndDone() {
@@ -388,6 +400,7 @@
 							currentItem: this.list[this.currentIndex],
 							type: this.love !== 0 ? 'love' : 'dislike'
 						})
+
 						this.currentIndex++
 						this.x.move = 0
 						this.y.move = 0

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

@@ -19,12 +19,13 @@
           </view>
       </view>
     </view>
+    {{list.length}}
     <view class="dynamic-item" v-for="(item,itemIndex) in list">
       <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>
+        <view class="dynamic-title-left" v-if="item.dateArr.length>0">
+          <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 +33,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">
+          <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 +56,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 +79,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 +115,55 @@ 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},
-      ]
+      list:[],
+      isAjax:false,
+      total:undefined,
+      page:1,
+    }
+  },
+  watch: {
+    'userId':function () {
+      this.startList()
     }
   },
-  watch: {},
   mounted() {
-
+    this.startList()
   },
   methods: {
+    startList(){
+      if(this.userId<=0){
+        // return false
+      }
+      this.list=[]
+      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){
+          res.data.data.forEach((item)=>{
+            item.dateArr=tools.getDateArr(item.createdAt)
+            that.list.push(item )
+          })
+          ++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
       }
     }
   }

+ 35 - 64
pages/index/model/slide-item.vue

@@ -1,6 +1,6 @@
 <template>
   <view class="slide-box">
-    <tantan ref="jmList"  @onChange="change" @onClickImage="clickImage"></tantan>
+    <tantan ref="jmList"  @onChange="getDiscoverList" @onClickImage="clickImage"></tantan>
   </view>
 </template>
 
@@ -26,7 +26,6 @@ export default {
 
   mounted() {
 
-    // this.change({'currentIndex':1})
     this.getDiscoverList()
     this.getMoments()
   },
@@ -40,74 +39,46 @@ export default {
       if(this.isAjax){
         return
       }
-
       this.isAjax=true
       getDiscoverList({'count':10}).then((res)=>{
         this.isAjax=false
-        this.list=res
-        let arr=[]
-        res.forEach((item)=>{
-          let galleryUrls=item.galleryUrls
-          let age=tools.getAge(item.dateOfBirth)
-          if(galleryUrls.length>0){
-            if(galleryUrls.length>8){
-              galleryUrls=galleryUrls.slice(0,7)
-            }
-            let newdata = {
-              image: galleryUrls[0],
-              images: galleryUrls,
-              imgIndex:0,
-              title:  item.nickname,
-              age:  age,
-              online:  item.online,
-              longitude:  item.longitude,
-              latitude:  item.latitude,
-              distance: 17,
-              city:  item.province+' '+item.city,
-              weChat:  item.wechatId,
-              animation:{}
+        if(res.code===0){
+          this.list=res
+          let arr=[]
+          res.data.forEach((item)=>{
+            let galleryUrls=item.galleryUrls
+            let age=tools.getAge(item.dateOfBirth)
+            if(galleryUrls.length>0){
+              if(galleryUrls.length>8){
+                galleryUrls=galleryUrls.slice(0,7)
+              }
+              let newdata = {
+                image: galleryUrls[0],
+                images: galleryUrls,
+                imgIndex:0,
+                title:  item.nickname,
+                userId:  item.userId,
+                age:  age,
+                online:  item.online,
+                longitude:  item.longitude,
+                latitude:  item.latitude,
+                distance: 17,
+                city:  item.province+' '+item.city,
+                weChat:  item.wechatId,
+                likeCount:  item.likeCount,
+                tagList:  item.tagList,
+                slogan:  item.slogan,
+                animation:{}
+              }
+              console.log(newdata)
+              arr.push(newdata)
             }
-            console.log(newdata)
-            arr.push(newdata)
-          }
-
-        })
-        this.$refs.jmList.setData(arr)
-      })
-    },
 
-    change(data) {
-      // 判断倒数
-      let arr=[]
-      // 模拟一下最加数据
-      const tu = [
-        'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
-        'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
-        'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
-        'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
-      ]
-      for (let index = 0; index < 10; index++) {
-        const n = Math.floor(Math.random() * (tu.length - 1))
-        let newdata = {
-          image: tu[n],
-          images: [
-            'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2Fc7a27a1ej00qvpu700019c000hs00vlc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
-            'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F9f81e6aaj00qvpu70001xc000hs00vmc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
-            'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F55bf2cb3j00qvpu70002cc000hs012jc.jpg&thumbnail=660x2147483647&quality=80&type=jpg',
-            'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0704%2F2017725bj00qvpu70001jc000hs00zxc.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
-          ],
-          imgIndex:0,
-          title: '你好',
-          age: '19',
-          distance: '19.6',
-          city: '香港九龙城',
-          weChat: 'siococos',
-          animation:{}
+          })
+          this.$refs.jmList.setData(arr)
         }
-        arr.push(newdata)
-      }
-      this.$refs.jmList.setData(arr)
-      // console.log(data);
+
+      })
     },
     clickImage(data) {
       console.log(data);

+ 24 - 9
pages/index/model/user-content.vue

@@ -4,14 +4,14 @@
       <view class="top-left">“</view>
       <view class="top-right">
         <image  class="right-img"   mode="aspectFill" src="/static/img/index/like.png" ></image>
-        <view class="right-text sys-color-white sys-weight-400">108喜欢</view>
+        <view class="right-text sys-color-white sys-weight-400">{{userItem.likeCount}}喜欢</view>
       </view>
     </view>
-    <view class="user-signature sys-color-white sys-weight-400">崇尚自由,热爱生活,足以!</view>
-    <view class="user-tag">
-      <view class="tag-item" v-for="i in 5">
+    <view class="user-signature sys-color-white sys-weight-400">{{userItem.slogan}}</view>
+    <view class="user-tag" v-if="userItem.tagList.length>0">
+      <view class="tag-item" v-for="i in userItem.tagList">
         <image  class="tag-img"   mode="aspectFill" src="/static/img/index/tag-img.png" ></image>
-        <view class="tag-text sys-color-gray-3 sys-weight-400">认识朋友</view>
+        <view class="tag-text sys-color-gray-3 sys-weight-400">{{i}}</view>
       </view>
     </view>
     <view class="user-wire"></view>
@@ -37,7 +37,7 @@
     </view>
 
     <view class="dynamic-list">
-      <dynamic-item ></dynamic-item>
+      <dynamic-item :user-id="userItem.userId"></dynamic-item>
 
     </view>
 
@@ -49,10 +49,19 @@ 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: {
+    'userItem':{
+      default:{
+        'userId':0,
+        'likeCount':0,
+        'tagList':[],
+      }
+    }
+  },
   data() {
     return {
       giftList:[
@@ -64,13 +73,19 @@ export default {
         {'num':0,'url':'/static/img/temporary/gift3.png'},
       ],
 
+
     }
   },
-  watch: {},
-  mounted() {
+  watch: {
+    'userId':function () {
 
+    }
+  },
+  mounted() {
+    console.log()
   },
   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('.');