提交 3f8655ae 编写于 作者: W weixin_47563380

Tue Jul 30 11:42:00 CST 2024 inscode

上级 ca207a2f
run = "npm i && npm run dev"
language = "node"
[env]
PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}"
XDG_CONFIG_HOME = "/root/.config"
npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global"
\ No newline at end of file
npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global"
[debugger]
program = "main.js"
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/InvMgmtIN/InvMgmtIN.wxss */
.input {
display: flex;
width: 100%;
padding: 16px;
box-sizing: border-box;
border-top: .5px solid rgba(0, 0, 0, 0.1);
border-bottom: .5px solid rgba(0, 0, 0, 0.1);
color: black;
}
.label {
width: 105px;
}
// pages/InvMgmtIN/InvMgmtIN.ts
Page({
/**
* 页面的初始数据
*/
data: {
noError: true,
isShow: true,
currentTime: '',//年月日时分秒
MText: '',//物料描述
MCode: '',//批次编码
MLocation: '',//存放地点
src: '',// 存储拍摄的照片路径
formData: {
MText: '',//物料描述
MCode: '',//批次编码
MLocation: '',//存放地点
src: '',// 存储拍摄的照片路径
},
// 初始时,stkmat数组为空
stkmats: []
},
selectImage: function () {
wx.chooseImage({
count: 1,
success: function (res) {
const tempFilePath = res.tempFilePaths[0]; // 用户选择的图片临时文件路径
// 将图片路径保存到本地缓存
wx.setStorageSync('imagePath', tempFilePath);
// 同时更新页面的数据,以便立即显示图片
this.setData({
src: tempFilePath
});
this.setData({
'formData.src': tempFilePath
});
}.bind(this) // 注意这里需要绑定this
});
},
// 错误处理函数
error: function (e: any) {
console.error('摄像头组件发生错误:', e.detail);
this.setData({
isShow: false // 现在显示
});
// 这里可以添加你的错误处理逻辑
},
addOrUpdateItem: function (e: any) {
const { MText, MCode, MLocation, src } = this.data.formData;
if (!MText || !MCode || !MLocation || !src) {
this.setData({
noError: false
})
return wx.showToast({ title: '请填写完整信息', icon: 'none' });
}else{
this.setData({
noError: true
})
}
let stkmat = {
MText: MText,//物料描述
MCode: MCode,//批次编码
MLocation: MLocation,//存放地点
src: this.data.src,// 存储拍摄的照片路径
};
// 尝试从本地存储中获取'stkmats'
let storedItems = wx.getStorageSync('stkmats');
// 检查storedItems是否为null(或undefined,但wx.getStorageSync不会返回undefined)
const itemslist = storedItems ? JSON.parse(storedItems) : [];
// 使用Object.keys()来获取所有键,并计算它们的数量
let recordCount = Object.keys(itemslist).length;
// 将新记录添加到itemsList对象中,使用新记录的ID作为键
itemslist[recordCount.toString()] = stkmat;
this.saveItems(itemslist);
},
saveItems: function (itemslist: any) {
wx.setStorageSync('stkmats', JSON.stringify(itemslist));
/* let storedItems = wx.getStorageSync('stkmats');
// 检查storedItems是否为null(或undefined,但wx.getStorageSync不会返回undefined)
const itemslist1 = storedItems ? JSON.parse(storedItems) : [];
this.setData({
items: itemslist
}); */
},
onInputMText(e: any) {
this.setData({
'formData.MText': e.detail.value
});
},
onInputMCode(e: any) {
this.setData({
'formData.MCode': e.detail.value
});
},
onInputMLocation(e: any) {
this.setData({
'formData.MLocation': e.detail.value
});
},
takePhoto() {
const ctx = wx.createCameraContext()
ctx.takePhoto({
quality: 'high',
success: (res) => {
this.setData({
src: res.tempImagePath
})
this.setData({
'formData.src': res.tempImagePath
});
}
})
},
savePhoto() {
this.addOrUpdateItem();
if (this.data.noError) {
wx.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
})
} else {
wx.showToast({
title: '保存失败',
icon: 'none',
duration: 2000
})
}
/* wx.saveImageToPhotosAlbum({
filePath: this.data.src,
success: function (res) {
wx.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
})
},
fail: function (err) {
wx.showToast({
title: '保存失败',
icon: 'none',
duration: 2000
})
}
}) */
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
// 获取当前时间
let now = new Date();
// 格式化日期时间字符串
let formattedTime = `${now.getFullYear()}${(now.getMonth() + 1).toString().padStart(2, '0')}${now.getDate().toString().padStart(2, '0')}${now.getHours().toString().padStart(2, '0')}${now.getMinutes().toString().padStart(2, '0')}${now.getSeconds().toString().padStart(2, '0')}`;
// 更新页面数据
this.setData({
'formData.MCode': formattedTime
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
wx.setNavigationBarTitle({
title: '扫码入库',
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!-- pages/camera/camera.wxml -->
<camera device-position="back" flash="off" binderror="error" bindtap="selectImage" style="width: 100%; height: 300px;"></camera>
<image src="{{src}}" wx:if="{{src}}">显示图片</image>
<button bindtap="takePhoto" wx:if="{{isShow}}">拍照</button>
<button bindtap="savePhoto" wx:if="{{src}}">保存</button>
<view class="input">
<text class="label">物料描述</text>
<input placeholder="请输入物料描述" bind:change="onInputMText" value="{{formData.MText}}"/>
</view>
<view class="input">
<text class="label">批次编码</text>
<input placeholder="现在手输,未来实现扫描二维码" bind:change="onInputMCode" value="{{formData.MCode}}"/>
</view>
<view class="input">
<text class="label">存放地点</text>
<input placeholder="请输入存放地点" bind:change="onInputMLocation" value="{{formData.MLocation}}"/>
</view>
<!-- <view class="input">
<text class="label">图片地址</text>
<text>{{src}}</text>
</view> -->
<!-- <view class="input">
<text class="label">显示传值</text>
<input placeholder="显示传值" value="{{formData.MText}}"/>
</view> -->
\ No newline at end of file
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
\ No newline at end of file
/* pages/MDmaterial/MDmaterial.wxss */
.menu {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 10rpx;
background-color: #feffff;
}
.menu-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.menu-item image {
width: 80rpx;
height: 80rpx;
}
.menu-item text {
margin-top: 10rpx;
font-size: 28rpx;
color: #000000;
}
.shop-item{
display: flex;
padding: 15rpx;
border: 1px solid #efefef;
margin: 15rpx;
border-radius: 8rpx;
box-shadow: 1rpx 1rpx 15rpx #ddd;
}
.thumb image{
width: 250rpx;
height: 250rpx;
display: block;
margin-right: 15rpx;
}
.info{
display: flex;
flex-direction: column;
justify-content: space-around;
font-size: 24rpx;
}
.shop-title{
font-weight: bold;
}
\ No newline at end of file
// pages/MDmaterial/MDmaterial.ts
Page({
/**
* 页面的初始数据
*/
data: {
isShow:true,
searchInput: '', // 用户输入的查询条件
searchResults: [], // 查询结果
imagePath: '', // 用于存储图片的路径
MText: '',//物料描述
MCode: '',//批次编码
MLocation: '',//存放地点
src: '',// 存储拍摄的照片路径
item: {
MText: '',//物料描述
MCode: '',//批次编码
MLocation: '',//存放地点
src: '',// 存储拍摄的照片路径
},
// 初始时,stkmat数组为空
itmes: []
},
// 处理输入事件
handleInput: function (e) {
this.setData({
searchInput: e.detail.value
});
},
// 执行查询
searchData: function () {
let searchInput = this.data.searchInput.trim();
let searchResults = [];
// 这里我们进行简单的模糊查询,即检查name或info字段是否包含搜索条件
this.data.items.forEach(item => {
if (item.MText.includes(searchInput) || item.MCode.includes(searchInput) || item.MLocation.includes(searchInput)) {
searchResults.push(item);
this.setData({
isShow: false
});
}
});
// 更新查询结果到页面上
this.setData({
searchResults: searchResults
});
},
selectImage: function () {
wx.chooseImage({
count: 1,
success: function (res) {
const tempFilePath = res.tempFilePaths[0]; // 用户选择的图片临时文件路径
// 将图片路径保存到本地缓存
wx.setStorageSync('imagePath', tempFilePath);
// 同时更新页面的数据,以便立即显示图片
this.setData({
imagePath: tempFilePath
});
}.bind(this) // 注意这里需要绑定this
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
// 页面加载时,尝试从缓存中读取图片路径
const cachedImagePath = wx.getStorageSync('imagePath') || '';
if (cachedImagePath) {
this.setData({
imagePath: cachedImagePath
});
} else {
this.setData({
imagePath: "/images/banner1.jpg" //初始图片
});
}
// 尝试从本地存储中获取'items'
const storedItems = wx.getStorageSync('stkmats');
//console.log('storedItems:'+storedItems);
// 检查storedItems是否为null(或undefined,但wx.getStorageSync不会返回undefined)
// 如果是null,则默认为空数组;否则,尝试解析JSON字符串为数组
const itemslist = storedItems ? JSON.parse(storedItems) : [];
//if(itemslist)
//console.log('itemslist:'+itemslist);
// 更新页面的items数据
this.setData({
items: itemslist
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
wx.setNavigationBarTitle({
title: '物料管理',
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<view>
<input type="text" bindinput="handleInput" placeholder="请输入查询条件" />
<button bindtap="searchData">查询</button>
<view wx:for="{{searchResults}}" wx:key="id">
{{item.MText}} - {{item.MCode}} - {{item.MLocation}}
</view>
</view>
<view class="shop-item" wx:for="{{searchResults}}" wx:key="id">
<!-- 图片资源 -->
<view class="thumb">
<image src="{{item.src}}" mode="aspectFit" bindtap="selectImage"></image>
</view>
<!-- 文字信息 -->
<view class="info">
<text class="shop-title">物料描述: {{item.MText}}</text>
<text>批次编码:{{item.MCode}}</text>
<text>存放地点: {{item.MLocation}}</text>
</view>
</view>
<view class="shop-item" wx:if="{{isShow}}" wx:for="{{items}}" wx:key="index">
<!-- 图片资源 -->
<view class="thumb">
<image src="{{item.src}}" mode="aspectFit" bindtap="selectImage"></image>
</view>
<!-- 文字信息 -->
<view class="info">
<text class="shop-title">物料描述: {{item.MText}}</text>
<text>批次编码:{{item.MCode}}</text>
<text>存放地点: {{item.MLocation}}</text>
</view>
</view>
{
"pages": [
"pages/home/home",
"pages/passlist/passlist",
"pages/InvMgmtIN/InvMgmtIN",
"pages/MDmaterial/MDmaterial"
],
"window": {
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#008c8c",
"navigationBarTitleText": "小型仓储系统-单机版",
"navigationBarTextStyle":"white"
},
"tabBar": {
"list": [{
"pagePath": "pages/home/home",
"text": "首页",
"iconPath": "/images/card1.jpg",
"selectedIconPath": "/images/card1.jpg"
},{
"pagePath": "pages/message/message",
"text": "消息",
"iconPath": "/images/card1.jpg",
"selectedIconPath": "/images/card1.jpg"
},{
"pagePath": "pages/contact/contact",
"text": "联系我们",
"iconPath": "/images/card1.jpg",
"selectedIconPath": "/images/card1.jpg"
}]
},
"style": "v2",
"rendererOptions": {
"skyline": {
"defaultDisplayBlock": true,
"disableABTest": true,
"sdkVersionBegin": "3.0.0",
"sdkVersionEnd": "15.255.255"
}
},
"componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents"
}
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
.swiper-image{
width: 100%;
height: 100%;
}
.grid-list{
display: flex;
flex-wrap: wrap; /* 让弹性盒元素在必要的时候拆行 */
border-left: 1px solid #efefef;
border-top: 1px solid #efefef;
}
.grid-item{
width: 33.33%;
height: 200rpx;
display: flex;
flex-direction: column;/* 项目将垂直显示,正如一个列一样。 */
align-items: center; /* 定义flex子项在flex容器的中心 */
justify-content: center;/*用于设置或检索弹性盒子元素在主轴(横轴)方向上的对齐方式为居中*/
border-right: 1px solid #efefef;
border-bottom: 1px solid #efefef;
box-sizing: border-box;
}
.grid-item image {
width: 60rpx;
height: 60rpx;
}
.grid-item text{
font-size: 24rpx;
margin-top: 10rpx;
}
/* 图片 */
.img-box{
display: flex;
padding: 20rpx 10rpx;
justify-content: space-around;
}
.img-box image{
width: 45%;
height: 250rpx;
}
\ No newline at end of file
// pages/home/home.ts
Page({
/**
* 页面的初始数据
*/
data: {
SwiperList: []
},
// 获取轮播图的方法
getSwiperList() {
console.log('执行getSwiperList')
// wx.request({
// //url: 'https://www.escook.cn/slides',
// url: 'https://www.csdn.net/',
// method: 'GET',
// success: (res) => {
// // 类似于React中的setState,将状态数据更新
// this.setData({
// SwiperList: res.data
// })
// }
// })
},
goToInvMgmt: function() {
wx.navigateTo({
url: '/pages/InvMgmt/InvMgmt' // 库存管理
});
},
goToMDmaterial: function() {
wx.navigateTo({
url: '/pages/MDmaterial/MDmaterial' // 物料管理
});
},
goToPasslist: function() {
wx.navigateTo({
url: '/pages/passlist/passlist' // 用户管理
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
this.getSwiperList()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!-- 轮播图区域 -->
<swiper
indicator-dots="true"
autoplay="true"
interval="5000"
duration="500" >
<!-- <swiper-item wx:for="{{SwiperList}}" wx:key="id">
<image src="{{item.image}}"></image>
</swiper-item> -->
<swiper-item>
<image class="swiper-image" src="/images/swiper1.jpg" mode="aspectFill"></image>
</swiper-item>
<swiper-item>
<image class="swiper-image" src="/images/swiper2.jpg" mode="aspectFill"></image>
</swiper-item>
<swiper-item>
<image class="swiper-image" src="/images/swiper3.jpg" mode="aspectFill"></image>
</swiper-item>
</swiper>
<!-- 九宫格区域 -->
<view class="grid-list">
<view class="grid-item">
<image src="/images/banner1.jpg" bindtap="goToMDmaterial"></image>
<text>物料管理</text>
</view>
<view class="grid-item">
<image src="/images/banner1.jpg" bindtap="goToInvMgmt"></image>
<text>库存管理</text>
</view>
<view class="grid-item">
<image src="/images/banner1.jpg" bindtap="goToPasslist"></image>
<text>用户管理</text>
</view>
<view class="grid-item">
<image src="/images/building.jpg"></image>
<text>赚钱建家</text>
</view>
<view class="grid-item">
<image src="/images/building.jpg"></image>
<text>赚钱建家</text>
</view>
<view class="grid-item">
<image src="/images/building.jpg"></image>
<text>赚钱建家</text>
</view>
<view class="grid-item">
<image src="/images/building.jpg"></image>
<text>赚钱建家</text>
</view>
<view class="grid-item">
<image src="/images/building.jpg"></image>
<text>赚钱建家</text>
</view>
<view class="grid-item">
<image src="/images/building.jpg"></image>
<text>赚钱建家</text>
</view>
</view>
<!-- 图片区域 -->
<view class="img-box">
<image src="/images/banner1.jpg"></image>
<image src="/images/banner1.jpg"></image>
</view>
\ No newline at end of file
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
\ No newline at end of file
.container {
padding: 20px;
}
.input{
margin: 10px 0;
}
.textlist {
display: flex;
justify-content: space-between;
align-items: left;
padding: 10px;
height: 100px;
width: 100%;
}
.form-container{
display: grid;
width:100%;
padding: 10px;
}
.list-container{
display: grid;
width:100%;
}
.list-container .item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border-bottom: 1px solid #ccc;
}
.button{
display: flex;
margin-left: 10px;
width: 50%;
}
// pages/passlist/passlist.ts
Page({
/**
* 页面的初始数据
*/
data: {
name:'',
age:'',
formData: {
name: '',
age: ''
},
// 初始时,items数组为空
items: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
this.loadItems();
},
bindNameInput: function(e:any) {
console.log(e.detail.value);
this.setData({
'formData.name': e.detail.value
});
},
bindAgeInput: function(e:any) {
this.setData({
'formData.age': e.detail.value
});
},
addOrUpdateItem: function(e:any) {
const { name, age } = this.data.formData;
if (!name || !age) return wx.showToast({ title: '请填写完整信息', icon: 'none' });
let item = {
name: name,
age: age
};
// 尝试从本地存储中获取'items'
let storedItems = wx.getStorageSync('items');
// 检查storedItems是否为null(或undefined,但wx.getStorageSync不会返回undefined)
const itemslist = storedItems ? JSON.parse(storedItems) : [];
// 使用Object.keys()来获取所有键,并计算它们的数量
let recordCount = Object.keys(itemslist).length;
// 将新记录添加到itemsList对象中,使用新记录的ID作为键
itemslist[recordCount.toString()] = item;
this.saveItems(itemslist);
},
editItem: function(e:any) {
const index = e.currentTarget.dataset.index;
const item = this.data.items[index];
console.log(typeof item);
this.setData({
//这里会报错:类型“never”上不存在属性“name”。这不影响传值。不用理会报错。
formData: { name: item.name, age: item.age }
});
},
deleteItem: function(e:any) {
const index = e.currentTarget.dataset.index;
const items = [...this.data.items];
items.splice(index, 1);
this.setData({
items:items
});
this.saveItems(items);
},
saveItems: function(itemslist:any) {
console.log('保存');
wx.setStorageSync('items', JSON.stringify(itemslist));
let storedItems = wx.getStorageSync('items');
// 检查storedItems是否为null(或undefined,但wx.getStorageSync不会返回undefined)
const itemslist1 = storedItems ? JSON.parse(storedItems) : [];
//var itemslist = wx.getStorageSync('items');
this.setData({
items:itemslist
});
},
loadItems: function() {
// 尝试从本地存储中获取'items'
const storedItems = wx.getStorageSync('items');
//console.log('storedItems:'+storedItems);
// 检查storedItems是否为null(或undefined,但wx.getStorageSync不会返回undefined)
// 如果是null,则默认为空数组;否则,尝试解析JSON字符串为数组
const itemslist = storedItems ? JSON.parse(storedItems) : [];
//if(itemslist)
//console.log('itemslist:'+itemslist);
// 更新页面的items数据
this.setData({
items:itemslist
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
wx.setNavigationBarTitle({
title: '用户管理',
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
// 在这里调用API显示提示框
wx.showToast({
title: '人家是有底线的。', // 提示的内容
icon: 'none', // 图标,'success'、'loading'等,默认无图标
duration: 2000 // 提示的延迟时间,单位毫秒,默认1500
});
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!--要使用微信开发者工具创建一个包含新增、修改、删除功能的表单,并可以保存到本地以及从本地读取之前保存的记录-->
<navigation-bar title="用户管理" back="{{false}}" color="black" background="#FFF"></navigation-bar>
<view class="container">
<view class="form-container">
<input type="text" class="input" placeholder="请输入用户名" bindinput="bindNameInput" value="{{formData.name}}"/>
<input type="text" class="input" placeholder="请输入密码" bindinput="bindAgeInput" value="{{formData.age}}"/>
<button bindtap="addOrUpdateItem">保存</button>
</view>
<view class="list-container">
<block wx:for="{{items}}" wx:key="index">
<view class="item">
<text type='text' class='textlist'>{{item.name}} - {{item.age}}</text>
</view>
<view class="button">
<button bindtap="editItem" data-index="{{index}}">编辑</button>
<button bindtap="deleteItem" data-index="{{index}}">删除</button>
</view>
</block>
</view>
</view>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册