|
@@ -1,5 +1,6 @@
|
|
|
// pages/home/index.js
|
|
|
const app = getApp()
|
|
|
+import QRCode from '../../utils/weapp-qrcode'
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -36,7 +37,8 @@ Page({
|
|
|
num: 1,
|
|
|
reserve: '100'
|
|
|
},
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ thrTitle: ''
|
|
|
},
|
|
|
// 查看本周菜谱
|
|
|
reserveBtn: function () {
|
|
@@ -68,7 +70,6 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- console.log(app.globalData.wxInfo);
|
|
|
wx.request({
|
|
|
url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
|
|
|
method: "get",
|
|
@@ -86,10 +87,8 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- console.log('function in')
|
|
|
wx.getWeRunData({
|
|
|
success(res) {
|
|
|
- console.log(res);
|
|
|
const { encryptedData, iv } = res
|
|
|
const session_key = app.globalData.wxInfo.session_key
|
|
|
const data = { encryptedData, iv, session_key }
|
|
@@ -101,12 +100,15 @@ Page({
|
|
|
header: {
|
|
|
'x-tenant': app.globalData.tenant
|
|
|
},
|
|
|
- success: (res) => {
|
|
|
+ success: (res) => {
|
|
|
console.log(res);
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
+ app.toLogin().then(res => {
|
|
|
+ this.getMealCard();
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -139,7 +141,6 @@ Page({
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function () {
|
|
|
-
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -161,5 +162,43 @@ Page({
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
+ },
|
|
|
+
|
|
|
+ getMealCard() {
|
|
|
+ const openid = app.globalData.wxInfo.openid;
|
|
|
+ if (!openid) return;
|
|
|
+ wx.request({
|
|
|
+ url: `${app.globalData.publicUrl}/api/st/dining/order/mealCard/${openid}`,
|
|
|
+ method: "POST",
|
|
|
+ header: {
|
|
|
+ 'x-tenant': app.globalData.tenant
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.errcode === 0) {
|
|
|
+ const { data } = res.data
|
|
|
+ this.initQrCode(data.data._id)
|
|
|
+ this.setData({
|
|
|
+ thrList: data.data.list || [],
|
|
|
+ thrTitle: data.type
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: (err) => {
|
|
|
+ console.error(err.data.errmsg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ initQrCode(id) {
|
|
|
+ const url = `${app.globalData.publicUrl}/api/st/dining/order/useMeal/${id}?_tenant=${app.globalData.tenant}`;
|
|
|
+ console.log(url);
|
|
|
+ var qrcode = new QRCode(`myQrcode`, {
|
|
|
+ text: url,
|
|
|
+ width: 130,
|
|
|
+ height: 130,
|
|
|
+ padding: 3,
|
|
|
+ colorDark: "#000000",
|
|
|
+ colorLight: "#ffffff",
|
|
|
+ correctLevel: QRCode.CorrectLevel.L,
|
|
|
+ });
|
|
|
}
|
|
|
})
|