更新项目文件结构,统一文档风格

This commit is contained in:
ylweng
2025-09-01 02:45:51 +08:00
parent 5ea25b7bac
commit 216cf80eab
95 changed files with 210 additions and 75446 deletions

View File

@@ -0,0 +1,80 @@
App({
onLaunch() {
// 小程序初始化
console.log('牛肉商城小程序初始化');
// 检查登录状态
this.checkLoginStatus();
},
onShow() {
// 小程序显示
console.log('牛肉商城小程序显示');
},
onHide() {
// 小程序隐藏
console.log('牛肉商城小程序隐藏');
},
onError(msg) {
// 错误处理
console.log('小程序发生错误:', msg);
},
globalData: {
userInfo: null,
token: null,
baseUrl: 'http://localhost:8000/api'
},
// 检查登录状态
checkLoginStatus() {
try {
const token = wx.getStorageSync('token');
if (token) {
this.globalData.token = token;
// 验证token有效性
this.verifyToken(token);
}
} catch (e) {
console.error('检查登录状态失败:', e);
}
},
// 验证token
verifyToken(token) {
wx.request({
url: `${this.globalData.baseUrl}/auth/verify`,
method: 'GET',
header: {
'Authorization': `Bearer ${token}`
},
success: (res) => {
if (res.data.valid) {
this.globalData.userInfo = res.data.user;
} else {
// token无效清除本地存储
wx.removeStorageSync('token');
this.globalData.token = null;
this.globalData.userInfo = null;
}
},
fail: (err) => {
console.error('验证token失败', err);
}
});
},
// 登录方法
login(userInfo) {
this.globalData.userInfo = userInfo;
},
// 登出方法
logout() {
this.globalData.userInfo = null;
this.globalData.token = null;
wx.removeStorageSync('token');
}
})

View File

@@ -0,0 +1,14 @@
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "锡林郭勒盟智慧养殖",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

View File

@@ -0,0 +1,174 @@
/* 全局样式 */
page {
background-color: #f5f5f5;
font-size: 28rpx;
color: #333;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
}
.container {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f5f5f5;
}
/* 通用样式类 */
.flex-row {
display: flex;
flex-direction: row;
}
.flex-column {
display: flex;
flex-direction: column;
}
.align-center {
align-items: center;
}
.justify-center {
justify-content: center;
}
.justify-between {
justify-content: space-between;
}
.text-center {
text-align: center;
}
.text-primary {
color: #4CAF50;
}
.text-secondary {
color: #388E3C;
}
.text-accent {
color: #FF9800;
}
.bg-white {
background-color: #ffffff;
}
.padding {
padding: 20rpx;
}
.padding-horizontal {
padding-left: 20rpx;
padding-right: 20rpx;
}
.padding-vertical {
padding-top: 20rpx;
padding-bottom: 20rpx;
}
.margin {
margin: 20rpx;
}
.margin-horizontal {
margin-left: 20rpx;
margin-right: 20rpx;
}
.margin-vertical {
margin-top: 20rpx;
margin-bottom: 20rpx;
}
/* 按钮样式 */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 30rpx;
border-radius: 10rpx;
font-size: 32rpx;
font-weight: 500;
border: none;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background-color: #4CAF50;
color: white;
}
.btn-primary:hover {
background-color: #388E3C;
}
.btn-secondary {
background-color: #FF9800;
color: white;
}
.btn-secondary:hover {
background-color: #F57C00;
}
.btn-block {
width: 100%;
}
/* 卡片样式 */
.card {
background-color: #ffffff;
border-radius: 10rpx;
padding: 20rpx;
margin: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}
/* 表单样式 */
.form-group {
margin-bottom: 30rpx;
}
.form-group label {
display: block;
margin-bottom: 10rpx;
font-weight: 500;
}
.form-group input,
.form-group picker,
.form-group textarea {
width: 100%;
padding: 20rpx;
border: 2rpx solid #ddd;
border-radius: 10rpx;
font-size: 28rpx;
}
/* 加载动画 */
.loading {
display: flex;
justify-content: center;
align-items: center;
padding: 40rpx;
}
.spinner {
width: 50rpx;
height: 50rpx;
border: 5rpx solid #f3f3f3;
border-top: 5rpx solid #4CAF50;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

View File

@@ -0,0 +1,52 @@
{
"description": "牛肉商城小程序",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.24.7",
"appid": "wxa123456789012345",
"projectname": "beef-mall",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

View File

@@ -0,0 +1,80 @@
App({
onLaunch() {
// 小程序初始化
console.log('牛肉商城小程序初始化');
// 检查登录状态
this.checkLoginStatus();
},
onShow() {
// 小程序显示
console.log('牛肉商城小程序显示');
},
onHide() {
// 小程序隐藏
console.log('牛肉商城小程序隐藏');
},
onError(msg) {
// 错误处理
console.log('小程序发生错误:', msg);
},
globalData: {
userInfo: null,
token: null,
baseUrl: 'http://localhost:8000/api'
},
// 检查登录状态
checkLoginStatus() {
try {
const token = wx.getStorageSync('token');
if (token) {
this.globalData.token = token;
// 验证token有效性
this.verifyToken(token);
}
} catch (e) {
console.error('检查登录状态失败:', e);
}
},
// 验证token
verifyToken(token) {
wx.request({
url: `${this.globalData.baseUrl}/auth/verify`,
method: 'GET',
header: {
'Authorization': `Bearer ${token}`
},
success: (res) => {
if (res.data.valid) {
this.globalData.userInfo = res.data.user;
} else {
// token无效清除本地存储
wx.removeStorageSync('token');
this.globalData.token = null;
this.globalData.userInfo = null;
}
},
fail: (err) => {
console.error('验证token失败', err);
}
});
},
// 登录方法
login(userInfo) {
this.globalData.userInfo = userInfo;
},
// 登出方法
logout() {
this.globalData.userInfo = null;
this.globalData.token = null;
wx.removeStorageSync('token');
}
})

View File

@@ -0,0 +1,14 @@
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "锡林郭勒盟智慧养殖",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

View File

@@ -0,0 +1,174 @@
/* 全局样式 */
page {
background-color: #f5f5f5;
font-size: 28rpx;
color: #333;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
}
.container {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f5f5f5;
}
/* 通用样式类 */
.flex-row {
display: flex;
flex-direction: row;
}
.flex-column {
display: flex;
flex-direction: column;
}
.align-center {
align-items: center;
}
.justify-center {
justify-content: center;
}
.justify-between {
justify-content: space-between;
}
.text-center {
text-align: center;
}
.text-primary {
color: #4CAF50;
}
.text-secondary {
color: #388E3C;
}
.text-accent {
color: #FF9800;
}
.bg-white {
background-color: #ffffff;
}
.padding {
padding: 20rpx;
}
.padding-horizontal {
padding-left: 20rpx;
padding-right: 20rpx;
}
.padding-vertical {
padding-top: 20rpx;
padding-bottom: 20rpx;
}
.margin {
margin: 20rpx;
}
.margin-horizontal {
margin-left: 20rpx;
margin-right: 20rpx;
}
.margin-vertical {
margin-top: 20rpx;
margin-bottom: 20rpx;
}
/* 按钮样式 */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 30rpx;
border-radius: 10rpx;
font-size: 32rpx;
font-weight: 500;
border: none;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background-color: #4CAF50;
color: white;
}
.btn-primary:hover {
background-color: #388E3C;
}
.btn-secondary {
background-color: #FF9800;
color: white;
}
.btn-secondary:hover {
background-color: #F57C00;
}
.btn-block {
width: 100%;
}
/* 卡片样式 */
.card {
background-color: #ffffff;
border-radius: 10rpx;
padding: 20rpx;
margin: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}
/* 表单样式 */
.form-group {
margin-bottom: 30rpx;
}
.form-group label {
display: block;
margin-bottom: 10rpx;
font-weight: 500;
}
.form-group input,
.form-group picker,
.form-group textarea {
width: 100%;
padding: 20rpx;
border: 2rpx solid #ddd;
border-radius: 10rpx;
font-size: 28rpx;
}
/* 加载动画 */
.loading {
display: flex;
justify-content: center;
align-items: center;
padding: 40rpx;
}
.spinner {
width: 50rpx;
height: 50rpx;
border: 5rpx solid #f3f3f3;
border-top: 5rpx solid #4CAF50;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

View File

@@ -0,0 +1,52 @@
{
"description": "牛肉商城小程序",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.24.7",
"appid": "wxa123456789012345",
"projectname": "beef-mall",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

View File

@@ -0,0 +1,80 @@
App({
onLaunch() {
// 小程序初始化
console.log('牛肉商城小程序初始化');
// 检查登录状态
this.checkLoginStatus();
},
onShow() {
// 小程序显示
console.log('牛肉商城小程序显示');
},
onHide() {
// 小程序隐藏
console.log('牛肉商城小程序隐藏');
},
onError(msg) {
// 错误处理
console.log('小程序发生错误:', msg);
},
globalData: {
userInfo: null,
token: null,
baseUrl: 'http://localhost:8000/api'
},
// 检查登录状态
checkLoginStatus() {
try {
const token = wx.getStorageSync('token');
if (token) {
this.globalData.token = token;
// 验证token有效性
this.verifyToken(token);
}
} catch (e) {
console.error('检查登录状态失败:', e);
}
},
// 验证token
verifyToken(token) {
wx.request({
url: `${this.globalData.baseUrl}/auth/verify`,
method: 'GET',
header: {
'Authorization': `Bearer ${token}`
},
success: (res) => {
if (res.data.valid) {
this.globalData.userInfo = res.data.user;
} else {
// token无效清除本地存储
wx.removeStorageSync('token');
this.globalData.token = null;
this.globalData.userInfo = null;
}
},
fail: (err) => {
console.error('验证token失败', err);
}
});
},
// 登录方法
login(userInfo) {
this.globalData.userInfo = userInfo;
},
// 登出方法
logout() {
this.globalData.userInfo = null;
this.globalData.token = null;
wx.removeStorageSync('token');
}
})

View File

@@ -0,0 +1,14 @@
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "锡林郭勒盟智慧养殖",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

View File

@@ -0,0 +1,174 @@
/* 全局样式 */
page {
background-color: #f5f5f5;
font-size: 28rpx;
color: #333;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
}
.container {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f5f5f5;
}
/* 通用样式类 */
.flex-row {
display: flex;
flex-direction: row;
}
.flex-column {
display: flex;
flex-direction: column;
}
.align-center {
align-items: center;
}
.justify-center {
justify-content: center;
}
.justify-between {
justify-content: space-between;
}
.text-center {
text-align: center;
}
.text-primary {
color: #4CAF50;
}
.text-secondary {
color: #388E3C;
}
.text-accent {
color: #FF9800;
}
.bg-white {
background-color: #ffffff;
}
.padding {
padding: 20rpx;
}
.padding-horizontal {
padding-left: 20rpx;
padding-right: 20rpx;
}
.padding-vertical {
padding-top: 20rpx;
padding-bottom: 20rpx;
}
.margin {
margin: 20rpx;
}
.margin-horizontal {
margin-left: 20rpx;
margin-right: 20rpx;
}
.margin-vertical {
margin-top: 20rpx;
margin-bottom: 20rpx;
}
/* 按钮样式 */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 30rpx;
border-radius: 10rpx;
font-size: 32rpx;
font-weight: 500;
border: none;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background-color: #4CAF50;
color: white;
}
.btn-primary:hover {
background-color: #388E3C;
}
.btn-secondary {
background-color: #FF9800;
color: white;
}
.btn-secondary:hover {
background-color: #F57C00;
}
.btn-block {
width: 100%;
}
/* 卡片样式 */
.card {
background-color: #ffffff;
border-radius: 10rpx;
padding: 20rpx;
margin: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}
/* 表单样式 */
.form-group {
margin-bottom: 30rpx;
}
.form-group label {
display: block;
margin-bottom: 10rpx;
font-weight: 500;
}
.form-group input,
.form-group picker,
.form-group textarea {
width: 100%;
padding: 20rpx;
border: 2rpx solid #ddd;
border-radius: 10rpx;
font-size: 28rpx;
}
/* 加载动画 */
.loading {
display: flex;
justify-content: center;
align-items: center;
padding: 40rpx;
}
.spinner {
width: 50rpx;
height: 50rpx;
border: 5rpx solid #f3f3f3;
border-top: 5rpx solid #4CAF50;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

View File

@@ -0,0 +1,52 @@
{
"description": "牛肉商城小程序",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.24.7",
"appid": "wxa123456789012345",
"projectname": "beef-mall",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

View File

@@ -0,0 +1,80 @@
App({
onLaunch() {
// 小程序初始化
console.log('牛肉商城小程序初始化');
// 检查登录状态
this.checkLoginStatus();
},
onShow() {
// 小程序显示
console.log('牛肉商城小程序显示');
},
onHide() {
// 小程序隐藏
console.log('牛肉商城小程序隐藏');
},
onError(msg) {
// 错误处理
console.log('小程序发生错误:', msg);
},
globalData: {
userInfo: null,
token: null,
baseUrl: 'http://localhost:8000/api'
},
// 检查登录状态
checkLoginStatus() {
try {
const token = wx.getStorageSync('token');
if (token) {
this.globalData.token = token;
// 验证token有效性
this.verifyToken(token);
}
} catch (e) {
console.error('检查登录状态失败:', e);
}
},
// 验证token
verifyToken(token) {
wx.request({
url: `${this.globalData.baseUrl}/auth/verify`,
method: 'GET',
header: {
'Authorization': `Bearer ${token}`
},
success: (res) => {
if (res.data.valid) {
this.globalData.userInfo = res.data.user;
} else {
// token无效清除本地存储
wx.removeStorageSync('token');
this.globalData.token = null;
this.globalData.userInfo = null;
}
},
fail: (err) => {
console.error('验证token失败', err);
}
});
},
// 登录方法
login(userInfo) {
this.globalData.userInfo = userInfo;
},
// 登出方法
logout() {
this.globalData.userInfo = null;
this.globalData.token = null;
wx.removeStorageSync('token');
}
})

View File

@@ -0,0 +1,14 @@
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "锡林郭勒盟智慧养殖",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

View File

@@ -0,0 +1,174 @@
/* 全局样式 */
page {
background-color: #f5f5f5;
font-size: 28rpx;
color: #333;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
}
.container {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f5f5f5;
}
/* 通用样式类 */
.flex-row {
display: flex;
flex-direction: row;
}
.flex-column {
display: flex;
flex-direction: column;
}
.align-center {
align-items: center;
}
.justify-center {
justify-content: center;
}
.justify-between {
justify-content: space-between;
}
.text-center {
text-align: center;
}
.text-primary {
color: #4CAF50;
}
.text-secondary {
color: #388E3C;
}
.text-accent {
color: #FF9800;
}
.bg-white {
background-color: #ffffff;
}
.padding {
padding: 20rpx;
}
.padding-horizontal {
padding-left: 20rpx;
padding-right: 20rpx;
}
.padding-vertical {
padding-top: 20rpx;
padding-bottom: 20rpx;
}
.margin {
margin: 20rpx;
}
.margin-horizontal {
margin-left: 20rpx;
margin-right: 20rpx;
}
.margin-vertical {
margin-top: 20rpx;
margin-bottom: 20rpx;
}
/* 按钮样式 */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 30rpx;
border-radius: 10rpx;
font-size: 32rpx;
font-weight: 500;
border: none;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background-color: #4CAF50;
color: white;
}
.btn-primary:hover {
background-color: #388E3C;
}
.btn-secondary {
background-color: #FF9800;
color: white;
}
.btn-secondary:hover {
background-color: #F57C00;
}
.btn-block {
width: 100%;
}
/* 卡片样式 */
.card {
background-color: #ffffff;
border-radius: 10rpx;
padding: 20rpx;
margin: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}
/* 表单样式 */
.form-group {
margin-bottom: 30rpx;
}
.form-group label {
display: block;
margin-bottom: 10rpx;
font-weight: 500;
}
.form-group input,
.form-group picker,
.form-group textarea {
width: 100%;
padding: 20rpx;
border: 2rpx solid #ddd;
border-radius: 10rpx;
font-size: 28rpx;
}
/* 加载动画 */
.loading {
display: flex;
justify-content: center;
align-items: center;
padding: 40rpx;
}
.spinner {
width: 50rpx;
height: 50rpx;
border: 5rpx solid #f3f3f3;
border-top: 5rpx solid #4CAF50;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

View File

@@ -0,0 +1,52 @@
{
"description": "牛肉商城小程序",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.24.7",
"appid": "wxa123456789012345",
"projectname": "beef-mall",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

View File

@@ -0,0 +1,80 @@
App({
onLaunch() {
// 小程序初始化
console.log('牛肉商城小程序初始化');
// 检查登录状态
this.checkLoginStatus();
},
onShow() {
// 小程序显示
console.log('牛肉商城小程序显示');
},
onHide() {
// 小程序隐藏
console.log('牛肉商城小程序隐藏');
},
onError(msg) {
// 错误处理
console.log('小程序发生错误:', msg);
},
globalData: {
userInfo: null,
token: null,
baseUrl: 'http://localhost:8000/api'
},
// 检查登录状态
checkLoginStatus() {
try {
const token = wx.getStorageSync('token');
if (token) {
this.globalData.token = token;
// 验证token有效性
this.verifyToken(token);
}
} catch (e) {
console.error('检查登录状态失败:', e);
}
},
// 验证token
verifyToken(token) {
wx.request({
url: `${this.globalData.baseUrl}/auth/verify`,
method: 'GET',
header: {
'Authorization': `Bearer ${token}`
},
success: (res) => {
if (res.data.valid) {
this.globalData.userInfo = res.data.user;
} else {
// token无效清除本地存储
wx.removeStorageSync('token');
this.globalData.token = null;
this.globalData.userInfo = null;
}
},
fail: (err) => {
console.error('验证token失败', err);
}
});
},
// 登录方法
login(userInfo) {
this.globalData.userInfo = userInfo;
},
// 登出方法
logout() {
this.globalData.userInfo = null;
this.globalData.token = null;
wx.removeStorageSync('token');
}
})

View File

@@ -0,0 +1,14 @@
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "锡林郭勒盟智慧养殖",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

View File

@@ -0,0 +1,174 @@
/* 全局样式 */
page {
background-color: #f5f5f5;
font-size: 28rpx;
color: #333;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei', sans-serif;
}
.container {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f5f5f5;
}
/* 通用样式类 */
.flex-row {
display: flex;
flex-direction: row;
}
.flex-column {
display: flex;
flex-direction: column;
}
.align-center {
align-items: center;
}
.justify-center {
justify-content: center;
}
.justify-between {
justify-content: space-between;
}
.text-center {
text-align: center;
}
.text-primary {
color: #4CAF50;
}
.text-secondary {
color: #388E3C;
}
.text-accent {
color: #FF9800;
}
.bg-white {
background-color: #ffffff;
}
.padding {
padding: 20rpx;
}
.padding-horizontal {
padding-left: 20rpx;
padding-right: 20rpx;
}
.padding-vertical {
padding-top: 20rpx;
padding-bottom: 20rpx;
}
.margin {
margin: 20rpx;
}
.margin-horizontal {
margin-left: 20rpx;
margin-right: 20rpx;
}
.margin-vertical {
margin-top: 20rpx;
margin-bottom: 20rpx;
}
/* 按钮样式 */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 30rpx;
border-radius: 10rpx;
font-size: 32rpx;
font-weight: 500;
border: none;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background-color: #4CAF50;
color: white;
}
.btn-primary:hover {
background-color: #388E3C;
}
.btn-secondary {
background-color: #FF9800;
color: white;
}
.btn-secondary:hover {
background-color: #F57C00;
}
.btn-block {
width: 100%;
}
/* 卡片样式 */
.card {
background-color: #ffffff;
border-radius: 10rpx;
padding: 20rpx;
margin: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}
/* 表单样式 */
.form-group {
margin-bottom: 30rpx;
}
.form-group label {
display: block;
margin-bottom: 10rpx;
font-weight: 500;
}
.form-group input,
.form-group picker,
.form-group textarea {
width: 100%;
padding: 20rpx;
border: 2rpx solid #ddd;
border-radius: 10rpx;
font-size: 28rpx;
}
/* 加载动画 */
.loading {
display: flex;
justify-content: center;
align-items: center;
padding: 40rpx;
}
.spinner {
width: 50rpx;
height: 50rpx;
border: 5rpx solid #f3f3f3;
border-top: 5rpx solid #4CAF50;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

View File

@@ -0,0 +1,52 @@
{
"description": "牛肉商城小程序",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.24.7",
"appid": "wxa123456789012345",
"projectname": "beef-mall",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}