Browse Source

'message'

machinecat520 2 years ago
parent
commit
f523d1ffe4

+ 1 - 0
app.json

@@ -1,6 +1,7 @@
 {
     "pages": [
         "pages/main/main",
+        "pages/strategyDetail/strategyDetail",
         "pages/foodDetail/foodDetail",
         "pages/recommendFood/recommendFood",
         "pages/noticeDetail/noticeDetail",

+ 2 - 0
pages/foodDetail/foodDetail.js

@@ -12,6 +12,7 @@ Page({
         foodList:[],    //美食照片路径
         shopDescribe: '', //商铺简介
         heat: '', //商铺热度
+        dish:'',    //招牌菜
         shopPhone: '', //商铺电话
         shopAddress: '', //商铺地址
         shopLatitude: 0, //商铺纬度
@@ -36,6 +37,7 @@ Page({
                     shopTitle: result[i].title,
                     shopDescribe: result[i].describes,
                     heat: result[i].viewCount,
+                    dish:result[i].dish,
                     shopPhone: result[i].phone,
                     shopAddress: result[i].location,
                     shopLatitude: result[i].latitude,

+ 1 - 1
pages/foodDetail/foodDetail.wxml

@@ -16,7 +16,7 @@
         </view>
         <view class="shopDetail">
             <text class="shopDetailTile">招牌菜:</text>
-            <text>红烧肉、糖醋排骨</text>
+            <text>{{dish}}</text>
         </view>
         <view class="shopDetail">
             <text class="shopDetailTile">电话:</text>

+ 15 - 6
pages/main/main.js

@@ -8,6 +8,7 @@ Page({
      * 页面的初始数据
      */
     data: {
+        bannerList:[],  //轮播图列表
         newNoticeTitle:''   //滚动显示的公告标题
     },
 
@@ -15,23 +16,31 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad:async function(options) {
-        let result = await request('/front/notificationFront')  //获取公告列表
+        //获取轮播图列表
+        let banners = await request('/front/banner')
+        // console.log(banners);
+        this.setData({
+            bannerList:banners
+        })
+
+        //获取公告列表
+        let result = await request('/front/notificationFront') 
         // console.log(result);
         // 对公告列表按id降序排序(即按发布时间由近到远排序)
-        if(result.length == 0){
+        if(result.length == 0){ //如果公告列表长度为0,则显示无公告
             this.setData({
                 newNoticeTitle:'暂无公告内容'
             })
-        }else if(result.length == 1 && result[0].status == 1){
+        }else if(result.length == 1 && result[0].status == 1){  //如果有一条公告,且状态为1,则展示标题
             this.setData({
                 newNoticeTitle:result[0].title
             })
-        }else if(result.length == 1 && result[0].status == 0){
+        }else if(result.length == 1 && result[0].status == 0){  //如果有一条公告,且状态为0,则展示无公告
             this.setData({
                 newNoticeTitle:'暂无公告内容'
             })
         }
-        else{
+        else{   //超过2条公告时,根据公告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){
@@ -42,7 +51,7 @@ Page({
                 }                
             }
             // console.log(result);
-            // 遍历重新排序后的列表,取出第一个状态为1的标题
+            // 遍历重新排序后的列表,取出第一个状态为1的标题,即为最新发布的公告
             for(let i = 0;i < result.length;i++){
                 if(result[i].status == 1){
                     this.setData({

+ 13 - 9
pages/main/main.wxml

@@ -1,14 +1,18 @@
 <!--pages/main/main.wxml-->
 <view class="indexContainer">
     <!-- 轮播图区域 -->
-    <swiper class="banners" autoplay circular interval="2000" indicator-dots="true" indicator-color="ivory" indicator-active-color="#d43c33" next-margin="0rpx" previous-margin="0rpx">
-        <swiper-item>
-            <image src="../../images/1.jpg"></image>
-        </swiper-item>
-        <swiper-item>
-            <image src="../../images/2.jpg"></image>
-        </swiper-item>
-    </swiper>
+    <view>
+        <view class="noBanners" wx:if="{{bannerList.length == 0}}">
+            <text>暂无图片展示</text>
+        </view>
+        <view wx:else>
+            <swiper class="banners" autoplay circular interval="3000" indicator-dots="true" indicator-color="ivory" indicator-active-color="#d43c33" next-margin="0rpx" previous-margin="0rpx">
+                <swiper-item wx:for="{{bannerList}}" wx:key="key">
+                    <image src="{{item.iconPath}}"></image>
+                </swiper-item>
+            </swiper>
+        </view>
+    </view>
     <!-- 公告栏 -->
     <view class="notice" bindtap="toNotice">
         <text class="noticeTitle">公告:</text>
@@ -34,5 +38,5 @@
         </view>
         <button class="suggest" open-type="feedback" type="primary">反馈建议</button>
     </view>
-   
+
 </view>

+ 7 - 0
pages/main/main.wxss

@@ -1,6 +1,13 @@
 /* pages/main/main.wxss */
 
 /* 轮播图区域 */
+.noBanners{
+    display: flex;
+    font-size: 40rpx;
+    color: gray;
+    justify-content: center;
+    line-height: 400rpx;
+}
 .banners {
     width: 100%;
     height: 400rpx;

+ 22 - 10
pages/mainIntro/mainIntro.wxml

@@ -1,17 +1,29 @@
 <view class="indexContainer">
     <!-- 轮播图区域 -->
-    <swiper class="banners" autoplay circular interval="2000" indicator-dots="true" indicator-color="ivory" indicator-active-color="#d43c33" next-margin="0rpx" previous-margin="0rpx">
-        <swiper-item wx:for="{{bannersList}}" wx:key="key">
-            <image src="{{item.iconPath}}"></image>
-        </swiper-item>
-    </swiper>
+    <view>
+        <view class="noBanners" wx:if="{{bannersList.length == 0}}">
+            <text>暂无图片展示</text>
+        </view>
+        <view wx:else>
+            <swiper class="banners" autoplay circular interval="2000" indicator-dots="true" indicator-color="ivory" indicator-active-color="#d43c33" next-margin="0rpx" previous-margin="0rpx">
+                <swiper-item wx:for="{{bannersList}}" wx:key="key">
+                    <image src="{{item.iconPath}}"></image>
+                </swiper-item>
+            </swiper>
+        </view>
+    </view>
     <!-- 景区介绍的正文 -->
-    <view class="textContainer">
-        <view class="titleHead">
-            <text>{{intro.title}}</text>
+    <view>
+        <view wx:if="{{intro == ''}}" class="noInto">
+            <text>暂无介绍内容</text>
         </view>
-        <view class="introContent" style="white-space: pre-wrap;">
-            <text user-select="true">{{intro.describes}}</text>
+        <view wx:else class="textContainer">
+            <view class="titleHead">
+                <text>{{intro.title}}</text>
+            </view>
+            <view class="introContent" style="white-space: pre-wrap;">
+                <text user-select="true">{{intro.describes}}</text>
+            </view>
         </view>
     </view>
 

+ 14 - 0
pages/mainIntro/mainIntro.wxss

@@ -2,6 +2,13 @@
 
 
 /* 轮播图区域 */
+.noBanners{
+    display: flex;
+    font-size: 40rpx;
+    color: gray;
+    justify-content: center;
+    line-height: 400rpx;
+}
 .banners{
     width: 100%;
     height: 400rpx;
@@ -38,3 +45,10 @@
     margin-top: 20rpx;
     color: gray;
 }
+
+.noInto{
+    padding: 20rpx;
+    font-size: 40rpx;
+    color: gray;
+    text-align: center;
+}

+ 7 - 3
pages/noticeDetail/noticeDetail.js

@@ -8,7 +8,8 @@ Page({
      * 页面的初始数据
      */
     data: {
-        noticeDetailList: []
+        noticeDetailList: [],   //公告列表
+        notification:'' //公告描述
     },
 
     /**
@@ -18,15 +19,18 @@ Page({
         // console.log(options.id);
         let id = options.id
         let result = await request('/front/notificationFront') //获取公告列表
-        // console.log(result);
+        console.log(result);
         let noticeDetailList = this.data.noticeDetailList
+        let notification = this.data.notification
         for (let i = 0; i < result.length; i++) {
             if (result[i].id == id) {
                 noticeDetailList = result[i].iconList
+                notification = result[i].notification
             }
         }
         this.setData({
-            noticeDetailList
+            noticeDetailList,
+            notification
         })
         // console.log(this.data.noticeDetailList);
     },

+ 3 - 11
pages/noticeDetail/noticeDetail.wxml

@@ -1,17 +1,9 @@
 <!--pages/noticeDetail/noticeDetail.wxml-->
 <view>
-    <!-- <view>
-        <text class="noticeDetailTitle">关于防疫政策的公告关于防疫政策的公告关于防疫政策的公告关于防疫政策的公告</text>
-        <text class="noticeTime">发布时间:2022-11-12</text>
-        <view>
-        <view class="intervalOne"></view>
-        <view class="intervalTwo"></view>
-    </view>
-    </view>
-    <view class="noticeDetail">
-        <text user-select="true">其中,“大家谈阅读”收录全国政协常委兼副秘书长、民进中央副主席、全民阅读形象代言人朱永新,北京大学中文系教授、博士生导师、国际安徒生奖得主曹文轩,大童话家、收藏家朱奎,“幻想大王”、中国首位迪士尼签约作家杨鹏,少儿科幻作家马传思,儿童文学作家王林柏、王君心、龙向梅关于想象力、关于阅读的文章。值得一提的是,马传思、王林柏、王君心、龙向梅均为“大白鲸”优秀作品征集活动获奖作家。“书香能致远”“开卷润童心”分别收录了“浓情书香•伴您成长”征文大赛成人组、青少组的获奖征文。该征文大赛由大连出版社、中国农业银行大连市分行联合主办。而“书香能致远”中,中国散文学会会员郑江泉、大连市残联党组成员王荔、儿童文学新锐王庆兰,来自大连南金实验学校、金普新区新桥小学、金普新区滨海学校小学部等中小学的一线老师,深情讲述了在书香中逆袭、成长的故事。</text>
-    </view> -->
     <view class="noticeDetailImage" wx:for="{{noticeDetailList}}" wx:key="key">
+        <view wx:if="{{notification}}" class="noticeText">
+            <text>{{notification}}</text>
+        </view>
         <image class="noticeDetailImg" bindtap="toPreviewImage" src="{{item.icon}}" mode="widthFix"/>
     </view>
 </view>

+ 5 - 0
pages/noticeDetail/noticeDetail.wxss

@@ -47,4 +47,9 @@
 
 .noticeDetailImg{
     width: 100%;
+}
+
+/* 公告文字 */
+.noticeText{
+    padding: 20rpx;
 }

+ 6 - 1
pages/recommendFood/recommendFood.wxml

@@ -1,5 +1,10 @@
 <!--pages/recommendFood/recommendFood.wxml-->
-<view class="foodWrap">
+
+<view class="recommendNo" wx:if="{{foodList.length == 0}}">
+    <text>暂无美食推荐</text>
+</view>
+
+<view class="foodWrap" wx:else>
     <view class="foodDetail" bindtap="tofoodDetail" data-item="{{item}}" wx:for="{{foodList}}" wx:key="key">
         <image class="foodImg" src="{{item[0].iconPath}}"></image>
         <view class="foodIntro">

+ 8 - 1
pages/recommendFood/recommendFood.wxss

@@ -1,4 +1,11 @@
 /* pages/recommendFood/recommendFood.wxss */
+
+.recommendNo{
+    font-size: 32rpx;
+    color: gray;
+    padding: 20rpx;
+}
+
 /* 美食推荐外部容器 */
 .foodWrap{
     display: flex;
@@ -14,7 +21,7 @@
     flex-shrink: 0;
     width: 45%;
     height: 600rpx;
-    margin: 20rpx 0 0 20rpx;
+    margin: 20rpx 0 20rpx 20rpx;
     border: 1rpx solid gray;
     border-radius: 20rpx;
 }

+ 4 - 0
pages/scenicDetail/scenicDetail.js

@@ -11,6 +11,8 @@ Page({
         imgList:[],     //景点路径列表
         scenicTitle:'', //景点标题
         scenicDescribe:'',   //景点介绍
+        attention:'',   //旅游注意事项
+        playTime:'',    //建议游玩时间
         scenicLatitude:'',  //景点纬度
         scenicLongtitude:''     //景点经度
     },
@@ -32,6 +34,8 @@ Page({
                 this.setData({
                     scenicTitle:result[i].title,
                     scenicDescribe:result[i].describes,
+                    attention:result[i].attention,
+                    playTime:result[i].playTime,
                     scenicLatitude:result[i].latitude,
                     scenicLongtitude:result[i].longitude
                 })

+ 3 - 3
pages/scenicDetail/scenicDetail.wxml

@@ -8,15 +8,15 @@
         <text class="sceneryTitle">{{scenicTitle}}</text>
     </view>
     <view class="sceneryTitleWrap">
-        <text class="sceneryIntroContent">{{scenicDescribe}}</text>
+        <text class="sceneryIntroContent" user-select>{{scenicDescribe}}</text>
     </view>
     <view class="tourNotice">
         <text class="tourNoticeTitle">旅游注意事项:</text>
-        <text class="tourNoticeContent">需要带雨伞需要带雨伞需要带雨伞需要带雨伞需要带雨伞需要带雨伞</text>
+        <text class="tourNoticeContent">{{attention}}</text>
     </view>
     <view class="tourNotice">
         <text class="tourNoticeTitle">建议游玩时间:</text>
-        <text class="tourNoticeContent">全年每天均可</text>
+        <text class="tourNoticeContent">{{playTime}}</text>
     </view>
     <!-- 去往景点按钮 -->
     <view class="goDestination">

+ 5 - 1
pages/scenicList/scenicList.wxml

@@ -1,6 +1,10 @@
 <!--pages/scenicList/scenicList.wxml-->
 
-<view>
+<view class="scenicNo" wx:if="{{scenicList.length == 0}}">
+    <text>暂无景点介绍</text>
+</view>
+
+<view wx:else>
     <view wx:for="{{scenicList}}" wx:key="key">
         <view class="scenery" bindtap="toScenicDetail" data-item="{{item}}">
             <image class="sceneryImg" mode="widthFix" lazy-load="true" src="{{item[0].iconPath}}"></image>

+ 5 - 9
pages/scenicList/scenicList.wxss

@@ -1,14 +1,10 @@
 /* pages/scenicList/scenicList.wxss */
 
-/* 标题样式 */
-/* .title{
-    width: 100%;
-    font-size: 42rpx;
-    font-weight: bold;
-    height: 80rpx;
-    line-height: 80rpx;
-    text-align: center;
-} */
+.scenicNo{
+    font-size: 32rpx;
+    color: gray;
+    padding: 20rpx;
+}
 
 .scenery{
     display: flex;

+ 3 - 2
pages/secondIntro/secondIntro.js

@@ -8,7 +8,7 @@ Page({
      * 页面的初始数据
      */
     data: {
-        bannerList:[],
+        bannersList:[],
         textIntro:''
     },
 
@@ -17,11 +17,12 @@ Page({
      */
     onLoad:async function(options) {
         let result = await request('/front/introduce/files/2')  //获取轮播图
+        // console.log(result);
         let introduce = await request('/front/introduce/2') //获取简介信息
         this.setData({
             bannersList:result,
             textIntro:introduce
-        })        
+        })
     },
 
     /**

+ 17 - 10
pages/secondIntro/secondIntro.wxml

@@ -1,16 +1,23 @@
 <!--pages/secondIntro/secondIntro.wxml-->
 <view class="indexContainer">
     <!-- 轮播图区域 -->
-    <swiper class="banners" autoplay circular interval="2000" indicator-dots="true" indicator-color="ivory" indicator-active-color="#d43c33" next-margin="0rpx" previous-margin="0rpx">
-        <swiper-item>
-            <image src="../../images/1.jpg"></image>
-        </swiper-item>
-        <swiper-item>
-            <image src="../../images/2.jpg"></image>
-        </swiper-item>
-    </swiper>
+    <view>
+        <view wx:if="{{bannersList.length != 0}}">
+            <swiper class="banners" autoplay circular interval="2000" indicator-dots="true" indicator-color="ivory" indicator-active-color="#d43c33" next-margin="0rpx" previous-margin="0rpx">
+                <swiper-item wx:for="{{bannersList}}" wx:key="key">
+                    <image src="{{item.iconPath}}"></image>
+                </swiper-item>
+            </swiper>
+        </view>
+        <view wx:else class="noBanners">
+            <text>暂无图片展示</text>
+        </view>
+    </view>
     <!-- 景区介绍的正文 -->
-    <view class="textContainer">
+    <view wx:if="{{textIntro == ''}}" class="noSecondIntro">
+        <text>暂无介绍内容</text>
+    </view>
+    <view wx:else class="textContainer">
         <view class="titleHead">
             <text>{{textIntro.title}}</text>
         </view>
@@ -19,4 +26,4 @@
         </view>
     </view>
 
-</view>
+</view>

+ 15 - 0
pages/secondIntro/secondIntro.wxss

@@ -2,6 +2,14 @@
 
 
 /* 轮播图区域 */
+.noBanners{
+    display: flex;
+    font-size: 40rpx;
+    color: gray;
+    justify-content: center;
+    line-height: 400rpx;
+}
+
 .banners{
     width: 100%;
     height: 400rpx;
@@ -26,4 +34,11 @@
 .introContent{
     font-size: 42rpx;
     font-family: '仿宋';
+}
+
+.noSecondIntro{
+    padding: 20rpx;
+    font-size: 40rpx;
+    color: gray;
+    text-align: center;
 }

+ 27 - 3
pages/strategy/strategy.js

@@ -1,18 +1,42 @@
+import request from "../../utils/request"
+
 // pages/strategy/strategy.js
 Page({
 
     /**
      * 页面的初始数据
      */
-    data: {
-
+    data: {        
+        strategyList:[]
     },
 
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad(options) {
+    onLoad:async function(options) {
+        let result = await request('/front/strategyFront')
+        // console.log(result);
+        var strategy = []
+        for(let i = 0;i < result.length;i++){
+            if(result[i].status == 1){
+                strategy.push(result[i])
+            }
+            // console.log(strategy);
+        }
+        this.setData({
+            strategyList:strategy
+        })
+        // console.log(this.data.strategyList);
+    },
 
+    //点击跳转到攻略详情
+    toStrategyDetail(e){
+        // console.log(e);
+        // console.log(e.currentTarget.dataset.item.id);
+        let currentId = e.currentTarget.dataset.item.id
+        wx.navigateTo({
+          url: '/pages/strategyDetail/strategyDetail?id='+currentId,
+        })
     },
 
     /**

+ 2 - 1
pages/strategy/strategy.json

@@ -1,3 +1,4 @@
 {
-    "usingComponents": {}
+    "usingComponents": {},
+    "navigationBarTitleText":"攻略"
 }

+ 7 - 10
pages/strategy/strategy.wxml

@@ -1,13 +1,10 @@
 <!--pages/strategy/strategy.wxml-->
-<view>
-    <view class="strategy">
-        <view class="route">
-            <text class="title">路线一:</text>
-            <text>卧室→客厅→厨房→阳台→客厅→卧室</text>
-        </view>
-        <view class="route">
-            <text class="title">路线二:</text>
-            <text>卧室→客厅→厨房→阳台→客厅→卧室</text>
-        </view>
+
+<view wx:if="{{strategyList.length == 0}}" class="strategyNo">
+    <text>暂无攻略展示</text>
+</view>
+<view wx:else >
+    <view wx:for="{{strategyList}}" wx:key="key"  class="strategy" bindtap="toStrategyDetail" data-item="{{item}}">
+        <text>{{item.title}}</text>
     </view>
 </view>

+ 12 - 11
pages/strategy/strategy.wxss

@@ -1,16 +1,17 @@
 /* pages/strategy/strategy.wxss */
 
+page{
+    padding: 20rpx;
+}
+
 .strategy{
-    margin: 10rpx 20rpx;
-    font-size: 42rpx;
+    margin-bottom: 40rpx;
+    font-size: 36rpx;
+    color:blue;
+    text-decoration: underline;
 }
-.route{
-    display: flex;
-    flex-direction: column;
-    padding-bottom: 50rpx;
+
+.strategyNo{
+    font-size: 32prx;
+    color: gray;
 }
-.title{
-    font-size: 50rpx;
-    font-weight: bold;
-    padding-bottom: 20rpx;
-}

+ 97 - 0
pages/strategyDetail/strategyDetail.js

@@ -0,0 +1,97 @@
+import request from "../../utils/request";
+
+// pages/strategyDetail/strategyDetail.js
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+
+        title:'',   //攻略标题
+        strategy:'',    //攻略描述
+        iconList:[] //攻略图片数组
+    },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad:async function(options) {
+        console.log(options.id);
+        var id = options.id
+        let result = await request('/front/strategyFront')
+        console.log(result);
+        for(let i = 0;i < result.length;i++){
+            if(id == result[i].id){
+                this.setData({
+                    title:result[i].title,
+                    strategy:result[i].strategy,
+                    iconList:result[i].iconList
+                })
+            }
+        }
+    },
+
+    //点击预览图片
+    toPreviewImage() {
+        let iconList = this.data.iconList
+        var imgList = []
+        for(let j = 0;j < iconList.length;j++){
+            imgList[j] = iconList[j].icon
+        }
+        // console.log(imgList);
+        wx.previewImage({
+            // current: imgList, // 当前显示图片的 http 链接
+            urls: imgList // 需要预览的图片 http 链接列表
+        })
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide() {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload() {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh() {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom() {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage() {
+
+    }
+})

+ 4 - 0
pages/strategyDetail/strategyDetail.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText":"攻略详情"
+}

+ 13 - 0
pages/strategyDetail/strategyDetail.wxml

@@ -0,0 +1,13 @@
+<!--pages/strategyDetail/strategyDetail.wxml-->
+
+<view>
+    <view class="strategyTitle">
+        <text>{{title}}</text>
+    </view>
+    <view class="strategyDescribe">
+        <text>{{strategy}}</text>
+    </view>
+    <view wx:for="{{iconList}}" wx:key="key">
+        <image class="strategyImg" src="{{item.icon}}" mode="widthFix" bindtap="toPreviewImage"/>
+    </view>
+</view>

+ 26 - 0
pages/strategyDetail/strategyDetail.wxss

@@ -0,0 +1,26 @@
+/* pages/strategyDetail/strategyDetail.wxss */
+
+page{
+    padding: 20rpx;
+    height: 100%;
+}
+
+/* 标题 */
+.strategyTitle{
+    margin-bottom: 20rpx;
+    font-size: 36rpx;
+    font-weight: bold;
+}
+
+/* 描述 */
+.strategyDescribe{
+    font-size: 28rpx;
+    margin-bottom: 20rpx;
+    width: 94%;
+}
+
+/* 照片 */
+.strategyImg{
+    width: 94%;
+    margin-top: 10rpx;
+}

+ 1 - 1
utils/config.js

@@ -1,4 +1,4 @@
 //配置服务器相关信息
 export default{
-    host:'http://192.168.0.177:9090'
+    host:'http://192.168.0.184:9090'
 }