app.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. function app_ready($){
  2. $("#login").height($(window).height());
  3. if(Modernizr.mq("(max-width:767px)")){
  4. if($('#right').size()>0){
  5. $('#right_box').empty();
  6. $('#right').appendTo('#right_box');
  7. // 防止多次监听
  8. $('#main').off('swipeLeft.once');
  9. $('#main').on('swipeLeft.once',function(){
  10. $('#main').addClass('show_right_nav');
  11. });
  12. $('#main').off('swipeRight.once');
  13. $('#main').on('swipeRight.once',function(){
  14. $('#main').removeClass('show_right_nav');
  15. });
  16. }
  17. }
  18. $('input:file').TPMupload('/Index/upload');
  19. }
  20. function show_right_nav(){
  21. if($('#main').is('.show_right_nav')){
  22. $('#main').removeClass('show_right_nav');
  23. }else{
  24. $('#main').addClass('show_right_nav');
  25. }
  26. }
  27. //扫描二维码
  28. function qrcode(){
  29. sina.barcodeScanner.scan(function(result) {
  30. TPM.http(result.text);
  31. });
  32. }
  33. //语言识别
  34. function voice(){
  35. if(!isclient){
  36. alert('请在手机客户端中使用');
  37. return ;
  38. }
  39. var appId = '4fa77fe4';
  40. sina.voice.recognizer.init(appId);
  41. sina.voice.recognizer.setOption({
  42. engine: 'sms',
  43. sampleRate: 'rate16k',
  44. });
  45. sina.voice.recognizer.setListener("onResults");
  46. sina.voice.recognizer.start(function(response) {
  47. console.log("response: " + response.errorCode + ", msg: " + response.message);
  48. });
  49. }
  50. function onResults(response)
  51. {
  52. response.results.forEach(function(recognizerResult) {
  53. $("#content").val( $("#content").val() + recognizerResult.text );
  54. });
  55. }
  56. //绑定账户
  57. function bind(type){
  58. var url="/Index/bind/type/"+type;
  59. if(isclient){
  60. tpm_popurl(TPM.op.api_base+url,function(){
  61. TPM.reload(TPM.op.main);
  62. },'绑定账号')
  63. }else{
  64. url=$('<a href="'+url+'"></a>')[0].href;
  65. tpm_popurl(url,function(){
  66. location.reload();
  67. },'绑定账号');
  68. }
  69. }