From 06ff1dc23ff8aa623554237dea51ae41bf315826 Mon Sep 17 00:00:00 2001 From: 26947 <12@1> Date: Wed, 5 Jun 2024 16:57:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/activityInfo/info.js | 44 +++++ main.js | 8 +- pages/activity/index.vue | 139 ++++++++----- pages/activity/info.vue | 135 ++++++++----- pages/activity/publish.vue | 95 +++++++-- pages/common/activityList/index.vue | 29 ++- pages/common/file/fileUpload/index.vue | 10 +- pages/common/talkState/audit.vue | 87 ++++++++- pages/common/talkState/auditFailure.vue | 102 +++++++++- pages/common/talkState/publish.vue | 8 +- pages/work/index.vue | 12 +- static/logo200.png | Bin 7995 -> 0 bytes utils/icon/icon.js | 20 +- utils/request.js | 2 +- utils/ruoyi.js | 246 ++++++++++++++++++++++++ utils/upload.js | 2 +- 16 files changed, 797 insertions(+), 142 deletions(-) create mode 100644 api/activityInfo/info.js delete mode 100644 static/logo200.png create mode 100644 utils/ruoyi.js diff --git a/api/activityInfo/info.js b/api/activityInfo/info.js new file mode 100644 index 0000000..d1e0d7e --- /dev/null +++ b/api/activityInfo/info.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询活动详情列表 +export function listInfo(query) { + return request({ + url: '/activityInfo/info/list', + method: 'get', + params: query + }) +} + +// 查询活动详情详细 +export function getInfo(id) { + return request({ + url: '/activityInfo/info/' + id, + method: 'get' + }) +} + +// 新增活动详情 +export function addInfo(data) { + return request({ + url: '/activityInfo/info', + method: 'post', + data: data + }) +} + +// 修改活动详情 +export function updateInfo(data) { + return request({ + url: '/activityInfo/info', + method: 'put', + data: data + }) +} + +// 删除活动详情 +export function delInfo(id) { + return request({ + url: '/activityInfo/info/' + id, + method: 'delete' + }) +} diff --git a/main.js b/main.js index 3ff3274..fcae548 100644 --- a/main.js +++ b/main.js @@ -6,10 +6,16 @@ import './permission.js' // permission import iconConfig from './utils/icon/icon.js' // main.js import uviewPlus from 'uview-plus' - +import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi' export function createApp() { const app = createSSRApp(App) app.config.globalProperties.iconConfig = iconConfig + app.config.globalProperties.parseTime = parseTime + app.config.globalProperties.resetForm = resetForm +app.config.globalProperties.handleTree = handleTree +app.config.globalProperties.addDateRange = addDateRange +app.config.globalProperties.selectDictLabel = selectDictLabel +app.config.globalProperties.selectDictLabels = selectDictLabels app.use(uviewPlus) app.use(store) diff --git a/pages/activity/index.vue b/pages/activity/index.vue index b9f5e53..038c2fd 100644 --- a/pages/activity/index.vue +++ b/pages/activity/index.vue @@ -48,10 +48,11 @@ - \ No newline at end of file diff --git a/pages/common/activityList/index.vue b/pages/common/activityList/index.vue index 05f81c7..7216e40 100644 --- a/pages/common/activityList/index.vue +++ b/pages/common/activityList/index.vue @@ -5,7 +5,7 @@ - {{ item.title }} + {{ item.acTitle }} @@ -17,16 +17,16 @@ - 活动地点:{{ item.addrs }} + 活动地点:{{ item.addres }} - + + {{ getDictLabelByValue(item.state).dictLabel }} - + @@ -42,7 +42,7 @@ import { ref, reactive, getCurrentInstance } from 'vue' import { useStore } from 'vuex'; const emit = defineEmits(['scrolltolower']); const { proxy } = getCurrentInstance(); - +const activityState = ref([])//字典 const iconConfig = proxy.iconConfig; const tu21 = iconConfig.tu21; const tu22 = iconConfig.tu22; @@ -60,6 +60,21 @@ const scrolltolower = () => { const toInfo = (item) => { proxy.$tab.navigateTo(`/pages/activity/info?id=${item.id}`); } +const getDictLabelByValue = (state) => { + const dict = activityState.value.find((dict) => dict.dictValue === state); + return dict ? dict : '未知状态'; +}; +onLoad((options) => { + getDicts('activity_state').then(e => { + activityState.value = e.data + console.log(activityState.value); + }) + +}) + +onShow(() => { + console.log('Page onShow') +}) \ No newline at end of file diff --git a/pages/common/talkState/auditFailure.vue b/pages/common/talkState/auditFailure.vue index 91ad993..c646b4b 100644 --- a/pages/common/talkState/auditFailure.vue +++ b/pages/common/talkState/auditFailure.vue @@ -1,6 +1,28 @@ \ No newline at end of file diff --git a/pages/common/talkState/publish.vue b/pages/common/talkState/publish.vue index 1e6d523..05c9713 100644 --- a/pages/common/talkState/publish.vue +++ b/pages/common/talkState/publish.vue @@ -11,10 +11,10 @@ - + - + 待审核 @@ -33,8 +33,8 @@ const emit = defineEmits(['scrolltolower']); const { proxy } = getCurrentInstance(); const iconConfig = proxy.iconConfig; -const sh2x1 = iconConfig.sh2x1; -const sh2x = iconConfig.sh2x; +const cg2x21 = iconConfig.cg2x21; +const cg2x22 = iconConfig.cg2x21; const bgColor = ref(''); bgColor.value = 'rgba(170, 0, 0, 0)' diff --git a/pages/work/index.vue b/pages/work/index.vue index ef3b22d..394f26a 100644 --- a/pages/work/index.vue +++ b/pages/work/index.vue @@ -18,6 +18,8 @@ + + @@ -56,9 +58,17 @@ const fileList1 = ref([]) function clickBannerItem(item) { - if (item === 1) { + if(item === 1){ + proxy.$tab.navigateTo('/pages/common/talkState/audit') + } + if(item === 2){ proxy.$tab.navigateTo('/pages/common/talkState/publish') } + if(item === 3){ + proxy.$tab.navigateTo('/pages/common/talkState/auditFailure') + } + + } function changeSwiper(e) { diff --git a/static/logo200.png b/static/logo200.png deleted file mode 100644 index ffa9988266f7852b40e1475a89bd02aae63976bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7995 zcmV-BAH?8^P)KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5 z07D)V%>y7z1E4U{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;TKay?=?Efr=0CrCg+?U2ep=MGQ-&aVh|*teG3p7&hw_$E z7HylvAkMew;@R3L zQvWdUQq)Ygh9IRO%7KV!_^=R0Uj-bkS~TR-OO6D_B31PLZvECE;rp)ue*qR4QW%1S zMU;_>D7yU;-y((R-swbv?}4QI4n;!z`yv%jx*;)Q8<7y0W$N#3;2+s^qS3rOLy%&T zqy{( { showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => { if (res.confirm) { store.dispatch('LogOut').then(res => { - uni.reLaunch({ url: '/pages/login' }) + uni.reLaunch({ url: '/pages/loginInfo/login' }) }) } }) diff --git a/utils/ruoyi.js b/utils/ruoyi.js new file mode 100644 index 0000000..4efca08 --- /dev/null +++ b/utils/ruoyi.js @@ -0,0 +1,246 @@ + + +/** + * 通用js方法封装处理 + * Copyright (c) 2019 ruoyi + */ + +// 日期格式化 +export function parseTime(time, pattern) { + if (arguments.length === 0 || !time) { + return null + } + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if (typeof time === 'object') { + date = time + } else { + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } else if (typeof time === 'string') { + time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm), ''); + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } + date = new Date(time) + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + } + const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { + let value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] } + if (result.length > 0 && value < 10) { + value = '0' + value + } + return value || 0 + }) + return time_str +} + +// 表单重置 +export function resetForm(refName) { + if (this.$refs[refName]) { + this.$refs[refName].resetFields(); + } +} + +// 添加日期范围 +export function addDateRange(params, dateRange, propName) { + let search = params; + search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}; + dateRange = Array.isArray(dateRange) ? dateRange : []; + if (typeof (propName) === 'undefined') { + search.params['beginTime'] = dateRange[0]; + search.params['endTime'] = dateRange[1]; + } else { + search.params['begin' + propName] = dateRange[0]; + search.params['end' + propName] = dateRange[1]; + } + return search; +} + +// 回显数据字典 +export function selectDictLabel(datas, value) { + if (value === undefined) { + return ""; + } + var actions = []; + Object.keys(datas).some((key) => { + if (datas[key].value == ('' + value)) { + actions.push(datas[key].label); + return true; + } + }) + if (actions.length === 0) { + actions.push(value); + } + return actions.join(''); +} + +// 回显数据字典(字符串数组) +export function selectDictLabels(datas, value, separator) { + if (value === undefined || value.length ===0) { + return ""; + } + if (Array.isArray(value)) { + value = value.join(","); + } + var actions = []; + var currentSeparator = undefined === separator ? "," : separator; + var temp = value.split(currentSeparator); + Object.keys(value.split(currentSeparator)).some((val) => { + var match = false; + Object.keys(datas).some((key) => { + if (datas[key].value == ('' + temp[val])) { + actions.push(datas[key].label + currentSeparator); + match = true; + } + }) + if (!match) { + actions.push(temp[val] + currentSeparator); + } + }) + return actions.join('').substring(0, actions.join('').length - 1); +} + +// 字符串格式化(%s ) +export function sprintf(str) { + var args = arguments, flag = true, i = 1; + str = str.replace(/%s/g, function () { + var arg = args[i++]; + if (typeof arg === 'undefined') { + flag = false; + return ''; + } + return arg; + }); + return flag ? str : ''; +} + +// 转换字符串,undefined,null等转化为"" +export function parseStrEmpty(str) { + if (!str || str == "undefined" || str == "null") { + return ""; + } + return str; +} + +// 数据合并 +export function mergeRecursive(source, target) { + for (var p in target) { + try { + if (target[p].constructor == Object) { + source[p] = mergeRecursive(source[p], target[p]); + } else { + source[p] = target[p]; + } + } catch (e) { + source[p] = target[p]; + } + } + return source; +}; + +/** + * 构造树型结构数据 + * @param {*} data 数据源 + * @param {*} id id字段 默认 'id' + * @param {*} parentId 父节点字段 默认 'parentId' + * @param {*} children 孩子节点字段 默认 'children' + */ +export function handleTree(data, id, parentId, children) { + let config = { + id: id || 'id', + parentId: parentId || 'parentId', + childrenList: children || 'children' + }; + + var childrenListMap = {}; + var nodeIds = {}; + var tree = []; + + for (let d of data) { + let parentId = d[config.parentId]; + if (childrenListMap[parentId] == null) { + childrenListMap[parentId] = []; + } + nodeIds[d[config.id]] = d; + childrenListMap[parentId].push(d); + } + + for (let d of data) { + let parentId = d[config.parentId]; + if (nodeIds[parentId] == null) { + tree.push(d); + } + } + + for (let t of tree) { + adaptToChildrenList(t); + } + + function adaptToChildrenList(o) { + if (childrenListMap[o[config.id]] !== null) { + o[config.childrenList] = childrenListMap[o[config.id]]; + } + if (o[config.childrenList]) { + for (let c of o[config.childrenList]) { + adaptToChildrenList(c); + } + } + } + return tree; +} + +/** +* 参数处理 +* @param {*} params 参数 +*/ +export function tansParams(params) { + let result = '' + for (const propName of Object.keys(params)) { + const value = params[propName]; + var part = encodeURIComponent(propName) + "="; + if (value !== null && value !== "" && typeof (value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') { + let params = propName + '[' + key + ']'; + var subPart = encodeURIComponent(params) + "="; + result += subPart + encodeURIComponent(value[key]) + "&"; + } + } + } else { + result += part + encodeURIComponent(value) + "&"; + } + } + } + return result +} + + +// 返回项目路径 +export function getNormalPath(p) { + if (p.length === 0 || !p || p == 'undefined') { + return p + }; + let res = p.replace('//', '/') + if (res[res.length - 1] === '/') { + return res.slice(0, res.length - 1) + } + return res; +} + +// 验证是否为blob格式 +export function blobValidate(data) { + return data.type !== 'application/json' +} diff --git a/utils/upload.js b/utils/upload.js index 09f4a2c..04c2423 100644 --- a/utils/upload.js +++ b/utils/upload.js @@ -38,7 +38,7 @@ export default function upload(config) { showConfirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then(res => { if (res.confirm) { store.dispatch('LogOut').then(res => { - uni.reLaunch({ url: '/pages/login/login' }) + uni.reLaunch({ url: '/pages/loginInfo/login' }) }) } })