guhongwei 3 years ago
parent
commit
5b878a63a5

+ 2 - 2
app.json

@@ -6,10 +6,10 @@
     "pages/reserve/index",
     "pages/my/index",
     "pages/history/index",
+    "pages/history/detail",
     "pages/news/index",
     "pages/news/detail",
-    "pages/login/index",
-    "pages/history/detail"
+    "pages/login/index"
   ],
   "usingComponents": {
     "van-button": "/miniprogram_npm/vant-weapp/button/index",

+ 7 - 3
icon/icon.wxss

@@ -1,8 +1,8 @@
 @font-face {
   font-family: "iconfont"; /* Project id 2613405 */
-  src: url('//at.alicdn.com/t/font_2613405_2994e8r08x4.woff2?t=1623834927977') format('woff2'),
-       url('//at.alicdn.com/t/font_2613405_2994e8r08x4.woff?t=1623834927977') format('woff'),
-       url('//at.alicdn.com/t/font_2613405_2994e8r08x4.ttf?t=1623834927977') format('truetype');
+  src: url('//at.alicdn.com/t/font_2613405_l8r537v1c3j.woff2?t=1624501843494') format('woff2'),
+       url('//at.alicdn.com/t/font_2613405_l8r537v1c3j.woff?t=1624501843494') format('woff'),
+       url('//at.alicdn.com/t/font_2613405_l8r537v1c3j.ttf?t=1624501843494') format('truetype');
 }
 
 .iconfont {
@@ -13,6 +13,10 @@
   -moz-osx-font-smoothing: grayscale;
 }
 
+.icon-erweima:before {
+  content: "\e60d";
+}
+
 .icon-swticondingcan1:before {
   content: "\e621";
 }

+ 1 - 3
pages/food/index.js

@@ -58,13 +58,11 @@ Page({
           style.total = style.one + style.two + style.thr;
           val.style = style;
         }
-        console.log(res.data.data);
         this.setData({ list: res.data.data });
-        // this.searchStyle(res.data.data)
       },
       error: err => {
         wx.showToast({
-          title: err.msg,
+          title: err.errmsg,
           icon: 'error'
         })
       }

+ 59 - 6
pages/history/detail.js

@@ -1,22 +1,37 @@
 // pages/history/detail.js
 const app = getApp()
+import QRCode from '../../utils/weapp-qrcode'
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
+    height: app.globalData.height * 2 + 25,
+    windowHeight: app.globalData.windowHeight,
+    navbarData: {
+      name: '点餐详情'
+    },
+    logo: '',
+    tenant: '',
     meal: {},
-    info: {}
+    info: {},
+  },
+  // 返回
+  back: function () {
+    wx.reLaunch({
+      url: `/pages/history/index?openid=${app.globalData.wxInfo.openid}`
+    })
   },
-
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    this.searchST();
     const { id, label, date } = options
     this.setData({ info: { label, date } })
     this.getMeal(id);
+    this.initQrCode(id);
   },
 
   getMeal(id) {
@@ -26,16 +41,54 @@ Page({
       header: { 'x-tenant': app.globalData.tenant },
       success: (res) => {
         if (res.data.errcode !== 0) return;
-        const { data } = res.data;
-        this.setData({
-          meal: data
-        })
+        let arr = res.data.data;
+        arr = this.dealImg(arr)
+        this.setData({ meal: arr })
       },
       error: (e) => {
         console.error(e)
       }
     })
   },
+  dealImg(list) {
+    for (let i of list.list) {
+      if (i.img && i.img.length > 0 && i.img[0]) i.url = `${app.globalData.fileUrl}${i.img[0].url}`;
+      else i.url = this.data.logo;
+    }
+    return list;
+  },
+  searchST: function () {
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
+      method: "get",
+      header: { 'x-tenant': app.globalData.tenant },
+      data: {},
+      success: res => {
+        const { data } = res.data;
+        this.setData({ tenant: data.name });
+        this.setData({ logo: `${app.globalData.fileUrl}` + data.img.logo })
+      },
+      error: err => {
+        wx.showToast({
+          title: err.msg,
+          icon: 'error'
+        })
+      }
+    })
+  },
+  // 创建二维码
+  initQrCode(id) {
+    const url = `${app.globalData.publicUrl}/api/st/dining/order/useMeal/${id}?_tenant=${this.data.tenant}`;
+    var qrcode = new QRCode(`myQrcode`, {
+      text: url,
+      width: 130,
+      height: 130,
+      padding: 3,
+      colorDark: "#000000",
+      colorLight: "#ffffff",
+      correctLevel: QRCode.CorrectLevel.L,
+    });
+  },
 
 
   /**

+ 3 - 1
pages/history/detail.json

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

+ 21 - 2
pages/history/detail.wxml

@@ -1,2 +1,21 @@
-<!--pages/history/detail.wxml-->
-<text>pages/history/detail.wxml</text>
+<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">
+    <text class="iconfont icon-erweima" style="display:none"></text>
+    <text>{{info.date}}</text>
+    <text>{{info.label}}</text>
+    <text>{{meal.is_use==0?'待使用':meal.is_use=='1'?'待评价':meal.is_use=='2'?'已完成':meal.is_use=='3'?'已失效':'未识别'}}</text>
+  </view>
+  <view class="two">
+    <view class="list" wx:key="item" wx:for="{{meal.list}}" data-id="{{item.id}}">
+      <view class="list_1">
+        <image src="{{item.url}}"></image>
+      </view>
+      <view class="list_2">{{item.name}}</view>
+      <view class="list_3">{{item.num}}份</view>
+    </view>
+  </view>
+  <view class="thr" wx:if="{{meal.is_use=='0'}}">
+    <canvas class="qrcode" canvas-id="myQrcode"></canvas>
+  </view>
+</view>

+ 81 - 1
pages/history/detail.wxss

@@ -1 +1,81 @@
-/* pages/history/detail.wxss */
+.main {
+  background: #f1f1f1;
+}
+
+.main .one {
+  float: left;
+  width: 91%;
+  margin: 0 0 8px 0;
+  height: 30px;
+  line-height: 30px;
+  background: #fff;
+  margin: 8px 8px;
+  padding: 8px;
+  border-radius: 5px;
+}
+
+.main .one text {
+  float: left;
+  margin: 0 5px 0 0;
+  font-size: 15px;
+}
+
+.main .one text:nth-child(1) {
+  font-size: 30px;
+  color: #409eff;
+}
+
+.main .one text:nth-child(4) {
+  float: right;
+}
+
+.main .two {
+  float: left;
+  width: 96%;
+  padding: 0 8px;
+  border-radius: 5px;
+}
+
+.main .two .list {
+  float: left;
+  width: 95%;
+  background: #fff;
+  border-bottom: 1px solid #ccc;
+  padding: 8px;
+  height: 43px;
+  line-height: 43px;
+}
+
+.main .two .list .list_1 {
+  float: left;
+  width: 15%;
+  height: 43px;
+  text-align: center;
+}
+
+.main .two .list .list_1 image {
+  width: 40px;
+  height: 40px;
+  border-radius: 90px;
+  border: 1px solid #f1f1f1;
+}
+
+.main .two .list .list_2 {
+  float: left;
+  width: 60%;
+  font-size: 15px;
+}
+
+.main .two .list .list_3 {
+  float: left;
+  width: 20%;
+  text-align: right;
+  font-size: 15px;
+}
+
+.main .thr {
+  float: left;
+  width: 100%;
+  text-align: center;
+  padding: 20px 30%;
+}

+ 4 - 10
pages/history/index.js

@@ -24,15 +24,9 @@ Page({
   },
   detail: function (data) {
     const { id, label, date, isuse } = data.currentTarget.dataset;
-    let url = `/pages/history/detail?id=${id}&label=${label}&date=${date}`;
-    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: '已失效' })
+    let url = '';
+    if (isuse == '0' || isuse == '1' || isuse == '2' || isuse == '3') {
+      url = `/pages/history/detail?id=${id}&label=${label}&date=${date}`;
     } else {
       url = null;
       wx.showToast({ title: '未订餐' })
@@ -52,7 +46,7 @@ Page({
   onLoad: function (options) {
     if (options.openid) {
       wx.request({
-        url: `${app.globalData.publicUrl}/api/st/dining/order?openid=${'oDiAy5JAhb2ReM-LwmqbTCx5OteA'}`,
+        url: `${app.globalData.publicUrl}/api/st/dining/order?openid=${options.openid}`,
         method: "get",
         header: { 'x-tenant': app.globalData.tenant },
         data: {},

+ 0 - 2
pages/my/index.js

@@ -16,7 +16,6 @@ Page({
   // 跳转页面
   routeBtn: function (e) {
     let type = e.currentTarget.dataset.type;
-    console.log(app.globalData.wxInfo)
     if (type == '1') {
       wx.redirectTo({
         url: `/pages/history/index?openid=${app.globalData.wxInfo.openid}`
@@ -33,7 +32,6 @@ Page({
    */
   onLoad: function (options) {
     let data = app.globalData.userInfo;
-    console.log(data);
     if (data) this.setData({ userInfo: data })
   },