页面构成
This commit is contained in:
1 parent
66b2e3ddac
commit
c2f0c46c4d
40 files changed
+2817
No files matched your search
@@ -0,0 +1,433 @@
|
||||
// pages/SetPasswordCode/SetPasswordCode.js
|
||||
const MyApi = require('../../Api/api.js');
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
isAdmin:null,
|
||||
//添加口令码提交参数
|
||||
selectcoursename:"请选择课程",
|
||||
selectcourseindex:null,
|
||||
addCourseCode:"",
|
||||
codecount:"",
|
||||
IntegerValid:"",
|
||||
addCourse_enddata:"2099-12-31 00:00:00",
|
||||
add_show:false,
|
||||
add_courseinfo:"",
|
||||
add_courseid:"",
|
||||
columnsID:[],
|
||||
columns: [],
|
||||
columnsInfo:[],
|
||||
|
||||
//修改口令码提交参数
|
||||
changeData:null,
|
||||
changeindex:null,
|
||||
oldcourpswdsecode:[],
|
||||
|
||||
tempCourseData_2:null,
|
||||
activeNames: ['修改栏目-点击展开关闭'],
|
||||
showCourse:false,
|
||||
show: false,
|
||||
minHour: 10,
|
||||
maxHour: 20,
|
||||
minDate: new Date(2023, 1, 1).getTime(),
|
||||
maxDate: new Date(2035, 1, 1).getTime(),
|
||||
currentDate: new Date().getTime(),
|
||||
},
|
||||
confirm_to_delete(e){
|
||||
wx.showModal({
|
||||
title: '删除课程码',
|
||||
confirmColor:"#ff0000",
|
||||
content: '确定删除吗?',
|
||||
complete: (res) => {
|
||||
if (res.cancel) {}
|
||||
if (res.confirm) {
|
||||
var delete_index=e.currentTarget.dataset.index;
|
||||
|
||||
wx.showToast({
|
||||
title: '删除课程码中',
|
||||
duration: 10000,
|
||||
icon: "loading",
|
||||
mask: true,
|
||||
});
|
||||
var delete_openid=wx.getStorageSync('UserInfoCache').user_openid;
|
||||
MyApi.ApiDeletePasswordCode(delete_openid,this.data.changeData[delete_index].口令码)
|
||||
.then(result => {
|
||||
|
||||
if (result.result) {
|
||||
wx.hideToast();
|
||||
|
||||
//本地也删除口令码数据
|
||||
var tempdata=this.data.changeData
|
||||
tempdata.splice(delete_index, 1);
|
||||
this.setData({
|
||||
changeData:tempdata,
|
||||
//恢复默认收缩栏目
|
||||
activeNames: ["修改栏目-点击展开关闭", 998],
|
||||
});
|
||||
|
||||
wx.showToast({
|
||||
title: '删除成功',
|
||||
duration: 1000,
|
||||
icon: "success",
|
||||
mask: true,
|
||||
});
|
||||
|
||||
} else {
|
||||
wx.hideToast();
|
||||
wx.showToast({
|
||||
title: '提交失败',
|
||||
duration: 1000,
|
||||
icon: "error",
|
||||
mask: true,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("请求失败:" + err);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
},
|
||||
confirm_to_change(e){
|
||||
wx.showModal({
|
||||
title: '修改口令信息',
|
||||
confirmColor:"#ff0000",
|
||||
content: '确定修改吗?',
|
||||
complete: (res) => {
|
||||
if (res.cancel) {}
|
||||
if (res.confirm) {
|
||||
var change_index=e.currentTarget.dataset.index;
|
||||
|
||||
wx.showToast({
|
||||
title: '修改课程码中',
|
||||
duration: 10000,
|
||||
icon: "loading",
|
||||
mask: true,
|
||||
});
|
||||
//openid,coursePswdCode,courseEndDate,courseInfo,courseCount,oldCoursePswdCode
|
||||
var change_openid=wx.getStorageSync('UserInfoCache').user_openid;
|
||||
var coursePswdCode=this.data.changeData[change_index].口令码;
|
||||
var courseEndDate=this.data.changeData[change_index].口令结束日期;
|
||||
var courseInfo=this.data.changeData[change_index].课程介绍;
|
||||
var courseCount=this.data.changeData[change_index].剩余有效次数;
|
||||
var oldCoursePswdCode=this.data.oldcourpswdsecode[change_index];
|
||||
|
||||
|
||||
MyApi.ApiChangePasswordCode(change_openid,coursePswdCode,courseEndDate,courseInfo,courseCount,oldCoursePswdCode)
|
||||
.then(result => {
|
||||
if (result.result) {
|
||||
wx.hideToast();
|
||||
|
||||
//旧口令码修改为修改后的口令码
|
||||
var oldcoursepswdcode2=this.data.oldcourpswdsecode;
|
||||
oldcoursepswdcode2[change_index]=coursePswdCode;
|
||||
this.setData({
|
||||
oldcourpswdsecode:oldcoursepswdcode2,
|
||||
});
|
||||
|
||||
wx.showToast({
|
||||
title: '修改成功',
|
||||
duration: 1000,
|
||||
icon: "success",
|
||||
mask: true,
|
||||
});
|
||||
|
||||
} else {
|
||||
wx.hideToast();
|
||||
wx.showToast({
|
||||
title: '提交失败',
|
||||
duration: 1000,
|
||||
icon: "error",
|
||||
mask: true,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("请求失败:" + err);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
onchangecodeconfirm(e){
|
||||
var timeformat_02= this.formatTimestamp(e.detail);
|
||||
var tempcode004=this.data.changeData;
|
||||
tempcode004[this.data.changeindex].口令结束日期=timeformat_02;
|
||||
this.setData({
|
||||
changeData:tempcode004,
|
||||
show: false,
|
||||
});
|
||||
},
|
||||
onchangeconde_info(e){
|
||||
var tempcode003=this.data.changeData;
|
||||
tempcode003[e.currentTarget.dataset.index].课程介绍=e.detail;
|
||||
this.setData({
|
||||
changeData:tempcode003
|
||||
});
|
||||
},
|
||||
onchangecode(e){
|
||||
|
||||
var tempcode001=this.data.changeData;
|
||||
tempcode001[e.currentTarget.dataset.index].口令码=e.detail;
|
||||
this.setData({
|
||||
changeData:tempcode001
|
||||
});
|
||||
},
|
||||
onchangecodecount(e){
|
||||
//正则表达式验证纯数字
|
||||
if ( /^\d+$/.test(e.detail) ) {
|
||||
var tempcode002=this.data.changeData;
|
||||
tempcode002[e.currentTarget.dataset.index].剩余有效次数=e.detail;
|
||||
this.setData({
|
||||
IntegerValid: "",
|
||||
changeData:tempcode002
|
||||
});
|
||||
} else {
|
||||
var tempcode002=this.data.changeData;
|
||||
tempcode002[e.currentTarget.dataset.index].剩余有效次数="";
|
||||
this.setData({
|
||||
IntegerValid: "请输入整数!",
|
||||
changeData:tempcode002
|
||||
});
|
||||
}
|
||||
},
|
||||
onAddcourseBtnClick() {
|
||||
wx.showModal({
|
||||
title: '添加课程',
|
||||
content: '确定添加课程码?',
|
||||
complete: (res) => {
|
||||
if (res.cancel) {}
|
||||
if (res.confirm) {
|
||||
wx.showToast({
|
||||
title: '提交中',
|
||||
duration: 10000,
|
||||
icon: "loading",
|
||||
mask: true,
|
||||
});
|
||||
|
||||
var var1=wx.getStorageSync('UserInfoCache').user_openid;
|
||||
var var2=this.data.add_courseid
|
||||
var var3=this.data.selectcoursename
|
||||
var var4=this.data.addCourseCode
|
||||
var var5=this.data.addCourse_enddata
|
||||
var var6=this.data.add_courseinfo
|
||||
var var7=this.data.codecount
|
||||
|
||||
MyApi.ApiAddPasswordCode(var1,var2,var3,var4,var5,var6,var7)
|
||||
.then(result => {
|
||||
if (result.Data) {
|
||||
wx.hideToast();
|
||||
wx.showToast({
|
||||
title: '提交成功',
|
||||
duration: 1000,
|
||||
icon: "success",
|
||||
mask: true,
|
||||
});
|
||||
|
||||
//修改拉取的口令码数据
|
||||
var changelistdata01=result.Data
|
||||
var changechangeData=this.data.changeData
|
||||
changechangeData.push(changelistdata01);
|
||||
this.setData({
|
||||
changeData:changechangeData,
|
||||
//恢复默认收缩栏目
|
||||
activeNames: ["修改栏目-点击展开关闭", 998],
|
||||
});
|
||||
|
||||
} else {
|
||||
wx.hideToast();
|
||||
wx.showToast({
|
||||
title: '提交失败',
|
||||
duration: 1000,
|
||||
icon: "error",
|
||||
mask: true,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error("请求失败:" + err);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
addcourse_onInputCourseInfo(e) {
|
||||
this.setData({ add_courseinfo: e.detail });
|
||||
},
|
||||
addcourse_showPopup(e) {
|
||||
this.setData({ add_show: true });
|
||||
},
|
||||
addcourse_onClose(event) {
|
||||
this.setData({ add_show: false });
|
||||
},
|
||||
addcourse_onconfirm(e) {
|
||||
var timeformat_01= this.formatTimestamp(e.detail)
|
||||
this.setData({
|
||||
addCourse_enddata: timeformat_01,
|
||||
});
|
||||
this.setData({ add_show: false });
|
||||
},
|
||||
addCode_onInputCode(e){
|
||||
this.setData({
|
||||
addCourseCode: e.detail,
|
||||
});
|
||||
},
|
||||
addCode_onInputCodecount(e){
|
||||
//正则表达式验证纯数字
|
||||
if ( /^\d+$/.test(e.detail) ) {
|
||||
this.setData({
|
||||
IntegerValid: "",
|
||||
codecount:e.detail
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
IntegerValid: "请输入整数!",
|
||||
codecount:"",
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
onInput(event) {
|
||||
this.setData({
|
||||
currentDate: event.detail,
|
||||
});
|
||||
},
|
||||
onInputCourse(event) {
|
||||
this.setData({
|
||||
currentDate: event.detail,
|
||||
});
|
||||
},
|
||||
showPopup(e) {
|
||||
this.setData({
|
||||
show: true,
|
||||
changeindex:e.currentTarget.dataset.index
|
||||
});
|
||||
|
||||
},
|
||||
showPopupCourse() {
|
||||
this.setData({ showCourse: true });
|
||||
},
|
||||
|
||||
onClose(e) {
|
||||
this.setData({ show: false });
|
||||
|
||||
},
|
||||
onCloseCourse(event) {
|
||||
var info=this.data.columnsInfo
|
||||
var id=this.data.columnsID
|
||||
this.setData({
|
||||
showCourse: false,
|
||||
selectcoursename:event.detail.value,
|
||||
selectcourseindex:event.detail.index,
|
||||
add_courseinfo:info[event.detail.index],
|
||||
add_courseid:id[event.detail.index]
|
||||
});
|
||||
},
|
||||
|
||||
onCloseCourse_popup(event) {
|
||||
this.setData({
|
||||
showCourse: false,
|
||||
});
|
||||
},
|
||||
|
||||
onCloseCourse_selectcourse(event) {this.setData({showCourse: false});},
|
||||
|
||||
onChange(event) {
|
||||
this.setData({
|
||||
activeNames: event.detail,
|
||||
});
|
||||
},
|
||||
onChangeCourse(event) {
|
||||
const { picker, value, index } = event.detail;
|
||||
},
|
||||
/*** 生命周期函数--监听页面加载*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/*** 生命周期函数--监听页面初次渲染完成*/
|
||||
onReady() {
|
||||
|
||||
|
||||
},
|
||||
|
||||
/*** 生命周期函数--监听页面显示*/
|
||||
onShow() {
|
||||
var openid=wx.getStorageSync('UserInfoCache').user_openid;
|
||||
this.setData({
|
||||
isAdmin:wx.getStorageSync('UserInfoCache').IsAdministor
|
||||
});
|
||||
//获取可以添加的课程目录
|
||||
MyApi.ApiAddPasswordCodeBefor(openid)
|
||||
.then(result => {
|
||||
var tempcolumns=[];
|
||||
var tempcolumnsInfo=[];
|
||||
var tempcolumnsID=[];
|
||||
|
||||
for (var i = 0; i < result.Data.length; i++) {
|
||||
tempcolumnsID=tempcolumnsID.concat(result.Data[i].课程id);
|
||||
tempcolumns=tempcolumns.concat(result.Data[i].课程名称);
|
||||
tempcolumnsInfo=tempcolumnsInfo.concat(result.Data[i].课程介绍);
|
||||
}
|
||||
this.setData({
|
||||
tempCourseData_2:result.Data,
|
||||
columns: tempcolumns,
|
||||
columnsID:tempcolumnsID,
|
||||
columnsInfo:tempcolumnsInfo,
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
// 失败后执行的代码
|
||||
console.error("请求失败:" + err);
|
||||
});
|
||||
|
||||
//获取课程口令码
|
||||
MyApi.ApiGetPasswordCode(openid)
|
||||
.then(result => {
|
||||
var tempoldcode=[];
|
||||
for (var i = 0; i < result.Data.length; i++) {
|
||||
tempoldcode=tempoldcode.concat(result.Data[i].口令码);
|
||||
}
|
||||
|
||||
this.setData({
|
||||
changeData:result.Data,
|
||||
oldcourpswdsecode:tempoldcode
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
// 失败后执行的代码
|
||||
console.error("请求失败:" + err);
|
||||
});
|
||||
},
|
||||
|
||||
/*** 生命周期函数--监听页面隐藏*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/*** 生命周期函数--监听页面卸载*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
formatTimestamp(timestamp) {
|
||||
// 创建一个新的Date对象,传入时间戳(以毫秒为单位)
|
||||
var date = new Date(timestamp);
|
||||
// 获取年、月、日、时、分、秒
|
||||
var year = date.getFullYear();
|
||||
var month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
|
||||
var day = String(date.getDate()).padStart(2, '0');
|
||||
var hours = String(date.getHours()).padStart(2, '0');
|
||||
var minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
var seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
// 拼接成指定格式的日期时间字符串
|
||||
var formattedDateTime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
|
||||
return formattedDateTime;
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-collapse": "@vant/weapp/collapse/index",
|
||||
"van-collapse-item": "@vant/weapp/collapse-item/index",
|
||||
"van-field": "@vant/weapp/field/index",
|
||||
"van-button": "@vant/weapp/button/index",
|
||||
"van-cell": "@vant/weapp/cell/index",
|
||||
"van-cell-group": "@vant/weapp/cell-group/index",
|
||||
"van-popup": "@vant/weapp/popup/index",
|
||||
"van-picker": "@vant/weapp/picker/index",
|
||||
"van-datetime-picker": "@vant/weapp/datetime-picker/index"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<!--pages/SetPasswordCode/SetPasswordCode.wxml-->
|
||||
<!-- 弹出课程选择 -->
|
||||
<van-popup show="{{ showCourse }}" round position="bottom" bind:close="onCloseCourse_popup">
|
||||
<!-- 课程选择器 -->
|
||||
<van-picker title="课程选择" show-toolbar columns="{{ columns }}"
|
||||
bind:change="onChangeCourse" bind:confirm="onCloseCourse" bind:cancel="onCloseCourse_selectcourse"/>
|
||||
</van-popup>
|
||||
<!-- 弹出添加模块时间选择 -->
|
||||
<van-popup show="{{ add_show }}" round position="bottom" bind:close="addcourse_onClose">
|
||||
<!-- 添加模块时间选择器 -->
|
||||
<van-datetime-picker title="(添加课程)选择时间" type="datetime" value="{{ currentDate }}" min-date="{{ minDate }}" max-date="{{ maxDate }}" bind:confirm="addcourse_onconfirm" bind:cancel="addcourse_onClose" />
|
||||
</van-popup>
|
||||
|
||||
|
||||
|
||||
<!-- 弹出时间选择 -->
|
||||
<van-popup show="{{ show }}" round position="bottom" bind:close="onClose">
|
||||
<!-- 时间选择器 -->
|
||||
<van-datetime-picker title="选择时间" type="datetime" value="{{ currentDate }}" min-date="{{ minDate }}" max-date="{{ maxDate }}" bind:input="onInput" bind:confirm="onchangecodeconfirm" bind:cancel="onClose"/>
|
||||
</van-popup>
|
||||
|
||||
<van-collapse value="{{ activeNames }}" bind:change="onChange">
|
||||
<!-- 下面是添加口令码功能 -->
|
||||
<van-collapse-item disabled="{{!isAdmin}}" name="{{999}}">
|
||||
<view slot="title">添加课程码</view>
|
||||
<van-cell-group>
|
||||
<van-cell title="课程" is-link value="{{selectcoursename}}" bind:click="showPopupCourse" />
|
||||
<van-field label="课程码" value="{{addCourseCode}}" placeholder="请输入课程码" border="{{ false }}" bind:change="addCode_onInputCode" />
|
||||
<van-field label="有效次数" error-message="{{IntegerValid}}" type="digit" value="{{codecount}}" placeholder="请输入整数" border="{{ false }}" bind:change="addCode_onInputCodecount" />
|
||||
<van-cell title="结束日期" is-link value="{{addCourse_enddata}}" bind:click="addcourse_showPopup" />
|
||||
<van-field label="课程介绍" type="textarea" autosize value="{{add_courseinfo}}" placeholder="请输入课程介绍" border="{{ false }}" bind:change="addcourse_onInputCourseInfo" />
|
||||
<view style="display: flex; justify-content: center; align-items: center;">
|
||||
<van-button style="align-self: center;" type="primary" bind:click="onAddcourseBtnClick">确认添加</van-button>
|
||||
</view>
|
||||
|
||||
</van-cell-group>
|
||||
|
||||
|
||||
</van-collapse-item>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 下面是修改口令码功能 -->
|
||||
<van-collapse-item disabled="{{!isAdmin}}" title="修改/删除课程码" name="{{998}}">
|
||||
<van-collapse-item wx:for="{{changeData}}" wx:for-item="item" wx:for-index="index" wx:key="index" name="{{index}}">
|
||||
<view slot="title">{{item['口令码']}}</view>
|
||||
<van-cell-group>
|
||||
<van-field label="课程" value="{{item['课程']}}" disabled border="{{ false }}"/>
|
||||
<van-field label="课程码" value="{{item['口令码']}}" placeholder="请输入修改值" border="{{ false }}" data-index="{{index}}" bind:change="onchangecode" />
|
||||
<van-field label="有效次数" error-message="{{IntegerValid}}" type="digit" value="{{item['剩余有效次数']}}" placeholder="请输入整数" border="{{ false }}" data-index="{{index}}" bind:change="onchangecodecount" />
|
||||
<van-cell title="结束日期" is-link value="{{item['口令结束日期']}}" data-index="{{index}}" bind:click="showPopup" />
|
||||
<van-field label="课程介绍" type="textarea" autosize value="{{item['课程介绍']}}" placeholder="请输入修改值" border="{{ false }}" data-index="{{index}}" bind:change="onchangeconde_info" />
|
||||
<view style="display: flex; justify-content: center; align-items: center;">
|
||||
<van-button style="margin: 0 20rpx;" type="danger" data-index="{{index}}" bind:click="confirm_to_delete">确认删除</van-button>
|
||||
<van-button style="margin: 0 20rpx;" type="primary" data-index="{{index}}" bind:click="confirm_to_change">确认修改</van-button>
|
||||
</view>
|
||||
|
||||
</van-cell-group>
|
||||
|
||||
|
||||
</van-collapse-item>
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
@@ -0,0 +1 @@
|
||||
/* pages/SetPasswordCode/SetPasswordCode.wxss */
|
||||
Reference in new issue
Block a user