feat: 计划列表

This commit is contained in:
yangzhe 2025-04-09 15:05:52 +08:00
parent 02e8848740
commit 9b8734a39a
3 changed files with 333 additions and 280 deletions

View File

@ -43,7 +43,7 @@
</view>
<view class="planList" :class="{ activeList: activeTab === 'incomplete' }">
<view class="plan-item">
<!-- <view class="plan-item">
<view class="plan-header">
<image
src="/static/images/icon-date.png"
@ -62,24 +62,24 @@
北大门右侧操场跑道/南广场升旗台/A区第二食堂3楼
</view>
</view>
</view>
<view class="plan-item">
</view> -->
<view class="plan-item" v-for="(item, index) in planList" :key="index">
<view class="plan-header">
<image
src="/static/images/icon-date.png"
mode="scaleToFill"
style="width: 40rpx; height: 40rpx"
/>
<view class="date">05-21</view>
<view>1天前</view>
<view class="date">{{ item.date }}</view>
<view>{{ item.date ? getDateDiff(item.date) : "-" }}</view>
</view>
<view class="plan-content">
<view class="plan-content-top">
<view class="place">校门A区教学楼</view>
<view class="place">{{ item.name }}</view>
<u-tag text="9:00~12:00" type="info" border-color="transparent" />
</view>
<view class="plan-content-main">
北大门右侧操场跑道/南广场升旗台/A区第二食堂3楼
{{ item.areas }}
</view>
</view>
</view>
@ -97,6 +97,9 @@
<script>
import { GetPlanList } from "@/api/apiList";
import { GetNowTime } from "@/utils/common";
import { getDateDiff } from "@/utils/utils";
export default {
data() {
return {
@ -105,11 +108,25 @@ export default {
maxDate: "2049-12-31",
showCalendar: false,
dateRange: "",
//
params: {
// '0 1 2'
"Item1.IsCompleted": 0,
dateBegin: GetNowTime(new Date()),
dateEnd: GetNowTime(new Date()),
},
//
planList: [],
};
},
created() {},
created() {
this.getPlanList();
},
methods: {
getDateDiff,
toggleDate() {
this.showCalendar = !this.showCalendar;
},
@ -118,9 +135,18 @@ export default {
},
changeDate(e) {
console.log("333", e);
this.params.dateBegin = e.startDate;
this.params.dateEnd = e.endDate;
this.getPlanList();
},
this.dateRange = e;
//
async getPlanList() {
const res = await GetPlanList(this.params);
if (res.succeed) {
this.planList = res.data;
}
},
},
};
@ -128,7 +154,8 @@ export default {
<style lang="scss" scoped>
.content {
height: 100vh;
// height: 100vh;
padding-bottom: 100rpx;
background: #f7f8fc;
.selectTab {
display: flex;

View File

@ -8,7 +8,7 @@ const manager = new RequestManager()
// 先写死调接口
uni.setStorageSync('token', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiIwOGRkNzFiZC01N2MxLTQ1YmMtODBiYS0xMjkzYjU4MTViMmEiLCJ1bmlxdWVfbmFtZSI6IuS_nea0gSIsInJvbGUiOiJVc2VyIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiIxODE3NDAxMDU2MiIsImdyb3Vwc2lkIjoiNGIyZDk2NjItYTc2OC0wOGYyLWEwYzgtNzYyYjhjNzZkYTJhIiwibmJmIjoxNzQ0MTc1MjA2LCJleHAiOjE3NDQxNzg4MDYsImlhdCI6MTc0NDE3NTIwNn0.1qDnEAJH-bJlEr1wbwjTfqLY9xAyJKzf6bmLP6svUNo')
uni.setStorageSync('token', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiIwOGRkNzFiZC01N2MxLTQ1YmMtODBiYS0xMjkzYjU4MTViMmEiLCJ1bmlxdWVfbmFtZSI6IuS_nea0gSIsInJvbGUiOiJVc2VyIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiIxODE3NDAxMDU2MiIsImdyb3Vwc2lkIjoiNGIyZDk2NjItYTc2OC0wOGYyLWEwYzgtNzYyYjhjNzZkYTJhIiwibmJmIjoxNzQ0MTgyMTM4LCJleHAiOjE3NDQxODU3MzgsImlhdCI6MTc0NDE4MjEzOH0.QQNQNiKe14L-anWPNAKcvLXtzy-eo1FL9hhTsbLKAxg')
const baseRequest = async (url, method, data = {}, loading = true) =>{

View File

@ -4,14 +4,14 @@
* @param {String} icon icon图片
* @param {Number} duration 提示时间
*/
export function toast(title, icon = 'none', duration = 1500) {
if(title) {
uni.showToast({
title,
icon,
duration
})
}
export function toast(title, icon = "none", duration = 1500) {
if (title) {
uni.showToast({
title,
icon,
duration,
});
}
}
/**
@ -20,91 +20,85 @@ export function toast(title, icon = 'none', duration = 1500) {
* @description navigateTo跳转
*/
export function Jump(url) {
uni.navigateTo({
url: url
})
uni.navigateTo({
url: url,
});
}
/**
* 提示信息
* **/
export function showModal(title, msg, showCancel) {
uni.showModal({
title: title,
content: msg,
showCancel: showCancel,
success: function(res) {
}
})
uni.showModal({
title: title,
content: msg,
showCancel: showCancel,
success: function (res) {},
});
}
export function showLoading(content) {
uni.showLoading({
title: content
})
uni.showLoading({
title: content,
});
}
/**
* 隐藏loading
* **/
export function hideLoading() {
uni.hideLoading()
uni.hideLoading();
}
/***
* 获取时间戳
*/
export function getTimStamp() {
var timestamp = Date.parse(new Date());
timestamp = timestamp / 1000;
return timestamp;
var timestamp = Date.parse(new Date());
timestamp = timestamp / 1000;
return timestamp;
}
/***
* 生成随机数
*/
export function getNonce() {
var t = '';
for (var i = 0; i < 12; i++) {
t += Math.floor(Math.random() * 10);
}
return t;
var t = "";
for (var i = 0; i < 12; i++) {
t += Math.floor(Math.random() * 10);
}
return t;
}
/**
* 获取32位随机数
* ***/
export function getnoncestr() {
let len = len || 32;
var $chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
var maxPos = $chars.length;
var pwd = '';
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
let len = len || 32;
var $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
var maxPos = $chars.length;
var pwd = "";
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
/**
* 解析url中的参数
*/
export function UrlParamHash(url) {
var params = {},
h;
var hash = url.slice(url.indexOf("?") + 1).split("&");
for (var i = 0; i < hash.length; i++) {
h = hash[i].split("=");
if (h.length > 1) {
params[h[0]] = h[1];
} else {
params[h[0]] = "";
}
}
return params;
var params = {},
h;
var hash = url.slice(url.indexOf("?") + 1).split("&");
for (var i = 0; i < hash.length; i++) {
h = hash[i].split("=");
if (h.length > 1) {
params[h[0]] = h[1];
} else {
params[h[0]] = "";
}
}
return params;
}
/**
* 一键复制 uni.setClipboardData
* 用法
@ -112,19 +106,19 @@ export function UrlParamHash(url) {
* 2. 利用async await
* 3. await setClipboardData(需要复制的文本)
*/
const setClipboardData = (text) =>{
return new Promise((resolve,reject)=>{
uni.setClipboardData({
data: text,
success: (res) => {
resolve(res)
},
fail: (err) => {
reject(err)
}
})
})
}
const setClipboardData = (text) => {
return new Promise((resolve, reject) => {
uni.setClipboardData({
data: text,
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
},
});
});
};
/**
* 获取系统剪贴板内容 uni.getClipboardData
@ -133,18 +127,18 @@ const setClipboardData = (text) =>{
* 2. 利用async await来接收获取到的数据
* 3. await getClipboardData()
*/
const getClipboardData = () =>{
return new Promise((resolve,reject)=>{
uni.getClipboardData({
success: (res) => {
resolve(res)
},
fail: (err) => {
reject(err)
}
})
})
}
const getClipboardData = () => {
return new Promise((resolve, reject) => {
uni.getClipboardData({
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
},
});
});
};
/**
* 拨打电话 uni.makePhoneCall()
@ -152,12 +146,11 @@ const getClipboardData = () =>{
* 1. import {getBatteryInfo} from '该文件的地址'
* 2. 直接makePhoneCall(拨打的电话号码)
*/
const makePhoneCall = (phone) =>{
uni.makePhoneCall({
phoneNumber:phone
})
}
const makePhoneCall = (phone) => {
uni.makePhoneCall({
phoneNumber: phone,
});
};
/**
* 设置缓存
@ -165,7 +158,7 @@ const makePhoneCall = (phone) =>{
* @param {String} data
*/
export function setStorageSync(key, data) {
uni.setStorageSync(key, data)
uni.setStorageSync(key, data);
}
/**
@ -173,7 +166,7 @@ export function setStorageSync(key, data) {
* @param {String} key 键名
*/
export function getStorageSync(key) {
return uni.getStorageSync(key)
return uni.getStorageSync(key);
}
/**
@ -181,7 +174,7 @@ export function getStorageSync(key) {
* @param {String} key 键名
*/
export function removeStorageSync(key) {
return uni.removeStorageSync(key)
return uni.removeStorageSync(key);
}
/**
@ -189,43 +182,46 @@ export function removeStorageSync(key) {
* @param {String} key 键名
*/
export function clearStorageSync() {
return uni.clearStorageSync()
return uni.clearStorageSync();
}
/**
* 页面跳转
* @param {'navigateTo' | 'redirectTo' | 'reLaunch' | 'switchTab' | 'navigateBack' | number } url 转跳路径
* @param {String} params 跳转时携带的参数
* @param {String} type 转跳方式
**/
export function useRouter(url, params = {}, type = 'navigateTo') {
try {
if (Object.keys(params).length) url = `${url}?data=${encodeURIComponent(JSON.stringify(params))}`
if (type === 'navigateBack') {
uni[type]({ delta: url })
} else {
uni[type]({ url })
}
} catch (error) {
console.error(error)
export function useRouter(url, params = {}, type = "navigateTo") {
try {
if (Object.keys(params).length)
url = `${url}?data=${encodeURIComponent(JSON.stringify(params))}`;
if (type === "navigateBack") {
uni[type]({ delta: url });
} else {
uni[type]({ url });
}
} catch (error) {
console.error(error);
}
}
/**
* 预览图片
* @param {Array} urls 图片链接
*/
export function previewImage(urls, itemList = ['发送给朋友', '保存图片', '收藏']) {
uni.previewImage({
urls,
longPressActions: {
itemList,
fail: function (error) {
console.error(error,'===previewImage')
}
}
})
export function previewImage(
urls,
itemList = ["发送给朋友", "保存图片", "收藏"]
) {
uni.previewImage({
urls,
longPressActions: {
itemList,
fail: function (error) {
console.error(error, "===previewImage");
},
},
});
}
/**
@ -233,90 +229,93 @@ export function previewImage(urls, itemList = ['发送给朋友', '保存图片'
* @param {String} filePath 图片临时路径
**/
export function saveImage(filePath) {
if (!filePath) return false
uni.saveImageToPhotosAlbum({
filePath,
success: (res) => {
toast('图片保存成功', 'success')
},
fail: (err) => {
if (err.errMsg === 'saveImageToPhotosAlbum:fail:auth denied' || err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
uni.showModal({
title: '提示',
content: '需要您授权保存相册',
if (!filePath) return false;
uni.saveImageToPhotosAlbum({
filePath,
success: (res) => {
toast("图片保存成功", "success");
},
fail: (err) => {
if (
err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" ||
err.errMsg === "saveImageToPhotosAlbum:fail auth deny"
) {
uni.showModal({
title: "提示",
content: "需要您授权保存相册",
showCancel: false,
success: (modalSuccess) => {
uni.openSetting({
success(settingdata) {
if (settingdata.authSetting["scope.writePhotosAlbum"]) {
uni.showModal({
title: "提示",
content: "获取权限成功,再次点击图片即可保存",
showCancel: false,
success: (modalSuccess) => {
uni.openSetting({
success(settingdata) {
if (settingdata.authSetting['scope.writePhotosAlbum']) {
uni.showModal({
title: '提示',
content: '获取权限成功,再次点击图片即可保存',
showCancel: false
})
} else {
uni.showModal({
title: '提示',
content: '获取权限失败,将无法保存到相册哦~',
showCancel: false
})
}
},
fail(failData) {
console.log('failData', failData)
}
})
}
})
}
}
})
});
} else {
uni.showModal({
title: "提示",
content: "获取权限失败,将无法保存到相册哦~",
showCancel: false,
});
}
},
fail(failData) {
console.log("failData", failData);
},
});
},
});
}
},
});
}
/**
* 深拷贝
* @param {Object} data
**/
export const clone = (data) => JSON.parse(JSON.stringify(data))
/**
export const clone = (data) => JSON.parse(JSON.stringify(data));
/**
* 获取平台名称
* @return {string} 平台名称
*/
export function getPlatform() {
let platform;
switch (process.env.VUE_APP_PLATFORM) {
case 'app':
case 'app-plus':
let n = uni.getSystemInfoSync().platform.toLowerCase();
if (n === 'ios') {
platform = 'ios';
} else if (n === 'android') {
platform = 'android';
} else {
platform = 'app';
}
break;
case 'mp-weixin':
platform = 'wx';
break;
case 'mp-alipay':
platform = 'alipay';
break;
case 'mp-baidu':
platform = 'baidu';
break;
case 'mp-qq':
platform = 'qq';
break;
case 'mp-toutiao':
platform = 'toutiao';
break;
case 'quickapp-webview':
platform = 'kuai';
break;
}
let platform;
switch (process.env.VUE_APP_PLATFORM) {
case "app":
case "app-plus":
let n = uni.getSystemInfoSync().platform.toLowerCase();
if (n === "ios") {
platform = "ios";
} else if (n === "android") {
platform = "android";
} else {
platform = "app";
}
break;
case "mp-weixin":
platform = "wx";
break;
case "mp-alipay":
platform = "alipay";
break;
case "mp-baidu":
platform = "baidu";
break;
case "mp-qq":
platform = "qq";
break;
case "mp-toutiao":
platform = "toutiao";
break;
case "quickapp-webview":
platform = "kuai";
break;
}
return platform;
return platform;
}
/**
@ -324,15 +323,17 @@ export function getPlatform() {
* @param {Array} array 数值
* @retrun {Array} 数值
*/
export function arrayShuffle(array) {
let i = array.length, t, j;
while (i) {
j = Math.floor(Math.random() * i--);
t = array[i];
array[i] = array[j];
array[j] = t;
}
return array;
export function arrayShuffle(array) {
let i = array.length,
t,
j;
while (i) {
j = Math.floor(Math.random() * i--);
t = array[i];
array[i] = array[j];
array[j] = t;
}
return array;
}
/**
@ -341,23 +342,23 @@ export function arrayShuffle(array) {
* @param {string} format 返回的日期格式
* @retrun {string} 日期
*/
export function dateFormat(date, format = 'YYYY-MM-DD HH:mm:ss') {
const config = {
YYYY: date.getFullYear(),
MM: date.getMonth()+1,
DD: date.getDate(),
HH: date.getHours(),
mm: date.getMinutes(),
ss: date.getSeconds(),
}
for(const key in config){
let value = config[key];
if (value < 10) {
value = '0' + value;
}
format = format.replace(key, value)
}
return format
export function dateFormat(date, format = "YYYY-MM-DD HH:mm:ss") {
const config = {
YYYY: date.getFullYear(),
MM: date.getMonth() + 1,
DD: date.getDate(),
HH: date.getHours(),
mm: date.getMinutes(),
ss: date.getSeconds(),
};
for (const key in config) {
let value = config[key];
if (value < 10) {
value = "0" + value;
}
format = format.replace(key, value);
}
return format;
}
/**
@ -366,28 +367,29 @@ export function dateFormat(date, format = 'YYYY-MM-DD HH:mm:ss') {
* @param {Function} cb 回调
*/
export function base64ToSrc(base64data, cb) {
const FILE_BASE_NAME = 'tmp_base64src';
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || [];
if (!format) {
return (new Error('格式错误'));
}
const FILE_BASE_NAME = "tmp_base64src";
const [, format, bodyData] =
/data:image\/(\w+);base64,(.*)/.exec(base64data) || [];
if (!format) {
return new Error("格式错误");
}
// #ifdef MP-WEIXIN
let filePath = `${wx.env.USER_DATA_PATH}/${FILE_BASE_NAME}.${format}`;
// #endif
// #ifdef MP-QQ
let filePath = `${qq.env.USER_DATA_PATH}/${FILE_BASE_NAME}.${format}`;
// #endif
// #ifdef MP-WEIXIN
let filePath = `${wx.env.USER_DATA_PATH}/${FILE_BASE_NAME}.${format}`;
// #endif
// #ifdef MP-QQ
let filePath = `${qq.env.USER_DATA_PATH}/${FILE_BASE_NAME}.${format}`;
// #endif
const buffer = uni.base64ToArrayBuffer(bodyData);
uni.getFileSystemManager().writeFile({
filePath,
data: buffer,
encoding: 'binary',
success() {
cb && cb(filePath);
}
});
const buffer = uni.base64ToArrayBuffer(bodyData);
uni.getFileSystemManager().writeFile({
filePath,
data: buffer,
encoding: "binary",
success() {
cb && cb(filePath);
},
});
}
/**
@ -396,7 +398,7 @@ export function base64ToSrc(base64data, cb) {
* @param {string}
*/
export function encodeBase64(str) {
return new Buffer.from(str).toString('base64');
return new Buffer.from(str).toString("base64");
}
/**
@ -405,8 +407,8 @@ export function encodeBase64(str) {
* @param {string}
*/
export function decodeBase64(str) {
const commonContent = str.replace(/\s/g, '+');
return new Buffer.from(commonContent, 'base64').toString();
const commonContent = str.replace(/\s/g, "+");
return new Buffer.from(commonContent, "base64").toString();
}
/**
@ -415,12 +417,12 @@ export function decodeBase64(str) {
* @param {Boolean} loop 是否循环
*/
export function playSound(src, loop = false) {
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.loop = loop;
innerAudioContext.src = src;
innerAudioContext.onPlay(() => {});
innerAudioContext.onError((res) => {});
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.loop = loop;
innerAudioContext.src = src;
innerAudioContext.onPlay(() => {});
innerAudioContext.onError((res) => {});
}
/**
@ -428,8 +430,8 @@ export function playSound(src, loop = false) {
* @param {string} prefix 订单前缀
* @param {string} 订单ID
*/
export function createOrderSn(prefix = '') {
return `${prefix}${this.randomString(10).toUpperCase()}${+new Date()}`;
export function createOrderSn(prefix = "") {
return `${prefix}${this.randomString(10).toUpperCase()}${+new Date()}`;
}
/**
@ -438,38 +440,62 @@ export function createOrderSn(prefix = '') {
* @return {Promise} base64
*/
export function imageToBase64(src) {
return new Promise((resolve, reject) => {
uni.getImageInfo({
src,
success: image => {
console.log(image);
uni.getFileSystemManager().readFile({
filePath: image.path,
encoding: 'base64',
success: e => {
return resolve(`data:image/jpeg;base64,${e.data}`);
},
fail: e => {
return reject(null);
}
})
}
});
})
return new Promise((resolve, reject) => {
uni.getImageInfo({
src,
success: (image) => {
console.log(image);
uni.getFileSystemManager().readFile({
filePath: image.path,
encoding: "base64",
success: (e) => {
return resolve(`data:image/jpeg;base64,${e.data}`);
},
fail: (e) => {
return reject(null);
},
});
},
});
});
}
/**
* 随机范围内的数字
* @param {number} start 起始数字
* @param {number} end 起始数字
* @return {number || null} 随机数
*/
export function randomByRange(start, end){
if (typeof start === 'number' && typeof end === 'number') {
return start + Math.floor(Math.random() * (end - start));
} else {
console.error('参数必须为数字');
return null;
}
export function randomByRange(start, end) {
if (typeof start === "number" && typeof end === "number") {
return start + Math.floor(Math.random() * (end - start));
} else {
console.error("参数必须为数字");
return null;
}
}
/**
* 判断所给时间和今天的差值
* @param {string} date 所给时间
* @returns {string} 差值
*/
export function getDateDiff(date) {
const inputDate = new Date(date.replace(/\//g, "-"));
const today = new Date();
today.setHours(0, 0, 0, 0);
inputDate.setHours(0, 0, 0, 0);
const timeDiff = inputDate - today;
const oneDay = 24 * 60 * 60 * 1000;
const daysDiff = Math.floor(timeDiff / oneDay);
if (daysDiff === 0) {
return "今天";
} else if (daysDiff > 0) {
return `${daysDiff}天后`;
} else {
return `${Math.abs(daysDiff)}天前`;
}
}