调整文件发布及在进度页面显示问题

wyd_branch
Your Name 3 years ago
parent ea67192ba8
commit 5087a09c70

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,135 @@
// const app = getApp()
Page({
data: {
realName: '',
number: '',
isDisabled: true //表示页面加载完成时disabled为禁用状态
},
onLoad: function(options) {
let number = options.number
let realName = options.realName
this.setData({
number,
realName
})
},
save: function() {
let realName = this.data.realName;
let number=this.data.number
let skey = wx.getStorageSync('skey')
wx.request({
url: 'http://192.168.58.210:81/save',
method: 'GET',
data: {
skey:skey,
number:number,
realName:realName
},
success: function(res :any) {
if (res.data.error == true) {
wx.showToast({
title: res.data.message,
icon: 'none',
duration: 2000
})
} else {
wx.showToast({
title: res.data.message,
icon: 'success',
duration: 5000
})
wx.removeStorageSync('info')
wx.navigateBack({
delta: 2
})
}
}
})
},
inputRealName: function(e :any) {
var realName = e.detail.value
this.setData({
realName
})
console.log(realName)
if (realName !== '') {
this.setData({
isDisabled: false
})
} else {
this.setData({
isDisabled: true
})
}
},
inputNumber: function(e :any) {
var number = e.detail.value
this.setData({
number
})
// console.log()
if (number !== '') {
this.setData({
isDisabled: false
})
} else {
this.setData({
isDisabled: true
})
}
},
onReady: function() {
},
/**
* --
*/
onShow: function() {
},
/**
* --
*/
onHide: function() {
},
/**
* --
*/
onUnload: function() {
},
/**
* --
*/
onPullDownRefresh: function() {
},
/**
*
*/
onReachBottom: function() {
},
/**
*
*/
onShareAppMessage: function() {
}
})

@ -0,0 +1,15 @@
<!--pages/bd/bd.wxml-->
<view>
<view class="btn-area" id="buttonContainer">
<view class='binding-item'>
<view>姓名</view>
<input type="text" placeholder="请输入您的真实姓名" value="{{realName}}" bindinput="inputRealName"></input>
</view>
<view class='binding-item'>
<view>学号</view>
<input type="number" placeholder="请输入您的学号" value="{{number}}" bindinput="inputNumber"></input>
</view>
<button type="submit" bindtap="save" class="save" disabled='{{isDisabled}}'>提交</button>
</view>
</view>

@ -0,0 +1,30 @@
/* pages/bd/bd.wxss */
.binding-item {
margin: 40rpx;
padding-top: 20rpx;
padding-bottom: 40rpx;
display: flex;
font-size: 32rpx;
/* 在模拟器为iphone 6 时1px=2rpx 这里设置32rpx即16px */
border-bottom: 1rpx solid #dedede;
}
.binding-item input {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
padding-left: 20rpx;
}
.binding-btn{
background-color:#19be6b;
padding: 28rpx;
margin: 40rpx;
color: pink;
text-align: center;
}
.button{
margin-top: 30rpx;
margin-bottom: 30rpx;
}

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,24 @@
// index.ts
// 获取应用实例
const app = getApp<IAppOption>()
Page({
data: {
taskList: [],
motto: 'Hello World',
},
onShow() {
// let list = [
// { id: 1, title: "任务一", startTime: "2022-10-01", endTime: "1020-20-22", end: "40" },
// { id: 2, title: "任务二", startTime: "2022-10-01", endTime: "1020-20-22", end: "40" },
// { id: 3, title: "任务三", startTime: "2022-10-01", endTime: "1020-20-22", end: "40" }
// ]
this.setData({
taskList: wx.getStorageSync("taskList") || []
});
},
onLoad() {
this.setData({
taskList: wx.getStorageSync("taskList") || []
});
},
})

@ -0,0 +1,33 @@
<view class="wrip-view">
<!-- 轮播区域 -->
<view>
<view class="swip">
<text class="swip-text">公告栏</text>
<swiper indicator-dots="{{true}}" autoplay="{{true}}" interval="{{2000}}">
<block wx:for="{{3}}" wx:key="*this">
<swiper-item>
<view class="swiper-item">
<image src="/static/index/spwr01.jpg"></image>
</view>
</swiper-item>
</block>
</swiper>
</view>
</view>
<!-- 任务列表 -->
<view class="task" wx:if="{{taskList.length!=0}}">
<block wx:for="{{taskList}}" wx:key="id">
<view class="task-item">
<view class="task-item-title"> {{item.title}}: </view>
<view class="task-item-text">
<text> 开始时间:{{item.startTime}} </text>
<text> 截止时间:{{item.endTime}} </text>
</view>
</view>
</block>
</view>
<view class="error" wx:else>
暂无数据
</view>
</view>

@ -0,0 +1,43 @@
.wrip-view {
height: 100%;
}
.swip {
background: rgb(243, 243, 243);
position: relative;
}
.swip-text {
position: absolute;
width: 100%;
z-index: 100;
text-align: center;
font-size: 20px;
color: rgb(95, 95, 95);
}
.task {
padding: 8px;
}
.task-item {
padding: 8px 4px 10px 4px;
margin: 10px 0;
border-radius: 10px;
background-color: #fff;
}
.task-item-title {
font-family: "楷体";
font-size: 18px;
margin-bottom: 6px;
}
.task-item-text {
font-size: 10px;
color: rgb(146, 146, 146);
}
.error{
text-align: center;
padding: 20px;
}

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "任务信息列表"
}

@ -0,0 +1,137 @@
// pages/list/list.js
Page({
/**
*
*/
data: {
list:[]
},
/**
* --
*/
onLoad: function () {
},
/**
* --
*/
onReady: function () {
},
/**
* --
* Show
*/
onShow: function () {
//这里的this是指窗口而在request中this是指onShow方法(因为是页面调用onShow,onShow调用request),所以要先定义
var that = this;
wx.request({
//后端接口提供的url
url: 'http://localhost:8080/task/taskList',
method:'GET',
//需要传入的参数
data:{},
success:function(res :any){
var list = res.data.data;
if(list == null){
//如果获取数据失败,提示使用者
var toastText = '获取数据失败' + res.data.msg;
wx.showToast({
title: toastText,
//显示时长为2s
duration:2000
})
}else{
that.setData({
list:list
})
}
}
})
},
/**
* --
*/
onHide: function () {
},
/**
* --
*/
onUnload: function () {
},
/**
* --
*/
onPullDownRefresh: function () {
},
/**
*
*/
onReachBottom: function () {
},
/**
*
*/
onShareAppMessage: function () {
},
addTask: function(){
wx.navigateTo({
url: '../operation/operation',
})
},
//e表示响应的控件
delTask: function(e :any){
var that = this;
//相当于confirm窗口
wx.showModal({
title: '提示',
//这里的变量名需要与响应控件的data-后面的变量名相同
content: '确认要删除['+e.target.dataset.name+']吗?',
success:function(sm){
if(sm.confirm){
wx.request({
url: 'http://localhost:8080/task/delete',
data: {'id':e.target.dataset.id},
header: {
//默认是 'content-type': 'application/json'要传post的参数必须写成这样要传delete参数则为null
"content-type": "application/x-www-form-urlencoded"
},
method: 'DELETE',
success: function(res:any) {
var result = res.data.success;
var toastText='删除成功';
if(result == true){
that.data.list.splice(e.target.dataset.index,1);
that.setData({
list:that.data.list
});
}else{
toastText = '删除失败';
}
wx.showToast({
title: toastText,
duration:2000
})
},
})
}
}
})
}
})

@ -0,0 +1,27 @@
<!--pages/list/list.wxml-->
<view class='container'>
<view class='widget'>
<text class='column'>ID</text>
<text class='column'>名字</text>
<text class='column'>信息</text>
<text class='column'>时间</text>
<text class='link-column'>操作</text>
</view>
<scroll-view scroll-y="true">
<!--遍历list变量名要和js中的名字相同且item是定值不可修改 -->
<block class='widget' wx:for="{{list}}">
<view class='widget'>
<text class='column'>{{item.id}}</text>
<text class='column'>{{item.name}}</text>
<text class='column'>{{item.property}}</text>
<text class='column'>{{item.deadtime}}</text>
<view class='link-column'>
<navigator class='link' url='../operation/operation?id={{item.id}}'>编辑</navigator>|
<text class='link' bindtap='delTask' data-id='{{item.id}}' data-index='{{index}}' data-name='{{item.name}}'>删除
</text>
</view>
</view>
</block>
</scroll-view>
<button type='primary' bindtap='addTask'>添加任务信息</button>
</view>

@ -0,0 +1,37 @@
/* pages/list/list.wxss */
.container{
height: 100%;
display: table;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding-top: 10rpx;
padding-bottom: 10rpx;
text-align: center;
}
.widget{
position: relative;
margin-top: 5rpx;
margin-bottom: 5rpx;
padding-top: 10rpx;
padding-bottom: 10rpx;
padding-left: 40rpx;
padding-right: 40rpx;
border: #ddd 1px solid;
}
.column{
width: 4rem;
display: table-cell;
}
.link-column{
width: 6rem;
display: table-cell;
}
.link{
color: blue;
display: inline-table;
}

@ -0,0 +1,99 @@
// logs.ts
// const util = require('../../utils/util.js')
import { formatTime } from '../../utils/util'
Page({
data: {
logs: [],
taskList: [],
taskFlag: false,
releaseFlag: false,
from: {
taskName: "",
end: ""
}
},
inputFrom(event: any) {
if (event.currentTarget.dataset.gater == "from.end") {
let num = event.detail.value;
if (num.length == 4) num += "-";
if (num.length == 7) num += "-";
this.setData({ [`from.end`]: num })
} else if(event.currentTarget.dataset.gater == "from.taskName"){
this.setData({
[`${event.currentTarget.dataset.gater}`]: event.detail.value
})
}else{
this.setData({
[`${event.currentTarget.dataset.gater}`]: event.detail.value
})
}
},
addSelect() {
const { taskName, end } = this.data.from;
if (end.length != 10) return;
if (!taskName || !end) {
wx.showToast({
title: "请填写任务名称和任务进度",
icon: 'error',
});
return;
}
const list = wx.getStorageSync("taskList") || [];
const index = list.findIndex((item: any) => item.title == taskName);
if (index >= 0) {
wx.showToast({
title: "任务名称重复",
icon: 'error',
});
return;
}
const data = {
id: list.length + 1,
title: taskName,
startTime: formatTime(new Date), endTime: end, end: '40',
}
list.push(data)
wx.setStorageSync("taskList", list);
wx.showToast({
title: "发布成功",
icon: 'success',
});
this.setData({
taskList: wx.getStorageSync("taskList") || []
});
},
atReleaseFlag() {
const user = wx.getStorageSync("userInfo");
console.log(user)
if (user!=null) {
wx.showToast({
title: "请先登录",
icon: 'error',
});
return;
}
this.setData({ releaseFlag: !this.data.releaseFlag })
},
atTaskFlag() {
this.setData({ taskFlag: !this.data.taskFlag })
},
onShow() {
this.setData({
taskList: wx.getStorageSync("taskList") || []
});
},
onLoad() {
this.setData({
taskList: wx.getStorageSync("taskList") || []
});
// this.setData({
// logs: (wx.getStorageSync('logs') || []).map((log: string) => {
// return {
// date: formatTime(new Date(log)),
// timeStamp: log
// }
// }),
// })
},
})

@ -0,0 +1,50 @@
<view class="wrip-view">
<view>
<view catchtap="atReleaseFlag">
<navigator url="/pages/list/list" hover-class="navigator-hover" class="title">发布任务</navigator>
</view>
<!-- <view class="title" catchtap="atReleaseFlag">
发布任务
</view>
<view wx:if="{{releaseFlag}}" class="release-view">
<label>任务名称
<input type="text" data-gater="from.taskName" value="{{from.taskName}}" bindinput="inputFrom" placeholder="输入任务名称" />
</label>
<label>任务结束时间
<input type="number" maxlength="20" data-gater="from.end" value="{{from.end}}" bindinput="inputFrom" placeholder="输入任务结束时间" />
</label>
<label>任务类型
<input type="file" name="upload" maxlength="10" value="{{from.type}}" bindinput="inputFrom" placeholder="输入任务类型" />
</label>
<label>任务详情
<input type="text" data-gater="from.taskdetail" value="{{from.taskdetail}}" bindinput="inputFrom" placeholder="输入任务详情" />
</label>
<button catchtap="addSelect">发布</button>
</view> -->
</view>
<view>
<view class="title">发布接龙</view>
</view>
<view>
<view class="title" catchtap="atTaskFlag">查看任务进度</view>
<view class="task" wx:if="{{taskFlag}}">
<view wx:if="{{taskList.length!=0}}">
<block wx:for="{{taskList}}" wx:key="id">
<view class="task-item">
<view class="task-item-title"> {{item.title}}: </view>
<view class="task-item-text">
<text>完成进度:{{item.end}} </text>
</view>
<view class="task-item-backg" style="width: {{item.end+'%'}};"></view>
</view>
</block>
</view>
<view wx:else>
暂无任务
</view>
</view>
</view>
</view>

@ -0,0 +1,78 @@
.wrip-view {
height: 100%;
padding: 0 12px;
}
.task {
padding: 8px;
background-color: #fff;
border-radius: 4px;
}
.task-item {
padding: 4px 0;
margin: 10px 0;
border-radius: 10px;
position: relative;
z-index: 100;
background-color: #fff;
overflow: hidden;
}
.task-item-backg {
position: absolute;
top: 0;
background: #77bef0;
height: 100%;
width: 100%;
z-index: -1;
border-radius: 10px 0 0 10px;
}
.task-item-title {
font-family: "楷体";
font-size: 18px;
margin-bottom: 6px;
margin-left: 10px;
}
.task-item-text {
text-align: right;
font-family: "楷体";
font-size: 14px;
margin-right: 10px;
}
.title {
background: #fff;
display: inline-block;
border-radius: 4px;
padding: 4px;
margin: 10px 0;
position: relative;
}
.title::after {
content: "";
position: absolute;
top: 50%;
width: 100vw;
height: 4px;
background: #fff;
}
.release-view{
padding: 8px;
background-color: #fff;
border-radius: 4px;
}
.release-view input{
border: 1px #ccc solid;
border-radius: 4px;
margin: 6px 0;
padding: 4px;
}

@ -0,0 +1,77 @@
// logs.ts
// const util = require('../../utils/util.js')
// import { formatTime } from '../../utils/util'
Page({
data: {
userInfo: {},
key:{},
},
atLogin() {
wx.getUserProfile({
desc: '展示用户信息',
success: (res) => {
this.setData({
userInfo: res.userInfo,
})
// wx.setStorageSync("userInfo", res.userInfo);
wx.setStorage({
key:"userInfo",
data:this.data.userInfo,
// userInfo:res.userInfo,
encrypt: true, // 若开启加密存储setStorage 和 getStorage 需要同时声明 encrypt 的值为 true
success() {
wx.getStorage({
key: "key",
encrypt: true, // 若开启加密存储setStorage 和 getStorage 需要同时声明 encrypt 的值为 true
success(res) {
console.log(res.data)
}
})
}
})
 wx.login({
      success: function(login_res){
        if(login_res.code){
          wx.request({
            url:'http://192.168.58.210:81/atlogin',
            method:'GET',
            data:{
              code:login_res.code,
            },
success:function(res :any){
console.log(res)
let skey=res.data.skey
console.log(skey)
wx.setStorageSync('skey',skey)
}
          })
        }else{
          console.log('登录失败!'+login_res.errMsg)
        }
      }
    })   
}
})
},   
onShow() {
const userInfo = wx.getStorageSync("userInfo");
if (userInfo!=null) return;
this.setData({
userInfo: userInfo,
})
  
},
onLoad() {
const userInfo = wx.getStorageSync("userInfo");
if (userInfo!=null) return;
this.setData({
userInfo: userInfo,
})
},
})

@ -0,0 +1,23 @@
<view class="wrip">
<view class="my-head">
<view class="my-head-box">
<view class="head-box-child">
<view wx:if="{{!userInfo.avatarUrl}}" catchtap="atLogin">
登录
</view>
<view wx:else>
<image src="{{userInfo.avatarUrl}}"></image>
</view>
</view>
</view>
</view>
<view>
<view class="my-box">
<view class="my-top">
<navigator url="/pages/bd/bd" hover-class="navigator-hover">已绑定,点击可重新绑定</navigator>
</view>
</view>
</view>
</view>

@ -0,0 +1,58 @@
.wrip {
padding: 10px;
}
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
.my-head {
margin: 0 0 10px 0;
}
.my-head-box {
height: 160px;
background: white;
border-radius: 5px;
position: relative;
background-image: linear-gradient(to right top, #d16ba5, #c777b9, #ba83ca, #aa8fd8, #9a9ae1, #8aa7ec, #79b3f4, #69bff8, #52cffe, #41dfff, #46eefa, #5ffbf1);
}
.my-box {
height: 140px;
background-image: linear-gradient(to right top, #051937, #004d7a, #008793, #00bf72, #a8eb12);
border-radius: 5px;
}
.head-box-child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 80px;
height: 80px;
border-radius: 50%;
text-align: center;
border: 1px #ccc solid;
color: rgb(255, 255, 255);
line-height: 80px;
overflow: hidden;
}
.head-box-child image {
width: 100%;
height: 80px;
}
.my-top {
padding: 4px;
color: white;
box-shadow: rgba(116, 116, 116, 0.521) 0 0 10px ;
background: rgba(204, 204, 204, 0.384);
}

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "任务信息表单"
}

@ -0,0 +1,129 @@
// logs.ts
// const util = require('../../utils/util.js')
import { formatTime } from '../../utils/util'
Page({
data: {
logs: [],
taskList: [],
taskFlag: false,
releaseFlag: false,
id:undefined,
name:'',
property:'',
stuid:'',
deadtime:'',
addUrl:'http://localhost:8080/task/addTask',
updateUrl:'http://localhost:8080/task/taskInfo',
from: {
taskName: "",
end: ""
}
},
inputFrom(event:any) {
if (event.currentTarget.dataset.gater == "from.end") {
let num = event.detail.value;
if (num.length == 4) num += "-";
if (num.length == 7) num += "-";
this.setData({ [`from.end`]: num })
} else if(event.currentTarget.dataset.gater == "from.taskName"){
this.setData({
[`${event.currentTarget.dataset.gater}`]: event.detail.value
})
}else{
this.setData({
[`${event.currentTarget.dataset.gater}`]: event.detail.value
})
}
},
addSelect() {
const { taskName, end } = this.data.from;
if (end.length != 10) return;
if (!taskName || !end) {
wx.showToast({
title: "请填写任务名称和任务进度",
icon: 'error',
});
return;
}
const list = wx.getStorageSync("taskList") || [];
const index = list.findIndex((item:any) => item.title == taskName);
if (index >= 0) {
wx.showToast({
title: "任务名称重复",
icon: 'error',
});
return;
}
const data = {
id: list.length + 1,
title: taskName,
startTime: formatTime(new Date), endTime: end, end: '40',
}
list.push(data)
wx.setStorageSync("taskList", list);
wx.showToast({
title: "发布成功",
icon: 'success',
});
this.setData({
taskList: wx.getStorageSync("taskList") || []
});
},
formSubmit:function(e:any){
// var that = this;
//获取表单值
var formData = e.detail.value;
var url = this.data.addUrl;
if(this.data.id != undefined){
//如果是编辑按钮跳转
formData.id = this.data.id;
url = this.data.updateUrl;
}
console.log(JSON.stringify(formData));
wx.request({
url: url,
//将其转换成JSON
data: JSON.stringify(formData),
method: 'POST',
success: function(res:any) {
var result = res.data.success;
var toastText = '请求成功';
if(!result){
toastText = '请求失败'+res.data.msg;
}
wx.showToast({
title: toastText,
duration: 2000,
})
if(result){
wx.redirectTo({
//操作结束后跳转回列表页
url: '../list/list',
})
}
},
})
},
atTaskFlag() {
this.setData({ taskFlag: !this.data.taskFlag })
},
onShow() {
this.setData({
taskList: wx.getStorageSync("taskList") || []
});
},
onLoad() {
this.setData({
taskList: wx.getStorageSync("taskList") || []
});
// this.setData({
// logs: (wx.getStorageSync('logs') || []).map((log: string) => {
// return {
// date: formatTime(new Date(log)),
// timeStamp: log
// }
// }),
// })
},
})

@ -0,0 +1,19 @@
<view class="release-view">
<form bindsubmit='formSubmit' bindreset='formReset'>
<label>任务名称
<input type="text" data-gater="from.taskName" value="{{from.taskName}}" bindinput="inputFrom" placeholder="输入任务名称" />
</label>
<label>任务结束时间
<input type="number" maxlength="20" data-gater="from.end" value="{{from.end}}" bindinput="inputFrom" placeholder="输入任务结束时间" />
</label>
<label>任务详情
<input type="text" data-gater="from.taskdetail" value="{{from.taskdetail}}" bindinput="inputFrom" placeholder="输入任务详情" />
</label>
<view class='row'>
<button type='primary' form-type='submit' catchtap="addSelect">提交</button>
<button type='primary' form-type='reset'>清空</button>
</view>
</form>
</view>

@ -0,0 +1,69 @@
/* pages/opration/opration.wxss */
.row input {
font-size: 0.7rem;
flex-grow: 3;
border: ipx solid #09c;
display: inline-block;
border-radius: 0.3rem;
box-shadow: 0 0 0.15rem #aaa;
padding: 0.3rem;
}
.row button {
padding: 0.3rem;
margin: 3rem 1rem;
}
.container {
padding: 1rem;
font-size: 0.9rem;
line-height: 1.5rem;
}
.row {
display: flex;
align-items: center;
margin-bottom: 0.8rem;
}
.row text {
flex-grow: 1.5;
text-align: right;
}
.form-box picker{
margin: 30rpx 30rpx 0 0;
color: rgb(153, 153, 153);
}
.title {
background: #fff;
display: inline-block;
border-radius: 4px;
padding: 4px;
margin: 10px 0;
position: relative;
}
.title::after {
content: "";
position: absolute;
top: 50%;
width: 100vw;
height: 4px;
background: #fff;
}
.release-view{
padding: 8px;
background-color: #fff;
border-radius: 4px;
}
.release-view input{
border: 1px #ccc solid;
border-radius: 4px;
margin: 6px 0;
padding: 4px;
}

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,66 @@
// pages/uploadfile/uploadfile.ts
Page({
/**
*
*/
data: {
},
/**
* --
*/
onLoad() {
},
/**
* --
*/
onReady() {
},
/**
* --
*/
onShow() {
},
/**
* --
*/
onHide() {
},
/**
* --
*/
onUnload() {
},
/**
* --
*/
onPullDownRefresh() {
},
/**
*
*/
onReachBottom() {
},
/**
*
*/
onShareAppMessage() {
}
})

@ -0,0 +1,2 @@
<!--pages/uploadfile/uploadfile.wxml-->
<text>文件提交</text>

@ -0,0 +1 @@
/* pages/uploadfile/uploadfile.wxss */
Loading…
Cancel
Save