提交 2b91a63c 编写于 作者: W weixin_47563380

Mon Sep 23 21:01:00 CST 2024 inscode

上级 f5bc9e93
{"containers":[],"config":{}}
\ No newline at end of file
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}
{
"pages": [
"pages/home/home",
"pages/passlist/passlist",
"pages/InvMgmtIN/InvMgmtIN",
"pages/MDmaterial/MDmaterial",
"pages/item/item",
"pages/InvMgmt/InvMgmt",
"pages/message/message",
"pages/contact/contact",
"pages/camera/camera",
"pages/appbar/appbar",
"pages/logo/logo",
"pages/index/index",
"pages/fingerPrint/fingerPrint",
"pages/logs/logs",
"pages/about/about",
"pages/generateCode/createCode",
"pages/generateCode/generateCode",
"pages/scanCode/scanCode",
"pages/hello/hello"
],
"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
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
// app.ts
App<IAppOption>({
globalData: {},
onLaunch(option) {
console.log(option.scene)
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
console.log(res.code)
// 发送 res.code 到后台换取 openId, sessionKey, unionId
},
})
},
})
\ No newline at end of file
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {}
}
\ No newline at end of file
.weui-navigation-bar {
--weui-FG-0:rgba(0,0,0,.9);
--height: 44px;
--left: 16px;
}
.weui-navigation-bar .android {
--height: 48px;
}
.weui-navigation-bar {
overflow: hidden;
color: var(--weui-FG-0);
flex: none;
}
.weui-navigation-bar__inner {
position: relative;
top: 0;
left: 0;
height: calc(var(--height) + env(safe-area-inset-top));
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding-top: env(safe-area-inset-top);
width: 100%;
box-sizing: border-box;
}
.weui-navigation-bar__left {
position: relative;
padding-left: var(--left);
display: flex;
flex-direction: row;
align-items: flex-start;
height: 100%;
box-sizing: border-box;
}
.weui-navigation-bar__btn_goback_wrapper {
padding: 11px 18px 11px 16px;
margin: -11px -18px -11px -16px;
}
.weui-navigation-bar__btn_goback_wrapper.weui-active {
opacity: 0.5;
}
.weui-navigation-bar__btn_goback {
font-size: 12px;
width: 12px;
height: 24px;
-webkit-mask: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E") no-repeat 50% 50%;
mask: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='24' viewBox='0 0 12 24'%3E %3Cpath fill-opacity='.9' fill-rule='evenodd' d='M10 19.438L8.955 20.5l-7.666-7.79a1.02 1.02 0 0 1 0-1.42L8.955 3.5 10 4.563 2.682 12 10 19.438z'/%3E%3C/svg%3E") no-repeat 50% 50%;
-webkit-mask-size: cover;
mask-size: cover;
background-color: var(--weui-FG-0);
}
.weui-navigation-bar__center {
font-size: 17px;
text-align: center;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
font-weight: bold;
flex: 1;
height: 100%;
}
.weui-navigation-bar__loading {
margin-right: 4px;
align-items: center;
}
.weui-loading {
font-size: 16px;
width: 16px;
height: 16px;
display: block;
background: transparent url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg width='80px' height='80px' viewBox='0 0 80 80' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Ctitle%3Eloading%3C/title%3E%3Cdefs%3E%3ClinearGradient x1='94.0869141%25' y1='0%25' x2='94.0869141%25' y2='90.559082%25' id='linearGradient-1'%3E%3Cstop stop-color='%23606060' stop-opacity='0' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3ClinearGradient x1='100%25' y1='8.67370605%25' x2='100%25' y2='90.6286621%25' id='linearGradient-2'%3E%3Cstop stop-color='%23606060' offset='0%25'%3E%3C/stop%3E%3Cstop stop-color='%23606060' stop-opacity='0.3' offset='100%25'%3E%3C/stop%3E%3C/linearGradient%3E%3C/defs%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd' opacity='0.9'%3E%3Cg%3E%3Cpath d='M40,0 C62.09139,0 80,17.90861 80,40 C80,62.09139 62.09139,80 40,80 L40,73 C58.2253967,73 73,58.2253967 73,40 C73,21.7746033 58.2253967,7 40,7 L40,0 Z' fill='url(%23linearGradient-1)'%3E%3C/path%3E%3Cpath d='M40,0 L40,7 C21.7746033,7 7,21.7746033 7,40 C7,58.2253967 21.7746033,73 40,73 L40,80 C17.90861,80 0,62.09139 0,40 C0,17.90861 17.90861,0 40,0 Z' fill='url(%23linearGradient-2)'%3E%3C/path%3E%3Ccircle id='Oval' fill='%23606060' cx='40.5' cy='3.5' r='3.5'%3E%3C/circle%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A") no-repeat;
background-size: 100%;
margin-left: 0;
animation: loading linear infinite 1s;
}
@keyframes loading {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
Component({
options: {
multipleSlots: true // 在组件定义时的选项中启用多slot支持
},
/**
* 组件的属性列表
*/
properties: {
extClass: {
type: String,
value: ''
},
title: {
type: String,
value: ''
},
background: {
type: String,
value: ''
},
color: {
type: String,
value: ''
},
back: {
type: Boolean,
value: true
},
loading: {
type: Boolean,
value: false
},
homeButton: {
type: Boolean,
value: false,
},
animated: {
// 显示隐藏的时候opacity动画效果
type: Boolean,
value: true
},
show: {
// 显示隐藏导航,隐藏的时候navigation-bar的高度占位还在
type: Boolean,
value: true,
observer: '_showChange'
},
// back为true的时候,返回的页面深度
delta: {
type: Number,
value: 1
},
},
/**
* 组件的初始数据
*/
data: {
displayStyle: ''
},
lifetimes: {
attached() {
const rect = wx.getMenuButtonBoundingClientRect()
wx.getSystemInfo({
success: (res) => {
const isAndroid = res.platform === 'android'
const isDevtools = res.platform === 'devtools'
this.setData({
ios: !isAndroid,
innerPaddingRight: `padding-right: ${res.windowWidth - rect.left}px`,
leftWidth: `width: ${res.windowWidth - rect.left }px`,
safeAreaTop: isDevtools || isAndroid ? `height: calc(var(--height) + ${res.safeArea.top}px); padding-top: ${res.safeArea.top}px` : ``
})
}
})
},
},
/**
* 组件的方法列表
*/
methods: {
_showChange(show: boolean) {
const animated = this.data.animated
let displayStyle = ''
if (animated) {
displayStyle = `opacity: ${
show ? '1' : '0'
};transition:opacity 0.5s;`
} else {
displayStyle = `display: ${show ? '' : 'none'}`
}
this.setData({
displayStyle
})
},
back() {
const data = this.data
if (data.delta) {
wx.navigateBack({
delta: data.delta
})
}
this.triggerEvent('back', { delta: data.delta }, {})
}
},
})
<view class="weui-navigation-bar {{extClass}}">
<view class="weui-navigation-bar__inner {{ios ? 'ios' : 'android'}}" style="color: {{color}}; background: {{background}}; {{displayStyle}}; {{innerPaddingRight}}; {{safeAreaTop}};">
<!-- 左侧按钮 -->
<view class='weui-navigation-bar__left' style="{{leftWidth}};">
<block wx:if="{{back || homeButton}}">
<!-- 返回上一页 -->
<block wx:if="{{back}}">
<view class="weui-navigation-bar__buttons weui-navigation-bar__buttons_goback">
<view
bindtap="back"
class="weui-navigation-bar__btn_goback_wrapper"
hover-class="weui-active"
hover-stay-time="100"
aria-role="button"
aria-label="返回"
>
<view class="weui-navigation-bar__button weui-navigation-bar__btn_goback"></view>
</view>
</view>
</block>
<!-- 返回首页 -->
<block wx:if="{{homeButton}}">
<view class="weui-navigation-bar__buttons weui-navigation-bar__buttons_home">
<view
bindtap="home"
class="weui-navigation-bar__btn_home_wrapper"
hover-class="weui-active"
aria-role="button"
aria-label="首页"
>
<view class="weui-navigation-bar__button weui-navigation-bar__btn_home"></view>
</view>
</view>
</block>
</block>
<block wx:else>
<slot name="left"></slot>
</block>
</view>
<!-- 标题 -->
<view class='weui-navigation-bar__center'>
<view wx:if="{{loading}}" class="weui-navigation-bar__loading" aria-role="alert">
<view
class="weui-loading"
aria-role="img"
aria-label="加载中"
></view>
</view>
<block wx:if="{{title}}">
<text>{{title}}</text>
</block>
<block wx:else>
<slot name="center"></slot>
</block>
</view>
<!-- 右侧留空 -->
<view class='weui-navigation-bar__right'>
<slot name="right"></slot>
</view>
</view>
</view>
{
"usingComponents": {}
}
\ No newline at end of file
.swiper{
height: 250rpx; /*rpx能实现高度的自动缩放*/
indicator-dots:"true";
autoplay:true;
interval:"5000";
duration:"500";
}
.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/InvMgmt/InvMgmt.ts
Page({
/**
* 页面的初始数据
*/
data: {
},
goToInvMgmtIN: function() {
wx.navigateTo({
url: '/pages/InvMgmtIN/InvMgmtIN' // 扫码入库
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
wx.setNavigationBarTitle({
title: '库存管理',
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!-- 库存管理 -->
<!-- 轮播图区域 -->
<swiper
indicator-dots="true"
autoplay="true"
interval="5000"
duration="500" >
<swiper-item>
<image src="/images/banner1.jpg" mode="aspectFill"></image>
</swiper-item>
<swiper-item>
<image src="/images/card1.jpg" mode="aspectFill"></image>
</swiper-item>
<swiper-item>
<image src="/images/menu1.jpg" mode="aspectFill"></image>
</swiper-item>
</swiper>
<!-- 九宫格区域 -->
<view class="grid-list">
<view class="grid-item">
<image src="/images/banner1.jpg" bindtap="goToInvMgmtIN"></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" 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": {}
}
\ 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>
{
"navigationBarTitleText": "Hello Page"
}
\ No newline at end of file
// pages/about/about.ts
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<view class="container">
<text>HELLO</text>
</view>
\ No newline at end of file
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
text {
font-size: 30rpx;
color: #333;
}
\ No newline at end of file
// components/app-bar/index.js
Component({
properties: {
},
data: {
showAppbar: false
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
}
}
\ No newline at end of file
/* pages/appbar/appbar.wxss */
\ No newline at end of file
// pages/appbar/appbar.ts
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<view wx:if="{{showAppbar}}">
<app-bar-course></app-bar-course>
</view>
\ No newline at end of file
.expand-container {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 0 24px;
padding-bottom: env(safe-area-inset-bottom);
pointer-events: auto;
overflow: hidden;
background-color: #e9f8f7;
color: #7e8081;
}
.hide {
display: none;
}
.nav-bar {
overflow: hidden;
box-sizing: border-box;
}
.icon--back {
width: 30px;
height: 30px;
}
.title {
margin-left: 10px;
min-width: 160px;
flex: 1;
}
.title .name {
margin-top: 4px;
font-size: 12px;
}
.title-wrap {
flex: 1;
min-width: 240px;
}
.footer {
padding: 0 24px;
}
.footer .icon {
width: 40px;
height: 40px;
}
.expand-cover {
width: 100%;
height: 100%;
}
.music-title {
margin-top: 48px;
font-size: 20px;
font-weight: bold;
color: #07c160;
}
.music-title .name {
margin-top: 12px;
font-size: 14px;
font-weight: 200;
color: #b1b2b3;
}
.cover-area {
margin: 8px 0;
width: 100%;
aspect-ratio: 1 / 1;
overflow: hidden;
}
.cover {
/* aspect-ratio: 1 / 1; */
flex-shrink: 0;
}
.icon {
width: 18px;
height: 18px;
}
.row {
display: flex;
flex-direction: row;
align-items: center;
}
.row-between {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.column {
display: flex;
flex-direction: column;
}
.column-main-center {
display: flex;
flex-direction: column;
justify-content: center;
}
.column-cross-center {
display: flex;
flex-direction: column;
align-items: center;
}
.center {
display: flex;
align-items: center;
justify-content: center;
}
.circle {
width: 100%;
height: 100%;
overflow: hidden;
border-radius: 50%;
}
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/camera/camera.wxss */
\ No newline at end of file
// pages/camera/camera.ts
Page({
/**
* 页面的初始数据
*/
data: {
src: '' // 存储拍摄的照片路径
},
takePhoto() {
const ctx = wx.createCameraContext()
console.log('takePhoto拍照')
ctx.takePhoto({
quality: 'high',
success: (res) => {
this.setData({
src: res.tempImagePath
})
}
})
},
savePhoto() {
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(options) {
// options.scene 是场景值
console.log('onLoad启动时的场景值:', options.scene);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!-- pages/camera/camera.wxml -->
<camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>
<button bindtap="takePhoto">拍照</button>
<button bindtap="savePhoto" wx:if="{{src}}">保存到相册</button>
<text>{{src}}</text>
<image src="{{src}}">显示图片</image>
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/contact/contact.wxss */
\ No newline at end of file
// pages/contact/contact.ts
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
wx.setNavigationBarTitle({
title: '联系我们',
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!--pages/contact/contact.wxml 使用微信的「联系我」插件-->
<text>pages/contact/contact.wxml 使用微信的「联系我」插件</text>
\ No newline at end of file
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
\ No newline at end of file
/* pages/fingerPrint/fingerPrint.wxss */
\ No newline at end of file
// pages/fingerPrint/fingerPrint.ts
Page({
/**
* 页面的初始数据
*/
data: {
hasLogin: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function () {
const _this = this
console.log('节点信息:onLoad')
wx.checkIsSupportSoterAuthentication({
success(res) {
console.log(res.supportMode.indexOf('fingerPrint'))
if (res.supportMode.indexOf('fingerPrint') === -1) {
wx.showToast({
title: '您的手机暂不支持指纹识别',
icon: 'none',
duration: 2000
})
return
}
_this.setData({
hasLogin: true
})
},
fail() {
wx.showToast({
title: '系统错误',
icon: 'none',
duration: 2000
})
}
})
},
startSoterAuthentication: function () {
const _this = this
console.log('节点信息:wx.checkIsSoterEnrolledInDevice')
wx.checkIsSoterEnrolledInDevice({
checkAuthMode: 'fingerPrint',
success(res) {
if (res.isEnrolled) {
wx.showToast({
title: '您尚未录入指纹,请到系统设置中录入',
icon: 'none',
duration: 2000
})
return
}
wx.startSoterAuthentication({
requestAuthModes: ['fingerPrint'],
challenge: '123456',
authContent: '请用指纹进行身份验证',
success(res) {
wx.showToast({
title: '登录成功',
icon: 'success',
duration: 2000
})
_this.setData({
hasLogin: true
})
},
fail(res) {
wx.showToast({
title: '登录失败,请重试',
icon: 'none',
duration: 2000
})
}
})
},
fail() {
wx.showToast({
title: '系统错误',
icon: 'none',
duration: 2000
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!--指纹识别登录-->
<view class="container">
<view wx:if="{{!hasLogin}}">
<button bindtap="startSoterAuthentication">点击登录</button>
</view>
</view>
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/generateCode/createCode.wxss */
\ No newline at end of file
// pages/generateCode/createCode.ts
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!--pages/generateCode/createCode.wxml-->
<text>pages/generateCode/createCode.wxml</text>
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/generateCode/generateCode.wxss */
\ No newline at end of file
// pages/generateCode/generateCode.ts
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
console.log('onReady')
this.generateCode()
},
generateCode: function () {
console.log('generateCode-begin')
const ctx = wx.createCanvasContext('codeCanvas')
const codeData = 'https://example.com' // 二维码包含的信息,可以是文本或URL等
const codeSize = 200 // 二维码的尺寸
const imageMargin = 10 // 二维码与画布边缘的距离
wx.createSelectorQuery().select('#codeCanvas').boundingClientRect((rect) => {
//const canvasWidth = rect.width
const canvasWidth = 100
//const canvasHeight = rect.height
const canvasHeight = 100
const codeWidth = canvasWidth - 2 * imageMargin
const codeHeight = canvasHeight - 2 * imageMargin
// 绘制白色背景
ctx.setFillStyle('#ffffff')
ctx.fillRect(0, 0, canvasWidth, canvasHeight)
// 绘制二维码
console.log('绘制二维码')
ctx.drawImage('/images/qrcode.png', imageMargin, imageMargin, codeWidth, codeHeight)
ctx.draw()
}).exec()
console.log('generateCode-end')
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!--pages/generateCode/generateCode.wxml-->
<view class="container">
<view>
<canvas canvas-id="codeCanvas" style="width: 200px; height: 200px;"></canvas>
</view>
</view>
\ No newline at end of file
{
"navigationBarTitleText": "Hello Page"
}
\ No newline at end of file
<view class="container">
<text>HELLO</text>
</view>
\ No newline at end of file
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
text {
font-size: 30rpx;
color: #333;
}
\ 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
/**index.less**/
page {
height: 100vh;
display: flex;
flex-direction: column;
}
.scrollarea {
flex: 1;
overflow-y: hidden;
}
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
color: #aaa;
width: 80%;
}
.userinfo-avatar {
overflow: hidden;
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.usermotto {
margin-top: 200px;
}
.avatar-wrapper {
padding: 0;
width: 56px !important;
border-radius: 8px;
margin-top: 40px;
margin-bottom: 40px;
}
.avatar {
display: block;
width: 56px;
height: 56px;
}
.nickname-wrapper {
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;
}
.nickname-label {
width: 105px;
}
.nickname-input {
flex: 1;
}
// index.ts
// 获取应用实例
const app = getApp<IAppOption>()
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
Component({
data: {
motto: 'Hello World',
QRStr:'',
plant:'',
materialnum:'',
materialtxt:'',
materialbatch:'',
materialamount:'',
materialBUoM:'',
userInfo: {
avatarUrl: defaultAvatarUrl,
nickName: '',
},
hasUserInfo: false,
canIUseGetUserProfile: wx.canIUse('getUserProfile'),
canIUseNicknameComp: wx.canIUse('input.type.nickname'),
},
methods: {
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs',
})
},
onInputPlant(e:any){
this.setData({
plant: e.detail.value
});
console.log(this.data.plant)
},
onInputMaterialnum(e:any){
this.setData({
materialnum: e.detail.value
});
console.log(this.data.materialnum)
},
onInputMaterialtxt(e:any){
this.setData({
materialtxt: e.detail.value
});
console.log(this.data.materialtxt)
},
onInputmaterialbatch(e:any){
this.setData({
materialbatch: e.detail.value
});
console.log(this.data.materialbatch)
},
onInputmaterialamount(e:any){
this.setData({
materialamount: e.detail.value
});
console.log(this.data.materialamount)
},
onInputmaterialBUoM(e:any){
this.setData({
materialBUoM: e.detail.value
});
console.log(this.data.materialBUoM)
},
onCreateQR(e:any){
let QRStr="plant:"+this.data.plant+" materialnum:"+this.data.materialnum+" materialtxt:"+this.data.materialtxt+" materialbatch:"+this.data.materialbatch;
console.log(QRStr)
},
onChooseAvatar(e: any) {
const { avatarUrl } = e.detail
const { nickName } = this.data.userInfo
this.setData({
"userInfo.avatarUrl": avatarUrl,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
})
},
onInputChange(e: any) {
const nickName = e.detail.value
const { avatarUrl } = this.data.userInfo
this.setData({
"userInfo.nickName": nickName,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
})
},
getUserProfile() {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
},
})
<!--index.wxml-->
<navigation-bar title="scanMM" back="{{false}}" color="black" background="#FFF"></navigation-bar>
<scroll-view class="scrollarea" scroll-y type="list">
<view class="container">
<view class="userinfo">
<block wx:if="{{canIUseNicknameComp && !hasUserInfo}}">
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image class="avatar" src="{{userInfo.avatarUrl}}"></image>
</button>
<view class="nickname-wrapper">
<text class="nickname-label">工厂</text>
<input type="plant" class="nickname-input" placeholder="请输入工厂" bind:change="onInputPlant" />
</view>
<view class="nickname-wrapper">
<text class="nickname-label">物料号</text>
<input type="materialnum" class="nickname-input" placeholder="请输入物料号" bind:change="onInputMaterialnum" />
</view>
<view class="nickname-wrapper">
<text class="nickname-label">物料描述</text>
<input type="materialtxt" class="nickname-input" placeholder="请输入物料描述" bind:change="onInputMaterialtxt" />
</view>
<view class="nickname-wrapper">
<text class="nickname-label">批次号</text>
<input type="materialbatch" class="nickname-input" placeholder="请输入批次号" bind:change="onInputmaterialbatch" />
</view>
<view class="nickname-wrapper">
<text class="nickname-label">数量</text>
<input type="materialamount" class="nickname-input" placeholder="请输入数量" bind:change="onInputmaterialamount" />
</view>
<view class="nickname-wrapper">
<text class="nickname-label">基本计量单位</text>
<input type="materialBUoM" class="nickname-input" placeholder="请输入基本计量单位" bind:change="onInputmaterialBUoM" />
</view>
<button class="button" bindtap="onCreateQR">生成二维码</button>
</block>
<block wx:elif="{{!hasUserInfo}}">
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
<view wx:else> 请使用2.10.4及以上版本基础库 </view>
</block>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>
</scroll-view>
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/item/item.wxss */
.avatar {
display: block;
width: 16px;
height: 16px;
}
.header {
display: flex;
align-items: center;
justify-content: center;
height: 88rpx;
background-color: #ffffff;
box-shadow: 0 1rpx 1rpx rgba(0, 0, 0, 0.1);
}
.logo {
width: 60rpx;
height: 60rpx;
margin-right: 20rpx;
}
.title {
font-size: 32rpx;
font-weight: bold;
color: #333333;
}
.banner {
width: 10px; /* 使 banner 宽度充满容器 */
height: 10px; /* 设定 banner 的高度 */
background-color: rgb(41, 28, 110); /* 设定背景色,实际使用中通常会用图片 */
display: flex; /* 使用 Flex 布局来居中对齐 banner 中的内容 */
justify-content: center; /* 水平居中 */
align-items: center; /* 垂直居中 */
overflow: hidden; /* 如果图片尺寸过大,防止内容溢出 */
}
.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;
}
.content {
flex: 1;
padding: 30rpx 60rpx;
background-color: #cc6363;
}
.section {
margin-bottom: 60rpx;
padding: 30rpx 60rpx;
}
.section-title {
font-size: 32rpx;
font-weight: bold;
color: #333333;
margin-bottom: 30rpx;
margin-left: 30rpx;
}
.card-group {
display: flex;
justify-content: space-between;
padding: 5%;
}
.card {
display: flex;
flex-direction: column;
align-items: center;
background-color: #ffffff;
box-shadow: 0 1rpx 1rpx rgba(0, 0, 0, 0.1);
width: 200rpx;
padding: 20rpx;
border-radius: 10rpx;
box-sizing: border-box;
}
.card image {
width: 190rpx;
height: 190rpx;
margin-bottom: 20rpx;
}
.card-title {
font-size: 28rpx;
font-weight: bold;
color: #333333;
margin-bottom: 10rpx;
}
.card-desc {
font-size: 24rpx;
color: #999999;
margin-bottom: 10rpx;
}
.card-price {
font-size: 28rpx;
color: #ff4d4f;
}
.topic-group {
display: flex;
justify-content: space-between;
color: #6e7e94;
padding: 20rpx;
width: 100px;
height: 100px;
}
.topic {
display: flex;
flex-direction: column;
align-items: center;
background-color: #ffffff;
box-shadow: 0 1rpx 1rpx rgba(0, 0, 0, 0.1);
width: 80%;
padding: 20rpx;
border-radius: 10rpx;
}
.topic image {
width: 300rpx;
height: 240rpx;
margin-bottom: 20rpx;
}
.topic-title {
font-size: 28rpx;
font-weight: bold;
color: #333333;
margin-bottom: 10rpx;
}
.footer {
display: flex;
align-items: center;
justify-content: center;
height: 60rpx;
background-color: #ffffff;
box-shadow: 0 -1rpx 1rpx rgba(0, 0, 0, 0.1);
}
.info {
font-size: 24rpx;
color: #999999;
}
// pages/item/item.ts
Page({
/**
* 页面的初始数据
*/
data: {
},
goToPasslist: function() {
wx.navigateTo({
url: '/pages/passlist/passlist' // 用户管理
});
},
goToMDmaterial: function() {
wx.navigateTo({
url: '/pages/MDmaterial/MDmaterial' // 物料主数据
});
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
// 在这里调用API显示提示框
wx.showToast({
title: '已经到底部了', // 提示的内容
icon: 'none', // 图标,'success'、'loading'等,默认无图标
duration: 2000 // 提示的延迟时间,单位毫秒,默认1500
});
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<view class="container">
<view class="banner">
<swiper indicator-dots="true" autoplay="true">
<swiper-item>
<image class="avatar" src="/images/banner1.jpg"></image>
</swiper-item>
<swiper-item>
<image src="/images/banner1.jpg"></image>
</swiper-item>
<swiper-item>
<image src="/images/banner1.jpg"></image>
</swiper-item>
</swiper>
</view>
<view class="menu">
<view class="menu-item">
<image src="/images/menu1.jpg"></image>
<text>主数据管理</text>
</view>
<view class="menu-item">
<image src="/images/menu1.jpg"></image>
<text>采购管理</text>
</view>
<view class="menu-item">
<image src="/images/menu1.jpg"></image>
<text>销售管理</text>
</view>
<view class="menu-item">
<image src="/images/menu1.jpg"></image>
<text>库存管理</text>
</view>
</view>
<view class="content">
<view class="section">
<view class="section-title">主数据管理</view>
<view class="card-group">
<view class="card">
<image src="/images/card1.jpg" bindtap="goToMDmaterial"></image>
<text class="card-title">物料主数据</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">客户主数据</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">供应商主数据</text>
</view>
</view>
<view class="card-group">
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">银行主数据</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">设备主数据</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">其它主数据</text>
</view>
</view>
</view>
<view class="section">
<view class="section-title">供应链管理-对内</view>
<view class="card-group">
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">采购计划</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">采购订单</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">库存管理</text>
</view>
</view>
</view>
<view class="section">
<view class="section-title">供应链管理-对外</view>
<view class="card-group">
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">销售订单</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">外向交货</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">生产出库</text>
</view>
</view>
</view>
<view class="section">
<view class="section-title">系统管理</view>
<view class="card-group">
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">其它管理</text>
</view>
<view class="card">
<image src="/images/card1.jpg" bindtap="goToPasslist"></image>
<text class="card-title">用户管理</text>
</view>
<view class="card">
<image src="/images/card1.jpg"></image>
<text class="card-title">其它</text>
</view>
</view>
</view>
<view class="section">
<view class="section-title">管理主题</view>
<view class="topic-group">
<view class="topic">
<image src="/images/topic1.jpg"></image>
<text class="topic-title">成品控制</text>
</view>
<view class="topic">
<image src="/images/topic1.jpg"></image>
<text class="topic-title">获客</text>
</view>
</view>
</view>
</view>
<view class="footer">
<text class="info">版权所有 © 林涛</text>
</view>
</view>
\ No newline at end of file
// pages/logo/logo.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
setTimeout(() => {
wx.navigateTo({
//url: '/pages/index/index'
url: '/pages/item/item'
});
}, 1000);
},
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/logo/logo.wxml-->
<view class="container">
<image src="/pages/images/contoursw.jpg" class="image-style"></image>
</view>
\ No newline at end of file
{
"usingComponents": {
"navigation-bar": "/components/navigation-bar/navigation-bar"
}
}
\ No newline at end of file
page {
height: 100vh;
display: flex;
flex-direction: column;
}
.scrollarea {
flex: 1;
overflow-y: hidden;
}
.log-item {
margin-top: 20rpx;
text-align: center;
}
.log-item:last-child {
padding-bottom: env(safe-area-inset-bottom);
}
// logs.ts
// const util = require('../../utils/util.js')
import { formatTime } from '../../utils/util'
Component({
data: {
logs: [],
},
lifetimes: {
attached() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map((log: string) => {
return {
date: formatTime(new Date(log)),
timeStamp: log
}
}),
})
}
},
})
<!--logs.wxml-->
<navigation-bar title="查看启动日志" back="{{true}}" color="black" background="#FFF"></navigation-bar>
<scroll-view class="scrollarea" scroll-y type="list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<view class="log-item">{{index + 1}}. {{log.date}}</view>
</block>
</scroll-view>
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/message/message.wxss */
\ No newline at end of file
// pages/message/message.ts
Page({
/**
* 页面的初始数据
*/
data: {
query: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('执行onLoad')
this.setData({
query: options
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
console.log('执行message onReady')
wx.setNavigationBarTitle({
title: '消息',
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
<!--pages/message/message.wxml-->
<text>pages/message/message.wxml</text>
\ 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.
先完成此消息的编辑!
想要评论请 注册