123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <script>
- import {
- login
- } from '@/api/user.js'
- import md5 from 'js-md5'
- export default {
- onLaunch: function(options) {
- if(options && options.query && options.query.user){
- this.getUserInfo({
- smsCode: "",
- captchaKey: "",
- captchaValue: "",
- username: options.query.user,
- password: "",
- mark: ""
- }).then(res => {
- if(this.loginCallBack){
- this.loginCallBack()
- }
- })
- }
- },
- onShow: function() {
- let mac = this.getDeviceMac();
- uni.setStorageSync("mac", mac);
- },
- onHide: function() {
- },
- methods: {
- getUserInfo(params) {
- return new Promise((resolve, reject) => {
- login({
- ...params,
- mark: md5(params.username + 'gdnxfdexam321')
- }).then(res => {
- // 保存本地token
- uni.setStorageSync('token', res.token);
- resolve(res)
- }).catch(err => {
- reject(err)
- })
- })
- },
- //获取设备的mac地址
- getDeviceMac() {
- //获取本机Mac地址
- var deviceMac = 'pc';
- if (uni.getSystemInfoSync().platform == "android") {
- var net = plus.android.importClass('java.net.NetworkInterface');
- var wl0 = net.getByName('wlan0');
- var macByte = wl0.getHardwareAddress();
- deviceMac = '';
- for (var i = 0; i < macByte.length; i++) {
- var tmp = '';
- var num = macByte[i];
- if (num < 0) {
- tmp = (255 + num + 1).toString(16);
- } else {
- tmp = num.toString(16);
- }
- if (tmp.length == 1) {
- tmp = '0' + tmp;
- }
- deviceMac += tmp;
- }
- }
- return deviceMac;
- },
- }
- }
- </script>
- <style lang="scss">
- /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
- @import './style/uni.css';
- /* 考试相关样式 */
- @import './style/style.css';
- /* 重写样式 */
- .uni-load-more__text {
- font-size: 14px !important;
- }
- .page-box {
- padding: 20px;
- font-size: 14px;
- display: flex;
- flex-direction: column;
- height: 100vh;
- }
- </style>
|