Commit 34b2ff20 by jscat

nyx-master:

- 删除不用的matchStudy模块
parent 5f60a876
// pages/key/matchStudy/matchStudy.js
// pages/key/matchStudy/matchStudy.js
var config = wx.getStorageSync("config");
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
//用户信息初始化
nyxCode: "",
authStatus: "",
userInfo: {},
matchSeason: "", // 学习赛季
studyResult: {
"wset1" : "0",
"wset2": "0",
"wset3": "0",
"wset4": "0",
"wine": "0",
"whisky": "0",
"sake": "0",
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
//初始化数据
if (wx.getStorageSync('nyxCode')) {
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
matchSeason: wx.getStorageSync('matchSeason'),
matchType: "daily", // 学习类型
})
}
/**
* 系统配置:主要用于置底页面设置 step2
*/
var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法
this.setData({
windowHeight: windowHeight
})
/* end */
//tips:每次进入都重新更新
var matchSeason = _this.data.matchSeason
var nyxCode = _this.data.nyxCode
_this.getMatchRank(matchSeason, nyxCode);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
var _this = this;
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
// 用户自定义函数
// 获取真实数据
getMatchRank: function (matchSeason, matchTeam) {
var _this = this;
var strUrl = config.match_rank_query_url + '?matchSeason=' + matchSeason + '&matchTeam=' + matchTeam
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.data.resultCode == 200) {
//表示上传成功(可以在阿里云服务器查看上传的图片)
console.log(res.data);
var result = _this.data.studyResult
var list = res.data.data
for (var j = 0; j < list.length; j++) {
var matchType = list[j].matchType
result[matchType] = list[j].ratioFinish == null ? 0 : list[j].ratioFinish
}
wx.setStorageSync('studyResult', result)
_this.setData({
studyResult: result,
})
}
}
})
},
})
\ No newline at end of file
{
{
"usingComponents": {},
"navigationBarTitleText": "知识学习"
}
\ No newline at end of file
<!--pages/key/matchStudy/matchStudy.wxml-->
<!--pages/key/matchStudy/matchStudy.wxml-->
<wxs module="tutil" src="../../../utils/date.wxs"></wxs>
<view class="page">
<view class="workbench">
<text class="title">认证</text>
<view class="list">
<view class="items">
<text>Level-1</text>
<navigator url="matchStudyDetail/matchStudyDetail?studyType=wset1">
<image src="/icon/study/wset2.jpg"></image>
</navigator>
<text>已完成 {{tutil.toFix(studyResult.wset1)}}%</text>
</view>
<view class="items">
<text>Level-2</text>
<navigator url="matchStudyDetail/matchStudyDetail?studyType=wset2">
<image src="/icon/study/wset2.jpg"></image>
</navigator>
<text>已完成 {{tutil.toFix(studyResult.wset2)}}%</text>
</view>
<view class="items">
<text>Level-3</text>
<navigator url="matchStudyDetail/matchStudyDetail?studyType=wset3">
<image src="/icon/study/wset2.jpg"></image>
</navigator>
<text>已完成 {{tutil.toFix(studyResult.wset3)}}%</text>
</view>
<view class="items">
<text>Level-4</text>
<navigator url="matchStudyDetail/matchStudyDetail?studyType=wset4">
<image src="/icon/study/wset2.jpg"></image>
</navigator>
<text>已完成 {{tutil.toFix(studyResult.wset4)}}%</text>
</view>
</view>
</view>
<view class="workbench">
<text class="title">品类</text>
<view class="list">
<view class="items">
<text class="top">红酒</text>
<navigator url="matchStudyDetail/matchStudyDetail?studyType=wine">
<image src="/icon/study/wine.png"></image>
</navigator>
<text class="bottom">已完成 {{tutil.toFix(studyResult.wine)}}%</text>
</view>
<view class="items">
<text >威士忌</text>
<navigator url="matchStudyDetail/matchStudyDetail?studyType=whisky">
<image src="/icon/study/whisky.png"></image>
</navigator>
<text >已完成 {{tutil.toFix(studyResult.whisky)}}%</text>
</view>
</view>
<text>\n</text>
<view class="list">
<!-- start view -->
<view class="items">
<text class="top">清酒</text>
<navigator url="matchStudyDetail/matchStudyDetail?studyType=sake">
<image src="/icon/study/sake.png"></image>
</navigator>
<text class="bottom">已完成 {{tutil.toFix(studyResult.wine)}}%</text>
</view>
<!-- end view -->
<!-- start view -->
<view class="items">
<text class="top">精酿</text>
<navigator url="matchStudyDetail/matchStudyDetail?studyType=beer">
<image src="/icon/study/beer.png"></image>
</navigator>
<text class="bottom">已完成 {{tutil.toFix(studyResult.wine)}}%</text>
</view>
<!-- end view -->
</view>
</view>
</view>
.workbench{
.workbench{
font-size: 30rpx;
background: #fff;
padding-bottom: 30rpx;
margin-bottom:10rpx;
color: #333;
}
.workbench .title{
font-size: 35rpx;
padding: 20rpx 20rpx;
margin-bottom: 40rpx;
display: block;
}
.workbench .items{
width: 100rpx;
flex:1;
text-align: center;
}
.workbench .items image{
width: 100rpx;
height: 100rpx;
}
.workbench .items image.service-icon{
width: 50rpx;
height: 50rpx;
}
.workbench .items text{
display: block;
text-align: center;
margin-top: 0rpx;
margin-bottom: 0rpx;
}
.workbench .items text.top{
display: block;
text-align: center;
margin-bottom: 0rpx;
}
.workbench .items text.bottom{
display: block;
text-align: center;
margin-top: 0rpx;
}
.workbench .list{
display: flex;
flex-direction: row;
flex:1;
}
/* end */
\ No newline at end of file
// pages/key/matchStudy/matchStudyDetail/matchStudyDetail.js
// pages/key/matchStudy/matchStudyDetail/matchStudyDetail.js
var config=wx.getStorageSync("config");
var app=getApp();
Page({
/**
* 系统配置:主要用于置底页面设置 step1
*/
windowHeight: '',
/**
* 页面的初始数据
*/
data: {
//用户信息初始化
nyxCode: "",
authStatus: "",
userInfo: {},
matchSeason: "", // 学习赛季
studyType : "",
/* study 相关 */
/* 学习状态 */
studyStatus :
{
init_score : "0", //初始值,用于计算本次学习的题目数量
total_score : "0", // 已学习的题目数量
total_quiz : "0", // 某一类match_type的总的题目数量
},
isQuizReady : false, //如果该类题目的总数量为0, 则显示此view
isStudyDone : false, //是否已经完成该项学习
studyResult: {
"wset1": "0",
"wset2": "0",
"wset3": "0",
"wset4": "0",
"wine": "0",
"whisky": "0",
"sake": "0",
},
rankList : [],
/*
jscat 20200303
注意upload上传数据和显示数据的差异
显示永远是当前题的questionId,在onClick之前都是未完成状态
而upload永远是OnClick之后的已完成的题的questionId_done
也就是show question和comment需要从questionId来获取
而upload保存的时候需要从questionId_done来获取
此questionId还不能从item_list和item_index来获取,因为获取后10题的时候,item_list也已经随之改变了
*/
/* 问题列表 */
item_list : [],
item_index : 0 ,
score : 0,
questionId : 0, //当前的questionId, 未完成
questionId_done : 0, //上一个questionId, 已完成,用于保存学习状态
/* 某一个问题的当前选项 */
current_item: 10, /* 指向当前button的item */
hidden_type: 1, /* 表明icon的可见程度,0表示可见 1=hidden默认 */
button_disabled : 0, /* 表明button的可用程度, 0表示可用,1表示不可用*/
operateResult : "/icon/icon_success.png",
/* 数据初始化 */
// answer: 5,
// questionId: "",
// questionName: "",
// choiceString: []
quizResult : {},
/* 评论 */
bGetCommentOp : false,
comment_hidden_type : 1,
commentList : [],
likeDict : {},
inputContentValue: null,
isHideLoadMore: false,
pageIndex: 1, //分页搜索的page index
inputHolderValue : "评论才叫真诚",
inputUseridToValue: "",
inputContentToValue: "",
autoFocus: true, //对话框默认为focus
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
//初始化数据
if (wx.getStorageSync('nyxCode')) {
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
matchSeason: wx.getStorageSync('matchSeason'),
})
}
var studyType = _this.data.studyType
if(studyType == "")
{
studyType = options.studyType;
}
wx.setNavigationBarTitle({
title: "知识学习-" + studyType,
})
/**
* 系统配置:主要用于置底页面设置 step2
*/
var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法
this.setData({
windowHeight: windowHeight,
studyType: studyType,
})
/* end */
//如果未拿到数据
if (_this.__data__.item_list.length == 0) {
// 获取总的学习状态: 比如wset2 题目 1/10 表示 已完成/总题数
// 从tbl_match_rank读取, 需要先运行genMatchRank
var matchSeason = _this.data.matchSeason
var nyxCode = _this.data.nyxCode
_this.getStudyStatus(matchSeason, studyType, nyxCode);
// 获取学习的题目, 需要从tbl_match读取
_this.getStudyQuiz(matchSeason, studyType, nyxCode, 0);
wx.setStorageSync('updateStatus', false);
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
var _this = this;
let updateStatus = wx.getStorageSync('updateStatus');
if (updateStatus) {
var score = parseInt(_this.data.studyStatus.total_score) - parseInt(_this.data.studyStatus.init_score)
var sendMsg = JSON.stringify({
'cmd': 'onScore',
'uid': app.globalData.nyxCode == "" ? wx.getStorageSync('nyxCode') : app.globalData.nyxCode,
'msg': "完成" + _this.data.studyType + "栏目,喜提" + score + "分"
})
wx.setStorageSync('sendMsg', sendMsg);
_this.uploadStudy()
}
wx.setStorageSync('updateStatus', false);
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('页面上拉触底')
var _this = this;
var isHideLoadMore = _this.__data__.isHideLoadMore;
var objectId = _this.__data__.questionId;;//获取当前questionId的值,未完成的题
var pageIndex = _this.__data__.pageIndex;
//控制逻辑, 在onClick之后或者onGetComment事件之后再允许下拉更新操作
//避免下拉更新发生在之前
var bGetCommentOp = _this.__data__.bGetCommentOp
if (bGetCommentOp == true) {
//判断是否已经全部加载完毕
//没有则加载更多
if (!isHideLoadMore) {
console.log('加载更多')
setTimeout(() => {
_this.getComment(1, pageIndex, 4, objectId);
}, 1000)
}
else {
console.log('没有更多')
}
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
/*
* 动态的高亮选中的button
* disable未选中的button
* 点击选项说明已经学习完该题
*/
onClick: function (e) {
var _this = this;
let cuu = e.target.id;//获取index值
console.log(cuu);
var operateResult = "";
var answer = _this.__data__.quizResult.answer;
var score = _this.__data__.score;
var questionId_done = _this.__data__.questionId; //如果点击, 则默认此题已学习完毕
var studyStatus = _this.__data__.studyStatus;
studyStatus.total_score = parseInt(studyStatus.total_score) + 1 //同时总的学习题数+1
if(cuu == answer-1)
{
operateResult = "/icon/icon_success.png"
score = score + 1
}
else{
operateResult = "/icon/icon_fail.png"
}
var selected = parseInt(cuu) + 1
console.log("current choice is: \"" + selected + "\"");
console.log("correct answer is: \"" + answer + "\"");
console.log("current button_disabled is: \"" + 1 + "\"");
//设置为已更新状态
wx.setStorageSync('updateStatus', true)
//优先获取comment
//避免使用onGetComment, 因为此处没有onGetComment的点击事件
var bGetCommentOp = _this.__data__.bGetCommentOp
if (bGetCommentOp == false) {
//获取第一页数据,每页四条
_this.getComment(0, 1, 4, _this.data.questionId)
}
//ps: jscat 20200303 最后重置状态
_this.setData({
questionId_done: questionId_done, //用于存储题号 select * from tbl where id > questionId_done;
current_item: cuu,
operateResult: operateResult,
hidden_type: 0,
button_disabled: 1,
score: score,
comment_hidden_type: 0, /* 点击按钮之后,评论自动弹出 */
studyStatus: studyStatus, //用于本地更新学习成绩
})
},
/* 点击 进入下一题 */
// item_index要增加,需要在进入下一题时候进行
onTypeNext: function (e) {
var _this = this;
//拿到当前的index
var current_index = _this.__data__.item_index;
var button_disabled = _this.__data__.button_disabled;
var matchSeason = _this.__data__.matchSeason
var studyType = _this.__data__.studyType
var matchTeam = _this.__data__.nyxCode
//将指针指向下一题,与questionId对应
current_index = current_index + 1
/*
未按下button,在"查看评论"和"隐藏评论"中切换
已按下button,则直接显示评论,同时显示"下一题"
*/
//具体功能实现
//首先重置数据状态
_this.setData({
item_index: current_index, //已经指向下一题
hidden_type: 1,
button_disabled: 0,
current_item: 10, /* 指向当前button的item */
comment_hidden_type: 1, /* 默认隐藏comment */
commentList: [],
bGetCommentOp: false,
inputContentValue: "", //清除提交内容
inputHolderValue: "评论才叫真诚",
inputUseridToValue: "",
inputContentToValue: "",
})
// 如果已完成所有的题目
// 判断: 当前获取的题目length<10, 比如只有5个
// 而指向下一题current_index的已经=5,则表明所有题目都已经学习完毕
if (_this.__data__.item_list.length < 10 && current_index >= _this.__data__.item_list.length)
{
config.debug==1?console.log("=== length_"+_this.__data__.item_list.length+"_item_index"+current_index):""
_this.doneStudy()
}
else
{
//如果超过了10题, 重置数据, 重新获取数据
//说明当前十组题回答完毕了
//获取下10题 (current_index from [0...9])
if (current_index >= 10)
{
var questionId_done = _this.__data__.questionId_done
_this.getStudyQuiz(matchSeason, studyType, matchTeam, questionId);
}
else //继续获取下一题
{
var questionId = _this.__data__.item_list[current_index]
_this.getData(questionId)
}
}
//载入页面
getCurrentPages()[getCurrentPages().length - 1].onLoad()
},
// 获取学习部分的Quiz
getStudyQuiz: function (matchSeason, studyType, matchTeam, quizId) {
var _this = this;
var strUrl = config.quiz_study_query_url + '?matchSeason=' + matchSeason + '&matchType=' + studyType
+ '&matchTeam=' + matchTeam + '&quizId=' + quizId
config.debug==1?console.log("===getStudyQuiz strUrl_" +strUrl):""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
console.log(res.data);
var itemList = [];
for (var k = 0; k < res.data.totalCount; k++) {
itemList.push(res.data.data[k].id)
}
_this.setData({
item_list: itemList,
item_index: 0, //默认从0开始
})
var wid = itemList[0]
if(wid!= null)
{
_this.getData(wid)
}
}
})
},
// 获取真实数据
getData: function (questionId) {
var _this = this;
var strUrl = config.data_url + '?questionId=' + questionId
config.debug==1?console.log("===getData strUrl_"+strUrl):""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.data.resultCode == 200) {
//表示查询成功
console.log(res.data);
var result = {}
result["questionId"] = res.data.data["0"].id
result["questionName"] = res.data.data["0"].questionName
result["answer"] = res.data.data["0"].answer
var list = res.data.data["0"].choiceString.split("::")
for (var j = 0; j < list.length; j++) {
var str = "A";
list[j] = (String.fromCharCode(str.charCodeAt()+j)) +". "+ list[j];
}
result["choiceString"] = list
_this.setData({
quizResult : result,
questionId: questionId,
})
}
}
})
},
// 如果完成了学习
doneStudy: function (res) {
var _this = this
wx.showModal({
title: '恭喜你完成该项学习',
content: '正确率'+_this.__data__.score + '/10',
showCancel: false, // 将cancel按钮disable掉
confirmText: '谢谢老师',
success(res) {
if (res.confirm) {
// 用户点击了确定属性的按钮,于是跳转到tabbar /pages/key/key
// wx.navigateTo 和 wx.redirectto都无法跳转到tabbar
_this.setData({
isStudyDone: _this.data.isQuizReady==true ? true: false,
})
// 基于用户交互原则,不直接跳转到/pages/key/key页面, 让用户自主选择
// wx.switchTab({
// url: '/pages/key/key'
// });
}
}
})
},
// 这题有问题; report bug
onReportBug: function (e) {
var _this = this
/* 调用接口新增bug记录 2019-12-13
通过x-www-form-urlencoded 格式调用,可以兼容swagger的前端请求
*/
var questionId = _this.__data__.questionId
config.debug == 1 ? console.log("===onReportBug strUrl_" + config.bug_url + "_id_" + questionId):""
wx.request({
url: config.bug_url,
method: 'POST',
data: {
questionId: _this.__data__.questionId,
userId: _this.__data__.nyxCode, //获取userid
userComment : "格式错误"
},
header: {
"Content-Type": "application/x-www-form-urlencoded",
'Cookie': wx.getStorageSync('cookieKey'),
},
dataType : "json",
success: function (res) {
var score = parseInt(_this.__data__.score) + 1;
var studyStatus = _this.__data__.studyStatus;
studyStatus.total_score = parseInt(studyStatus.total_score) + 1 //同时总的学习题数+1
_this.setData({
score: score, //更新正确得分
button_disabled : 1,
questionId_done: questionId, //用于存储已完成题号 select * from tbl where id > questionId_done;
studyStatus: studyStatus, //用于更新已完成题数
})
config.debug == 1 ? console.log("===onBug score_" + score + "_idDone_" + questionId + "_total_score_" + studyStatus.total_score):""
//设置为已更新状态
wx.setStorageSync('updateStatus', true)
/*通过弹窗方式确认 */
// begin showModal
wx.showModal({
title: '谢谢你反馈问题',
content: '此题已判定为正确',
showCancel: false, // 将cancel按钮disable掉
confirmText: '下一题',
success(res) {
if (res.confirm) {
// 用户点击了确定属性的按钮,于是跳转到tabbar /pages/key/key
// wx.navigator 和 wx.redirectto都无法跳转到tabbar
console.log("showModal success");
console.log(res)
}
},
fail: function (res) {
console.log("showModal failed");
console.log(res)
},//接口调用失败的回调函数
complete: function (res) {
console.log("showModal complete");
console.log(res)
},//接口调用结束的回调函数(调用成功、失败都会执行)
}) // end showModal
//载入页面
_this.onTypeNext();
} // end success
}) // end wx.request
console.log("show modal");
},
/*
* 用户自定义函数
* 查看评论
* 输入值为quiz id
* 默认返回5条
*/
// 获取评论 per quiz id
getComment(scrollType, pageNum, pageCount, objectId)
{
var _this = this;
var strUrl = "";
if (pageNum != 0 && pageCount != 0) {
strUrl = config.msg_query_url + "?pageCount=" + pageCount
+ "&pageNum=" + pageNum
+ "&objectId=" + objectId
}
config.debug==1?console.log("===getComment strUrl_" + strUrl):1
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.data.resultCode == 200) {
//表示查询成功
console.log(res.data);
var list = res.data.data
var bisHideLoadMoreType = false;
if (list.length < pageCount) {
bisHideLoadMoreType = true;
}
//进行翻页设置(加载更多)
if (scrollType == 1) {
var commentList = _this.__data__.commentList;
list = commentList.concat(list)
}
_this.setData({
commentList: list,
isHideLoadMore: bisHideLoadMoreType,
pageIndex: pageNum + 1,
bGetCommentOp: true,
})
}
}
})
},
onGetComment: function (e) {
var _this = this;
var objectId = _this.__data__.questionId;//获取index值
var commentList = _this.__data__.commentList
var bGetCommentOp = _this.__data__.bGetCommentOp
config.debug==1?console.log("===onGetComment objectId is_" + objectId):""
if (bGetCommentOp == false || bGetCommentOp == undefined)
{
//获取第一页数据,每页四条
_this.getComment(0, 1, 4, objectId)
}
_this.setData({
comment_hidden_type: _this.data.comment_hidden_type == 1 ? 0 : 1,
})
},
/*
* 提交评论
*/
submitComment: function (objectId, objectName, useridFrom, useridTo, content, contentTo)
{
var _this = this
var strUrl = config.msg_add_url
config.debug == 1 ? console.log("===submitComment strUrl_" + strUrl + "_objectId_" + objectId
+ "_useridFrom_" + useridFrom
+ "_useridTo_" + useridTo
+ "_content_" + content
+ "_contentTo_" + contentTo
) : ""
wx.request({
url: strUrl,
method: 'POST',
data: {
commentType: '知识学习',
objectId: objectId,
objectName: objectName,
useridFrom: useridFrom,
useridTo : useridTo,
content :content,
contentTo: contentTo,
},
header: {
"Content-Type": "application/x-www-form-urlencoded",
'Cookie': wx.getStorageSync('cookieKey'),
},
dataType: "json",
success: function (res) {
if (res.data.resultCode == 200) {
//表示提交成功
console.log(res.data);
var list = res.data.data['0']
var commentList = _this.data.commentList
commentList.push(list)
_this.setData({
commentList: commentList,
inputContentValue: "", //清除提交内容
inputHolderValue: "评论才叫真诚",
inputUseridToValue: "",
inputContentToValue: "",
})
}
}
})
},
onSubmitComment: function (e) {
var _this = this;
var objectId = _this.__data__.questionId //获取index值
var objectName = _this.__data__.quizResult.questionName //获取index值
let content = e.detail.value.content;//获取评论内容
var useridFrom = _this.__data__.nyxCode;//获取userid
var useridTo = e.detail.value.useridTo;//获取评论内容
var contentTo = e.detail.value.contentTo;//获取reply content
if(content != undefined && content != "")
{
_this.submitComment(objectId, objectName, useridFrom, useridTo, content, contentTo)
}
},
/*
* 提交点赞
*/
submitLike:function(commentId)
{
var _this = this;
var strUrl = config.msg_like_url + '?commentId=' + commentId
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.statusCode == 200) {
//表示查询成功
console.log(res.data);
var commentList = _this.data.commentList
var likeDict = _this.data.likeDict
for (var j = 0; j < commentList.length; j++) {
if(commentList[j].commentId == commentId)
commentList[j].numLike = parseInt(commentList[j].numLike) + 1
likeDict[commentId] = 1
}
_this.setData({
likeDict: likeDict,
commentList : commentList,
})
}
}
})
},
onSubmitLike: function (e) {
var _this = this;
let commentId = e.currentTarget.dataset.commentId;//获取评论内容
var useridFrom = _this.__data__.nyxCode;//获取userid
var likeDict = _this.__data__.likeDict;//获取userid
if(likeDict[commentId] == 0 || likeDict[commentId] == undefined)
{
_this.submitLike(commentId)
}
},
/*
* 回复里@某人
*/
onReplyUser : function (e)
{
var _this = this;
let nickname = e.currentTarget.dataset.nickname; //获取nickname的值
let useridTo = e.currentTarget.dataset.userid; //获取useridTo的值
let contentTo = e.currentTarget.dataset.contentTo; //获取contentTo的值
_this.setData({
inputHolderValue: "@" + nickname,
inputUseridToValue: useridTo,
inputContentToValue: contentTo,
autoFocus: true,
})
},
onCancelReply: function (e) {
var _this = this;
var content = e.detail.value
if (content == "" && _this.__data__.inputUseridToValue != "")
{
this.setData({
inputHolderValue: "评论才叫真诚",
inputUseridToValue: "",
inputContentToValue: "",
});
}
},
getStudyStatus: function(matchSeason, studyType, yourname)
{
var _this = this;
var strUrl = config.match_rank_query_url + '?matchSeason=' + matchSeason
+ '&matchType=' + studyType
+ '&matchTeam=' + yourname
config.debug==1?console.log("===getStudyStatus strUrl_"+strUrl):""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.statusCode == 200) {
//表示查询成功
console.log(res.data);
var rankResult = res.data.data
// 如果match_rank表有记录
if(rankResult.length > 0)
{
var studyStatus = {}
studyStatus['init_score'] = rankResult['0'].score
studyStatus['total_score'] = rankResult['0'].score
studyStatus['total_quiz'] = rankResult['0'].totalQuiz
_this.setData({
rankList: rankResult,
studyStatus : studyStatus,
isQuizReady: rankResult['0'].totalQuiz>0 ? true: false,
isStudyDone: parseInt(rankResult['0'].ratioFinish)==1 ? true : false,
})
}
else
{
_this.getTotalQuiz(studyType)
}
}
}
})
},
getTotalQuiz: function (studyType) {
var _this = this;
var strUrl = config.quiz_total_query_url + '?matchType=' + studyType
config.debug == 1 ? console.log("===getTotalQuiz strUrl_" + strUrl) : ""
wx.request({
url: strUrl,
method: 'GET',
header: {
'Cookie': wx.getStorageSync('cookieKey'),
},
success: function (res) {
if (res.statusCode == 200) {
//表示查询成功
console.log(res.data);
var totalResult = res.data.data
// 如果match_rank表有记录
if (totalResult.length > 0) {
var studyStatus = {}
studyStatus['init_score'] = '0'
studyStatus['total_score'] = '0'
studyStatus['total_quiz'] = totalResult['0'].total == null ? '0' : totalResult['0'].total
_this.setData({
studyStatus: studyStatus,
isQuizReady: totalResult['0'].total != "0" ? true : false,
})
}
}
}
})
},
/*
* 更新tbl_match_rank的记录
*/
updateRankDefault() {
var _this = this;
var strUrl = config.match_rank_update_url;
var rankList = _this.data.rankList
var rankId = "rid_" + _this.data.matchSeason + "_" + _this.data.studyType + "_"+_this.data.nyxCode
var score = _this.data.studyStatus.total_score
var total = _this.data.studyStatus.total_quiz
var ratioFinish = (parseInt(_this.data.studyStatus.total_score) / parseInt(_this.data.studyStatus.total_quiz)).toFixed(2) + ''
config.debug == 1 ? console.log("===updateRankDefault strUrl_" + strUrl + "_score_" + score +"_ratioFinish_"+ratioFinish) : ""
if (rankList.length == 0) {
var result = {}
result['rankId'] = rankId
result['matchSeason'] = _this.data.matchSeason
result['matchType'] = _this.data.studyType
result['matchTeam'] = _this.data.nyxCode
result['defaultType'] = "0"
result['score'] = _this.data.studyStatus.total_score
result['rank'] = "0"
result['totalMatch'] = "0"
result['totalQuiz'] = _this.data.studyStatus.total_quiz
result['ratioRank'] = "0"
result['ratioFinish'] = ratioFinish
result['createDatetime'] = _this.formatDate(new Date())
rankList.push(result)
}
else
{
rankList['0']['rankId'] = rankId
rankList['0']['matchSeason'] = _this.data.matchSeason
rankList['0']['matchType'] = _this.data.studyType
rankList['0']['matchTeam'] = _this.data.nyxCode
rankList['0']['score'] = _this.data.studyStatus.total_score
rankList['0']['ratioFinish'] = ratioFinish
rankList['0']['createDatetime'] = _this.formatDate(new Date())
}
//暂存数据
if (wx.getStorageSync('studyResult')) {
var result = wx.getStorageSync('studyResult')
result[_this.data.studyType] = ratioFinish
wx.setStorageSync('studyResult', result)
_this.setData({
studyResult: result,
})
}
wx.request({
url: strUrl,
method: 'POST',
data: JSON.stringify(rankList),
header: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Cookie': wx.getStorageSync('cookieKey'),
},
dataType: "json",
success: function (res) {
console.log("排名记录成功");
} // end success
}) // end wx.request
},
/*
更新tbl_match的记录
*/
updateMatch() {
var _this = this;
var strUrl = config.match_add_item_url
var score = parseInt(_this.data.studyStatus.total_score) - parseInt(_this.data.studyStatus.init_score)
var id = _this.data.questionId_done
config.debug==1?console.log("===updateMatch strUrl_"+strUrl+"_id_"+id+"_score_"+score):""
wx.request({
url: strUrl,
method: 'POST',
data: {
matchSeason: _this.data.matchSeason,
matchType: _this.data.studyType,
matchTeam: _this.data.nyxCode,
matchScore: parseInt(_this.data.studyStatus.total_score)-parseInt(_this.data.studyStatus.init_score),
teamType: "blue",
matchResult: "1",
quizIndex: _this.data.questionId_done,
rankScore: parseInt(_this.data.studyStatus.total_score)-parseInt(_this.data.studyStatus.init_score),
},
header: {
"Content-Type": "application/x-www-form-urlencoded",
'Cookie': wx.getStorageSync('cookieKey'),
},
dataType: "json",
success: function (res) {
if (res.statusCode == 200) {
//表示提交成功
console.log("比赛记录成功");
}
}
})
},
/*更新学习记录 */
uploadStudy: function (e) {
var _this = this;
_this.updateMatch();
_this.updateRankDefault();
getCurrentPages()[getCurrentPages().length - 2].onLoad()
},
//inputTime 参数是毫秒级时间戳
formatDate(inputTime) {
var date = new Date(inputTime);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
},
})
\ No newline at end of file
{
{
"usingComponents": {},
"navigationBarTitleText": "知识学习"
}
\ No newline at end of file
<!--pages/key/matchStudyDetail/matchStudyDetail.wxml-->
<!--pages/key/matchStudyDetail/matchStudyDetail.wxml-->
<wxs module="tutil" src="../../../../utils/date.wxs"></wxs>
<view class="page bottom_fixed_page" style="min-height:{{ windowHeight }}px">
<view class="weui-flex">
<view class="weui-flex__item"><view class="placeholder">题目:{{studyStatus.total_score}}/{{studyStatus.total_quiz}}题</view></view>
<view class="weui-flex__item"><view class="placeholder">分数:{{score}}</view></view>
</view>
<view class="weui-loadmore" hidden="{{isQuizReady}}">
<view class="weui-loadmore__tips">题目准备中, 敬请期待 {{'>'}}_{{'<'}} </view>
</view>
<view class="weui-loadmore" hidden="{{!isStudyDone}}">
<view class="weui-loadmore__tips">好牛哦, 恭喜你已完成该项挑战 {{'>'}}_{{'<'}} </view>
</view>
<view hidden="{{isStudyDone}}"> <!-- start of isStudyDone flag -->
<view class="page__hd">
<!-- 标题 -->
<view class="page__desc">{{quizResult.questionName}}</view>
</view>
<view class="page__bd " wx:for-items="{{quizResult.choiceString}}" >
<button class="weui-btn button-sp-area {{current_item == index?'btn-selected':'btn-not-selected'}}" bind:tap="onClick" disabled="{{button_disabled==1?true:false}}" id="{{index}}">
<image src="{{operateResult}}" style="vertical-align:middle;width:60rpx;height:60rpx" hidden="{{hidden_type==1?true:(current_item == index?false:true)}}" />
{{item}}
</button>
</view>
<view class="page__hd" hidden="{{button_disabled==0}}">
<!-- 优化: 直接显示正确答案 -->
<view class="page__desc">推荐答案: {{tutil.formatAnswer(quizResult.answer)}}</view>
</view>
<!-- <text>\n</text> -->
<view class="weui-flex" hidden="{{!isQuizReady}}" >
<view class="weui-flex__item" bindtap="{{button_disabled==0?'onGetComment':'onTypeNext'}}">
<view class="placeholder-button">
<image src="{{button_disabled==0?(comment_hidden_type==1?'/icon/matchDaily/checkComment.png':'/icon/matchDaily/checkComment.png'):'/icon/matchDaily/next.png'}}" style="vertical-align:middle;width:60rpx;height:60rpx" />
{{button_disabled==0?(comment_hidden_type==1?"查看评论":"隐藏评论"):"下一题"}}</view>
</view>
<view class="weui-flex__item"><view class="{{button_disabled==0?'placeholder-button':'placeholder-button-disabled'}}" bind:tap="onReportBug">
<image src="{{button_disabled==0?'/icon/matchDaily/question.png':'/icon/matchDaily/question_0.png'}}" style="vertical-align:middle;width:60rpx;height:60rpx" />这题有问题</view>
</view>
</view>
<!-- 评论区 -->
<view class="page__bd" hidden="{{comment_hidden_type==1?true:false}}">
<view class="weui-panel weui-panel_access" wx:for="{{commentList}}" wx:key="commentList">
<view class="weui-panel__bd weui-media-box weui-media-box_appmsg" bind:tap="onReplyUser" data-nickname="{{item.nicknameFrom}}" data-userid="{{item.useridFrom}}" data-content-to="{{item.content}}">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{item.avatarUrlFrom}}" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell" style="height:20rpx;text-align:left;padding-left:0rpx;margin:0rpx">
<view class="weui-cell__bd" style="text-align:left;padding:rpx;margin:0rpx">
<!-- start id+日期 -->
<view class="workbench">
<view class="items weui-media-box__desc">
<text>{{item.nicknameFrom}}</text>
<text class="bottom">{{tutil.formatDate_ymd(item.createDatetime)}}</text>
</view>
</view>
<!-- end id+date -->
</view>
<!-- start 点赞数 + 图标 -->
<view class="weui-media-box__desc" style="font-size:30rpx">
{{item.numLike}}
<view bindtap="onSubmitLike" data-comment-id="{{item.commentId}}">
<image src="/icon/matchDaily/like.png" style="width:30rpx;height:30rpx" />
</view>
</view>
<!-- end 点赞数 + 图标 -->
</view>
</view>
<view class="weui-media-box__desc">{{item.nicknameTo==null?"":"@"+item.nicknameTo+" "}}{{item.content}}</view>
</view>
</view>
</view>
<view class="weui-loadmore" hidden="{{isHideLoadMore}}">
<view class="weui-loading"></view>
<view class="weui-loadmore__tips">正在加载</view>
</view>
<view class="weui-loadmore" hidden="{{!isHideLoadMore}}">
<view class="weui-loadmore__tips">没有更多啦 {{'>'}}_{{'<'}} </view>
</view>
<!-- 评论栏置底 -->
<view class="page__hd bottom_fixed_view" style="position:fixed; bottom:0;width: 750rpx;" >
<view class="weui-panel weui-panel_access">
<view class="weui-panel__ft">
<form catchsubmit="onSubmitComment" >
<view class="weui-cell weui-cell_access">
<view class="weui-cell__bd">
<input class="weui-input" type="text" name="content" focus="{{autoFocus}}" value='{{inputContentValue}}' pattern="" placeholder="{{inputHolderValue}}" bindblur="onCancelReply" />
<input type="text" style="display:none" name="useridTo" value='{{inputUseridToValue}}'/>
<input type="text" style="display:none" name="contentTo" value='{{inputContentToValue}}'/>
</view>
<view class="weui-cell__ft">
<button type="default" formType="submit">发送</button>
</view>
</view>
</form>
</view>
</view>
</view>
</view>
</view> <!-- end of isStudyDone flag -->
</view>
page{background-color:#EDEDED;}
page{background-color:#EDEDED;}
.button-sp-area{
margin-top: 20rpx; /* 用于表示button与button之间的间隔 */
padding-top: 0px;
margin-left: 0rpx;
padding-left: 100rpx;
text-align:left;
line-height: 60rpx; /*缩小行间距 */
font-size: 40rpx;
}
.mini-btn{
margin: 0 4px;
}
.btn-selected{
/* background-color: #ffffff; */
color: rgb(105, 72, 16);
border-color: #00ff00;
border-style:solid;
border-width:2px;
}
.btn-not-selected{
/* background-color: #111111; */
color: rgb(105, 72, 16);
}
.icon-success{
color: greenyellow;
size: 21px;
margin-top: 20rpx; /* 用于表示button与button之间的间隔 */
}
.icon-cancel{
color: red;
size: 21px;
margin-top: 20rpx; /* 用于表示button与button之间的间隔 */
}
.text{
font-size: 6px;
line-height: 0.5em;
}
.container {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
width: 100%;
line-height: 80rpx;
height: 100rpx;
}
.left {
color: #888;
}
.right {
color: #ff0000;
}
.placeholder{
margin: 5px;
padding: 0 10px;
text-align: center;
background-color: #F7F7F7;
height: 2.3em;
line-height: 2.3em;
color: rgba(0,0,0,.3);
}
.placeholder-button{
margin: 5px;
padding: 0 10px;
text-align: center;
background-color: #F7F7F7;
height: 2.3em;
line-height: 2.3em;
color: rgba(198, 133, 36);
font-size: 35rpx;
font-weight: bold;
}
.placeholder-button-disabled{
margin: 5px;
padding: 0 10px;
text-align: center;
background-color: #F7F7F7;
height: 2.3em;
line-height: 2.3em;
color: rgba(0,0,0,.3);
font-size: 35rpx;
font-weight: bold;
pointer-events: none;
}
/**
* 系统配置:主要用于置底页面设置 step3
*/
.bottom_fixed_page{
position: relative;
padding-bottom: 56px; /* 需要定位的盒子的高度 */
box-sizing: border-box;
}
.bottom_fixed_view {
position: fixed;
bottom:0;
}
/*
id+date css
*/
.workbench{
font-size: 25rpx;
padding-bottom: 0rpx;
margin-bottom: 0rpx;
}
.workbench .items{
width: 200rpx;
flex:1;
text-align: left;
}
.workbench .items text{
display: block;
text-align: left;
margin-top: 0rpx;
margin-bottom: 0rpx;
}
.workbench .items text.bottom{
font-size: 25rpx;
display: block;
text-align: left;
margin-top: 3rpx;
}
/* end */
/* 加载更多 */
.weui-loading {
margin: 0 5px;
width: 20px;
height: 20px;
display: inline-block;
vertical-align: middle;
-webkit-animation: weuiLoading 1s steps(12, end) infinite;
animation: weuiLoading 1s steps(12, end) infinite;
background: transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat;
background-size: 100%;
}
.weui-loadmore {
width: 65%;
margin: 1.5em auto;
line-height: 1.6em;
font-size: 14px;
text-align: center;
}
.weui-loadmore__tips {
display: inline-block;
vertical-align: middle;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论