Browse Source

Merge branch 'master' of http://git.cc-lotus.info/Free-canteen/smart-canteen

lrf402788946 3 years ago
parent
commit
b754b75a23

+ 2 - 1
app.js

@@ -53,7 +53,8 @@ App({
     // 手机页面高度
     windowHeight: 0,
     // 请求接口
-    publicUrl: 'http://192.168.1.19:9901',
+    // publicUrl: 'http://192.168.1.19:9901',
+    publicUrl: 'https://www.waityou24.cn',
     // 图片请求接口
     fileUrl: "http://broadcast.waityou24.cn",
     // 站点标识

+ 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",

+ 1 - 21
custom-tab-bar/index.js

@@ -34,27 +34,7 @@ Component({
   methods: {
     switchTab(e) {
       const { index, path } = e.currentTarget.dataset;
-      if (index == 3) {
-        wx.getStorage({
-          key: 'userInfo',
-          success: function (res) {
-            app.globalData.userInfo = res.data;
-            wx.switchTab({ url: path })
-          },
-          fail: function (res) {
-            wx.getUserProfile({
-              desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-              success: (res) => {
-                wx.setStorage({ key: "userInfo", data: res.userInfo })
-                app.globalData.userInfo = res.userInfo;
-                wx.switchTab({ url: path })
-              }
-            })
-          }
-        })
-      } else {
-        wx.switchTab({ url: path })
-      }
+      wx.switchTab({ url: path })
       // wx.switchTab({ url })
       // wx.reLaunch({ url })
       // this.setData({

+ 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'
         })
       }

+ 70 - 6
pages/history/detail.js

@@ -1,22 +1,48 @@
 // 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: {},
+    show: false,
+  },
+  showQR() {
+    this.setData({ show: true });
+  },
+  clearQR() {
+    this.setData({ show: false });
+  },
+  noop() { },
+  // 返回
+  back: function () {
+    wx.reLaunch({
+      url: `/pages/history/index?openid=${app.globalData.wxInfo.openid}`
+    })
   },
-
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    this.searchST();
     const { id, label, date } = options
+    // let id = '60d3ed0c55bc8a3b58245b73';
+    // let label = '午餐';
+    // let date = '2021-06-25';
     this.setData({ info: { label, date } })
     this.getMeal(id);
+    this.initQrCode(id);
   },
 
   getMeal(id) {
@@ -26,16 +52,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,
+    });
+  },
 
 
   /**

+ 4 - 1
pages/history/detail.json

@@ -1,3 +1,6 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "nav-bar": "/commpents/navbar/index",
+    "van-overlay": "/miniprogram_npm/@vant/weapp/overlay/index"
+  }
 }

+ 23 - 2
pages/history/detail.wxml

@@ -1,2 +1,23 @@
-<!--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" bindtap="showQR">
+    <text class="iconfont icon-erweima"></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>
+  <van-overlay show="{{ show }}" bind:click="clearQR">
+    <view class="wrapper">
+      <view class="block" catch:tap="noop"><canvas class="qrcode" canvas-id="myQrcode"></canvas></view>
+    </view>
+  </van-overlay>
+</view>

+ 87 - 1
pages/history/detail.wxss

@@ -1 +1,87 @@
-/* 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;
+}
+
+.wrapper {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  height: 100%;
+}
+
+.block {
+  width: 130px;
+  height: 130px;
+  background-color: #fff;
+}

+ 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: {},

+ 1 - 6
pages/my/index.js

@@ -11,18 +11,15 @@ Page({
     navbarData: {
       name: '我的'
     },
-    userInfo: {}
   },
   // 跳转页面
   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}`
       })
     } else if (type == '2') {
-      app.globalData.userInfo = {}
       wx.redirectTo({
         url: '/pages/login/index'
       })
@@ -32,9 +29,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    let data = app.globalData.userInfo;
-    console.log(data);
-    if (data) this.setData({ userInfo: data })
+   
   },
 
   /**

+ 4 - 3
pages/my/index.wxml

@@ -2,16 +2,17 @@
 <view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
   <view class="one">
     <view class="left">
-      <image src="{{userInfo.avatarUrl}}"></image>
+      <open-data type="userAvatarUrl" class="image"></open-data>
     </view>
     <view class="right">
       <view class="name">
-        {{userInfo.nickName}}
+        <open-data class="other" type="userNickName" lang="zh_CN"></open-data>
+        <open-data class="other" type="userGender" lang="zh_CN"></open-data>
       </view>
     </view>
   </view>
   <view class="two">
     <van-cell title="历史记录" is-link bind:click="routeBtn" data-type="1" />
-    <van-cell title="退出登录" is-link bind:click="routeBtn" data-type="2" />
+    <!-- <van-cell title="退出登录" is-link bind:click="routeBtn" data-type="2" /> -->
   </view>
 </view>

+ 11 - 2
pages/my/index.wxss

@@ -16,10 +16,13 @@
   text-align: center;
 }
 
-.main .one .left image {
+.main .one .left .image {
+  display: block;
   width: 66px;
   height: 66px;
-  border-radius: 90px;
+  overflow: hidden;
+  border-radius: 50%;
+  margin: 0 12px;
 }
 
 .main .one .right {
@@ -30,6 +33,12 @@
 .main .one .right .name {
   float: left;
   width: 100%;
+}
+
+.main .one .right .name .other {
+  float: left;
+  width: 100%;
+  margin: 0 0 5px 0;
   font-size: 16px;
   font-weight: bold;
   margin: 0 0 5px 0;