123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
- <link rel="stylesheet" href="./css/element.css">
- <script src="./js/babel.min.js"></script>
- <script src="./js/vue.js"></script>
- <script src="./js/axios.min.js"></script>
- <script src="./js/element.js"></script>
- <title>大卫博士-防伪查询</title>
- <script type="text/javascript">
- document.addEventListener('plusready', function() {
- //console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。")
- });
- </script>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
- html,
- body,
- #app {
- width: 100%;
- height: 100%;
- display: flex;
- justify-content: flex-start;
- flex-direction: column;
- }
- .LoginContainer {
- flex: 1;
- overflow: hidden;
- padding: 80px 25px;
- box-sizing: border-box;
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- }
- .LoginHeader {
- color: #333333;
- width: 100%;
- }
- .LoginHeader>p {
- display: inline-block;
- color: #333333;
- font-size: 32px;
- position: relative;
- }
- .LoginHeader>p:after {
- content: "";
- display: block;
- width: 25px;
- height: 8px;
- background: linear-gradient(to right, #A080FF, #5D6BFF);
- position: absolute;
- right: -15px;
- bottom: 5px;
- z-index: -1;
- }
- .FormInput {
- width: 100%;
- border: none;
- border-bottom: 1px solid #EEEEEE;
- padding: 15px 0;
- margin-bottom: 15px;
- outline: none;
- }
- .LoginSubmit {
- width: calc(100% - 40px);
- height: 48px;
- margin: 0 auto;
- border-radius: 48px;
- text-align: center;
- line-height: 48px;
- color: #FFFFFF;
- font-size: 20px;
- background: linear-gradient(to right, #A080FF, #5D6BFF);
- }
- /* [v-cloak]{
- display: none !important;
- } */
- </style>
- </head>
- <!-- <body v-cloak>
- <div id="app" v-cloak> -->
- <body>
- <div id="app">
- <div class="LoginContainer">
- <div class="LoginHeader">
- <!-- {{ width }} -->
- <p>登录</p>
- </div>
- <div class="LoginForm">
- <input v-model="phone" type="text" placeholder="请输入手机号" class="FormInput">
- <input v-model="password" type="password" placeholder="请输入密码" class="FormInput">
- </div>
- <p class="LoginSubmit" @click="toLogin">确认登录</p>
- </div>
- </div>
- <script type="text/babel">
- var app = new Vue({
- el: '#app',
- data() {
- return {
- width: 10,
- phone:'',
- password: '',
- uuid: '',
- // 账号密码15236877164 12345678
- // 860681052009616,860681052009624
-
- }
- },
- mounted() {
- this.width = document.documentElement.clientHeight
- this.isLogin()
- let that = this
- if (window.plus) {
- // 在这里调用5+ API
- this.getDeviceInfo()
- } else { // 兼容老版本的plusready事件
- document.addEventListener('plusready',function () {
- that.getDeviceInfo()
- },false)
- }
- },
- methods: {
- isLogin() {
- let token = window.localStorage.getItem("token")
- let name = window.localStorage.getItem("name")
- let uuid = window.localStorage.getItem("uuid")
- if(token && name && uuid) {
- this.checkLoginTokenSuccess()
- }
- },
- checkLoginTokenSuccess() {
- let loading = window.ELEMENT.Loading.service()
- let _this = this
- axios.get('http://fangwei.cliu.cc/api/get_good', {
- headers: {
- Authorization: `Bearer ` + localStorage.getItem("token")
- }
- }).then(res => {
- loading.close()
- if(res.code === 200) {
- window.location.href = "./pages/product.html"
- } else {
- window.localStorage.removeItem("token")
- }
- }).catch(() => {
- loading.close()
- window.localStorage.removeItem("token")
- })
- },
- getDeviceInfo(){
- let that = this
- plus.device.getInfo({
- success:function(e){
- that.uuid = e.uuid
- },
- fail:function(e){
- that.uuid = JSON.stringify(e.uuid)
- }
- });
- },
- toLogin() {
- if(!this.phone) {
- window.ELEMENT.Message.error('请输入手机号')
- return false
- }
- if(!this.password) {
- window.ELEMENT.Message.error('请输入密码')
- return false
- }
- let loading = window.ELEMENT.Loading.service()
- let _this = this
- axios.get('http://fangwei.cliu.cc/api/NewLogin', {
- params: {
- mobile: _this.phone,
- password: _this.password,
- uuid: _this.uuid
- }
- }).then(res => {
- loading.close()
- if (res.code === 200) {
- window.localStorage.setItem('token', res.data.token)
- window.localStorage.setItem('name', res.data.name)
- window.localStorage.setItem('uuid', _this.uuid)
- console.log(res.data)
- window.location.href = "./pages/product.html"
- } else {
- window.ELEMENT.Message.error(res.msg || '登陆失败')
- }
- }).catch(() => {
- loading.close()
- window.ELEMENT.Message.error('登陆失败')
- })
- }
- }
- })
- </script>
- </body>
- </html>
|