guhongwei 4 vuotta sitten
vanhempi
commit
4786d07ecc

+ 7 - 5
app.json

@@ -1,12 +1,14 @@
 {
   "pages": [
-    "pages/history/index",
-    "pages/my/index",
+    "pages/login/index",
+    "pages/home/index",
+    "pages/calorie/index",
+    "pages/food/index",
+    "pages/reserve/index",
     "pages/news/index",
     "pages/news/detail",
-    "pages/reserve/index",
-    "pages/home/index",
-    "pages/login/index"
+    "pages/my/index",
+    "pages/history/index"
   ],
   "usingComponents": {
     "van-button": "/miniprogram_npm/vant-weapp/button/index",

+ 4 - 2
commpents/navbar/index.js

@@ -5,7 +5,8 @@ Component({
       type: Object,
       value: {},
       height: app.globalData.height
-    }
+    },
+    needBack: { type: Boolean, value: true }
   },
   data: {
     height: '',
@@ -27,7 +28,8 @@ Component({
   methods: {
     // 返回上一页面
     _navback() {
-      wx.navigateBack()
+      // wx.navigateBack()
+      this.triggerEvent('back',)
     }
   }
 })

+ 1 - 1
commpents/navbar/index.wxml

@@ -3,7 +3,7 @@
   <cover-view class='nav-title' style='line-height: {{height*2 + 45}}px;'>
     {{navbarData.name}}
   </cover-view>
-  <cover-view style='display: flex; justify-content: space-around;flex-direction: column;'>
+  <cover-view style='display: flex; justify-content: space-around;flex-direction: column;' wx:if="{{needBack}}">
     <!-- 导航栏  左上角的返回按钮 -->
     <cover-view class='nav-capsule' style='height: {{height*2 + 45}}px;'>
       <cover-view bindtap='_navback'>

+ 90 - 0
pages/calorie/index.js

@@ -0,0 +1,90 @@
+// pages/home/index.js
+const app = getApp()
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    height: app.globalData.height * 2 + 25,
+    windowHeight: app.globalData.windowHeight,
+    navbarData: {
+      name: '卡路里计算'
+    },
+    form: {}
+  },
+  // 提交
+  formSubmit: function (e) {
+    console.log('form发生了submit事件,携带数据为:', e.detail.value)
+  },
+  // 重置
+  formReset: function (e) {
+    console.log('form发生了reset事件,携带数据为:', e.detail.value)
+    this.setData({ form: {} })
+  },
+  // 返回页面
+  back() {
+    wx.switchTab({
+      url: '/pages/home/index',
+    })
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    // if (typeof this.getTabBar === 'function' &&
+    //   this.getTabBar()) {
+    //   this.getTabBar().setData({
+    //     selected: 3
+    //   })
+    // }
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 5 - 0
pages/calorie/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "/commpents/navbar/index"
+  }
+}

+ 56 - 0
pages/calorie/index.wxml

@@ -0,0 +1,56 @@
+<nav-bar navbar-data='{{navbarData}}' bind:back="back"></nav-bar>
+<view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
+  <form catchsubmit="formSubmit" catchreset="formReset">
+    <view class="content">
+      <view class="left">
+        您的性别
+      </view>
+      <view class="right">
+        <radio-group name="gender">
+          <radio value="男">男</radio>
+          <radio value="女">女</radio>
+        </radio-group>
+      </view>
+    </view>
+    <view class="content">
+      <view class="left">
+        您的身高
+      </view>
+      <view class="right">
+        <input name="height" type="number" placeholder="请您输入您的身高" />
+      </view>
+    </view>
+    <view class="content">
+      <view class="left">
+        您的体重
+      </view>
+      <view class="right">
+        <input name="kg" type="number" placeholder="请您输入您的体重" />
+      </view>
+    </view>
+    <view class="content">
+      <view class="left">
+        您的年龄
+      </view>
+      <view class="right">
+        <input name="age" type="number" placeholder="请您输入您的年龄" />
+      </view>
+    </view>
+    <view class="content">
+      <view class="left">
+        日运动量
+      </view>
+      <view class="right">
+        <radio-group name="motion">
+          <radio value="轻度">轻度</radio>
+          <radio value="中度">中度</radio>
+          <radio value="高度">高度</radio>
+        </radio-group>
+      </view>
+    </view>
+    <view class="btn">
+      <button formType="reset">重置</button>
+      <button type="primary" formType="submit">提交</button>
+    </view>
+  </form>
+</view>

+ 44 - 0
pages/calorie/index.wxss

@@ -0,0 +1,44 @@
+.main .content {
+  float: left;
+  width: 95%;
+  background-color: #f1f1f1;
+  margin: 0 0 10px 0;
+  padding: 0 8px;
+  height: 40px;
+  line-height: 40px;
+  border-bottom: 1px dashed #409eff;
+}
+
+.main .content .left {
+  float: left;
+  width: 30%;
+  font-size: 12px;
+}
+
+.main .content .right {
+  float: right;
+  width: 70%;
+  text-align: right;
+}
+
+.main .content .right radio {
+  height: 40px;
+  font-size: 12px;
+  margin: 0 0 0 15px;
+}
+
+.main .content .right input {
+  height: 40px;
+}
+
+.main .btn {
+  float: left;
+  width: 95%;
+  padding: 0 8px;
+}
+
+.main .btn button {
+  float: left;
+  width: 45.5%;
+  margin: 0 8px;
+}

+ 81 - 0
pages/food/index.js

@@ -0,0 +1,81 @@
+// pages/home/index.js
+const app = getApp()
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    height: app.globalData.height * 2 + 25,
+    windowHeight: app.globalData.windowHeight,
+    navbarData: {
+      name: '卡路里计算'
+    },
+  },
+
+  // 返回页面
+  back() {
+    wx.switchTab({
+      url: '/pages/home/index',
+    })
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    // if (typeof this.getTabBar === 'function' &&
+    //   this.getTabBar()) {
+    //   this.getTabBar().setData({
+    //     selected: 3
+    //   })
+    // }
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 5 - 0
pages/food/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "nav-bar": "/commpents/navbar/index"
+  }
+}

+ 4 - 0
pages/food/index.wxml

@@ -0,0 +1,4 @@
+<nav-bar navbar-data='{{navbarData}}' bind:back="back"></nav-bar>
+<view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
+  本周菜谱
+</view>

+ 1 - 0
pages/food/index.wxss

@@ -0,0 +1 @@
+/* pages/food/index.wxss */

+ 6 - 1
pages/history/index.js

@@ -39,7 +39,12 @@ Page({
       },
     ]
   },
-
+  // 返回
+  back: function () {
+    wx.switchTab({
+      url: '/pages/my/index',
+    })
+  },
   /**
    * 生命周期函数--监听页面加载
    */

+ 1 - 1
pages/history/index.wxml

@@ -1,4 +1,4 @@
-<nav-bar navbar-data='{{navbarData}}'></nav-bar>
+<nav-bar navbar-data='{{navbarData}}' bind:back="back"></nav-bar>
 <view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
   <view class="one" style="height:{{windowHeight-height}}px;">
     <history-list list="{{list}}" bind:detail="detail"></history-list>

+ 7 - 7
pages/home/index.js

@@ -21,24 +21,24 @@ Page({
   },
   // 查看本周菜谱
   reserveBtn: function () {
-    wx.showToast({
-      title: '本周菜谱',
+    wx.redirectTo({
+      url: '/pages/food/index',
     })
   },
   // 报餐:1,余菜打包:2,卡路里计算:3
   twoBtn: function (e) {
     let type = e.currentTarget.dataset.smile
     if (type == '1') {
-      wx.showToast({
-        title: '报餐',
+      wx.switchTab({
+        url: '/pages/reserve/index',
       })
     } else if (type == '2') {
       wx.showToast({
-        title: '余菜打包',
+        title: '暂无开通',
       })
     } else {
-      wx.showToast({
-        title: '卡路里计算',
+      wx.redirectTo({
+        url: '/pages/calorie/index',
       })
     }
   },

+ 1 - 1
pages/home/index.wxml

@@ -1,4 +1,4 @@
-<nav-bar navbar-data='{{navbarData}}'></nav-bar>
+<nav-bar navbar-data='{{navbarData}}' needBack="{{false}}"></nav-bar>
 <view class="main" style="padding-top:{{height}}px;padding-bottom: 48px;">
   <view class="one" style="background-image:url('/image/home/image1.jpg')">
     <view class="one_1">

+ 1 - 1
pages/my/index.wxml

@@ -1,4 +1,4 @@
-<nav-bar navbar-data='{{navbarData}}'></nav-bar>
+<nav-bar navbar-data='{{navbarData}}' needBack="{{false}}"></nav-bar>
 <view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
   <view class="one">
     <view class="left">

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 6 - 1
pages/news/detail.js


+ 1 - 1
pages/news/detail.wxml

@@ -1,4 +1,4 @@
-<nav-bar navbar-data='{{navbarData}}'></nav-bar>
+<nav-bar navbar-data='{{navbarData}}' bind:back="back"></nav-bar>
 <view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
   <view class="one" style="height:{{windowHeight-height}}px">
     <news-detail detail="{{detailInfo}}"></news-detail>

+ 1 - 1
pages/news/index.wxml

@@ -1,4 +1,4 @@
-<nav-bar navbar-data='{{navbarData}}'></nav-bar>
+<nav-bar navbar-data='{{navbarData}}' needBack="{{false}}"></nav-bar>
 <view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
   <el-col class="one" style="height:{{windowHeight-height}}px">
     <view class="swiper-tab">

+ 1 - 1
pages/reserve/index.wxml

@@ -1,4 +1,4 @@
-<nav-bar navbar-data='{{navbarData}}'></nav-bar>
+<nav-bar navbar-data='{{navbarData}}' needBack="{{false}}"></nav-bar>
 <view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
   <view class="one">
     <view class="one_1">您的绑定餐厅为:{{restaurant}}</view>