guhongwei 4 年之前
父節點
當前提交
794871452a
共有 9 個文件被更改,包括 103 次插入130 次删除
  1. 1 1
      app.js
  2. 3 3
      app.json
  3. 3 8
      commpents/history/index.wxml
  4. 14 34
      commpents/history/index.wxss
  5. 0 33
      pages/history/index copy.wxml
  6. 0 34
      pages/history/index copy.wxss
  7. 16 7
      pages/history/index.js
  8. 12 10
      pages/history/index.wxml
  9. 54 0
      pages/history/index.wxss

+ 1 - 1
app.js

@@ -40,7 +40,7 @@ App({
     })
   },
   globalData: {
-    userInfo: null,
+    userInfo: {},
     height: 0,
     windowHeight: 0,
     publicUrl: 'http://192.168.1.19:9901',

+ 3 - 3
app.json

@@ -1,12 +1,12 @@
 {
   "pages": [
-    "pages/history/index",
-    "pages/my/index",
-    "pages/login/index",
     "pages/home/index",
+    "pages/login/index",
     "pages/food/index",
     "pages/calorie/index",
     "pages/reserve/index",
+    "pages/my/index",
+    "pages/history/index",
     "pages/news/index",
     "pages/news/detail"
   ],

+ 3 - 8
commpents/history/index.wxml

@@ -1,12 +1,7 @@
 <view class="main">
   <view class="list" wx:key="item" wx:for="{{list}}" bindtap="detail" data-id="{{item.id}}">
-    <view class="top">
-      <text>{{item.name}}</text>
-      <text>{{item.reserve}}大卡</text>
-      <text>{{item.num}}份</text>
-    </view>
-    <view class="down">
-      <text wx:key="tag" wx:for="{{item.children}}" wx:for-item="tag">{{tag.title}},</text>
-    </view>
+    <text>{{item.name}}</text>
+    <text>{{item.num}}份</text>
+    <text>{{item.reserve}}大卡</text>
   </view>
 </view>

+ 14 - 34
commpents/history/index.wxss

@@ -1,47 +1,27 @@
 .main {
-  padding: 8px;
+  float: left;
+  width: 100%;
+  margin: 10px 0 0 0;
 }
 
 .main .list {
   float: left;
-  width: 95%;
+  width: 100%;
+  height: 30px;
+  line-height: 30px;
   background-color: #ffffff;
-  margin: 0 0 10px 0;
   border-radius: 8px;
-  padding: 8px;
-}
-
-.main .list .top {
-  float: left;
-  width: 100%;
-  padding: 0 0 5px 0;
-  margin: 0 0 5px 0;
-  border-bottom: 1px solid #ccc;
-}
-
-.main .list .top text {
-  float: left;
-  width: 33%;
   font-size: 12px;
-  color: #000;
-}
-
-
-.main .list .top text:nth-child(2) {
-  text-align: center;
-}
-
-.main .list .top text:nth-child(3) {
-  text-align: right;
+  margin: 0 0 10px 0;
 }
 
-.main .list .down {
+.main .list text {
   float: left;
-  width: 100%;
-}
-
-.main .list .down text {
-  font-size: 12px;
+  width: 32.7%;
+  text-align: center;
+  border: 1px solid #f1f1f1;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
   color: #000;
-  margin: 0 5px 0 0;
 }

+ 0 - 33
pages/history/index copy.wxml

@@ -1,33 +0,0 @@
-<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">
-      <view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">待使用</view>
-      <view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">待评价</view>
-      <view class="swiper-tab-item {{currentTab==2?'active':''}}" data-current="2" bindtap="clickTab">已完成</view>
-      <view class="swiper-tab-item {{currentTab==3?'active':''}}" data-current="3" bindtap="clickTab">已失效</view>
-    </view>
-    <swiper current="{{currentTab}}" style="height:{{windowHeight-height-40}}px">
-      <swiper-item catchtouchmove="stopTab">
-        <view class="one_1" style="height:{{windowHeight-height-40}}px">
-          <history-list list="{{list}}"></history-list>
-        </view>
-      </swiper-item>
-      <swiper-item catchtouchmove="stopTab">
-        <view class="one_1" style="height:{{windowHeight-height-40}}px">
-          待评价
-        </view>
-      </swiper-item>
-      <swiper-item catchtouchmove="stopTab">
-        <view class="one_1" style="height:{{windowHeight-height-40}}px">
-          已完成
-        </view>
-      </swiper-item>
-      <swiper-item catchtouchmove="stopTab">
-        <view class="one_1" style="height:{{windowHeight-height-40}}px">
-          已失效
-        </view>
-      </swiper-item>
-    </swiper>
-  </el-col>
-</view>

+ 0 - 34
pages/history/index copy.wxss

@@ -1,34 +0,0 @@
-.main .one {
-  float: left;
-  width: 100%;
-  overflow: hidden;
-}
-
-.main .one .one_1 {
-  float: left;
-  width: 100%;
-  overflow-y: auto;
-  background-color: #f1f1f1;
-}
-
-.main .one .swiper-tab {
-  width: 100%;
-  border-top: 1px solid #f1f1f1;
-  border-bottom: 1rpx solid #f1f1f1;
-  text-align: center;
-  height: 39px;
-  line-height: 39px;
-  display: flex;
-  flex-flow: row;
-  justify-content: space-between;
-}
-
-.main .one .swiper-tab-item {
-  width: 50%;
-  color: #434343;
-}
-
-.main .one .active {
-  color: #409eff;
-  border-bottom: 2rpx solid #409eff;
-}

+ 16 - 7
pages/history/index.js

@@ -20,10 +20,22 @@ Page({
     ]
   },
   onChange(event) {
-    console.log(event);
-    console.log(event.detail);
     this.setData({ activeName: Number(event.detail) });
   },
+  detail: function (data) {
+    const { id, label, isuse } = data.currentTarget.dataset;
+    if (isuse == '0') {
+      wx.showToast({ title: '待使用' })
+    } else if (isuse == '1') {
+      wx.showToast({ title: '待评价', })
+    } else if (isuse == '2') {
+      wx.showToast({ title: '已完成' })
+    } else if (isuse == '3') {
+      wx.showToast({ title: '已失效' })
+    } else {
+      wx.showToast({ title: '未订餐' })
+    }
+  },
   // 返回
   back: function () {
     wx.switchTab({
@@ -34,18 +46,15 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    if (!options.openid) {
+    if (options.openid) {
       wx.request({
         url: `${app.globalData.publicUrl}/api/st/dining/order?openid=${'oDiAy5JAhb2ReM-LwmqbTCx5OteA'}`,
         method: "get",
         header: { 'x-tenant': app.globalData.tenant },
         data: {},
         success: res => {
-          console.log(res);
           const { data } = res.data;
-          this.setData({
-            list: data
-          })
+          this.setData({ list: data })
         },
         error: err => {
           wx.showToast({

+ 12 - 10
pages/history/index.wxml

@@ -1,16 +1,18 @@
-<nav-bar navbar-data='{{navbarData}}' needBack="{{false}}"></nav-bar>
+<nav-bar navbar-data='{{navbarData}}' bind:back="back"></nav-bar>
 <view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
   <van-collapse accordion value="{{ activeName }}" bind:change="onChange">
-    <van-collapse-item wx:key="item" wx:for="{{list}}" title="{{item.date}}" wx:for-index="idx" name="{{idx}}">
-      <view wx:for-item="meal" wx:for="{{mealList}}" wx:for-index="midx" wx:key="meal">
-        <view>
+    <van-collapse-item wx:key="item" wx:for="{{list}}" wx:for-index="idx" name="{{idx}}">
+      <view slot="title" class="date">
+        <van-icon name="clock-o" /><text>{{item.date}}</text>
+      </view>
+      <view class="mealList" wx:for-item="meal" wx:for="{{mealList}}" wx:for-index="midx" wx:key="meal"
+        data-id="{{item.id}}" data-label="{{meal.label}}"
+        data-isuse="{{item[meal.key].list.length>0?item[meal.key].is_use:''}}" bindtap="detail">
+        <view class="label">
           <text>{{meal.label}}</text>
-          <text wx:if="{{item[meal.key].list.length>0}}">
-            {{item[meal.key].is_use=='0'?"待使用":item[meal.key].is_use=='1'?"待评价":item[meal.key].is_use=='2'?"已完成":"失效"}}
-          </text>
-          <text wx:else>
-            未订餐
-          </text>
+          <text
+            wx:if="{{item[meal.key].list.length>0}}">{{item[meal.key].is_use=='0'?"待使用":item[meal.key].is_use=='1'?"待评价":item[meal.key].is_use=='2'?"已完成":"失效"}}</text>
+          <text wx:else>未订餐</text>
         </view>
         <history-list list="{{item[meal.key].list}}"></history-list>
       </view>

+ 54 - 0
pages/history/index.wxss

@@ -0,0 +1,54 @@
+.main .date .van-icon {
+  top: 2px;
+}
+
+.main .date text {
+  padding: 0 5px;
+}
+
+.main .mealList {
+  float: left;
+  width: 100%;
+}
+
+.main .mealList .label {
+  float: left;
+  width: 100%;
+  border-bottom: 1px solid #00BFFF;
+  padding: 10px 0;
+}
+
+.main .mealList:nth-child(2n) .label {
+  border-bottom: 1px solid #008B8B;
+}
+
+.main .mealList:nth-child(2n) .label text {
+  color: #008B8B;
+}
+
+.main .mealList:nth-child(3n) .label {
+  border-bottom: 1px solid #90EE90;
+}
+
+.main .mealList:nth-child(3n) .label text {
+  color: #90EE90;
+}
+
+.main .mealList .label text {
+  float: left;
+  width: 45%;
+  padding: 0 8px;
+  color: #00BFFF;
+  font-weight: bold;
+}
+
+.main .mealList .label text:last-child {
+  text-align: right;
+}
+
+
+.van-collapse-item__content {
+  float: left;
+  width: 96%;
+  padding: 0 8px !important;
+}