初步接触vue语言,使用ajax调用后台API nginx环境下打开页面
年会前端项目:
主要页面:annual-party/pages/vip.html (入口 )
annual-party/pages/list.html (显示节目列表,用户进行评分)
使用到的库或UI
使用Vue https://cn.vuejs.org/
UI : http://dev.dcloud.net.cn/mui/
http://materializecss.com/mobile.html
一、获取页面中的工号字符串:
1 2 3
| var href = window.location.href; //获取地址 var code = href.substring(href.lastIndexOf('/')+1,href.indexOf('.html')) //lastindexOf('/')表示url中第一个出现/的地方 console.log(code)
|
二、$.ajax的一般格式
1 2 3 4 5 6 7
| $.ajax({ type: 'POST', url: url , data: data , success: success , dataType: dataType });
|
三、用户保存分数接口如下:
代码实现如下:
【 $.post(FRONT_URL + url, params, callback);】
1 2 3 4 5 6
| $.post(FRONT_URL + "user/saveScore", {userId:app.user.id, userCode:app.user.code, seq:curRow+1, score:app.modalData.score}, function(result){ console.log(result), app.items[curRow].score=app.modalData.score });
|
四、判断是否使用微信
1 2 3 4 5 6 7 8
| function is_weixn(){ var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger/i)=="micromessenger") { return true; } else { return false; } }
|
五、若使用微信则延时三秒便关闭窗口
1 2 3
| if(is_weixn()){ WeixinJSBridge.call('closeWindow'); //weixin close browser }
|