Browse Source

no message

sys 2 years ago
parent
commit
8e600da495

+ 21 - 33
components/dgex-tantan/dgex-tantan.vue

@@ -38,7 +38,7 @@
                 <image     :style="{height: item.boxHeight + 'px',width:item.boxWidth+'px'}"  mode="aspectFill" :src="item.image" ></image>
 
               </view>
-              <view class="user-authentication">
+              <view class="user-authentication" v-show="item.verified">
                 <image  class="authentication-img"     mode="aspectFill" src="/static/img/index/authentication.png" ></image>
                 <view class="authentication-text sys-color-white sys-weight-600">真实头像</view>
               </view>
@@ -61,7 +61,7 @@
                   <text class="user-item sys-color-white sys-weight-600">{{item.age}}</text>
                 </view>
                 <view class="user-city">
-                  <text class="city-item sys-color-yellow sys-weight-600">17.16</text>
+                  <text class="city-item sys-color-yellow sys-weight-600">{{item.distance}}</text>
                   <text class="city-item sys-color-white sys-weight-400">km</text>
                   <text class="city-item sys-color-white sys-weight-600">{{item.city}}</text>
                 </view>
@@ -157,7 +157,6 @@
 
 		mounted() {
 			const res = uni.getSystemInfoSync()
-      console.log(res)
 			this.winWidth = res.windowWidth
 			this.winHeight = res.windowHeight-84
 
@@ -178,7 +177,9 @@
           }
         }
       },
-      setData(list){
+      async setData(list){
+
+        let isNew=false
         list.forEach((item)=>{
           item.imgIndex=0
           item.moveX=0
@@ -187,13 +188,16 @@
           if( this.list.length<=0){
             item.boxWidth=this.winWidth-18
             item.boxHeight=this.winHeight
+            isNew=true
           }else {
             item.boxWidth=this.winWidth-28
             item.boxHeight=this.winHeight-30
           }
-
           this.list.push(item)
         })
+        if(isNew && this.list.length>0){
+          this.list[0].distance=await tools.getDistance(this.list[0].latitude,this.list[0].longitude)
+        }
       },
       setImgKey(item, type){
         if(this.animationData){
@@ -362,45 +366,29 @@
           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) {
+
+		async	touchEndNext(index) {
 				this.slideing = true;
 				this.list[index].x = this.list[index].x * 5;
 				this.list[index].y = this.list[index].y * 5;
         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()
+      let newIndex=this.currentIndex+1
+        this.list[newIndex].distance=await tools.getDistance(this.list[newIndex].latitude,this.list[newIndex].longitude)
+
+       await	this.touchEndDone()
 			},
 			touchEndDone() {
-
+        this.$emit('onChange', {
+          currentIndex: this.currentIndex,
+          currentItem: this.list[this.currentIndex],
+          type: this.love !== 0 ? 'love' : 'dislike'
+        })
 				return new Promise((resolve) => {
           this.imgKey=0
-					setTimeout(() => {
+          setTimeout(() => {
 						this.slideing = false
-						this.$emit('onChange', {
-							currentIndex: this.currentIndex,
-							currentItem: this.list[this.currentIndex],
-							type: this.love !== 0 ? 'love' : 'dislike'
-						})
-
 						this.currentIndex++
 						this.x.move = 0
 						this.y.move = 0

+ 15 - 1
manifest.json

@@ -60,7 +60,12 @@
             /* SDK配置 */
             "sdkConfigs" : {
                 "ad" : {},
-                "maps" : {},
+                "maps" : {
+                    "baidu" : {
+                        "appkey_ios" : "",
+                        "appkey_android" : ""
+                    }
+                },
                 "geolocation" : {},
                 "oauth" : {
                     "univerify" : {},
@@ -140,6 +145,15 @@
                     "secure" : false
                 }
             }
+        },
+        "sdkConfigs" : {
+            "maps" : {
+                "amap" : {
+                    "key" : "40bff53b893ac5ccb05e3f018f7315f7",
+                    "securityJsCode" : "1bb5f515ea82f48a6b3ea37a3f88fa21",
+                    "serviceHost" : ""
+                }
+            }
         }
     }
 }

+ 0 - 1
pages/common/img/img-one.vue

@@ -22,7 +22,6 @@ export default {
   },
   methods: {
     previewImage(index){
-      return;
       uni.previewImage({
         urls: this.fileList,
         current:index

+ 0 - 1
pages/common/img/img-three.vue

@@ -24,7 +24,6 @@ export default {
   },
   methods: {
     previewImage(index){
-      return;
       uni.previewImage({
         urls: this.fileList,
         current:index

+ 0 - 1
pages/common/img/img-two.vue

@@ -24,7 +24,6 @@ export default {
   },
   methods: {
     previewImage(index){
-      return;
       uni.previewImage({
         urls: this.fileList,
         current:index

+ 25 - 11
pages/index/model/slide-item.vue

@@ -1,12 +1,12 @@
 <template>
   <view class="slide-box">
-    <tantan ref="jmList"  @onChange="getDiscoverList" @onClickImage="clickImage"></tantan>
+    <tantan ref="jmList"  @onChange="onChange" @onClickImage="clickImage"></tantan>
   </view>
 </template>
 
 <script>
 import tantan from '@/components/dgex-tantan/dgex-tantan.vue'
-import {getDiscoverList, getMoments} from "@/api/discovery";
+import {getDiscoverList, getMoments, setDislike, setLike} from "@/api/discovery";
 import tools from "@/service/tools";
 export default {
   name: "slide-item",
@@ -25,14 +25,29 @@ export default {
   watch: {},
 
   mounted() {
-
     this.getDiscoverList()
-    this.getMoments()
   },
   methods: {
-    getMoments(){
-      getMoments({'pageNo':1,'pageSize':20}).then((res)=>{
-
+    onChange(data){
+      if(this.type ==='love'){
+        //选择了喜欢
+        this.setLike(data.currentItem.userId)
+      }else {
+        //选择了不喜欢
+        this.setDislike(data.currentItem.userId)
+      }
+      if(this.list.length<data.currentIndex+5){
+        this.getDiscoverList()
+      }
+    },
+    setLike(userId){
+      setLike(userId).then((res)=>{
+        console.log(res)
+      })
+    },
+    setDislike(userId){
+      setDislike(userId).then((res)=>{
+        console.log(res)
       })
     },
     getDiscoverList(){
@@ -45,7 +60,7 @@ export default {
         if(res.code===0){
           this.list=res
           let arr=[]
-          res.data.forEach((item)=>{
+          res.data.forEach( (item)=>{
             let galleryUrls=item.galleryUrls
             let age=tools.getAge(item.dateOfBirth)
             if(galleryUrls.length>0){
@@ -62,18 +77,17 @@ export default {
                 online:  item.online,
                 longitude:  item.longitude,
                 latitude:  item.latitude,
-                distance: 17,
+                distance: 0,
                 city:  item.province+' '+item.city,
                 weChat:  item.wechatId,
                 likeCount:  item.likeCount,
                 tagList:  item.tagList,
                 slogan:  item.slogan,
+                verified:  item.verified,
                 animation:{}
               }
-              console.log(newdata)
               arr.push(newdata)
             }
-
           })
           this.$refs.jmList.setData(arr)
         }

+ 82 - 3
service/tools.js

@@ -401,7 +401,78 @@ tools.delCosToken=function (data){
     uni.removeStorageSync('cosToken')
 }
 
+/**
+ * 定位经纬度
+ * @returns {Promise<unknown>}
+ */
+tools.getLocation=async function (){
+    return new Promise((resolve, reject)=>{
+        //#ifdef APP-PLUS
+        let locationData= uni.getStorageSync('locationData')
+        console.log('locationData:',locationData)
+        if(locationData){
+            resolve(locationData);
+        }else {
+            console.log('执行获取')
+            uni.getLocation({
+                type: 'gcj02',
+                success:async function (res) {
+                    console.log('当前位置的经度:' + res.longitude);
+                    console.log('当前位置的纬度:' + res.latitude);
+                    resolve({'longitude':res.longitude,'latitude':res.latitude});
+                },
+                fail:async function (e) {
+                    console.log(e)
+                    resolve( {'longitude':"121.631691",'latitude':'38.922691'});
+                }
+            });
+        }
+        //#endif
+        //#ifdef H5
+        resolve( {'longitude':"121.631691",'latitude':'38.922691'});
+        //#endif
+    })
+
+
+}
 
+/**
+ * 计算距离
+ * @returns {Promise<void>}
+ */
+tools.getDistance=async function (lat1,  lng1){
+    let locationData=await tools.getLocation()
+    let lat2=locationData.latitude
+    let lng2=locationData.longitude
+    let radLat1 = lat1*Math.PI / 180.0;
+    let radLat2 = lat2*Math.PI / 180.0;
+    let a = radLat1 - radLat2;
+    let  b = lng1*Math.PI / 180.0 - lng2*Math.PI / 180.0;
+    let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
+    s = s *6378.137 ;// EARTH_RADIUS;
+    s = Math.round(s * 10000) / 10000;
+    return s;
+}
+
+/**
+ * 查看大图
+ * @param list
+ * @param index
+ */
+tools.lookBigImg = function (list, index) {
+    uni.previewImage({
+        current: index,//当前所点击预览的图片地址
+        urls: list,//这就是当前行图片数据,注意一定要是数组格式
+        indicator: 'number',
+        loop: true
+    });
+}
+
+/**
+ * 计算年龄
+ * @param birthYearMonthDay
+ * @returns {number}
+ */
 tools.getAge=function (birthYearMonthDay) {
     birthYearMonthDay=birthYearMonthDay.replace('-','/')
     //birthYearMonthDay必须为"1995/6/15"这种字符串格式,不可为"2020-6-15",这种格式在Safari中会报错
@@ -427,9 +498,10 @@ tools.getAge=function (birthYearMonthDay) {
 }
 
 
-
-
-
+/**
+ * 获取costoken
+ * @returns {{expiredTime}|any|undefined}
+ */
 tools.getCosToken=function (){
   let cosToken= uni.getStorageSync('cosToken')
     if(!cosToken){
@@ -442,6 +514,13 @@ tools.getCosToken=function (){
         return undefined
     }
 }
+
+/**
+ * 封装文件结构
+ * @param url
+ * @param type
+ * @returns {{serverSideEncryption: string, location, type: (string), version: string, hash: string}}
+ */
 tools.setFileObj=function (url,type){
     url= url.replace('https://','')
     url= url.replace('http://','')