You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
//app.js
//导入leancloud库, 与后台交互
import { Session } from "./data/requests" ;
import { Client } from "./data/client" ;
import { Account , Course , Exercise , ExerciseQuestion } from "./data/eduapi"
const AV = require ( './lib/av-live-query-weapp-min' ) ;
const Towxml = require ( '/towxml/main' ) ;
const login = require ( "./model/user" ) ;
//初始化
AV . init ( {
appId : 'eVHYNBdT5D2lDxNj5jtJXsWT-MdYXbMMI' ,
appKey : 'waM3bwf1ftpsMLjRBqqVyJIQ' ,
} ) ;
// test Appid
// appId: 'fQCxN98zS5thYY3AceKdI8Pj-MdYXbMMI',
// appKey: 'Tdi1DcLlVYrTabFiBaA00pjj',
App ( {
towxml : new Towxml ( ) ,
client : new Client ( ) ,
logining : false ,
string _format _init : function ( ) {
//使String类实现format方法
//@todo: 待测试
String . prototype . format = function ( kwargs ) {
return this . replace ( /\{(\w+)\}/g , function ( k , v ) {
return kwargs [ v ]
} ) ;
} ;
} ,
require _login ( ) {
if ( ! this . logining ) {
this . logining = true ;
wx . navigateTo ( {
url : "/pages/login/login"
} ) ;
}
} ,
onLaunch : function ( ) {
this . client . onRequireLogin ( ( ) => {
this . require _login ( ) ;
} ) ;
console . log ( "onLauch" ) ;
this . client . get _user _info ( {
success : res => {
console . log ( "app.js: userinfo get success" ) ;
console . log ( res ) ;
if ( res . data . user _id == 2 ) {
this . client . callback . require _login ( ) ;
}
} ,
fail : error => {
console . warn ( "app.js: get user info fail" ) ;
}
} ) ;
login ( ) ;
}
} ) ;