parent
222e364f48
commit
74bd7c5c9e
@ -1,15 +0,0 @@
|
|||||||
import apiConfig from "../js/apiConfig"
|
|
||||||
|
|
||||||
Object.assign(apiConfig,
|
|
||||||
{
|
|
||||||
competitions:{
|
|
||||||
common_header:{url:"{identifier}/*"},
|
|
||||||
competition_staff:{url:"{identifier}/*"},
|
|
||||||
competition_modules:{url:"{identifier}/*/{module_id}"},
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default apiConfig;
|
|
@ -1,2 +0,0 @@
|
|||||||
<!--miniprogram/competition/pages/competition/competition.wxml-->
|
|
||||||
<text>miniprogram/competition/pages/competition/competition.wxml</text>
|
|
@ -1 +0,0 @@
|
|||||||
/* miniprogram/competition/pages/competition/competition.wxss */
|
|
@ -0,0 +1,27 @@
|
|||||||
|
const app = getApp();
|
||||||
|
|
||||||
|
Component({
|
||||||
|
/**
|
||||||
|
* 组件的属性列表
|
||||||
|
*/
|
||||||
|
properties: {
|
||||||
|
data:Object
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
eduUrl: global.config.eduUrl
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
previewImage(){
|
||||||
|
let url = this.data.eduUrl +"/"+this.data.data.image;
|
||||||
|
wx.previewImage({
|
||||||
|
urls: [url],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
"component": true,
|
||||||
"usingComponents": {}
|
"usingComponents": {}
|
||||||
}
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<navigator class="item-container" hover-class="none" url="/markdown/competition/competition/competition?identifier={{data.identifier}}">
|
||||||
|
<view class="image-wrp" catchtap="previewImage">
|
||||||
|
<image class="item-image" lazy-load mode="heightFix" src="{{eduUrl}}/{{data.image}}"></image>
|
||||||
|
</view>
|
||||||
|
<view class="item-detail">
|
||||||
|
<view>{{data.name}}</view>
|
||||||
|
<view class="tip">竞赛时间:{{data.start_time}}~{{data.end_time}}</view>
|
||||||
|
</view>
|
||||||
|
</navigator>
|
@ -0,0 +1,30 @@
|
|||||||
|
.item-container{
|
||||||
|
padding: 10px 12px;
|
||||||
|
display: flex;
|
||||||
|
background: white;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-detail{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-size: 15pxs;
|
||||||
|
margin-left: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tip{
|
||||||
|
font-size: 12px;
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
|
.image-wrp{
|
||||||
|
flex: none;
|
||||||
|
width: 200rpx;
|
||||||
|
height: 110rpx;
|
||||||
|
overflow:hidden;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.item-image{
|
||||||
|
height: 100%;
|
||||||
|
width: 128.2%;
|
||||||
|
background: lightblue;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {
|
||||||
|
"competition-item":"./competition-item/competition-item"
|
||||||
|
},
|
||||||
|
"navigationBarTitleText": "在线竞赛"
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<view class="list-view">
|
||||||
|
<view class="item-wrp" wx:for="{{competitions}}">
|
||||||
|
<competition-item data="{{item}}"/>
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,6 @@
|
|||||||
|
.item-list{
|
||||||
|
background: #f0f0f0;
|
||||||
|
}
|
||||||
|
.item-wrp{
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
@ -0,0 +1,127 @@
|
|||||||
|
|
||||||
|
const app = getApp();
|
||||||
|
|
||||||
|
Page({
|
||||||
|
|
||||||
|
data: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad: function (options) {
|
||||||
|
app.reportPageHistory({page:this});
|
||||||
|
this.pullData();
|
||||||
|
},
|
||||||
|
async pullData(){
|
||||||
|
let header = await app.api("competitions.common_header")({identifier: this.options.identifier}).catch(app.showError);
|
||||||
|
header.modules = []
|
||||||
|
for(var m of header.competition_modules){
|
||||||
|
if(m.module_type=='enroll')
|
||||||
|
continue;
|
||||||
|
m.text = m.name;
|
||||||
|
header.modules.push(m);
|
||||||
|
}
|
||||||
|
this.setData(header);
|
||||||
|
try{
|
||||||
|
wx.showLoading({title: '加载中'});
|
||||||
|
let module = await app.api("competitions.competition_modules")({
|
||||||
|
identifier: this.options.identifier,
|
||||||
|
module_id: header.modules[0].id});
|
||||||
|
this.setData({module});
|
||||||
|
}catch(e){
|
||||||
|
app.showError(e);
|
||||||
|
}
|
||||||
|
wx.hideLoading()
|
||||||
|
},
|
||||||
|
onNavChange(e){
|
||||||
|
console.log(e);
|
||||||
|
let {detail:{value:{id}}} = e;
|
||||||
|
wx.showNavigationBarLoading();
|
||||||
|
app.api("competitions.competition_modules")(
|
||||||
|
{
|
||||||
|
identifier: this.options.identifier,
|
||||||
|
module_id: id
|
||||||
|
})
|
||||||
|
.then(res=>{
|
||||||
|
this.setData({module:res});
|
||||||
|
}).finally(()=>{
|
||||||
|
wx.hideNavigationBarLoading({});
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
onTapAttachment(e){
|
||||||
|
console.log(e);
|
||||||
|
let {currentTarget:{dataset:{url}}} = e;
|
||||||
|
console.log(url);
|
||||||
|
url = "https://www.educoder.net"+url;
|
||||||
|
wx.downloadFile({
|
||||||
|
url,
|
||||||
|
success: res=>{
|
||||||
|
wx.openDocument({
|
||||||
|
filePath: res.tempFilePath,
|
||||||
|
showMenu: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
onReady: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面显示
|
||||||
|
*/
|
||||||
|
onShow: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面隐藏
|
||||||
|
*/
|
||||||
|
onHide: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面卸载
|
||||||
|
*/
|
||||||
|
onUnload: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
|
*/
|
||||||
|
onPullDownRefresh: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面上拉触底事件的处理函数
|
||||||
|
*/
|
||||||
|
onReachBottom: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
onAddToFavorites:function(){
|
||||||
|
let {name, sub_title, avatar_url} = this.data
|
||||||
|
return app.addToFavorites({
|
||||||
|
title: "「在线竞赛」"+name+(sub_title?("--"+sub_title):""),
|
||||||
|
imageUrl:global.config.eduUrl+"/"+avatar_url
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onShareTimeline:function(){
|
||||||
|
let {name, sub_title, avatar_url} = this.data
|
||||||
|
return app.shareTimeline({
|
||||||
|
title: "「在线竞赛」"+name+(sub_title?("--"+sub_title):""),
|
||||||
|
imageUrl:global.config.eduUrl+"/"+avatar_url
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onShareAppMessage: function () {
|
||||||
|
let {name, sub_title, avatar_url} = this.data
|
||||||
|
return app.shareApp({
|
||||||
|
title: "「在线竞赛」"+name+(sub_title?("--"+sub_title):""),
|
||||||
|
imageUrl:global.config.eduUrl+"/"+avatar_url
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {
|
||||||
|
"nav-bar":"/components/nav-bar/nav-bar",
|
||||||
|
"rich-md":"../../components/rich-md/rich-md"
|
||||||
|
},
|
||||||
|
"navigationBarTitleText": "在线竞赛"
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
<page-meta>
|
||||||
|
|
||||||
|
<navigation-bar title="{{name+(sub_title?('--'+sub_title):'')}}"/>
|
||||||
|
</page-meta>
|
||||||
|
|
||||||
|
<view>
|
||||||
|
<view class="sticky-top">
|
||||||
|
<nav-bar list="{{modules}}" type="line" bindchange="onNavChange"/>
|
||||||
|
</view>
|
||||||
|
<rich-md nodes="{{module.md_content}}" type="markdown"/>
|
||||||
|
<view class="attachments">
|
||||||
|
<view class="attachment-item" wx:for="{{module.attachments}}" bindtap="onTapAttachment" data-url="{{item.url}}">
|
||||||
|
<mp-icon icon="link" type="field" color="#002389"/>{{item.title}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
@ -0,0 +1,15 @@
|
|||||||
|
.sticky-top{
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background: white;
|
||||||
|
padding-bottom: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attachments{
|
||||||
|
text-decoration: underline;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #003190;
|
||||||
|
}
|
||||||
|
.attachment-item{
|
||||||
|
padding: 8px;
|
||||||
|
}
|
@ -1,2 +1,4 @@
|
|||||||
<!--miniprogram/setting/pages/setting/setting.wxml-->
|
<view>
|
||||||
<text>miniprogram/setting/pages/setting/setting.wxml</text>
|
<switch class="save-flow" checked="{{saveFlow}}" color="#00b0f0" bindchange="onChangeSaveFlow">省流模式(内测功能)</switch>
|
||||||
|
</view>
|
||||||
|
<!--navigator wx:if="{{requireRelaunch}}" target="miniProgram" open-type="exit">立即重启小程序</navigator-->
|
Loading…
Reference in new issue