A 使用特定功能时登录校验

master
educoder_weapp 5 years ago
parent a9c184df1d
commit 11478a31b2

@ -161,6 +161,23 @@ App({
navigateTo({ url, success, fail, complete }) {
wx.navigateTo({ url: this.getPageUrl(url), success, fail, complete })
},
checkLogin({showModal=1, content="您需要登陆后才能使用该功能"}={}){
if(client.user.user_id==2){
if(showModal){
wx.showModal({
confirmText:"现在登录",
title:"提示",
content,
success:res=>{
if(res.confirm)
app.navigateTo({url:"{account}"})
}
})
}
return false;
}else
return true;
},
shareApp({ imageUrl, path, title }) {
return {
title: title || "EduCoder教学",

@ -33,7 +33,7 @@ Component({
methods: {
onShowChange(value){
if(value){
if(!this.checkLogin()||!this.checkProfile()){
if(!app.checkLogin({content:"您需要登录后才能加入课堂"})||!this.checkProfile()){
value = false;
this.setData({show: false});
}
@ -51,21 +51,6 @@ Component({
this.setData({showDialog: value});
}
},
checkLogin(){
if(app.user().user_id==2){
wx.showModal({
title:"提示",
content:"您需要登录后才能加入课堂",
confirmText:"现在登录",
success: res=>{
if(res.confirm)
app.navigateTo({url:"{account}"});
}
})
return false;
}
return true;
},
checkProfile(){
if(app.user().profile_completed)
return true;

@ -14,14 +14,14 @@ Page({
}
},
enterSend(){
if(app.user().user_id==2)
return wx.showToast({
title: '登录后才能操作哦',icon:"none"
});
if(!app.checkLogin())
return;
let {id} = this.data.subject;
app.navigateTo({url:"{path_send}?subject_id="+id});
},
collect(){
if(!app.checkLogin())
return;
let {id, is_collect} = this.data.subject;
let api_name = is_collect?"collections.cancel":"collections";
app.api(api_name)({container_type:"Subject", container_id:id})

@ -11,13 +11,18 @@ Page({
list:[
{text:"简介"},{text:"任务"}
],
attachDir:global.config.attachDir,
description:""
},
sendToCourse(){
if(!app.checkLogin())
return;
let {id} = this.data.shixun;
this.setData({shixun_ids: [id], showSendDialog: true});
},
collect(){
if(!app.checkLogin())
return;
let {id, is_collect} = this.data.shixun;
let api_name = is_collect?"collections.cancel":"collections";
app.api(api_name)({container_type:"Shixun", container_id:id})
@ -42,6 +47,8 @@ Page({
})
},
enterChallenge(){
if(!app.checkLogin())
return;
wx.showLoading({
title: '开启中',
});

@ -1,7 +1,6 @@
{
"usingComponents": {
"rich-md":"/markdown/components/rich-md/rich-md",
"require-login":"/components/require-login/require-login",
"challenge-item":"./challenge-item/challenge-item",
"nav-bar":"/components/nav-bar/nav-bar",
"send-to-course":"/components/modal/send-to-course/send-to-course"

@ -19,7 +19,13 @@
</view>
</view>
</view>
<require-login bg="#00b0f0" bindchange="pullShixun" message="点击登陆,可以获取更多内容哦"/>
<navigator target="miniProgram" hover-class="none"
app-id="wx2402d86a6b534f77"
path="pagesB/trainingdetails/trainingdetails?identifier={{shixun.identifier}}&shixunid={{shixun.id}}"
class="nav-educoder">
<image src="{{attachDir}}888038" class="icon"></image>
点击使用EduCoder云网实战
</navigator>
<nav-bar list="{{list}}" current="{{current}}" type="line" bindchange="switchNav"/>
<swiper class="body" current="{{current}}" bindchange="switchNav" circular="1">
<swiper-item>
@ -48,4 +54,4 @@
<button bindtap="enterChallenge" disabled="{{loading}}" type="main">{{shixun.task_operation[0]}}</button>
<button class="send" type="secondary" bindtap="sendToCourse">发送至</button>
</view>
<send-to-course show="{{showSendDialog}}" shixun_ids="{{shixun_ids}}"/>
<send-to-course show="{{showSendDialog}}" shixun_ids="{{shixun_ids}}"/>

@ -1,10 +1,8 @@
var top = 140;
var top = 172;
function scroll(e, ins){
//var scrollTop = e.detail.scrollTop;
var deltaY = e.detail.deltaY;
;
;
;
if(deltaY<0){
ins.callMethod("scrollTo", { scrollTop: top });
}

@ -54,6 +54,15 @@
border-radius: 10px;
border-left: 5px solid #00b0f0;
}
.nav-educoder{
padding: 6px;
text-align: center;
font-size: 12px;
}
.nav-educoder>.icon{
height: 20px;
width: 20px;
}
.cate-name{
padding: 0 10px;
}

@ -8,15 +8,16 @@
<block wx:if="{{challenge}}">
<view class="subject {{theme}}">第{{challenge.position}}关:{{challenge.subject}}</view>
<view class="sub-header {{theme}}">
<!--path="pagesB/shixuntasks/shixuntasks?game_identifier={{identifier}}"
path="pagesB/trainingdetails/trainingdetails?identifier={{shixun.identifier}}&shixunid={{shixun.id}}"
-->
<navigator target="miniProgram" hover-class="none" app-id="wx2402d86a6b534f77"
path="pages/shiyan/shixun?shixunDetailsid={{shixun.id}}&shixunidentifier={{shixun.identifier}}"
<!--
path="pagesB/shixuntasks/shixuntasks?game_identifier={{identifier}}"
path="pages/shiyan/shixun?shixunDetailsid={{shixun.id}}&shixunidentifier={{shixun.identifier}}"
-->
<navigator target="miniProgram" hover-class="none"
app-id="wx2402d86a6b534f77"
path="pagesB/trainingdetails/trainingdetails?identifier={{shixun.identifier}}&shixunid={{shixun.id}}"
class="nav-educoder">
<image src="{{attachDir}}888038" class="icon"></image>
用EduCoder云网实(推荐)
用EduCoder云网实(推荐)
</navigator>
<view class="switch-wrap">黑暗模式<switch class="theme-switch" bindchange="switchTheme" color="dimgrey" checked="{{theme=='dark'}}"></switch></view>
</view>

@ -1,7 +1,7 @@
<page-meta>
<navigation-bar loading="{{loading}}"/>
</page-meta>
<require-login message="点击登录查看消息通知"/>
<require-login message="点击登录查看消息通知"/>
<nav-bar bar-class="navbar" current="{{current}}" list="{{list}}" itemWidth="0" type="cap" bg="transparent" mg="8" bindchange="changeType"/>
<scroll-view class="tidings" refresher-enabled="1" scroll-y="1" bindrefresherrefresh="onPullDownRefresh" bindscrolltolower="_onReachBottom" lower-threshold="120" scroll-top="{{scrollTop}}">
<view class="message" wx:if="{{course_apply_count}}" bindtap="onTapMessage">

@ -232,6 +232,14 @@
"id": -1,
"name": "admin/pages/page_history/page_history",
"pathName": "admin/pages/page_history/page_history",
"query": "",
"scene": null
},
{
"id": -1,
"name": "markdown/shixun/shixun/shixun",
"pathName": "markdown/shixun/shixun/shixun",
"query": "identifier=tb7hw62n",
"scene": null
}
]

Loading…
Cancel
Save