Commit 0ca43638 authored by wangxuelai's avatar wangxuelai

'编辑模块完结'

parent afe69855
......@@ -3,10 +3,12 @@ time: 2018-10-31
author: wxl
*/
import {
themeEditor
themeEditor,
unlockSubjectEditor,
} from '../../../service/business/themeeditor.js';
import {
themeDetail
themeDetail,
unlockSubjectShow
} from '../../../service/business/themeindex.js';
import {
audioorigin,
......@@ -235,6 +237,10 @@ Page({
}],
currentSortIndex: 0,
lockSubjectLists: [], // 闯关打卡主题列表 源数据
radioList: [
],
radioname: '',
},
onLoad: function(options) { // Do some initialize when page load.
const that = this;
......@@ -273,25 +279,38 @@ Page({
wx.setNavigationBarTitle({
title: '新建闯关打卡'
})
// if (this.data.lockparams.subject_count) {
this.setData({
lockSubjectLists: this.data.lockSubjects.slice(that.data.currentSortIndex * 10, that.data.currentSortIndex * 10 + 10),
})
// }
this.getSubjectSort();
}
} else {
if (editType == 1) {
wx.setNavigationBarTitle({
title: '编辑作业打卡'
})
this.loadThemeData({
id,
tid,
extra: 'land_content,class'
});
} else if (editType == 2) {
wx.setNavigationBarTitle({
title: '编辑作业打卡'
})
this.loadCalendarThemeData({
id,
tid,
extra: 'land_content,class'
});
} else if (editType == 3) {
wx.setNavigationBarTitle({
title: '编辑作业打卡'
})
this.unlockSubjectShow();
}
}
if(tid != 0){
wx.setNavigationBarTitle({
title: '编辑作业打卡'
})
this.loadThemeData({
id,
tid,
extra: 'land_content,class'
});
}
initCalendar({
multi: true,
......@@ -554,6 +573,90 @@ Page({
}
},
loadCalendarThemeData({ id, tid, extra }) {
wx.showLoading({
title: '数据加载中...'
})
themeDetail({
id: this.data.tid,
school_id: this.data.sid,
extra
}).then((res) => {
wx.hideLoading();
const {
code,
data
} = res;
if (code == 200) {
let _content = [];
const selectRestDaysArr = [];
const restdates =data.calendar_set.rest_dates?data.calendar_set.rest_dates.split(','):[];
const weekArray = new Array("日", "一", "二", "三", "四", "五", "六");
const startD = data.calendar_set.start_time.split(" ")[0]
const endD = data.calendar_set.end_time.split(" ")[0]
for(let i=0,len=restdates.length;i<len;i++){
const year = restdates[i].split('-')[0];
const month = restdates[i].split('-')[1];
const day = restdates[i].split('-')[2];
selectRestDaysArr.push({
show: ((("" + month).length) < 2 ? ('0' + month) : month) + '-' + day,
data: {
year: year,
month: month,
day: day
},
date:restdates[i],
week:weekArray[new Date(restdates[i]).getDay()],
})
}
try {
_content = JSON.parse(data.content);
} catch (error) {
_content = []
}
this.getBetweenDateStr(startD,endD)
this.setData({
calendarparams: {
type: data.type,
title: data.title,
content: _content,
is_cheat: data.is_cheat,
is_encrypt: data.is_encrypt,
force_status: data.force_status,
force_num:Number(data.force_num),
text_require_status:data.text_require_status,
text_require_num:Number(data.text_require_num),
image_require_status:data.image_require_status,
image_require_num:Number(data.image_require_num),
video_require_status:data.video_require_status,
video_require_num:Number(data.video_require_num),
audio_require_status:data.audio_require_status,
audio_require_num:Number(data.audio_require_num),
clock_start_time:data.calendar_set.clock_start_time,
clock_end_time:data.calendar_set.clock_end_time,
supplement_status:data.calendar_set.supplement_status,
supplement_num:Number(data.calendar_set.supplement_num),
startDate: data.calendar_set.start_time.split(" ")[0],
startTime: data.calendar_set.start_time.split(" ")[1],
endDate: data.calendar_set.end_time.split(" ")[0],
endTime: data.calendar_set.end_time.split(" ")[1],
push_status:data.calendar_set.push_status,
push_time:data.calendar_set.push_time,
join_rule_type: data.join_rule_type,
join_secret: data.join_secret,
},
selectRestDays:selectRestDaysArr,
classes: data.classes.map(ele => ({title: ele.title, id: ele.id})),
calendarThemeAdInfo: {
id: (data.land_content && data.land_content.id) || 0,
title: (data.land_content && data.land_content.title) || ''
},
})
}
}).catch((err) => {
wx.hideLoading()
})
},
loadThemeData({ id, tid, extra }) {
wx.showLoading({
title: '数据加载中...'
......@@ -651,10 +754,9 @@ Page({
if (this.data.editType == 1) {
this.thisSaveTheme();
} else if (this.data.editType == 2) {
console.log('保存日历打卡');
this.saveCalendarTheme();
} else if (this.data.editType == 3) {
this.saveLock();
}
},
compareSmallTime(t1,t2) {
......@@ -1935,12 +2037,332 @@ Page({
addSort = 1;
}
wx.navigateTo({
url: `/business/pages/themeeditor/subjecteditor?tid=${this.data.id}&sid=${this.data.sid}&addSort=${addSort}&sort=${sort}&id=${item.id}&detail=${encodeURIComponent(JSON.stringify(item))}&index=${index}&currentSortIndex=${this.data.currentSortIndex}`,
url: `/business/pages/themeeditor/subjecteditor?tid=${this.data.tid}&sid=${this.data.sid}&addSort=${addSort}&sort=${sort}&id=${item.id}&detail=${encodeURIComponent(JSON.stringify(item))}&index=${index}&currentSortIndex=${this.data.currentSortIndex}`,
})
},
checknameIpt(e) {
const { value } = e.detail;
this.setData({
radioname: value
})
},
itemnameIpt(e) {
const { value } = e.detail;
const { index } = e.currentTarget.dataset
this.setData({
[`radioList[${index}].name`]: value
})
},
introducetitleipt(e){
const { value } = e.detail;
const { index } = e.currentTarget.dataset
this.setData({
[`introduceContent[${index}].title`]: value
})
},
addCheckItem(e) {
const { radioList } = this.data;
const len = radioList.length;
let text = '选项一'
switch (len) {
case 1:
text = '选项二'
break;
case 2:
text = '选项三'
break;
case 3:
text = '选项四'
break;
case 4:
text = '选项五'
break;
default:
break;
}
radioList.push(
{
name: '',
text
}
)
this.setData({
radioList
})
},
delallCheck() {
this.setData({
radioList: []
})
},
addRadio() {
this.setData({
radioname: '',
radioList: [
{
name: '',
text: '选项一'
},
{
name: '',
text: '选项二'
}
],
})
},
delCheckitme(e) {
const { index } = e.currentTarget.dataset;
let radioList = JSON.parse(JSON.stringify(this.data.radioList));
radioList.splice(index, 1);
for (let i = 0; i < radioList.length; i++) {
let text = '选项一'
switch (i) {
case 0:
text = '选项一'
break;
case 1:
text = '选项二'
break;
case 2:
text = '选项三'
break;
case 3:
text = '选项四'
break;
case 4:
text = '选项五'
break;
default:
break;
}
radioList[i].text = text
}
this.setData({
radioList
})
},
signupswitch() {
if (Number(this.data.lockparams.sign_up_status) == 2) {
this.setData({
'lockparams.sign_up_status': 1
})
} else if (Number(this.data.lockparams.sign_up_status) == 1) {
this.setData({
'lockparams.sign_up_status': 2
})
}
},
// 保存闯管打卡
saveLockParams() {
saveLock() {
const that = this;
// if (this.data.params.class_id == 0) {
// wx.showModal({
// title: '提示',
// content: '请选择班级',
// showCancel: false
// })
// return;
// }
if (this.data.lockparams.title.trim() == '') {
wx.showToast({
title: '请输入闯关活动标题',
duration: 1500,
icon: 'none',
})
return;
}
if (this.data.lockparams.subject_count < 1) {
wx.showToast({
title: '关卡时长不能小于1',
duration: 1500,
icon: 'none',
})
return;
}
// if (Number(this.data.lockparams.subject_count) < Number(this.data.copySubjectCount)) {
// wx.showToast({
// icon: 'none',
// title: `关卡数量只能增加不能减少,原关卡${this.data.copySubjectCount}关卡`
// })
// return;
// }
if (this.data.lockparams.unlock_limit < 1) {
wx.showToast({
title: '每天可闯关数必须大于1',
duration: 1500,
icon: 'none',
})
return;
}
if (this.data.lockparams.join_rule_type == 2 && !/^\d{6}$/.test(that.data.lockparams.join_secret)) {
wx.showToast({
title: '请输入6位数字的密码',
duration: 1500,
icon: 'none',
})
return;
}
if (this.data.lockparams.max_clock_count < 1) {
wx.showToast({
title: '同一关卡可打卡次数不能小于1',
duration: 1500,
icon: 'none',
})
return;
}
if (this.data.lockparams.sign_up_status == 1) {
if (this.data.radioList.length > 0) {
let flag = false;
const nameList = [];
if (!this.data.radioname) {
wx.showToast({
title: '单选项问题名不能为空',
duration: 1500,
icon: 'none',
})
return
}
this.data.radioList.forEach((item, index) => {
nameList.push(item.name)
if (!item.name) {
flag = true;
}
})
if (flag) {
wx.showToast({
title: '选项不能为空',
duration: 1500,
icon: 'none',
})
return
}
let narry = new Set(nameList);
if (narry.size != nameList.length) {
wx.showToast({
title: '选项不能重复',
duration: 1500,
icon: 'none',
})
return
}
}
}
if (this.data.publishing) {
return
}
this.data.publishing = true;
const { radioList, radioname } = this.data;
this.data.lockparams.sign_up_content = {
radioname,
radioList,
}
try {
// this.data.lockparams.introduce = JSON.stringify(sjdMediaEditorList);
this.data.lockparams.sign_up_content = JSON.stringify(this.data.lockparams.sign_up_content);
} catch (error) {
}
}
this.data.lockparams.content_id = this.data.lockThemeAdInfo.id;
wx.showLoading('保存中...');
const subject_ids = this.data.lockSubjects.map(ele => ele.id).join(',');
this.data.lockparams.subject_ids = subject_ids;
unlockSubjectEditor({
tid: this.data.clone == 'clone' ? 0 : this.data.tid,
data: this.data.lockparams,
school_id: this.data.sid,
}).then((res) => {
const { code, data } = res;
if (res.code == 200) {
this.setData({
confirmId: data.id,
showConfirmDialog: true
}, () => {
this.data.publishing = false;
})
wx.hideLoading();
} else {
this.data.publishing = false;
}
}).catch(() => {
this.data.publishing = false;
wx.hideLoading();
})
},
unlockSubjectShow() {
if (this.data.tid == 0) {
return
}
wx.showLoading({
title: '数据加载中...'
});
unlockSubjectShow({
id: this.data.tid,
school_id: this.data.sid,
extra: 'land_content,class'
}).then((res) => {
const { code, data } = res;
if (code == 200) {
wx.hideLoading();
try {
data.sign_up_content = JSON.parse(data.sign_up_content)
} catch (error) {
}
const introduce = data.introduce && typeof data.introduce == "string" ? JSON.parse(data.introduce) : '';
const lockSubjects = data.subjects;
const count = data.subject_count - data.subjects.length;
for (let i = 0; i < count; i++) {
lockSubjects.push({
id: 0,
title: '',
content: [],
force_status: 2,
force_num: 0,
text_require_status: 2,
text_require_num: 0,
image_require_status: 2,
image_require_num: 0,
video_require_status: 2,
video_require_num: 0,
audio_require_status: 2,
audio_require_num: 0,
})
}
console.log(lockSubjects, 'lockSubjects');
this.setData({
lockparams: {
school_id: data.school_id,
title: data.title,
subject_count: Number(data.subject_count),
max_clock_count: Number(data.max_clock_count),
join_rule_type: data.join_rule_type,
join_secret: data.join_secret,
unlock_limit: Number(data.unlock_limit),
push_status: data.push_status,
push_time: data.push_time,
sign_up_status: data.sign_up_status,
},
radioname: data.sign_up_content ? data.sign_up_content.radioname : '',
radioList: data.sign_up_content ? data.sign_up_content.radioList : '',
lockSubjects: lockSubjects,
lockThemeAdInfo: {
id: (data.land_content && data.land_content.id) || 0,
title: (data.land_content && data.land_content.title) || ''
},
})
this.setData({
lockSubjectLists: this.data.lockSubjects.slice(this.data.currentSortIndex * 10, this.data.currentSortIndex * 10 + 10),
})
this.getSubjectSort();
}
}).catch(() => {
wx.showToast({
icon: 'none',
title: '内容加载失败'
})
})
},
// 闯关打卡的相关代码
})
\ No newline at end of file
......@@ -261,6 +261,34 @@
</view>
</view>
</view>
<view class="new-setting-box">
<view class="title-wrapper">
<view class="title-box">
<text class="title">报名信息收集</text>
<text class="tips">(收集姓名、手机号)</text>
</view>
<view class="switch-box">
<w-switch slot="content" value="{{lockparams.sign_up_status}}" color="#16B0FD" size="small"
bind:onChange="signupswitch" />
</view>
</view>
<view class="content" wx:if="{{lockparams.sign_up_status==1}}">
<view class="tips">收集学员姓名和电话等信息</view>
<view class="check-box" wx:if="{{radioList.length>0}}">
<input class="check-name" type="text" maxlength="{{30}}" value="{{radioname}}" bindinput="checknameIpt" placeholder="请输入单选项问题"/>
<view class="del-btn" bindtap="delallCheck">删除</view>
</view>
<view class="check-item-box" wx:if="{{radioList.length>0}}">
<view class="item" wx:for="{{radioList}}" wx:key="index">
<view class="index-name">{{item.text}}</view>
<input class="item-ipt" type="text" maxlength="{{30}}" placeholder="输入内容" value="{{item.name}}" bindinput="itemnameIpt" data-index="{{index}}"/>
<image class="del-icon" bindtap="delCheckitme" data-index="{{index}}" src="{{imageRoot}}2b/common/reddelicon.png?{{imageVersion}}" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload="" />
</view>
<view class="add-item-btn" bindtap="addCheckItem" wx:if="{{radioList.length<=4}}">添加选项</view>
</view>
<view class="addRadio" wx:if="{{radioList.length==0}}" bindtap="addRadio">添加自定义单选项</view>
</view>
</view>
<view class="section-wrap" bindtap="goyinxiaoPage">
<view class="section-item">
<view class="form-item">
......
......@@ -644,4 +644,270 @@ page{
.locksubjectitem .editbtn {
color: #16B0FD;
font-size: 26rpx;
}
.new-setting-box{
margin-top: 25rpx;
background:rgba(255,255,255,1);
padding: 34rpx 24rpx;
margin-bottom: 24rpx;
}
.new-setting-box .title-wrapper{
display: flex;
align-items: center;
justify-content: space-between;
}
.new-setting-box .title-box .title{
font-size:30rpx;
font-family:PingFang SC;
font-weight:bold;
color:rgba(0,0,0,1);
line-height:1;
padding-right: 20rpx;
}
.new-setting-box .title-box .tips{
font-size:24rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(173,173,173,1);
line-height:1;
}
.new-setting-box .content{
padding: 0rpx 0 32rpx 0;
}
.new-setting-box .content .tips{
font-size:24rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(173,173,173,1);
line-height:1;
margin-top: 20rpx;
}
.new-setting-box .content .check-box{
display: flex;
justify-content:space-between;
align-items: center;
margin-top: 55rpx;
}
.new-setting-box .content .check-box .check-name{
width:507rpx;
padding: 0rpx 30rpx;
height:72rpx;
background:rgba(240,240,244,1);
border-radius:10rpx;
}
.check-box .del-btn{
width:94rpx;
height:70rpx;
background:rgba(255,39,39,.1);
border-radius:10rpx;
display: flex;
align-items: center;
justify-content: center;
font-size:28rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(255,39,39,1);
}
.new-setting-box .content .check-item-box{
}
.check-item-box .item{
margin-top: 21rpx;
width:507rpx;
height:70rpx;
background:rgba(240,240,244,1);
border-radius:35rpx;
padding: 20rpx 30rpx;
position: relative;
display: flex;
align-items: center;
}
.check-item-box .item .index-name{
font-size:28rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(32,32,32,1);
margin-right: 36rpx;
min-width: 100rpx;
}
.check-item-box .item .del-icon{
width:43rpx;
height:43rpx;
position: absolute;
top: 0;
right: -43rpx;
}
.check-item-box .add-item-btn{
width:255rpx;
height:68rpx;
background:rgba(255,255,255,1);
border:2rpx solid rgba(101,184,244,1);
border-radius:34rpx;
font-size:28rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(101,184,244,1);
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
margin-top: 46rpx;
}
.page-setting{
margin-top: 25rpx;
background:rgba(255,255,255,1);
padding: 0 24rpx;
}
.page-setting .title-box{
font-size:30rpx;
font-family:PingFang SC;
font-weight:bold;
color:rgba(0,0,0,1);
line-height:1;
padding: 36rpx 0 34rpx 0;
}
.page-setting .title-box .tips{
font-size:24rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(173,173,173,1);
margin-left: 10rxp;
}
.page-setting .big-img-box{
width:100%;
height:395rpx;
border-radius:10rpx;
background: rgba(0, 0, 0, 0.3);
position: relative;
}
.page-setting .big-img-box image{
width: 100%;
height: 100%;
border-radius:10rpx;
}
.page-setting .change-btn{
width:141rpx;
height:55rpx;
background:rgba(0,0,0,.4);
border-radius:28rpx;
font-size:24rpx;
font-family:PingFang SC;
font-weight:bold;
color:rgba(255,255,255,1);
display: flex;
align-items: center;
justify-content: center;
position: absolute;
right: 20rpx;
top: 21rpx;
}
.page-setting .big-img-box .img-tips{
width:100%;
height:52rpx;
background:rgba(0,0,0,.4);
border-radius:0px 0px 10rpx 10rpx;
font-size:24rpx;
font-family:PingFang SC;
font-weight:bold;
color:rgba(255,255,255,1);
display: flex;
align-items: center;
justify-content: center;
position: absolute;
left: 0;
bottom: 0;
}
.participation-rules-setting{
background:rgba(255,255,255,1);
padding: 45rpx 24rpx 30rpx 24rpx;
}
.introduce-setting{
padding: 0 24rpx 56rpx 24rpx;
background:rgba(255,255,255,1);
}
.introduce-setting .title-box{
padding: 46rpx 0 35rpx 0;
font-size:30rpx;
font-family:PingFang SC;
font-weight:bold;
color:rgba(0,0,0,1);
}
.introduce-setting .introduce-box {
width:100%;
background:rgba(255,255,255,1);
border:2px dashed rgba(208,208,208,1);
border-radius:10rpx;
padding: 36rpx 24rpx 30rpx 24rpx;
position: relative;
margin-bottom: 60rpx;
}
.introduce-setting .introduce-box .close-box{
position: absolute;
top: -25rpx;
right: -25rpx;
}
.introduce-setting .introduce-box .close-box image{
width: 50rpx;
height: 50rpx;
}
.introduce-title {
}
.introduce-title input{
width:390rpx;
height:83rpx;
background:rgba(244,244,244,1);
border-radius:10rpx;
padding: 0 28rpx;
margin: 0 auto;
font-weight: bold;
}
.introduce-title .tips{
font-size:24rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(157,157,157,1);
line-height: 1;
padding: 18rpx 0 22rpx 0;
text-align: center;
}
.introduce-setting .introduce-box .content-inputbox{
font-size:28rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(136,136,136,1);
text-align: center;
padding: 72rpx 0 83rpx 0;
}
.introduce-setting .add-btn{
width:427rpx;
height:65rpx;
background:rgba(255,255,255,1);
border:2rpx solid rgba(101,184,244,1);
border-radius:33rpx;
font-size:26rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(101,184,244,1);
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
margin-top: 56rpx;
}
.addRadio{
padding: 0 30rpx;
height:68rpx;
background:rgba(255,255,255,1);
border:2rpx solid rgba(101,184,244,1);
border-radius:34rpx;
font-size:28rpx;
font-family:PingFang SC;
font-weight:400;
color:rgba(101,184,244,1);
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
margin-top: 46rpx;
}
\ No newline at end of file
......@@ -198,7 +198,7 @@ Page({
unlock_limit: Number(value)
})
},
maxClockCountInput() {
maxClockCountInput(e) {
const {
value
} = e.detail;
......@@ -370,7 +370,7 @@ Page({
"lockparams.push_status": push_status,
"lockparams.supplement_num": supplement_num,
"lockparams.max_clock_count": max_clock_count,
"lockparams.unlock_limit": supplement_num,
"lockparams.unlock_limit": unlock_limit,
});
}
wx.navigateBack({
......
......@@ -184,6 +184,7 @@
<input type="number" placeholder-class="placeholderclass" class="iteminput" maxlength="5" value="{{unlock_limit}}" bindinput="unlockLimitChange" placeholder=""></input>关
</view>
</view>
<view class="usedesc" data-type="4">学生一天时间内,可以闯几关</view>
</view>
<view class="form-itembox borderbottom1px" data-type="1">
<view class="form-item ">
......@@ -194,6 +195,7 @@
<input type="number" placeholder-class="placeholderclass" class="iteminput" maxlength="5" value="{{max_clock_count}}" bindinput="maxClockCountInput" placeholder=""></input>次
</view>
</view>
<view class="usedesc" data-type="4">学生同一关卡,可以重复打卡几次</view>
</view>
</view>
<view class="modal-dialog" wx:if="{{psdshow}}">
......
......@@ -17,10 +17,10 @@ function themeEditor (data) {
errorresolve: 1,
})
}
function unlockSubjectEditor ({tid, data}) {
function unlockSubjectEditor ({tid, data, school_id}) {
let url = tid == 0 ? apis.business.themeEditor.unlockSubjectCreate : apis.business.themeEditor.unlockSubjectUpdate;
let saveData = {};
saveData = tid != 0 ? Object.assign({id: tid}, data) : data
saveData = tid != 0 ? Object.assign({id: tid}, data, {school_id}) : Object.assign(data, {school_id})
return wxRequest({
role: '2b',
url,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment