提交app

This commit is contained in:
guanj
2026-03-17 14:00:55 +08:00
parent b71200cb97
commit 00e34c168f
82 changed files with 13202 additions and 4602 deletions

View File

@@ -1,7 +1,7 @@
const debug = false // true 是连地服务端本地false 是连接线上
const debug = true // true 是连地服务端本地false 是连接线上
const development = {
domain: 'http://192.168.1.62:10215',
domain: 'http://192.168.2.126:10215',
}
const production = {

View File

@@ -1,92 +1,98 @@
export default {
onPullDownRefresh() {
this.store && this.store.reload()
},
onReachBottom() {
if (this.store.status != 'noMore') {
this.store.next && this.store.next()
}
},
data() {
return {
store: {},
}
},
methods: {
DataSource(url) {
var me = this
return {
data: [],
status: 'noMore',
empty: false,
total: 0,
header: {
'Content-Type': 'application/json;charset=UTF-8',
},
params: {
pageNum: 1,
pageSize: 20,
},
timer: null,
callBack: null,
firstCallBack: null,
loadedCallback: null,
reload() {
if (this.status == 'loading') return
this.data = []
this.empty = false
this.params.pageNum = 1
this.next()
},
search() {
// 节流搜索
clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.reload()
}, 300)
},
next() {
this.status = 'loading'
me.$request({
url: url,
data: this.params,
header: this.header,
method: 'POST',
debounce: false,
}).then((res) => {
console.warn(res)
let resultData = res.data?.list || res.data?.records || res.data || []
if (this.params.pageNum == 1) {
this.data = resultData
if (resultData.length == 0 || resultData == 0) {
this.empty = true
this.status = 'noMore'
} else if (resultData.length < this.params.pageSize) {
this.status = 'noMore'
} else if (res.total == resultData.length) {
this.status = 'noMore'
} else {
this.status = 'more'
}
} else {
this.data.push(...resultData)
if (resultData.length < this.params.pageSize) {
this.status = 'noMore'
} else {
this.status = 'more'
}
}
if (this.params.pageNum == 1) {
this.firstCallBack && this.firstCallBack()
}
this.loadedCallback && this.loadedCallback()
this.params.pageNum++
this.total = res.total
this.loading = false
uni.stopPullDownRefresh()
})
},
}
},
},
}
export default {
onPullDownRefresh() {
if (this.store.isListAtTop) {
this.store && this.store.reload()
}
},
onReachBottom() {
if (this.store.status != 'noMore') {
this.store.next && this.store.next()
}
},
data() {
return {
store: {},
}
},
methods: {
DataSource(url) {
var me = this
return {
data: [],
copyData: {},
status: 'noMore',
empty: false,
isListAtTop: true,
total: 0,
header: {
'Content-Type': 'application/json;charset=UTF-8',
},
params: {
pageNum: 1,
pageSize: 20,
},
timer: null,
callBack: null,
firstCallBack: null,
loadedCallback: null,
reload() {
if (this.status == 'loading') return
this.data = []
this.empty = false
this.params.pageNum = 1
this.next()
},
search() {
// 节流搜索
clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.reload()
}, 300)
},
next() {
this.status = 'loading'
me.$request({
url: url,
data: this.params,
header: this.header,
method: 'POST',
debounce: false,
}).then((res) => {
console.warn(res)
let resultData = res.data?.list || res.data?.records || res.data || []
this.copyData = res.data
if (this.params.pageNum == 1) {
this.data = resultData
if (resultData.length == 0 || resultData == 0) {
this.empty = true
this.status = 'noMore'
} else if (resultData.length < this.params.pageSize) {
this.status = 'noMore'
} else if (res.total == resultData.length) {
this.status = 'noMore'
} else {
this.status = 'more'
}
} else {
this.data.push(...resultData)
if (resultData.length < this.params.pageSize) {
this.status = 'noMore'
} else {
this.status = 'more'
}
}
if (this.params.pageNum == 1) {
this.firstCallBack && this.firstCallBack()
}
this.loadedCallback && this.loadedCallback()
this.params.pageNum++
this.total = res.total || res.data?.total
this.loading = false
uni.stopPullDownRefresh()
})
},
}
},
},
}

View File

@@ -1,5 +1,5 @@
export const MQTT_IP = 'pqmcn.com:8085/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt
// export const MQTT_IP = '192.168.1.24:8085/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt
// export const MQTT_IP = 'pqmcn.com:8085/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt
export const MQTT_IP = '192.168.1.103:8083/mqtt'//mqtt地址端口, 使用emqx时一定要加mqtt
const MQTT_USERNAME = 't_user'//mqtt用户名
const MQTT_PASSWORD = 'njcnpqs'//密码

View File

@@ -39,7 +39,7 @@ export default (options = {}) => {
},
method: options.method || 'GET',
success: async (res) => {
console.log(res)
// console.log(res)
if (arr.indexOf(options.url) > -1) {
setTimeout(() => {
arr.splice(arr.indexOf(options.url), 1)

View File

@@ -107,39 +107,61 @@ function formatTime(time, option) {
}
// 获取当天日期(年月日)
function getToday() {
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从0开始需+1
const day = String(today.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
const today = new Date()
const year = today.getFullYear()
const month = String(today.getMonth() + 1).padStart(2, '0') // 月份从0开始需+1
const day = String(today.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
// 获取当天日期 往前推30天
function getBeforeDays(days = 30) {
const today = new Date();
// 计算往前推N天的时间戳1天=86400000毫秒
const beforeDate = new Date(today.getTime() - days * 24 * 60 * 60 * 1000);
return formatDate(beforeDate);
const today = new Date()
// 计算往前推N天的时间戳1天=86400000毫秒
const beforeDate = new Date(today.getTime() - days * 24 * 60 * 60 * 1000)
return formatDate(beforeDate)
}
function formatDate(date) {
const year = date.getFullYear();
// 月份从0开始补零到2位
const month = String(date.getMonth() + 1).padStart(2, '0');
// 日期补零到2位
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
const year = date.getFullYear()
// 月份从0开始补零到2位
const month = String(date.getMonth() + 1).padStart(2, '0')
// 日期补零到2位
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
// 获取3个月前的日期
function getThreeMonthsAgo() {
const threeMonthsAgo = new Date();
threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3); // 月份减3
const year = threeMonthsAgo.getFullYear();
const month = String(threeMonthsAgo.getMonth() + 1).padStart(2, '0');
const day = String(threeMonthsAgo.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
const threeMonthsAgo = new Date()
threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3) // 月份减3
const year = threeMonthsAgo.getFullYear()
const month = String(threeMonthsAgo.getMonth() + 1).padStart(2, '0')
const day = String(threeMonthsAgo.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
//获取月最后一天
function getMonthFirstAndLastDay(monthStr) {
// 1. 校验输入格式正则匹配YYYY-MM
const reg = /^\d{4}-\d{2}$/
if (!reg.test(monthStr)) {
throw new Error('输入格式错误,请传入"YYYY-MM"格式的字符串例如2026-03')
}
// 2. 拆分年、月
const [year, month] = monthStr.split('-').map(Number)
// 3. 生成当月第一天直接拼接01
const firstDay = `${year}-${String(month).padStart(2, '0')}-01`
// 4. 生成当月最后一天核心利用Date的特性下个月0号 = 当月最后一天)
// 注意月份是0开始的0=1月11=12月所以month+1是下一个月
const lastDayDate = new Date(year, month, 0) // 下个月0号 = 当月最后一天
const lastDay = `${year}-${String(month).padStart(2, '0')}-${String(lastDayDate.getDate()).padStart(2, '0')}`
return {
firstDay,
lastDay,
}
}
const h5Helper = {
isAndroid: function () {
@@ -167,7 +189,7 @@ const getUserLocation = (call) => {
success: function (address) {
call(address)
},
fail: (err) => {
fail: (err) => {
uni.showModal({
title: '提示',
content: '定位失败,请打开定位权限',
@@ -309,12 +331,14 @@ const getDictData = (key) => {
resolve(dictData.filter((item) => item.code === key)[0]?.children || [])
} else {
// 查询字典
queryDictDataCache().then((res) => {
uni.setStorageSync(cacheKey.dictData, res.data)
resolve(res.data.filter((item) => item.code === key)[0]?.children || [])
}).catch(err=>{
reject(err)
})
queryDictDataCache()
.then((res) => {
uni.setStorageSync(cacheKey.dictData, res.data)
resolve(res.data.filter((item) => item.code === key)[0]?.children || [])
})
.catch((err) => {
reject(err)
})
}
})
}
@@ -333,5 +357,6 @@ export default {
getDictData,
getToday,
getBeforeDays,
getThreeMonthsAgo
getThreeMonthsAgo,
getMonthFirstAndLastDay,
}