|
|
@ -2,22 +2,10 @@ const app = getApp();
|
|
|
|
Component({
|
|
|
|
Component({
|
|
|
|
|
|
|
|
|
|
|
|
properties: {
|
|
|
|
properties: {
|
|
|
|
hidden:{
|
|
|
|
show:{
|
|
|
|
type:Boolean,
|
|
|
|
type:Boolean,
|
|
|
|
value: true,
|
|
|
|
value: false,
|
|
|
|
observer:function(hidden){
|
|
|
|
observer: "onShowChange"
|
|
|
|
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]});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
show_code:{
|
|
|
|
show_code:{
|
|
|
|
type:Number,
|
|
|
|
type:Number,
|
|
|
@ -36,23 +24,75 @@ Component({
|
|
|
|
|
|
|
|
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
identities:[],
|
|
|
|
identities:[],
|
|
|
|
hidden:true,
|
|
|
|
showDialog: false,
|
|
|
|
buttons:[
|
|
|
|
buttons:[
|
|
|
|
{text:"取消"},
|
|
|
|
{text:"取消"},
|
|
|
|
{text:"提交"}
|
|
|
|
{text:"提交"}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
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(){
|
|
|
|
scan(){
|
|
|
|
wx.scanCode({
|
|
|
|
wx.scanCode({
|
|
|
|
success:res=>{
|
|
|
|
success:res=>{
|
|
|
|
;
|
|
|
|
|
|
|
|
var fail = false;
|
|
|
|
var fail = false;
|
|
|
|
if(res.scanType=="QR_CODE")
|
|
|
|
if(res.scanType=="QR_CODE")
|
|
|
|
this.setData({invite_code: res.result});
|
|
|
|
this.setData({invite_code: res.result});
|
|
|
|
else if(res.scanType=="WX_CODE"&&res.path){
|
|
|
|
else if(res.scanType=="WX_CODE"&&res.path){
|
|
|
|
var match = res.path.match(/course_invite\?(.*)$/)
|
|
|
|
var match = res.path.match(/course_invite\?(.*)$/)
|
|
|
|
;
|
|
|
|
|
|
|
|
if(match){
|
|
|
|
if(match){
|
|
|
|
var options = {}
|
|
|
|
var options = {}
|
|
|
|
match[1].split("&").map(i=>{
|
|
|
|
match[1].split("&").map(i=>{
|
|
|
@ -60,7 +100,6 @@ Component({
|
|
|
|
var k = i.slice(0, index);
|
|
|
|
var k = i.slice(0, index);
|
|
|
|
var v = i.slice(index + 1);
|
|
|
|
var v = i.slice(index + 1);
|
|
|
|
options[k]=v})
|
|
|
|
options[k]=v})
|
|
|
|
;
|
|
|
|
|
|
|
|
if(options.scene){
|
|
|
|
if(options.scene){
|
|
|
|
var scene = {};
|
|
|
|
var scene = {};
|
|
|
|
for (var i of decodeURIComponent(options.scene).split("&")) {
|
|
|
|
for (var i of decodeURIComponent(options.scene).split("&")) {
|
|
|
@ -69,12 +108,10 @@ Component({
|
|
|
|
var v = i.slice(index+1);
|
|
|
|
var v = i.slice(index+1);
|
|
|
|
scene[k] = v;
|
|
|
|
scene[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
if(scene.course_id){
|
|
|
|
if(scene.course_id){
|
|
|
|
var {course_id} = scene;
|
|
|
|
var {course_id} = scene;
|
|
|
|
app.api("weapps.courses.basic_info")({ course_id })
|
|
|
|
app.api("weapps.courses.basic_info")({ course_id })
|
|
|
|
.then(({ course:{invite_code=""}}) => {
|
|
|
|
.then(({ course:{invite_code=""}}) => {
|
|
|
|
;
|
|
|
|
|
|
|
|
this.setData({invite_code});
|
|
|
|
this.setData({invite_code});
|
|
|
|
}).catch(app.showError);
|
|
|
|
}).catch(app.showError);
|
|
|
|
}else
|
|
|
|
}else
|
|
|
@ -93,7 +130,7 @@ Component({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onCancel() {
|
|
|
|
onCancel() {
|
|
|
|
this.setData({ hidden: true,invite_code:'', professor:"", student:"", assistant_professor:"" });
|
|
|
|
this.setData({ show: false, invite_code:'', professor:"", student:"", assistant_professor:"" });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onTapButton({detail:{index}}){
|
|
|
|
onTapButton({detail:{index}}){
|
|
|
|
if(index==0)
|
|
|
|
if(index==0)
|
|
|
@ -129,7 +166,13 @@ Component({
|
|
|
|
this.onCancel();
|
|
|
|
this.onCancel();
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(e=>{
|
|
|
|
.catch(e=>{
|
|
|
|
e.message =e.message||'未知错误';
|
|
|
|
if(e.code==402){ //一般是信息没完善
|
|
|
|
|
|
|
|
if(this.checkProfile()){ //信息已完善还是出错
|
|
|
|
|
|
|
|
wx.showToast({ title: '发生未知错误',icon:"none"})
|
|
|
|
|
|
|
|
global.realTimeLog.error("join course", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
app.showError(e);
|
|
|
|
app.showError(e);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|