machinecat520 2 tahun lalu
induk
melakukan
92213b08c9

+ 26 - 18
pages/main/main.js

@@ -8,7 +8,7 @@ Page({
      * 页面的初始数据
      * 页面的初始数据
      */
      */
     data: {
     data: {
-        newNoticeTitle:''
+        newNoticeTitle:''   //滚动显示的公告标题
     },
     },
 
 
     /**
     /**
@@ -16,34 +16,42 @@ Page({
      */
      */
     onLoad:async function(options) {
     onLoad:async function(options) {
         let result = await request('/front/notificationFront')  //获取公告列表
         let result = await request('/front/notificationFront')  //获取公告列表
-        console.log(result);
-        let newNoticeTitle = this.data.newNoticeTitle
-        var newId = ''
-        // 获取最新的公告标题(未完成)
+        // console.log(result);
+        // 对公告列表按id降序排序(即按发布时间由近到远排序)
         if(result.length == 0){
         if(result.length == 0){
             this.setData({
             this.setData({
-                newNoticeTitle:'暂无公告发布'
+                newNoticeTitle:'暂无公告内容'
             })
             })
-        }else if(result.length == 1){
+        }else if(result.length == 1 && result[0].status == 1){
             this.setData({
             this.setData({
                 newNoticeTitle:result[0].title
                 newNoticeTitle:result[0].title
             })
             })
-        }else{
-            for(let i = 0;i < result.length - 1;i++){
-                for(let j = i+1;j < result.length - 1 - i;j++){
+        }else if(result.length == 1 && result[0].status == 0){
+            this.setData({
+                newNoticeTitle:'暂无公告内容'
+            })
+        }
+        else{
+            for(let i = 0;i < result.length-1;i++){
+                for(let j = 0;j < result.length-1-i;j++){
                     if(result[j].id < result[j+1].id){
                     if(result[j].id < result[j+1].id){
-                        let temp = result[j].id
+                        let temp = result[j]
                         result[j] = result[j+1]
                         result[j] = result[j+1]
                         result[j+1] = temp
                         result[j+1] = temp
                     }
                     }
-                    
-                }
+                }                
             }
             }
-            console.log(result);
-            this.setData({
-                newNoticeTitle:result[0].title
-            })
-        }
+            // console.log(result);
+            // 遍历重新排序后的列表,取出第一个状态为1的标题
+            for(let i = 0;i < result.length;i++){
+                if(result[i].status == 1){
+                    this.setData({
+                        newNoticeTitle:result[0].title
+                    })
+                }
+                break;
+            }            
+        }       
     },
     },
 
 
     // 跳转到纳溪介绍页面
     // 跳转到纳溪介绍页面

+ 5 - 5
pages/main/main.wxss

@@ -47,7 +47,7 @@
 /* 公告文字 */
 /* 公告文字 */
 .noticeDetail {
 .noticeDetail {
     white-space: nowrap;
     white-space: nowrap;
-    animation: loop 8s 0.5s linear infinite normal;
+    animation: loop 10s 0.5s linear infinite normal;
     display: inline-block;
     display: inline-block;
     vertical-align: top;
     vertical-align: top;
     font-size: 32rpx;
     font-size: 32rpx;
@@ -56,8 +56,8 @@
 /* 公告文字滚动 */
 /* 公告文字滚动 */
 @keyframes loop {
 @keyframes loop {
     0% {
     0% {
-        transform: translateX(350px);
-        -webkit-transform: translateX(350px);
+        transform: translateX(400rpx);
+        -webkit-transform: translateX(400rpx);
     }
     }
     100% {
     100% {
         transform: translateX(-100%);
         transform: translateX(-100%);
@@ -67,8 +67,8 @@
 
 
 @-webkit-keyframes loop {
 @-webkit-keyframes loop {
     0% {
     0% {
-      transform: translateX(300px);
-      -webkit-transform: translateX(300px);
+      transform: translateX(600rpx);
+      -webkit-transform: translateX(600rpx);
     }  
     }  
     100% {
     100% {
       transform: translateX(-100%);
       transform: translateX(-100%);

+ 1 - 1
pages/map/map.js

@@ -58,7 +58,7 @@ Page({
             latitude:marker[0].latitude
             latitude:marker[0].latitude
         })
         })
         let marks = this.data.marks
         let marks = this.data.marks
-        console.log(marks);
+        // console.log(marks);
         var arr = new Array(marks.length)
         var arr = new Array(marks.length)
         for (let i = 0; i < marks.length; i++) {
         for (let i = 0; i < marks.length; i++) {
             let latitude = marks[i].latitude
             let latitude = marks[i].latitude

+ 12 - 2
pages/notice/notice.js

@@ -16,7 +16,17 @@ Page({
      */
      */
     onLoad:async function(options) {
     onLoad:async function(options) {
         let result = await request('/front/notificationFront')  //获取公告列表
         let result = await request('/front/notificationFront')  //获取公告列表
-        console.log(result);
+        // console.log(result);
+        // 按id降序排序(即按发布时间从近到远排序)
+        for(let i = 0;i < result.length-1;i++){
+            for(let j = 0;j < result.length-1-i;j++){
+                if(result[j].id < result[j+1].id){
+                    let temp = result[j]
+                    result[j] = result[j+1]
+                    result[j+1] = temp
+                }
+            }                
+        }
         
         
         this.setData({
         this.setData({
             noticeList:result
             noticeList:result
@@ -25,7 +35,7 @@ Page({
 
 
     // 点击跳转到公告详情
     // 点击跳转到公告详情
     toNoticeDetail(e){
     toNoticeDetail(e){
-        console.log(e);
+        // console.log(e);
         let noticeId = e.currentTarget.dataset.item.id
         let noticeId = e.currentTarget.dataset.item.id
         wx.navigateTo({
         wx.navigateTo({
           url: '/pages/noticeDetail/noticeDetail?id=' + noticeId,
           url: '/pages/noticeDetail/noticeDetail?id=' + noticeId,

+ 1 - 1
pages/notice/notice.wxml

@@ -5,7 +5,7 @@
     </view>
     </view>
     <view wx:else>
     <view wx:else>
         <view wx:for="{{noticeList}}" wx:key="key">
         <view wx:for="{{noticeList}}" wx:key="key">
-            <view class="noticeList" bindtap="toNoticeDetail" data-item="{{item}}">
+            <view class="noticeList" bindtap="toNoticeDetail" data-item="{{item}}" wx:if="{{item.status == 1}}">
                 <text class="noticeTitle">{{item.title}}</text>
                 <text class="noticeTitle">{{item.title}}</text>
                 <text class="noticeBtn">查看详情</text>
                 <text class="noticeBtn">查看详情</text>
             </view>
             </view>

+ 1 - 1
pages/noticeDetail/noticeDetail.js

@@ -28,7 +28,7 @@ Page({
         this.setData({
         this.setData({
             noticeDetailList
             noticeDetailList
         })
         })
-        console.log(this.data.noticeDetailList);
+        // console.log(this.data.noticeDetailList);
     },
     },
 
 
     //点击预览图片
     //点击预览图片

+ 3 - 2
pages/recommendFood/recommendFood.js

@@ -16,12 +16,13 @@ Page({
      */
      */
     onLoad:async function(options) {
     onLoad:async function(options) {
         let result = await request('/front/merchantAndCallout')  //获取商户信息
         let result = await request('/front/merchantAndCallout')  //获取商户信息
-        console.log(result);
+        // console.log(result);
         let imagePath = []
         let imagePath = []
         for(let i = 0;i < result.length;i++){
         for(let i = 0;i < result.length;i++){
             let id = result[i].id
             let id = result[i].id
             imagePath = await request('/front/findAllMerchantFilesPath/'+id)
             imagePath = await request('/front/findAllMerchantFilesPath/'+id)
             // console.log(imagePath);
             // console.log(imagePath);
+            // 将图片地址添加到商户列表对应的店铺内
             Object.assign(result[i],imagePath)
             Object.assign(result[i],imagePath)
             // console.log(result);
             // console.log(result);
         }
         }
@@ -33,7 +34,7 @@ Page({
 
 
     //跳转到美食详情页
     //跳转到美食详情页
     tofoodDetail(e){
     tofoodDetail(e){
-        console.log(e);
+        // console.log(e);
         let foodId = e.currentTarget.dataset.item.id
         let foodId = e.currentTarget.dataset.item.id
         wx.navigateTo({
         wx.navigateTo({
           url: '/pages/foodDetail/foodDetail?id=' + foodId,
           url: '/pages/foodDetail/foodDetail?id=' + foodId,

+ 1 - 1
pages/scenicList/scenicList.js

@@ -19,7 +19,7 @@ Page({
         let imageList = this.data.imageList
         let imageList = this.data.imageList
         let imagePath = []
         let imagePath = []
         let result = await request('/front/scenicSpotAndCallout')  //获取景点列表
         let result = await request('/front/scenicSpotAndCallout')  //获取景点列表
-        console.log(result);
+        // console.log(result);
         //获取景点照片列表
         //获取景点照片列表
         for(let i = 0;i < result.length;i++){
         for(let i = 0;i < result.length;i++){
             let id = result[i].id
             let id = result[i].id

+ 0 - 1
pages/scenicList/scenicList.wxml

@@ -3,7 +3,6 @@
 <view>
 <view>
     <view wx:for="{{scenicList}}" wx:key="key">
     <view wx:for="{{scenicList}}" wx:key="key">
         <view class="scenery" bindtap="toScenicDetail" data-item="{{item}}">
         <view class="scenery" bindtap="toScenicDetail" data-item="{{item}}">
-            <!-- <image class="secenryImg" mode="widthFix" lazy-load="true" src="../../images/1.jpg"></image> -->
             <image class="sceneryImg" mode="widthFix" lazy-load="true" src="{{item[0].iconPath}}"></image>
             <image class="sceneryImg" mode="widthFix" lazy-load="true" src="{{item[0].iconPath}}"></image>
             <view class="sceneryContent">
             <view class="sceneryContent">
                 <view>
                 <view>