|
|
|
@ -2,22 +2,10 @@ const app = getApp();
|
|
|
|
|
Component({
|
|
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
|
hidden:{
|
|
|
|
|
show:{
|
|
|
|
|
type:Boolean,
|
|
|
|
|
value: true,
|
|
|
|
|
observer:function(hidden){
|
|
|
|
|
if(!hidden){
|
|
|
|
|
wx.getClipboardData({
|
|
|
|
|
success:res=>{
|
|
|
|
|
if(!res.data||res.data==this.clipboardData) return;
|
|
|
|
|
this.clipboardData = res.data;
|
|
|
|
|
var match = res.data.match(/(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Z]{5,6}/);
|
|
|
|
|
if(match)
|
|
|
|
|
this.setData({invite_code: match[0]});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
value: false,
|
|
|
|
|
observer: "onShowChange"
|
|
|
|
|
},
|
|
|
|
|
show_code:{
|
|
|
|
|
type:Number,
|
|
|
|
@ -36,23 +24,75 @@ Component({
|
|
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
identities:[],
|
|
|
|
|
hidden:true,
|
|
|
|
|
showDialog: false,
|
|
|
|
|
buttons:[
|
|
|
|
|
{text:"取消"},
|
|
|
|
|
{text:"提交"}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
onShowChange(value){
|
|
|
|
|
if(value){
|
|
|
|
|
if(!this.checkLogin()||!this.checkProfile()){
|
|
|
|
|
value = false;
|
|
|
|
|
this.setData({show: false});
|
|
|
|
|
}
|
|
|
|
|
wx.getClipboardData({
|
|
|
|
|
success:res=>{
|
|
|
|
|
if(!res.data||res.data==this.clipboardData) return;
|
|
|
|
|
this.clipboardData = res.data;
|
|
|
|
|
var match = res.data.match(/(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Z]{5,6}/);
|
|
|
|
|
if(match)
|
|
|
|
|
this.setData({invite_code: match[0]});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.setData({showDialog: value});
|
|
|
|
|
}else{
|
|
|
|
|
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;
|
|
|
|
|
else{
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title:"提示",
|
|
|
|
|
content:"您需要完善您的个人资料,才能加入课堂",
|
|
|
|
|
confirmText:"立即完善",
|
|
|
|
|
success:res=>{
|
|
|
|
|
if(res.confirm){
|
|
|
|
|
app.navigateTo({
|
|
|
|
|
url:"{profile}"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
scan(){
|
|
|
|
|
wx.scanCode({
|
|
|
|
|
success:res=>{
|
|
|
|
|
;
|
|
|
|
|
var fail = false;
|
|
|
|
|
if(res.scanType=="QR_CODE")
|
|
|
|
|
this.setData({invite_code: res.result});
|
|
|
|
|
else if(res.scanType=="WX_CODE"&&res.path){
|
|
|
|
|
var match = res.path.match(/course_invite\?(.*)$/)
|
|
|
|
|
;
|
|
|
|
|
if(match){
|
|
|
|
|
var options = {}
|
|
|
|
|
match[1].split("&").map(i=>{
|
|
|
|
@ -60,7 +100,6 @@ Component({
|
|
|
|
|
var k = i.slice(0, index);
|
|
|
|
|
var v = i.slice(index + 1);
|
|
|
|
|
options[k]=v})
|
|
|
|
|
;
|
|
|
|
|
if(options.scene){
|
|
|
|
|
var scene = {};
|
|
|
|
|
for (var i of decodeURIComponent(options.scene).split("&")) {
|
|
|
|
@ -69,12 +108,10 @@ Component({
|
|
|
|
|
var v = i.slice(index+1);
|
|
|
|
|
scene[k] = v;
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
if(scene.course_id){
|
|
|
|
|
var {course_id} = scene;
|
|
|
|
|
app.api("weapps.courses.basic_info")({ course_id })
|
|
|
|
|
.then(({ course:{invite_code=""}}) => {
|
|
|
|
|
;
|
|
|
|
|
this.setData({invite_code});
|
|
|
|
|
}).catch(app.showError);
|
|
|
|
|
}else
|
|
|
|
@ -93,7 +130,7 @@ Component({
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
this.setData({ hidden: true,invite_code:'', professor:"", student:"", assistant_professor:"" });
|
|
|
|
|
this.setData({ show: false, invite_code:'', professor:"", student:"", assistant_professor:"" });
|
|
|
|
|
},
|
|
|
|
|
onTapButton({detail:{index}}){
|
|
|
|
|
if(index==0)
|
|
|
|
@ -129,8 +166,14 @@ Component({
|
|
|
|
|
this.onCancel();
|
|
|
|
|
})
|
|
|
|
|
.catch(e=>{
|
|
|
|
|
e.message =e.message||'未知错误';
|
|
|
|
|
app.showError(e);
|
|
|
|
|
if(e.code==402){ //一般是信息没完善
|
|
|
|
|
if(this.checkProfile()){ //信息已完善还是出错
|
|
|
|
|
wx.showToast({ title: '发生未知错误',icon:"none"})
|
|
|
|
|
global.realTimeLog.error("join course", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
app.showError(e);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|