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

master
educoder_weapp 5 years ago
parent a9c184df1d
commit 11478a31b2

@ -161,6 +161,23 @@ App({
navigateTo({ url, success, fail, complete }) { navigateTo({ url, success, fail, complete }) {
wx.navigateTo({ url: this.getPageUrl(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 }) { shareApp({ imageUrl, path, title }) {
return { return {
title: title || "EduCoder教学", title: title || "EduCoder教学",

@ -33,7 +33,7 @@ Component({
methods: { methods: {
onShowChange(value){ onShowChange(value){
if(value){ if(value){
if(!this.checkLogin()||!this.checkProfile()){ if(!app.checkLogin({content:"您需要登录后才能加入课堂"})||!this.checkProfile()){
value = false; value = false;
this.setData({show: false}); this.setData({show: false});
} }
@ -51,21 +51,6 @@ Component({
this.setData({showDialog: value}); 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(){ checkProfile(){
if(app.user().profile_completed) if(app.user().profile_completed)
return true; return true;

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

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

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

@ -19,7 +19,13 @@
</view> </view>
</view> </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"/> <nav-bar list="{{list}}" current="{{current}}" type="line" bindchange="switchNav"/>
<swiper class="body" current="{{current}}" bindchange="switchNav" circular="1"> <swiper class="body" current="{{current}}" bindchange="switchNav" circular="1">
<swiper-item> <swiper-item>

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

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

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

@ -1,7 +1,7 @@
<page-meta> <page-meta>
<navigation-bar loading="{{loading}}"/> <navigation-bar loading="{{loading}}"/>
</page-meta> </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"/> <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}}"> <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"> <view class="message" wx:if="{{course_apply_count}}" bindtap="onTapMessage">

@ -232,6 +232,14 @@
"id": -1, "id": -1,
"name": "admin/pages/page_history/page_history", "name": "admin/pages/page_history/page_history",
"pathName": "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 "scene": null
} }
] ]

Loading…
Cancel
Save