Commit 9f10fe24 authored by xinzhedeai's avatar xinzhedeai

登录 token

parent 69bfb31c
export default {
"list": [{
"letter": "A",
"data": [
"阿克苏机场",
"阿拉山口机场",
"阿勒泰机场",
"阿里昆莎机场",
"安庆天柱山机场",
"澳门国际机场"
]
}, {
"letter": "B",
"data": [
"保山机场",
"包头机场",
"北海福成机场",
"北京南苑机场",
"北京首都国际机场"
]
}, {
"letter": "C",
"data": [
"长白山机场",
"长春龙嘉国际机场",
"常德桃花源机场",
"昌都邦达机场",
"长沙黄花国际机场",
"长治王村机场",
"常州奔牛机场",
"成都双流国际机场",
"赤峰机场"
]
}, {
"letter": "D",
"data": [
"大理机场",
"大连周水子国际机场",
"大庆萨尔图机场",
"大同东王庄机场",
"达州河市机场",
"丹东浪头机场",
"德宏芒市机场",
"迪庆香格里拉机场",
"东营机场",
"敦煌机场"
]
}, {
"letter": "E",
"data": [
"鄂尔多斯机场",
"恩施许家坪机场",
"二连浩特赛乌苏国际机场"
]
}, {
"letter": "F",
"data": [
"阜阳西关机场",
"福州长乐国际机场"
]
}, {
"letter": "G",
"data": [
"赣州黄金机场",
"格尔木机场",
"固原六盘山机场",
"广元盘龙机场",
"广州白云国际机场",
"桂林两江国际机场",
"贵阳龙洞堡国际机场"
]
}, {
"letter": "H",
"data": [
"哈尔滨太平国际机场",
"哈密机场",
"海口美兰国际机场",
"海拉尔东山国际机场",
"邯郸机场",
"汉中机场",
"杭州萧山国际机场",
"合肥骆岗国际机场",
"和田机场",
"黑河机场",
"呼和浩特白塔国际机场",
"淮安涟水机场",
"黄山屯溪国际机场"
]
}, {
"letter": "I",
"data": []
}, {
"letter": "J",
"data": [
"济南遥墙国际机场",
"济宁曲阜机场",
"鸡西兴凯湖机场",
"佳木斯东郊机场",
"嘉峪关机场",
"锦州小岭子机场",
"景德镇机场",
"井冈山机场",
"九江庐山机场",
"九寨黄龙机场"
]
}, {
"letter": "K",
"data": [
"喀什机场",
"克拉玛依机场",
"库车龟兹机场",
"库尔勒机场",
"昆明巫家坝国际机场"
]
}, {
"letter": "L",
"data": [
"拉萨贡嘎机场",
"兰州中川机场",
"丽江三义机场",
"黎平机场",
"连云港白塔埠机场",
"临沧机场",
"临沂机场",
"林芝米林机场",
"柳州白莲机场",
"龙岩冠豸山机场",
"泸州蓝田机场",
"洛阳北郊机场"
]
}, {
"letter": "M",
"data": [
"满洲里西郊机场",
"绵阳南郊机场",
"漠河古莲机场",
"牡丹江海浪机场"
]
}, {
"letter": "N",
"data": [
"南昌昌北国际机场",
"南充高坪机场",
"南京禄口国际机场",
"南宁吴圩机场",
"南通兴东机场",
"南阳姜营机场",
"宁波栎社国际机场"
]
}, {
"letter": "O",
"data": []
}, {
"letter": "P",
"data": [
"普洱思茅机场"
]
}, {
"letter": "Q",
"data": [
"齐齐哈尔三家子机场",
"秦皇岛山海关机场",
"青岛流亭国际机场",
"衢州机场",
"泉州晋江机场"
]
}, {
"letter": "R",
"data": [
"日喀则和平机场"
]
}, {
"letter": "S",
"data": [
"三亚凤凰国际机场",
"汕头外砂机场",
"上海虹桥国际机场",
"上海浦东国际机场",
"深圳宝安国际机场",
"沈阳桃仙国际机场",
"石家庄正定国际机场",
"苏南硕放国际机场"
]
}, {
"letter": "T",
"data": [
"塔城机场",
"太原武宿国际机场",
"台州路桥机场 (黄岩机场)",
"唐山三女河机场",
"腾冲驼峰机场",
"天津滨海国际机场",
"通辽机场",
"铜仁凤凰机场"
]
}, {
"letter": "U",
"data": []
}, {
"letter": "V",
"data": []
}, {
"letter": "W",
"data": [
"万州五桥机场",
"潍坊机场",
"威海大水泊机场",
"文山普者黑机场",
"温州永强国际机场",
"乌海机场",
"武汉天河国际机场",
"乌兰浩特机场",
"乌鲁木齐地窝堡国际机场",
"武夷山机场",
"梧州长洲岛机场"
]
}, {
"letter": "X",
"data": [
"西安咸阳国际机场",
"西昌青山机场",
"锡林浩特机场",
"西宁曹家堡机场",
"西双版纳嘎洒机场",
"厦门高崎国际机场",
"香港国际机场",
"襄阳刘集机场",
"兴义机场",
"徐州观音机场"
]
}, {
"letter": "Y",
"data": [
"延安二十里堡机场",
"盐城机场",
"延吉朝阳川机场",
"烟台莱山国际机场",
"宜宾菜坝机场",
"宜昌三峡机场",
"伊春林都机场",
"伊宁机场",
"义乌机场",
"银川河东机场",
"永州零陵机场",
"榆林榆阳机场",
"玉树巴塘机场",
"运城张孝机场"
]
}, {
"letter": "Z",
"data": [
"湛江机场",
"昭通机场",
"郑州新郑国际机场",
"芷江机场",
"重庆江北国际机场",
"中卫香山机场",
"舟山朱家尖机场",
"珠海三灶机场"
]
}]
}
import { showCustomModal } from "./util";
import { showCustomModal, storageInfo } from "./util";
import { BASEURL, REQUESTIMEOUT } from "./config";
console.log(BASEURL, 'BASEURLBASEURLBASEURL')
const BASE_URL = BASEURL;
const REQUEST_TIMEOUT = REQUESTIMEOUT;
......@@ -13,6 +12,7 @@ export default function request(options) {
data: options.data || {},
header: options.header || {
'Content-Type': 'application/json',
'Authorization': storageInfo.get('token')
},
success: (res) => {
console.log(res, 'request')
......@@ -40,6 +40,17 @@ uni.addInterceptor("request", {
msg
} = res.data;
console.log('addInterceptor', code, msg)
if(code === 401){
showCustomModal({
content: msg,
success: function() {
uni.reLaunch({ // 登录超时跳转登录页面
url: "/pages/user/login"
})
}
});
return
}
if (code !== 200) {
showCustomModal({
content: msg,
......@@ -49,6 +60,7 @@ uni.addInterceptor("request", {
// });
return;
}
return Promise.resolve(res.data);
},
fail(err) {
......
......@@ -274,6 +274,58 @@ function stringToBytes(str) {
// return an array of bytes
return re;
}
var dater = {
getDate: function(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
}
var storager = {
set: function(key, content){
uni.setStorageSync(key, content)
},
get: function(key){
return uni.getStorageSync(key)
}
}
var popuper = {
showLoading: function(obj){
uni.showLoading({
title: obj.title || '加载中...',
mask: true
})
},
hideLoading: function(){
uni.hideLoading()
}
}
var pager = {
navTo: function(url){
uni.navigateTo({
url
})
},
relaunchTo: function(url){
uni.reLaunch({
url
})
}
}
var blueToother = {
openBluetoothAdapter: function() {
return new Promise((resolve, reject) => {
......@@ -467,5 +519,10 @@ export {
showCustomToast,
commonStateCodeDeal,
blueToother,
getCurrentPage
getCurrentPage,
popuper,
storager,
dater,
pager
}
\ No newline at end of file
......@@ -103,7 +103,7 @@
<view>备注</view>
</uni-col>
<uni-col :span="15">
<input class="uni-input inputEle" focus placeholder="请输入" />
<input class="uni-input inputEle" placeholder="请输入" />
</uni-col>
</uni-row>
</view>
......
......@@ -70,16 +70,14 @@
</template>
<script>
import {
formatNumber,
formatDateThis,
getUnixTime
} from "../../common/dateUtil.js"
import {
stringToBytes,
showCustomModal,
showCustomToast,
commonStateCodeDeal
commonStateCodeDeal,
popup,
storager,
pager
} from "../../common/util.js"
import * as XLSX from '@/common/excel.js'
import {
......@@ -104,6 +102,9 @@
uni.hideLoading()
},
mounted() {
const deviceInfo = uni.getStorageSync('deviceInfo')
if (deviceInfo) { // 获取蓝牙设备型号id
this.deviceInfo = deviceInfo
......@@ -124,9 +125,21 @@
filePath: res.tempFiles[0].path,
name: 'file', //接口需要的参数名
header: {
'Authorization': storager.get('token')
},
success(uploadRes) {
const res = JSON.parse(uploadRes.data)
if(res.code === 401){
showCustomModal({
content: res.msg,
success: function() {
pager.navTo({ // 登录超时跳转登录页面
url: "/pages/user/login"
})
}
});
return
}
showCustomToast({
title: res.msg
})
......
......@@ -4,25 +4,13 @@
</CustomNavbar>
<view class="body-wrapper">
<view class="demo-uni-row">
<uni-row>
<uni-col :span="6" class="_title">
<view>工程名称</view>
</uni-col>
<uni-col :span="16">
<uni-data-select v-model="form.productName" :localdata="selectListLv1" :clear="false"
@change="changeLv1"></uni-data-select>
</uni-col>
</uni-row>
</view>
<view class="demo-uni-row">
<uni-row class="demo-uni-row mb-10">
<uni-col :span="6" class="_title">
<view>爆区名称</view>
<view>测量员</view>
</uni-col>
<uni-col :span="16">
<uni-data-select v-model="form.artilleryAreaName" :localdata="selectListLv2" :clear="false"
@change="changeLv2"></uni-data-select>
<input class="uni-input inputEle" v-model="searchForm.operationPerson" placeholder="请输入" />
</uni-col>
</uni-row>
</view>
......@@ -41,7 +29,7 @@
</picker>
</uni-col>
</uni-row>
<view class="funcBtn end" @tap="resetForm">
<view class="funcBtn end" @tap="search">
搜索
</view>
</view>
......@@ -51,20 +39,21 @@
<view class="table-wrapper">
<uni-table ref="table" :loading="loading" emptyText="暂无更多数据" @selection-change="selectionChange">
<uni-tr>
<uni-th width="50" align="center"><span style="color:#3a74ba;font-size:30rpx;">序号</span></uni-th>
<uni-th width="100" align="center">操作模块</uni-th>
<uni-th width="80" align="center">操作类型</uni-th>
<uni-th width="120" align="center">操作人</uni-th>
<uni-th width="130" align="center">操作时间</uni-th>
<uni-th width="200" align="center">操作内容</uni-th>
<uni-th width="50" align="center"><span class="tableTh">序号</span></uni-th>
<uni-th width="100" align="center"><span class="tableTh">操作模块</span></uni-th>
<uni-th width="80" align="center"><span class="tableTh">操作类型</span></uni-th>
<uni-th width="120" align="center"><span class="tableTh">操作人</span></uni-th>
<uni-th width="200" align="center"><span class="tableTh">操作时间</span></uni-th>
<uni-th width="200" align="center"><span class="tableTh">操作内容</span></uni-th>
</uni-tr>
<uni-tr v-for="(item, index) in dataList" :key="index">
<uni-td align="center">{{index}}</uni-td>
<uni-td align="center">{{ item.operationModule }}</uni-td>
<uni-td align="center">{{ item.operationType }}</uni-td>
<uni-td align="center">{{ item.operationPerson }}</uni-td>
<uni-td align="center">{{ item.operationTime }}</uni-td>
<uni-td align="center">{{ item.operationRemark }}</uni-td>
<uni-td align="center"><span class="tableTd">{{index+1}}</span></uni-td>
<uni-td align="center"><span class="tableTd">{{ item.operationModule }}</span></uni-td>
<uni-td align="center"><span class="tableTd">{{ item.operationType }}</span></uni-td>
<uni-td align="center"><span class="tableTd">{{ item.operationPerson }}</span></uni-td>
<uni-td align="center"><span class="tableTd">{{ item.operationTime }}</span></uni-td>
<uni-td align="center"><span class="tableTd">{{ item.operationRemark }}</span></uni-td>
</uni-tr>
</uni-table>
</view>
......@@ -76,7 +65,8 @@
import {
getCurrentTime,
showCustomToast,
showCustomModal
showCustomModal,
dater
} from '../../common/util.js'
import {
getDataList,
......@@ -88,7 +78,7 @@
CustomNavbar,
},
data() {
const currentDate = this.getDate({
const currentDate = dater.getDate({
format: true
})
return {
......@@ -96,27 +86,10 @@
searchForm: {
startTime: currentDate,
endTime: currentDate,
operationPerson: ''
},
dataList: [],
navBarTitle: '操作日志',
redirectUrl: '/pages/home/blueSearch?refer=blueMeasure',
searchDate: '',
// 表单数据相关
zhuangyaoDict: [],
form: {
'productName': '',
'artilleryAreaName': '',
'cannonHoleArrayNum': '',
'cannonHoleNum': '',
'status': '',
'expectedDepth': '',
'actualDepth': '',
'actualWaterLevel': ''
},
selectList4productName: [],
selectList4tester: [],
};
},
......@@ -129,10 +102,10 @@
},
computed: {
startDate() {
return this.getDate('start');
return dater.getDate('start');
},
endDate() {
return this.getDate('end');
return dater.getDate('end');
}
},
methods: {
......@@ -163,69 +136,30 @@
bindDateChange4end: function(e) {
this.searchForm.endTime = e.detail.value
},
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
selectDate() {
// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center']
this.$refs.popup.open('center')
},
calendarConfirm(e) {
console.log(e)
const formattedDates = e.map(date => date.split(' ')[0]);
this.searchDate = formattedDates
this.$refs.popup.close()
},
dateRangeMaxDeal(e) {
console.log('超过最大连选天数:', e)
},
async getDetailInfo() {
let res = await getDetailInfo()
if (res) {
this.form['status'] = res['status']
this.form['expectedDepth'] = res['expectedDepth']
this.form['designInclination'] = res['designInclination']
return
}
showCustomToast({
title: '暂无详情信息'
})
},
}
};
</script>
<style lang="scss">
::v-deep .uni-popup .uni-popup__wrapper {
display: block;
position: relative;
width: 80vw;
.tableTh{
color:#3a74ba;font-size:30rpx;
font-family: Source Han Sans SC;
}
.tableTd{
color:#000;font-size:30rpx;
font-family: Source Han Sans SC;
font-weight: bold;
}
::v-deep .uni-select__input-placeholder {
// placeholder样式调整
font-size: 30rpx !important;
}
.inputEle {
.inputEle{
height: 110rpx;
display: flex;
align-items: center;
}
.uni-col-6 {
font-size: 32rpx;
font-weight: bold;
......@@ -267,30 +201,6 @@
}
}
.only-read-row {
background: #E3E6EC !important;
height: 108rpx;
align-items: center;
display: flex;
line-height: 70rpx;
position: relative;
padding-left: 13rpx;
&:after {
content: '米';
width: 70rpx;
height: 70rpx;
position: absolute;
right: 48rpx;
top: 50%;
transform: translateY(-50%);
text-align: center;
line-height: 70rpx;
font-size: 29rpx;
color: #000000;
}
}
::v-deep .uni-row::after {
clear: both;
width: 608rpx;
......
......@@ -7,10 +7,10 @@
</view>
<view class='content'>
<view class="title">手机号</view>
<input class="uni-input" focus placeholder="请输入手机号" />
<input class="uni-input" focus placeholder="请输入手机号" v-model="phone" />
</view>
<button class='loginBtn' type='primary' @getuserinfo="wxLogin">
<button class='loginBtn' type='primary' @click="wxLogin">
授权登录
</button>
</view>
......@@ -19,7 +19,7 @@
<script>
import {showCustomToast} from '../../common/util.js'
import {showCustomToast, popuper, storageInfo, pager} from '../../common/util.js'
import {login} from '../../api/login.js'
export default {
onLoad() {
......@@ -43,24 +43,27 @@
"errMsg": "getUserInfo:ok"
}
*/
},
data() {
return {
phone: ''
}
},
methods: {
async wxLogin(){
const token = uni.getStorageSync('accessToken')
popuper.hideLoading({title: '登录中...'})
const loginRes = await this.getWxCode()
if(!loginRes.code){
showCustomToast({
title: 'code未获取'
})
return
}
const userInfo = await this.getUserInfo()
if(!userInfo.iv){
showCustomToast({
title: 'iv未获取'
})
return
}
await this.getToken(loginRes.code, userInfo)
......@@ -95,37 +98,20 @@
data: {
"code": code,
"encryptedIv": userInfo.iv,
"encryptedData": userInfo.encryptedData
"encryptedData": userInfo.encryptedData,
phone: this.phone
},
})
console.log('res', res)
popuper.hideLoading()
if(res){
uni.setStorageSync('accessToken', res.token)
storageInfo.set('token', res.token)
console.log('获取token', res.token)
}
// let [error, res] = await uni.request({
// url: `http://192.168.2.14:8080/weixin/wxLogin`,
// data: {
// "code": code,
// "encryptedIv": userInfo.iv,
// "encryptedData": userInfo.encryptedData
// },
// method: 'POST',
// header: {
// // 'accessToken': uni.getStorageSync('accessToken'),
// }
// });
// if (error) {
// showCustomToast({
// title: '网络错误'
// })
// return
// }
// if(res.data.code === 200){
// uni.setStorageSync('accessToken', res.data.token)
// }
pager.relaunchTo({
url: '/pages/home/home'
})
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment