Browse Source

no message

sys 2 years ago
parent
commit
1b5d391fb7

+ 7 - 0
api/discovery.js

@@ -0,0 +1,7 @@
+import { request } from '@/service/ajax'
+// 商品模块路由
+const goodsUrl = '/admin/discovery/'
+// 猜你喜欢
+export const getMoments = (data) => request(goodsUrl + 'moments', 'get', { ...data })
+export const getDiscoverList = (data) => request(goodsUrl + 'list', 'get', { ...data })
+

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

@@ -51,19 +51,19 @@
               </view>
               <view class="slide-data">
                 <!--                用户个性消息-->
-                <view class="on-line-box">
+                <view class="on-line-box" v-show="item.online">
                   <image  class="on-line-img"     mode="aspectFill" src="/static/img/index/on-line.png" ></image>
                   <view class="on-line-text sys-color-black-0 sys-weight-400">当前在线</view>
                 </view>
                 <view class="user-data">
-                  <text class="user-item sys-color-white sys-weight-600">Maple</text>
+                  <text class="user-item sys-color-white sys-weight-600">{{item.title}}</text>
                   <text class="user-item sys-color-white sys-weight-600">,</text>
-                  <text class="user-item sys-color-white sys-weight-600">19</text>
+                  <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-white sys-weight-400">km</text>
-                  <text class="city-item sys-color-white sys-weight-600">重庆市九龙坡</text>
+                  <text class="city-item sys-color-white sys-weight-600">{{item.city}}</text>
                 </view>
                 <view class="open-wechat">
                   <image  class="open-wechat-img"     mode="aspectFill" src="/static/img/index/wechat.png" ></image>

+ 1 - 1
manifest.json

@@ -2,7 +2,7 @@
     "name" : "Icoco",
     "appid" : "__UNI__1B420CB",
     "description" : "",
-    "versionName" : "1.0.23",
+    "versionName" : "1.0.24",
     "versionCode" : 101,
     "transformPx" : false,
     /* 5+App特有相关 */

+ 48 - 2
pages/index/model/slide-item.vue

@@ -6,6 +6,8 @@
 
 <script>
 import tantan from '@/components/dgex-tantan/dgex-tantan.vue'
+import {getDiscoverList} from "@/api/discovery";
+import tools from "@/service/tools";
 export default {
   name: "slide-item",
   components: {
@@ -14,16 +16,60 @@ export default {
   props: {},
   data() {
     return {
-      list: []
+      page:1,
+      total:undefined,
+      isAjax:false,
+      list:[],
     }
   },
   watch: {},
 
   mounted() {
 
-    this.change({'currentIndex':1})
+    // this.change({'currentIndex':1})
+    this.getDiscoverList()
   },
   methods: {
+    getDiscoverList(){
+      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:{}
+            }
+            console.log(newdata)
+            arr.push(newdata)
+          }
+
+        })
+        this.$refs.jmList.setData(arr)
+      })
+    },
+
     change(data) {
       // 判断倒数
       let arr=[]

+ 2 - 0
service/ajax.js

@@ -12,6 +12,8 @@ console.log(BASE_URL)
 export const request = (url, method, data, show = false) => {
   console.log(url)
   let token=uni.getStorageSync('token')
+  let userId=uni.getStorageSync('userId')
+  data.userId=userId
   let header={
     'content-type': 'application/json',
     'hversion': '1.0',

+ 26 - 0
service/tools.js

@@ -358,6 +358,7 @@ tools.setLoginData = function (data) {
     uni.setStorageSync('tokenType', data.token_type)
     uni.setStorageSync('refreshToken', data.access_token)
     uni.setStorageSync('mobile', data.username)
+    uni.setStorageSync('userId', data.user_id)
     tools.success('登陆成功')
     // setTimeout(() => {
     //     if (data.status * 1 === 0) {
@@ -390,6 +391,31 @@ tools.delCosToken=function (data){
 }
 
 
+tools.getAge=function (birthYearMonthDay) {
+    birthYearMonthDay=birthYearMonthDay.replace('-','/')
+    //birthYearMonthDay必须为"1995/6/15"这种字符串格式,不可为"2020-6-15",这种格式在Safari中会报错
+    const birthDate = new Date(birthYearMonthDay);
+    const momentDate = new Date();
+    momentDate.setHours(0, 0, 0, 0); //因为new Date()出来的时间是当前的时分秒。我们需要把时分秒重置为0。使后面时间比较更精确
+    const thisYearBirthDate = new Date(
+        momentDate.getFullYear(),
+        birthDate.getMonth(),
+        birthDate.getDate()
+    );
+    const aDate = thisYearBirthDate - birthDate;
+    const bDate = momentDate - birthDate;
+    let tempAge = momentDate.getFullYear() - birthDate.getFullYear();
+    let age = null;
+    if (bDate < aDate) {
+        tempAge = tempAge - 1;
+        age = tempAge < 0 ? 0 : tempAge;
+    } else {
+        age = tempAge;
+    }
+    return age;
+}
+
+