From 41193d186d157937ba052e73dd04c12018e9ecab Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Thu, 07 Aug 2025 10:38:42 +0800
Subject: [PATCH] 新增
---
pages/tabBar/firstPage/firstPage.js | 225 +++++++++++++++++++++++++++++++++++---------------------
1 files changed, 141 insertions(+), 84 deletions(-)
diff --git a/pages/tabBar/firstPage/firstPage.js b/pages/tabBar/firstPage/firstPage.js
index 995d3e1..abe9538 100644
--- a/pages/tabBar/firstPage/firstPage.js
+++ b/pages/tabBar/firstPage/firstPage.js
@@ -56,29 +56,29 @@
getUserInfo() {
// 云开发
- const companyId = wx.getStorageSync('user').companyId
- cloudApi.queryPost('userInfoList',{company_id: companyId}).then(res=>{
- if(res.data.length>0){
- this.setData({
- user: cloudApi.changeKey(res.data)[0]
- });
- wx.setStorageSync('userSet', cloudApi.changeKey(res.data)[0])
- }
- })
- // api
- // api.getUserInfo().then(res => {
- // if(res.code == 200) {
+ // const companyId = wx.getStorageSync('user').companyId
+ // cloudApi.queryPost('userInfoList',{company_id: companyId}).then(res=>{
+ // if(res.data.length>0){
// this.setData({
- // user: res.data
+ // user: cloudApi.changeKey(res.data)[0]
// });
- // wx.setStorageSync('userSet', res.data);
- // } else {
- // wx.showToast({
- // title: res.message,
- // icon: 'none'
- // });
+ // wx.setStorageSync('userSet', cloudApi.changeKey(res.data)[0])
// }
- // });
+ // })
+ // api
+ api.getUserInfo().then(res => {
+ if(res.code == 200) {
+ this.setData({
+ user: res.data
+ });
+ wx.setStorageSync('userSet', res.data);
+ } else {
+ wx.showToast({
+ title: res.message,
+ icon: 'none'
+ });
+ }
+ });
},
closeModal(){
this.setData({
@@ -109,87 +109,89 @@
}
if(t.data.tabNum == 1) {
// 云开发请求
- wx.cloud.callFunction({
- name: 'getHazmatInfo',
- data: {
- code: res.result
- }
- }).then(res=>{
- if(res.result && Array.isArray(res.result.list) && res.result.list.length>0){
- t.setData({
- hazmat: cloudApi.changeKey(res.result.list[0]),
- showModal: true
- })
- }else{
- wx.showToast({
- title: '无条码信息',
- icon: 'error',
- duration: 2000
- });
- }
- })
- // api请求
- // api.getHazmatByCode({code: res.result}).then((re) => {
- // if(re.code == 200) {
+ // wx.cloud.callFunction({
+ // name: 'getHazmatInfo',
+ // data: {
+ // code: 'SJ08202502250003'
+ // }
+ // }).then(res=>{
+ // if(res.result && Array.isArray(res.result.list) && res.result.list.length>0){
// t.setData({
- // hazmat: re.data,
+ // hazmat: cloudApi.changeKey(res.result.list[0]),
// showModal: true
- // });
- // } else {
+ // })
+ // }else{
// wx.showToast({
- // title: re.message,
+ // title: '无条码信息',
// icon: 'error',
// duration: 2000
// });
// }
- // }).catch(err => {
- // wx.showToast({
- // title: err,
- // duration: 2000
- // });
- // });
+ // })
+ // api请求
+ api.getHazmatByCode({code: res.result}).then((re) => {
+ if(re.code == 200) {
+ t.setData({
+ hazmat: re.data,
+ showModal: true
+ });
+ } else {
+ wx.showToast({
+ title: re.message,
+ icon: 'error',
+ duration: 2000
+ });
+ }
+ }).catch(err => {
+ wx.showToast({
+ title: err,
+ duration: 2000
+ });
+ });
} else {
// 云开发请求
- wx.cloud.callFunction({
- name: 'getProductInfo',
- data: {
- code: res.result
- }
- }).then(res=>{
- if(res.result && Array.isArray(res.result.list) && res.result.list.length>0){
- t.setData({
- product: cloudApi.changeKey(res.result.list[0]),
- showModal: true
- })
- }else{
- wx.showToast({
- title: '无条码信息',
- icon: 'error',
- duration: 2000
- });
- }
- })
- // api请求
- // api.getProductByCode({code: res.result}).then((re) => {
- // if(re.code == 200) {
+ // wx.cloud.callFunction({
+ // name: 'getProductInfo',
+ // data: {
+ // code: res.result
+ // }
+ // }).then(res=>{
+ // if(res.result && Array.isArray(res.result.list) && res.result.list.length>0){
// t.setData({
- // product: re.data,
+ // product: cloudApi.changeKey(res.result.list[0]),
// showModal: true
- // });
- // } else {
+ // })
+ // }else{
// wx.showToast({
- // title: re.message,
+ // title: '无条码信息',
// icon: 'error',
// duration: 2000
// });
// }
- // }).catch(err => {
- // wx.showToast({
- // title: err,
- // duration: 2000
- // });
- // });
+ // })
+ // api请求
+ api.getProductByCode({code: res.result}).then((re) => {
+ if(re.code == 200) {
+ t.setData({
+ product: re.data,
+ showModal: true
+ });
+ } else {
+ wx.showToast({
+ title: re.message,
+ icon: 'error',
+ duration: 2000
+ });
+ }
+ }).catch(err => {
+ wx.showToast({
+ title: err,
+ duration: 2000
+ });
+ });
}
+
+
} else {
wx.showToast({
title: '该二维码已失效或不包含条码信息',
@@ -199,10 +201,39 @@
}
}
});
+
+
},
confirmTake1() {
const t = this;
+
+ // 云服务请求
+ // wx.cloud.callFunction({
+ // name: 'hazmatUsing',
+ // data: {
+ // warehouseId: t.data.hazmat.warehouseId,
+ // basicId: t.data.hazmat.basicId,
+ // companyId: t.data.hazmat.companyId,
+ // cupboardId: t.data.hazmat.cupboardId,
+ // hazmatId: t.data.hazmat.id,
+ // uid: wx.getStorageSync('user').id,
+ // id: t.data.hazmat.Id,
+ // remaining: t.data.hazmat.remaining,
+ // status: 0
+ // }
+ // }).then(res=>{
+ // if(res.result.code == 200){
+ // wx.showToast({
+ // title: '取用成功',
+ // icon: 'success',
+ // duration: 2000
+ // });
+ // }
+ // })
+
+
+ // api请求
api.postHazmatUse(t.data.hazmat.id, 0).then((r) => {
wx.showToast({
title: r.message,
@@ -219,6 +250,32 @@
confirmTake2() {
const t = this;
+
+ // 云服务请求
+ // wx.cloud.callFunction({
+ // name: 'hazmatUsing',
+ // data: {
+ // warehouseId: t.data.hazmat.warehouseId,
+ // basicId: t.data.hazmat.basicId,
+ // companyId: t.data.hazmat.companyId,
+ // cupboardId: t.data.hazmat.cupboardId,
+ // hazmatId: t.data.hazmat.id,
+ // uid: wx.getStorageSync('user').id,
+ // id: t.data.hazmat.Id,
+ // remaining: t.data.hazmat.remaining,
+ // status: 1
+ // }
+ // }).then(res=>{
+ // if(res.result.code == 200){
+ // wx.showToast({
+ // title: '取用成功',
+ // icon: 'success',
+ // duration: 2000
+ // });
+ // }
+ // })
+
+ // api请求
api.postHazmatUse(t.data.hazmat.id, 1).then((r) => {
wx.showToast({
title: r.message,
--
Gitblit v1.9.2