Commit c29e05e6 by jscat

nyx javaapp/weapp: 更新

1. weapp前端, javaapp后端联调, 完成竞答答题及结果入库流程
parent 32cfc084
USE rockwell_key; USE rockwell_key;
...@@ -19,20 +19,21 @@ USE rockwell_key; ...@@ -19,20 +19,21 @@ USE rockwell_key;
DROP TABLE IF EXISTS tbl_match; DROP TABLE IF EXISTS tbl_match;
CREATE TABLE tbl_match ( CREATE TABLE tbl_match (
`match_id` VARCHAR(100) COMMENT '竞答的id, uuid format, mid_001', `match_id` VARCHAR(100) COMMENT '竞答的id, uuid format, mid_001',
`activity_id` VARCHAR(100) COMMENT '活动的id, uuid format, mid_001', `activity_id` VARCHAR(100) COMMENT '活动的id, uuid format, aid_001',
`user_id` VARCHAR(100) COMMENT '用户的id, uuid format, uid_001', `user_id` VARCHAR(100) COMMENT '用户的id, uuid format, uid_001',
`match_status` VARCHAR(2) COMMENT '(可用|不可用): 01|00; 为什么00,因为所有RequestParam参数的defaultValue都设为0值, 会被认为是空或者null', `match_status` VARCHAR(2) COMMENT '(可用|不可用): 01|00; 为什么00,因为所有RequestParam参数的defaultValue都设为0值, 会被认为是空或者null',
`match_point` double(10,2) COMMENT '得分: 4.5 or 5.0', `match_point` double(10,2) COMMENT '得分: 4.5 or 5.0',
`match_result` VARCHAR(20) COMMENT '结果: 9/10', `match_result` VARCHAR(20) COMMENT '结果: 9/10',
`member_id` VARCHAR(100) COMMENT '商家的id, uuid format, mid_001',
`qrcode_url` VARCHAR(200) COMMENT 'qrcode的二维码url', `qrcode_url` VARCHAR(200) COMMENT 'qrcode的二维码url',
`create_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', `create_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`update_datetime` DATETIME DEFAULT NULL, `update_datetime` DATETIME DEFAULT NULL,
PRIMARY KEY(`match_id`), PRIMARY KEY(`match_id`),
KEY `query_key` (`activity_id`, `user_id`, `match_status`)) KEY `query_key` (`activity_id`, `member_id`, `user_id`, `match_status`))
ENGINE=INNODB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT='竞答结果'; ENGINE=INNODB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT='竞答结果';
INSERT INTO `tbl_match`(`match_id`, `activity_id`, `user_id`, `match_status`, `match_point`, `match_result`, `qrcode_url`, `create_datetime`,`update_datetime`) INSERT INTO `tbl_match`(`match_id`, `activity_id`, `user_id`, `match_status`, `match_point`, `match_result`, `member_id`, `qrcode_url`, `create_datetime`,`update_datetime`)
VALUES VALUES
('mid_001', 'aid_001', 'uid_030e7057-e6b5-4fb0-bcbf-d8bf055e38d9', '00', 4.0, '4/5', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'), ('mid_001', 'aid_001', 'uid_030e7057-e6b5-4fb0-bcbf-d8bf055e38d9', '00', 4.0, '4/5', 'mid_123', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'),
('mid_002', 'aid_001', 'uid_030e7057-e6b5-4fb0-bcbf-d8bf055e38d9', '01', 3.0, '3/5', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'), ('mid_002', 'aid_001', 'uid_030e7057-e6b5-4fb0-bcbf-d8bf055e38d9', '01', 3.0, '3/5', 'mid_123', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'),
('mid_003', 'aid_002', 'uid_088a957b-78e9-49cd-980b-ce8bc47b4e11', '01', 4.0, '8/10', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45'); ('mid_003', 'aid_002', 'uid_088a957b-78e9-49cd-980b-ce8bc47b4e11', '01', 4.0, '8/10', 'mid_123', 'https://930-test-sh.oss-cn-shanghai.aliyuncs.com/qrcode-dir/mid_11235813.png', '2019-11-20 11:24:45', '2019-11-20 11:24:45');
\ No newline at end of file \ No newline at end of file
/* /*
...@@ -67,25 +67,24 @@ ...@@ -67,25 +67,24 @@
-- 创建完毕 -> 发布 releaseActivity() -- 创建完毕 -> 发布 releaseActivity()
-- 我的活动 -> 发布 releaseActivity() -- 我的活动 -> 发布 releaseActivity()
三. 商家活动参与流程 三. 商家活动参与流程 activity -> quiz-info -> matchTest -> quiz-result -> my-points
三. 商家活动参与流程
1. 竞答 1. 竞答
--311 进入竞答, weapp activity.wxml --311 done 进入竞答, weapp activity.wxml
--312 点击进入竞答详情页面 weapp activity.wxml <navigator> --312 done 点击进入竞答详情页面 weapp activity.wxml <navigator>
--313 回到首页 weapp quiz-info.wxml bindtap="toHome" --313 回到首页 weapp quiz-info.wxml bindtap="toHome"
--314 页面分享 weapp quiz-info.js options.from == 'button' --314 页面分享 weapp quiz-info.js options.from == 'button'
--315 右上角分享 weapp quiz-info.js onShareAppMessage() --315 右上角分享 weapp quiz-info.js onShareAppMessage()
--316 立即参与 weapp quiz-info.wxml bindtap="toGame" --316 done 立即参与 weapp quiz-info.wxml bindtap="toGame"
--317 转到竞答页 weapp quiz-info.js wx.navigateTo(/matchTest) --317 done 转到竞答页 weapp quiz-info.js wx.navigateTo(/matchTest)
--318 下一题 weapp matchTest.wxml bindtap="onTypeNext" --318 done 下一题 weapp matchTest.wxml bindtap="onTypeNext"
--319 完成测试 weapp matchTest.js doneDaily() --319 done 完成测试 weapp matchTest.js doneDaily()
--3110 转到结果页 weapp quiz-info.js wx.navigateTo(/quiz-result) --3110 转到结果页 weapp quiz-info.js wx.navigateTo(/quiz-result)
--3111 查看积分 weapp quiz-result.wxml bindtap="onCheckPoints" --3111 查看积分 weapp quiz-result.wxml bindtap="onCheckPoints" to my-points.wxml
--3112 分享战绩 weapp quiz-result.wxml open-type="share" --3112 分享战绩 weapp quiz-result.wxml open-type="share"
--3113 返回首页 weapp quiz-result.wxml bindtap="toHome" --3113 返回首页 weapp quiz-result.wxml bindtap="toHome"
2. 活动 2. 活动
--321 进入活动, weapp activity.wxml --321 done 进入活动, weapp activity.wxml
图片 note_image 图片 note_image
标题 title 标题 title
价格 unit_price 价格 unit_price
...@@ -94,7 +93,9 @@ ...@@ -94,7 +93,9 @@
where 1=1 where 1=1
and tag='活动' and tag='活动'
--322 点击进入活动详情页面 weapp activity_info.wxml todo 新增 activity_info.wxml todo-1:1的image --322 点击进入活动详情页面 weapp activity_info.wxml todo 新增 activity_info.wxml todo-1:1的image
tips: 需要通过activity_id重新获取数据, 因为unit_price/product_desc 这个阶段不知道
图片 note_image 图片 note_image
价格 unit_price1/unit_price2 价格 unit_price1/unit_price2
标题 title 标题 title
......
// pages/activity/activity.js // pages/activity/activity.js
...@@ -218,15 +218,20 @@ Page({ ...@@ -218,15 +218,20 @@ Page({
result["product_desc"] = res.data.data[i].productDesc result["product_desc"] = res.data.data[i].productDesc
result["price"] = res.data.data[i].price result["price"] = res.data.data[i].price
result["note_image"] = res.data.data[i].noteImage.split("::") result["note_image"] = res.data.data[i].noteImage.split("::")
var url = "../activity/quiz-info/quiz-info?" var url_quiz = "../activity/quiz-info/quiz-info?"
+"&activity_id="+result["activity_id"]
+"&note_image="+res.data.data[i].noteImage //传递原始string数据, List不正确 +"&note_image="+res.data.data[i].noteImage //传递原始string数据, List不正确
+"&title="+result["title"] +"&title="+result["title"]
+"&content="+result["content"] +"&content="+result["content"]
+"&like="+result["num_like"] +"&like="+result["num_like"]
+"&quiz="+result["quiz"] +"&quiz="+result["quiz"]
+"&point="+result["point"]
+"&member_id="+result["member_id"]
+"&member_name="+result["member_name"] +"&member_name="+result["member_name"]
+"&member_slogan="+result["member_slogan"] +"&member_slogan="+result["member_slogan"]
result["url"] = url var url_activity = "../activity/activity-info/quiz-info?"
+"&activity_id="+result["activity_id"]
result["url"] = result["tag"]=='竞答'? url_quiz : url_activity
list.push(result) list.push(result)
} }
......
// pages/index/note-info/note-info.js // pages/index/note-info/note-info.js
...@@ -6,6 +6,11 @@ Page({ ...@@ -6,6 +6,11 @@ Page({
*/ */
data: { data: {
/* 用于判断是否已经登陆 */
nyxCode : "",
authStatus : "0",
userInfo : {},
windowHeight: "", windowHeight: "",
windowWidth: "", windowWidth: "",
contentHeight: "", contentHeight: "",
...@@ -28,14 +33,26 @@ Page({ ...@@ -28,14 +33,26 @@ Page({
contentHeight : windowHeight * 0.675, contentHeight : windowHeight * 0.675,
}) })
//初始化数据
if (wx.getStorageSync('nyxCode')) {
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
})
}
var quiz = _this.__data__.quiz var quiz = _this.__data__.quiz
if (Object.keys(quiz).length==0 && options.title != "") if (Object.keys(quiz).length==0 && options.title != "")
{ {
quiz['activity_id'] = options.activity_id;
quiz['note_image'] = options.note_image.split("::"); quiz['note_image'] = options.note_image.split("::");
quiz['title'] = options.title; quiz['title'] = options.title;
quiz['content'] = options.content.split("::"); quiz['content'] = options.content.split("::");
quiz['like'] = options.like; quiz['like'] = options.like;
quiz['quiz'] = options.quiz; quiz['quiz'] = options.quiz;
quiz['point'] = options.point;
quiz['member_id'] = options.member_id;
quiz['member_name'] = options.member_name; quiz['member_name'] = options.member_name;
quiz['member_slogan'] = options.member_slogan; quiz['member_slogan'] = options.member_slogan;
quiz['writer_name'] = options.writer_name == "null" ? "匿名用户" : options.writer_name; quiz['writer_name'] = options.writer_name == "null" ? "匿名用户" : options.writer_name;
...@@ -146,8 +163,16 @@ Page({ ...@@ -146,8 +163,16 @@ Page({
//跳转到知识竞答页面 //跳转到知识竞答页面
toGame: function (e) { toGame: function (e) {
var _this = this;
var url = "/pages/key/matchTest/matchTest?"
+ "&activity_id=" + _this.__data__.quiz["activity_id"]
+ "&quiz=" + _this.__data__.quiz["quiz"]
+ "&point=" + _this.__data__.quiz["point"]
+ "&member_id=" + _this.__data__.quiz["member_id"]
+ "&member_name=" + _this.__data__.quiz["member_name"]
+ "&title=" + _this.__data__.quiz["title"]
wx.navigateTo({ wx.navigateTo({
url: "/pages/key/matchTest/matchTest" url: url
}); });
}, },
......
// pages/index/note-info/note-info.js // pages/index/quiz-result/quiz-result.js
// pages/index/note-info/note-info.js // pages/index/quiz-result/quiz-result.js
var config=wx.getStorageSync("config");
var app = getApp();
var util = require('./../../../utils/util.js')
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
/* 用于判断是否已经登陆 */
nyxCode : "",
authStatus : "0",
userInfo : {}, // nickName, avartarUrl, gender, province, city, country
windowHeight: "", windowHeight: "",
windowWidth: "", windowWidth: "",
contentHeight: "", contentHeight: "",
scrollLeft: 0, //切换栏的滚动条位置
curIndex : 0, //竞答结果: match_id, member_name, title, num_valid, num_total, points
notes: {}, matchInfo : {},
//当前时间
nowDate : "",
}, },
...@@ -20,15 +32,37 @@ Page({ ...@@ -20,15 +32,37 @@ Page({
*/ */
onLoad: function (options) { onLoad: function (options) {
var _this = this; var _this = this;
//初始化数据
if (wx.getStorageSync('nyxCode')) {
_this.setData({
nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'),
})
}
var matchInfo = _this.__data__.matchInfo
if (Object.keys(matchInfo).length==0 && options.match_id != "")
{
matchInfo['match_id'] = options.match_id;
matchInfo['member_name'] = options.member_name;
matchInfo['title'] = options.title;
matchInfo['num_valid'] = options.num_valid;
matchInfo['num_total'] = options.num_total;
matchInfo['points'] = options.points;
}
var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法 var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法
var windowWidth = wx.getSystemInfoSync().windowWidth;//获取设备高度,小程序自带的方法 var windowWidth = wx.getSystemInfoSync().windowWidth;//获取设备高度,小程序自带的方法
this.setData({ this.setData({
windowHeight: windowHeight, windowHeight: windowHeight,
windowWidth: windowWidth, windowWidth: windowWidth,
contentHeight : windowHeight * 0.675, contentHeight : windowHeight * 0.675,
matchInfo : matchInfo,
nowDate: util.formatTime(new Date())
}) })
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title: '活动结果', title: '活动结果',
}) })
......
<view class="page"> <wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
<wxs module="tutil" src="./../../../utils/date.wxs"></wxs>
<view class="page"> <view class="page">
<!-- Tab: 酒肆风云 + 头像 --> <!-- Tab: 酒肆风云 + 头像 -->
...@@ -13,9 +15,9 @@ ...@@ -13,9 +15,9 @@
</view> </view>
</view> </view>
<view class="t3 justify align"> <view class="t3 justify align">
<view class="t3-left">2020年7月27日 星期一</view> <view class="t3-left">{{tutil.formatDate_ymdw_today(nowDate)}}</view>
<view class="t3-right" bindtap="onClickPoints"> <view class="t3-right" bindtap="onClickPoints">
<view style="line-height:1; font-size:14px">张三丰</view> <view style="line-height:1; font-size:14px">{{userInfo.nickName}}</view>
</view> </view>
</view> </view>
</view> </view>
...@@ -26,10 +28,10 @@ ...@@ -26,10 +28,10 @@
<!-- 文字内容 --> <!-- 文字内容 -->
<view class="note"> <view class="note">
<view class="note-title" style="font-weight: bold"> <view class="note-title" style="font-weight: bold">
Renaissance Bar知识竞答 {{matchInfo.member_name}} {{matchInfo.title}}
</view> </view>
<view class="note-content"> <view class="note-content">
张三丰 10题答对9题 喜提4.5积分 {{userInfo.nickName}} {{matchInfo.num_total}}题答对{{matchInfo.num_valid}}题 喜提{{matchInfo.points}}积分
</view> </view>
<view class="note-content"> <view class="note-content">
战胜99%玩家 战胜99%玩家
...@@ -68,19 +70,4 @@ ...@@ -68,19 +70,4 @@
</view> </view>
<!-- end bottom--> <!-- end bottom-->
<!-- start bottom-->
<!-- refer to https://www.jb51.net/article/129438.htm -->
<!-- <view class="bottom_total">
<view class="bottom_line"></view>
<view class="weui-flex" style="height: 180rpx;">
<view class="weui-flex__item weui-flex justify align"><view class="placeholder">
<button class="button-brown" bindtap="toBuy" formType="submit">查看积分</button>
</view></view>
<view class="weui-flex__item weui-flex justify align"><view class="placeholder">
<button class="button-red" bindtap="toGame">分享战绩</button>
</view></view>
</view>
</view> -->
<!-- end bottom-->
</view> </view>
// pages/key/matchTest/matchTest.js // pages/key/matchTest/matchTest.js
...@@ -20,7 +20,6 @@ Page({ ...@@ -20,7 +20,6 @@ Page({
nyxCode: "", nyxCode: "",
authStatus: "", authStatus: "",
userInfo: {}, userInfo: {},
matchSeason: "", // 学习赛季
matchType: "", // 学习类别 matchType: "", // 学习类别
isStudyDone: false, //是否已经完成该项学习 isStudyDone: false, //是否已经完成该项学习
...@@ -50,7 +49,12 @@ Page({ ...@@ -50,7 +49,12 @@ Page({
// questionName: "", // questionName: "",
// choiceString: [] // choiceString: []
quizResult : {}, // 接受从quiz-info来的参数
quizParam : {}, // activity_id, member_id, quiz, point, member_name, title
// 从tbl_quiz来的参数
quizInfo : {}, // questionId, questionName, answer
// 最后生成的结果
quizResult : {}, // num_valid, num_total, points
/* 评论 */ /* 评论 */
bGetCommentOp : false, bGetCommentOp : false,
...@@ -69,7 +73,6 @@ Page({ ...@@ -69,7 +73,6 @@ Page({
/* 模态框 */ /* 模态框 */
showModal: false, showModal: false,
}, },
/** /**
...@@ -84,11 +87,23 @@ Page({ ...@@ -84,11 +87,23 @@ Page({
nyxCode: wx.getStorageSync('nyxCode'), nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'), userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'), authStatus: wx.getStorageSync('authStatus'),
matchSeason: wx.getStorageSync('matchSeason'),
matchType: "daily", // 学习类型 matchType: "daily", // 学习类型
}) })
} }
var quizParam = _this.__data__.quizParam
var quiz_string = ""
if (Object.keys(quizParam).length==0 && options.activity_id != "")
{
quizParam['activity_id'] = options.activity_id;
quizParam['quiz'] = options.quiz;
quizParam['point'] = options.point;
quizParam['member_id'] = options.member_id;
quizParam['member_name'] = options.member_name;
quizParam['title'] = options.title;
quiz_string = options.quiz;
}
//随机获取10条数据的id //随机获取10条数据的id
/** /**
* 系统配置:主要用于置底页面设置 step2 * 系统配置:主要用于置底页面设置 step2
...@@ -96,12 +111,20 @@ Page({ ...@@ -96,12 +111,20 @@ Page({
var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法 var windowHeight = wx.getSystemInfoSync().windowHeight;//获取设备高度,小程序自带的方法
this.setData({ this.setData({
windowHeight: windowHeight, windowHeight: windowHeight,
quizParam : quizParam
}) })
/* end */ /* end */
if (_this.__data__.item_list.length == 0) if (_this.__data__.item_list.length == 0)
{ {
_this.getRand(); if(quiz_string != "")
{
_this.getQuiz(quiz_string);
}
else
{
_this.getRand();
}
_this.setData({ _this.setData({
isStudyDone: false, //每次进来从新操作 isStudyDone: false, //每次进来从新操作
}) })
...@@ -187,7 +210,7 @@ Page({ ...@@ -187,7 +210,7 @@ Page({
let cuu = e.target.id;//获取index值 let cuu = e.target.id;//获取index值
console.log(cuu); console.log(cuu);
var operateResult = ""; var operateResult = "";
var answer = _this.__data__.quizResult.answer; var answer = _this.__data__.quizInfo.answer;
var score = _this.__data__.score; var score = _this.__data__.score;
//拿到已经回答的题目数 //拿到已经回答的题目数
var item_index_done = _this.__data__.item_index_done; var item_index_done = _this.__data__.item_index_done;
...@@ -235,6 +258,7 @@ Page({ ...@@ -235,6 +258,7 @@ Page({
//拿到下一个item_index //拿到下一个item_index
var current_index = _this.__data__.item_index; var current_index = _this.__data__.item_index;
//指向下一题, 获取数据 //指向下一题, 获取数据
current_index = current_index + 1 current_index = current_index + 1
/* /*
...@@ -260,10 +284,10 @@ Page({ ...@@ -260,10 +284,10 @@ Page({
//功能实现 //功能实现
//逻辑判断 //逻辑判断
//超过了10题,溢出了,直接进入doneDaily //超过了10题(或者指定数量的题目),溢出了,直接进入doneTest
if(current_index >= 1) if(current_index >= _this.__data__.item_list.length)
{ {
_this.doneDaily() _this.doneTest()
} }
else else
{ {
...@@ -306,6 +330,20 @@ Page({ ...@@ -306,6 +330,20 @@ Page({
}) })
}, },
// 获取指定quiz_string数据
getQuiz : function (quiz_string) {
var _this = this;
var itemList = quiz_string.split("::")
_this.setData({
item_list: itemList,
item_index: 0 //初始化item_index
})
var wid = itemList[0]
_this.getData(wid)
},
// 获取真实数据 // 获取真实数据
getData: function (questionId) { getData: function (questionId) {
...@@ -332,7 +370,7 @@ Page({ ...@@ -332,7 +370,7 @@ Page({
} }
result["choiceString"] = list result["choiceString"] = list
_this.setData({ _this.setData({
quizResult : result, quizInfo : result,
questionId: questionId, questionId: questionId,
}) })
} }
...@@ -340,35 +378,33 @@ Page({ ...@@ -340,35 +378,33 @@ Page({
}) })
}, },
// 如果完成了10道题 /*
doneDaily: function (res) { 如果完成了指定的题目
1. 结算成绩
2. 存入数据库 tbl_match
3. 跳转到 /quiz-result.wxml 页面
*/
doneTest: function (res) {
var _this = this var _this = this
wx.navigateTo({
url: "/pages/activity/quiz-result/quiz-result" // 1. 结算成绩
}) var quizResult = {}
//     this.setData({ var num_valid = _this.__data__.score
//       showModal: true var num_total = _this.__data__.item_list.length
//     })
// wx.showModal({ var points = num_valid / num_total
// title: '恭喜你完成本次活动', var scores = parseFloat(_this.__data__.quizParam["point"])
// content: '获得'+_this.__data__.score + '积分,打败80%的玩家', var match_point = parseFloat(points * scores).toFixed(1)
// showCancel: false, // 将cancel按钮disable掉 // var match_result = num_valid + "/" + num_total
// confirmText: '谢谢老师',
// success(res) { // 2. 存入数据库 tbl_match, 并且拿到 match_id
// if (res.confirm) { _this.uploadMatch(match_point, num_valid, num_total);
// // 用户点击了确定属性的按钮,于是跳转到tabbar /pages/key/key
// // wx.navigateTo 和 wx.redirectto都无法跳转到tabbar // 3. 跳转到 /quiz-result.wxml 页面
// _this.setData({ // matchId
// isStudyDone: true, // 成绩 quizResult
// item_index : 9, // 信息 quizParam, member_name, title
// }) // _this.toResult()
// // 基于用户交互原则,不直接跳转到/pages/key/key页面, 让用户自主选择
// // wx.switchTab({
// // url: '/pages/key/key'
// // });
// }
// }
// })
}, },
...@@ -562,7 +598,7 @@ Page({ ...@@ -562,7 +598,7 @@ Page({
onSubmitComment: function (e) { onSubmitComment: function (e) {
var _this = this; var _this = this;
var objectId = _this.__data__.questionId //获取index值 var objectId = _this.__data__.questionId //获取index值
var objectName = _this.__data__.quizResult.questionName //获取index值 var objectName = _this.__data__.quizInfo.questionName //获取index值
let content = e.detail.value.content;//获取评论内容 let content = e.detail.value.content;//获取评论内容
var useridFrom = _this.__data__.nyxCode;//获取userid var useridFrom = _this.__data__.nyxCode;//获取userid
var useridTo = e.detail.value.useridTo;//获取reply id var useridTo = e.detail.value.useridTo;//获取reply id
...@@ -656,26 +692,21 @@ Page({ ...@@ -656,26 +692,21 @@ Page({
}, },
/* /*
更新daily的记录到tbl_match表 更新test的记录到tbl_match表
*/ */
uploadDaily: function(e){ uploadMatch(match_point, num_valid, num_total){
var _this = this; var _this = this;
var strUrl = config.match_add_item_url var strUrl = config.match_add_item_url
var quizIndex = _this.data.item_index_done config.debug == 1?console.log("===uploadMatch strUrl "+strUrl+"_point_"+match_point):""
var score = _this.data.score
config.debug == 1?console.log("===upload strUrl "+strUrl+"_quizIndex_"+quizIndex+"_socre_"+score):""
wx.request({ wx.request({
url: strUrl, url: strUrl,
method: 'POST', method: 'POST',
data: { data: {
matchSeason: _this.data.matchSeason, activityId: _this.__data__.quizParam["activity_id"],
matchType: _this.data.matchType, memberId: _this.__data__.quizParam["member_id"],
matchTeam: _this.data.nyxCode, userId: _this.data.nyxCode,
matchScore: _this.data.score, matchPoint: match_point,
teamType: "blue", matchResult: num_valid + "/" + num_total,
matchResult: _this.data.item_index_done==10 ? 1 : 0, //item_index永远指向下一题
quizIndex : _this.data.item_index_done, //已完成的quiz数目, 范围是1...10
rankScore: _this.data.score,
}, },
header: { header: {
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
...@@ -683,9 +714,13 @@ Page({ ...@@ -683,9 +714,13 @@ Page({
}, },
dataType: "json", dataType: "json",
success: function (res) { success: function (res) {
if (res.statusCode == 200) { if ( res.data.resultCode == 200 ) {
//表示提交成功 //表示提交成功
console.log("成绩记录成功"); console.log("成绩记录成功");
//得到matchId
var matchList = res.data.data;
var match_id = matchList.length >= 1 ? matchList[0].matchId : ""
_this.toResultPage(match_id, num_valid, num_total, match_point)
} }
} }
}) })
...@@ -717,6 +752,27 @@ Page({ ...@@ -717,6 +752,27 @@ Page({
}) })
}, },
//跳转到竞答结果页 quiz-result.wxml
toResultPage(match_id, num_valid, num_total, match_point) {
// matchId
// 成绩 quizResult
// 信息 quizParam, member_name, title
// toResult
var _this = this;
var url = "/pages/activity/quiz-result/quiz-result?"
+ "&match_id=" + match_id
+ "&member_name=" + _this.__data__.quizParam["member_name"]
+ "&title=" + _this.__data__.quizParam["title"]
+ "&num_total=" + num_total
+ "&num_valid=" + num_valid
+ "&points=" + match_point
wx.navigateTo({
url: url
})
},
}) })
\ No newline at end of file
<!--pages/key/matchTest/matchTest.wxml--> <!--pages/key/matchTest/matchTest.wxml-->
...@@ -49,10 +49,10 @@ ...@@ -49,10 +49,10 @@
<view hidden="{{isStudyDone}}"> <!-- start of isStudyDone flag --> <view hidden="{{isStudyDone}}"> <!-- start of isStudyDone flag -->
<view class="page__hd"> <view class="page__hd">
<!-- 标题 --> <!-- 标题 -->
<view class="page__desc">{{quizResult.questionName}}</view> <view class="page__desc">{{quizInfo.questionName}}</view>
</view> </view>
<view class="page__bd " wx:for-items="{{quizResult.choiceString}}" > <view class="page__bd " wx:for-items="{{quizInfo.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}}"> <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)}}" /> <image src="{{operateResult}}" style="vertical-align:middle;width:60rpx;height:60rpx" hidden="{{hidden_type==1?true:(current_item == index?false:true)}}" />
{{item}} {{item}}
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
<view class="page__hd" hidden="{{button_disabled==0}}"> <view class="page__hd" hidden="{{button_disabled==0}}">
<!-- 优化: 直接显示正确答案 --> <!-- 优化: 直接显示正确答案 -->
<view class="page__desc">推荐答案: {{tutil.formatAnswer(quizResult.answer)}}</view> <view class="page__desc">推荐答案: {{tutil.formatAnswer(quizInfo.answer)}}</view>
</view> </view>
<!-- <text>\n</text> --> <!-- <text>\n</text> -->
<view class="weui-flex"> <view class="weui-flex">
......
// pages/my/my.js // pages/my/my.js
...@@ -14,7 +14,6 @@ Page({ ...@@ -14,7 +14,6 @@ Page({
nyxCode : "", nyxCode : "",
authStatus : "0", authStatus : "0",
userInfo : {}, userInfo : {},
matchSeason : "",
bGetUserInfo : false, bGetUserInfo : false,
bUpdateUserData: false, bUpdateUserData: false,
...@@ -32,7 +31,6 @@ Page({ ...@@ -32,7 +31,6 @@ Page({
nyxCode: wx.getStorageSync('nyxCode'), nyxCode: wx.getStorageSync('nyxCode'),
userInfo: wx.getStorageSync('userInfo'), userInfo: wx.getStorageSync('userInfo'),
authStatus: wx.getStorageSync('authStatus'), authStatus: wx.getStorageSync('authStatus'),
matchSeason: wx.getStorageSync('matchSeason'),
}) })
} }
...@@ -42,7 +40,6 @@ Page({ ...@@ -42,7 +40,6 @@ Page({
log.info("my_onLoad_nyxCode", _this.data.nyxCode) log.info("my_onLoad_nyxCode", _this.data.nyxCode)
log.info("my_onLoad_authStatus", _this.data.authStatus) log.info("my_onLoad_authStatus", _this.data.authStatus)
log.info("my_onLoad_userInfo", _this.data.userInfo) log.info("my_onLoad_userInfo", _this.data.userInfo)
log.info("my_onLoad_matchSeason", _this.data.matchSeason)
}, },
......
var formatTime = function (date) { var formatTime = function (date) {
...@@ -19,14 +19,33 @@ var formatDate_md = function (date) { ...@@ -19,14 +19,33 @@ var formatDate_md = function (date) {
var formatDate_ymd = function (date) { var formatDate_ymd = function (date) {
// 输入 2020-02-04 19:33:00 // 输入 2020-02-04 19:33:00
// 返回 02-04 // 返回 2020-02-04
var str = date.toString().substring(0, 10) var str = date.toString().substring(0, 10)
return str return str
} }
var formatDate_ymdw_today = function (date) {
// 输入 2020-02-04 19:33:00
// 返回 2020年02月04日
var date = getDate(date);
var year = date.getFullYear()
var month = date.getMonth() + 1
var day = date.getDate()
var week = getWeekByDate_today(date)
return year +"年" + month + "月" + day + "日" + " " + week
}
var getWeekByDate_today = function (date) {
//数日
var show_day = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
var date = getDate(date);
var day = date.getDay();
return show_day[day];
}
var formatNumber = function(n) { var formatNumber = function(n) {
n = n.toString() n = n.toString()
console.log(n)
return n[1] ? n : '0' + n return n[1] ? n : '0' + n
} }
...@@ -40,31 +59,28 @@ var formatAnswer = function (n) { ...@@ -40,31 +59,28 @@ var formatAnswer = function (n) {
switch (n) { switch (n) {
case "1": case "1":
answer = "A" answer = "A"
console.log("input is 1")
break; break;
case "2": case "2":
answer = "B" answer = "B"
console.log("input is 2")
break; break;
case "3": case "3":
answer = "C" answer = "C"
console.log("input is 3")
break; break;
case "4": case "4":
answer = "D" answer = "D"
console.log("input is 4")
break; break;
case "5": case "5":
answer = "E" answer = "E"
break; break;
default: default:
console.log("input is n") break;
} }
return answer return answer
} }
module.exports = { module.exports = {
formatDate_ymd: formatDate_ymd, formatDate_ymd: formatDate_ymd,
formatDate_ymdw_today: formatDate_ymdw_today,
formatDate_md: formatDate_md, formatDate_md: formatDate_md,
formatTime: formatTime, formatTime: formatTime,
formatNumber: formatNumber, formatNumber: formatNumber,
......
package cn.com.fun.nyxkey.api.domain; package cn.com.fun.nyxkey.api.domain;
...@@ -16,6 +16,7 @@ import java.util.Date; ...@@ -16,6 +16,7 @@ import java.util.Date;
public class Rockwell_keyT_match{ public class Rockwell_keyT_match{
private String matchId; // 竞答的id uuid format private String matchId; // 竞答的id uuid format
private String activityId; // 活动id uuid format
private String memberId; // 商家的id uuid format private String memberId; // 商家的id uuid format
private String userId; // 用户的id uuid format private String userId; // 用户的id uuid format
private String matchStatus; // (可用|不可用): 01|00 private String matchStatus; // (可用|不可用): 01|00
......
package cn.com.fun.nyxkey.api.service; package cn.com.fun.nyxkey.api.service;
...@@ -30,7 +30,7 @@ public interface Rockwell_keyService { ...@@ -30,7 +30,7 @@ public interface Rockwell_keyService {
JSONResult Rockwell_keyServiceGetT_match_by_matchid(String matchId); JSONResult Rockwell_keyServiceGetT_match_by_matchid(String matchId);
JSONResult Rockwell_keyServiceGetT_match_by_page(String memberId, String userId, String matchStatus); JSONResult Rockwell_keyServiceGetT_match_by_page(String memberId, String userId, String matchStatus);
void Rockwell_keyServiceAddT_matchList(List<Rockwell_keyT_match> listRockwell_keyT_match); void Rockwell_keyServiceAddT_matchList(List<Rockwell_keyT_match> listRockwell_keyT_match);
void Rockwell_keyServiceAddT_matchItem(String matchId, String memberId, String userId, JSONResult Rockwell_keyServiceAddT_matchItem(String matchId, String activityId, String memberId, String userId,
Double matchPoint, String matchResult, String qrcodeUrl); Double matchPoint, String matchResult, String qrcodeUrl);
void Rockwell_keyServiceUpdateT_match_status(String matchId); void Rockwell_keyServiceUpdateT_match_status(String matchId);
void Rockwell_keyServiceAddT_match_bonusItem(String matchId, String userId, String userName, Double bonusPoint); void Rockwell_keyServiceAddT_match_bonusItem(String matchId, String userId, String userName, Double bonusPoint);
......
package cn.com.fun.nyxkey.api.service.impl; package cn.com.fun.nyxkey.api.service.impl;
...@@ -178,13 +178,14 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService { ...@@ -178,13 +178,14 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
rockwell_keyMapper.addT_matchList(rockwell_keyT_matchQuery); rockwell_keyMapper.addT_matchList(rockwell_keyT_matchQuery);
} }
public void Rockwell_keyServiceAddT_matchItem(String matchId, String memberId, String userId, public JSONResult Rockwell_keyServiceAddT_matchItem(String matchId, String activityId, String memberId, String userId,
Double matchPoint, String matchResult, String qrcodeUrl) Double matchPoint, String matchResult, String qrcodeUrl)
{ {
LOGGER.debug("find Rockwell_keyServiceAddT_matchItem"); LOGGER.debug("find Rockwell_keyServiceAddT_matchItem");
Rockwell_keyT_match rockwell_keyT_match = new Rockwell_keyT_match(); Rockwell_keyT_match rockwell_keyT_match = new Rockwell_keyT_match();
rockwell_keyT_match.setMatchId(matchId); rockwell_keyT_match.setMatchId(matchId);
rockwell_keyT_match.setMatchStatus("01"); rockwell_keyT_match.setMatchStatus("01");
rockwell_keyT_match.setActivityId(activityId);
rockwell_keyT_match.setMemberId(memberId); rockwell_keyT_match.setMemberId(memberId);
rockwell_keyT_match.setUserId(userId); rockwell_keyT_match.setUserId(userId);
rockwell_keyT_match.setMatchPoint(matchPoint); rockwell_keyT_match.setMatchPoint(matchPoint);
...@@ -193,6 +194,13 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService { ...@@ -193,6 +194,13 @@ public class Rockwell_keyServiceImpl implements Rockwell_keyService {
rockwell_keyT_match.setCreateDatetime(new Date()); rockwell_keyT_match.setCreateDatetime(new Date());
rockwell_keyT_match.setUpdateDatetime(new Date()); rockwell_keyT_match.setUpdateDatetime(new Date());
rockwell_keyMapper.addT_matchItem(rockwell_keyT_match); rockwell_keyMapper.addT_matchItem(rockwell_keyT_match);
List<Rockwell_keyT_match> listRockwell_keyT_match = new ArrayList<Rockwell_keyT_match>();
listRockwell_keyT_match.add(rockwell_keyT_match);
int totalCount = listRockwell_keyT_match.size();
JSONResult jsonResult = new JSONResult(totalCount, listRockwell_keyT_match);
return jsonResult;
} }
/* /*
......
package cn.com.fun.nyxkey.api.web.controller; package cn.com.fun.nyxkey.api.web.controller;
...@@ -129,6 +129,7 @@ public class NyxApiController { ...@@ -129,6 +129,7 @@ public class NyxApiController {
*/ */
@ApiOperation(value="为t_match添加match,对应tbl_match", notes="为t_match添加match,对应tbl_match") @ApiOperation(value="为t_match添加match,对应tbl_match", notes="为t_match添加match,对应tbl_match")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "activityId", value = "活动的id", required = true, dataType = "String"),
@ApiImplicitParam(name = "memberId", value = "商户的id", required = true, dataType = "String"), @ApiImplicitParam(name = "memberId", value = "商户的id", required = true, dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户的id", required = true, dataType = "String"), @ApiImplicitParam(name = "userId", value = "用户的id", required = true, dataType = "String"),
@ApiImplicitParam(name = "matchPoint", value = "得分: 4.5 or 5.0", required = true, dataType = "String"), @ApiImplicitParam(name = "matchPoint", value = "得分: 4.5 or 5.0", required = true, dataType = "String"),
...@@ -136,7 +137,8 @@ public class NyxApiController { ...@@ -136,7 +137,8 @@ public class NyxApiController {
}) })
@RequestMapping(value = "/nyx/match/add/item", method = RequestMethod.POST) @RequestMapping(value = "/nyx/match/add/item", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public void RockwellAddMatchItem( public JSONResult RockwellAddMatchItem(
@RequestParam(value = "activityId", required = false, defaultValue = "0") String activityId,
@RequestParam(value = "memberId", required = false, defaultValue = "0") String memberId, @RequestParam(value = "memberId", required = false, defaultValue = "0") String memberId,
@RequestParam(value = "userId", required = false, defaultValue = "0") String userId, @RequestParam(value = "userId", required = false, defaultValue = "0") String userId,
@RequestParam(value = "matchPoint", required = false, defaultValue = "0.0") Double matchPoint, @RequestParam(value = "matchPoint", required = false, defaultValue = "0.0") Double matchPoint,
...@@ -146,7 +148,7 @@ public class NyxApiController { ...@@ -146,7 +148,7 @@ public class NyxApiController {
String matchId = "mid_"+UUID.randomUUID().toString(); String matchId = "mid_"+UUID.randomUUID().toString();
//生成qrcode, 上传oss,得到qrcode_url //生成qrcode, 上传oss,得到qrcode_url
String qrcodeUrl = ossService.Rockwell_ossServiceGetQrcodeUrl(matchId); String qrcodeUrl = ossService.Rockwell_ossServiceGetQrcodeUrl(matchId);
keyService.Rockwell_keyServiceAddT_matchItem(matchId, memberId, userId, matchPoint, matchResult, qrcodeUrl); return keyService.Rockwell_keyServiceAddT_matchItem(matchId, activityId, memberId, userId, matchPoint, matchResult, qrcodeUrl);
} }
// APi2 t_match接口 jscat 20200731 // APi2 t_match接口 jscat 20200731
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
...@@ -119,10 +119,11 @@ limitations under the License. ...@@ -119,10 +119,11 @@ limitations under the License.
<!-- match api1-2 新增一条 tbl_match 记录 update jscat 20200731 --> <!-- match api1-2 新增一条 tbl_match 记录 update jscat 20200731 -->
<insert id="addT_matchItem" parameterType="cn.com.fun.nyxkey.api.domain.Rockwell_keyT_match"> <insert id="addT_matchItem" parameterType="cn.com.fun.nyxkey.api.domain.Rockwell_keyT_match">
insert into tbl_match(match_id, member_id, user_id, match_status, match_point, match_result, qrcode_url, create_datetime,update_datetime) insert into tbl_match(match_id, activity_id, member_id, user_id, match_status, match_point, match_result, qrcode_url, create_datetime,update_datetime)
values values
( (
#{matchId}, #{matchId},
#{activityId},
#{memberId}, #{memberId},
#{userId}, #{userId},
#{matchStatus}, #{matchStatus},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论