版本提交
This commit is contained in:
parent
2dfa821ffb
commit
1a3572800f
|
|
@ -50,3 +50,12 @@ export const assetInfo = (query) => {
|
|||
}
|
||||
|
||||
|
||||
// 轮播图
|
||||
export const bannerList = (query) => {
|
||||
return apiResquest({
|
||||
url: 'v1/banner.list',
|
||||
method: 'get',
|
||||
query: query
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
// 唤起倍速操作
|
||||
showSpeedOptions() {
|
||||
this.showSpeedModal = true;
|
||||
},
|
||||
},
|
||||
// 隐藏倍速操作
|
||||
hideSpeedOptions() {
|
||||
this.showSpeedModal = false;
|
||||
|
|
@ -100,11 +100,11 @@
|
|||
orientation: 'portrait'
|
||||
});
|
||||
}
|
||||
uni.showToast({
|
||||
title: that.fullScreen ? '开启全屏' : '关闭全屏',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
// uni.showToast({
|
||||
// title: that.fullScreen ? '开启全屏' : '关闭全屏',
|
||||
// icon: 'none',
|
||||
// duration: 1500
|
||||
// });
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +134,8 @@
|
|||
}
|
||||
|
||||
.video-heizith-menu {
|
||||
position: absolute;
|
||||
/* position: absolute; */
|
||||
position: fixed;
|
||||
right: 30rpx;
|
||||
bottom: 20%;
|
||||
z-index: 998;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<view>
|
||||
<u-sticky>
|
||||
<view style="position: relative;">
|
||||
<u-swiper :list="swiper" keyName="image" circular height="470rpx" bgColor="#ffffff"></u-swiper>
|
||||
<u-swiper :list="swiperList" keyName="src" interval='10000' circular height="470rpx" bgColor="#ffffff"></u-swiper>
|
||||
<view class="search-input">
|
||||
<view style="width: 90%;margin: 0 auto;">
|
||||
<u-search @search='search' searchIconColor='#e6e6e6' placeholderColor='#e6e6e6' color='#FFFFFF'
|
||||
|
|
@ -43,7 +43,8 @@
|
|||
import {
|
||||
trainHas,
|
||||
assetList,
|
||||
assetInfo
|
||||
assetInfo,
|
||||
bannerList
|
||||
} from '@/api/train.js'
|
||||
import {
|
||||
userInfo
|
||||
|
|
@ -61,11 +62,7 @@
|
|||
page: 1,
|
||||
limit: 10,
|
||||
},
|
||||
swiper: [ // 轮播图
|
||||
{
|
||||
image: '/static/img/demo/winter1.jpeg',
|
||||
}
|
||||
],
|
||||
swiperList: [],
|
||||
assetList: [],
|
||||
|
||||
tabsList: [{
|
||||
|
|
@ -105,6 +102,7 @@
|
|||
onLoad() {
|
||||
this.getUserInfo()
|
||||
this.getList()
|
||||
this.getBannerList()
|
||||
},
|
||||
onShow() {
|
||||
//查看是否填写意向调查表
|
||||
|
|
@ -135,6 +133,14 @@
|
|||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
getBannerList() {
|
||||
bannerList({
|
||||
position: 'home',
|
||||
org_id:getApp().globalData.org_id
|
||||
}).then(res => {
|
||||
this.swiperList = res.data
|
||||
})
|
||||
},
|
||||
search() {
|
||||
this.page = 1
|
||||
this.assetList = []
|
||||
|
|
@ -151,7 +157,7 @@
|
|||
if (!res.data.train) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先选择技能培训意向表',
|
||||
content: '请选择技能培训意向',
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/home/train'
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@
|
|||
<u-cell-group :border='false'>
|
||||
<!-- @click="handleName" -->
|
||||
<u-cell title="姓名" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">姓名</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 400rpx;" slot="value">
|
||||
<input type="text" v-model="userInfo.name" />
|
||||
</view>
|
||||
|
|
@ -12,6 +16,10 @@
|
|||
</u-cell>
|
||||
<!-- @click="handleIdcard" -->
|
||||
<u-cell title="身份证号" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">身份证号</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
<input type="text" v-model="userInfo.idcard" />
|
||||
</view>
|
||||
|
|
@ -19,6 +27,10 @@
|
|||
</u-cell>
|
||||
<!-- @click="handleMobile" -->
|
||||
<u-cell title="手机号" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">手机号</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
<input type="number" v-model="userInfo.contact_mobile" />
|
||||
</view>
|
||||
|
|
@ -26,6 +38,10 @@
|
|||
</u-cell>
|
||||
<u-cell title="性别" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}"
|
||||
@click="handleSex">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">性别</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
{{userInfo.sex?sexList[userInfo.sex-1]:''}}
|
||||
</view>
|
||||
|
|
@ -33,6 +49,10 @@
|
|||
</u-cell>
|
||||
<u-cell @click="handleBirth" title="生日" size="large" :border='false'
|
||||
:titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">生日</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
{{userInfo.birthday}}
|
||||
</view>
|
||||
|
|
@ -40,6 +60,10 @@
|
|||
</u-cell>
|
||||
<u-cell title="学历" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}"
|
||||
@click="handleEmotion">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">学历</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
{{userInfo.degree?educationList[userInfo.degree-1]:''}}
|
||||
</view>
|
||||
|
|
@ -47,6 +71,10 @@
|
|||
</u-cell>
|
||||
<u-cell title="政治面貌" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}"
|
||||
@click="handleJob">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">政治面貌</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
{{userInfo.political?politicalList[userInfo.political-1]:''}}
|
||||
</view>
|
||||
|
|
@ -54,6 +82,10 @@
|
|||
</u-cell>
|
||||
<u-cell title="安置地" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}"
|
||||
@click="showCity">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">安置地</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 450rpx;" slot="value">
|
||||
{{userInfo.to_province_name}}{{userInfo.to_city_name}}{{userInfo.to_area_name}}
|
||||
</view>
|
||||
|
|
@ -62,6 +94,10 @@
|
|||
|
||||
<u-cell title="现居住地" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}"
|
||||
@click="showReside">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">现居住地</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 450rpx;" slot="value">
|
||||
{{userInfo.reside_province_name}}{{userInfo.reside_city_name}}{{userInfo.reside_area_name}}
|
||||
</view>
|
||||
|
|
@ -69,6 +105,10 @@
|
|||
</u-cell>
|
||||
<!-- @click="handleDetail" -->
|
||||
<u-cell title="详细地址" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">详细地址</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 450rpx;" slot="value">
|
||||
<input type="text" v-model="userInfo.detail" />
|
||||
</view>
|
||||
|
|
@ -76,6 +116,10 @@
|
|||
</u-cell>
|
||||
<u-cell @click="handlejoinTime" title="入伍时间" size="large" :border='false'
|
||||
:titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">入伍时间</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
{{userInfo.join_time}}
|
||||
</view>
|
||||
|
|
@ -83,6 +127,10 @@
|
|||
</u-cell>
|
||||
<u-cell @click="handleretireTime" title="退役时间" size="large" :border='false'
|
||||
:titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">退役时间</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
{{userInfo.retire_time}}
|
||||
</view>
|
||||
|
|
@ -90,6 +138,10 @@
|
|||
</u-cell>
|
||||
<u-cell title="人员类别" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}"
|
||||
@click="handleCategory">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">人员类别</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
{{userInfo.category?categoryList[userInfo.category-1]:''}}
|
||||
</view>
|
||||
|
|
@ -97,6 +149,10 @@
|
|||
</u-cell>
|
||||
<u-cell title="健康状态" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}"
|
||||
@click="handleHealth">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">健康状态</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
{{ userInfo.health?healthList[userInfo.health-1]:''}}
|
||||
</view>
|
||||
|
|
@ -104,7 +160,11 @@
|
|||
</u-cell>
|
||||
<!-- @click="handlePurpose" -->
|
||||
<u-cell title="职业技能培训意向" size="large" :border='false' :titleStyle="{fontSize:'32rpx',color:'#9CA3AF'}">
|
||||
<view class="input-val" style="width: 350rpx;" slot="value">
|
||||
<view slot="title">
|
||||
<text style="color: #f56c6c;margin-right: 10rpx;">*</text>
|
||||
<text style="font-size: 16px; color: #9CA3AF;">职业技能培训意向</text>
|
||||
</view>
|
||||
<view class="input-val" style="width: 330rpx;" slot="value">
|
||||
<input type="text" v-model="userInfo.purpose" />
|
||||
</view>
|
||||
<u-icon slot="right-icon" name="edit-pen" size="26" color="#9CA3AF"></u-icon>
|
||||
|
|
@ -219,11 +279,17 @@
|
|||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
console.log(options, '');
|
||||
var that = this
|
||||
if (options.type && options.type == 'register') {
|
||||
this.userInfo.org_id = 1
|
||||
this.userInfo.code = options.code
|
||||
this.pageType = options.type
|
||||
that.userInfo.org_id = 1
|
||||
that.pageType = options.type
|
||||
uni.login({
|
||||
success(res) {
|
||||
if (res.errMsg == "login:ok") {
|
||||
that.userInfo.code = res.code
|
||||
}
|
||||
}
|
||||
})
|
||||
uni.setNavigationBarTitle({
|
||||
title: '用户注册'
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
<!-- 状态栏 -->
|
||||
<view class="status-bar bg-white pt-30"></view>
|
||||
<!-- 头像栏 -->
|
||||
<view class="flex items-center wrap-card" hover-class="bg-gray-100" @click="$u.route('/pages/mine/set')">
|
||||
<image class="header-img" src="/static/img/header/a.svg" mode="" @click.stop="$u.route('/pages/mine/set')">
|
||||
<view class="flex items-center wrap-card" hover-class="bg-gray-100" @click="$u.route('/pages/mine/edit-info')">
|
||||
<image class="header-img" src="/static/img/header/a.svg" mode=""
|
||||
@click.stop="$u.route('/pages/mine/edit-info')">
|
||||
</image>
|
||||
<view class="flex flex-col flex-1 px-20">
|
||||
<text class="text-32 font-bold">{{userInfo.name}}</text>
|
||||
|
|
@ -25,8 +26,10 @@
|
|||
</view>
|
||||
</view> -->
|
||||
<!-- 广告位 -->
|
||||
<view class="wrap-card">
|
||||
<image class="adv-img rounded-20" src="../../static/img/demo/winter1.jpeg" mode="aspectFill"></image>
|
||||
<view class="wrap-cards">
|
||||
<!-- <image class="adv-img rounded-20" src="../../static/img/demo/winter1.jpeg" mode="aspectFill"></image> -->
|
||||
<u-swiper :list="swiperList" keyName="src" interval='10000' circular height="180rpx"
|
||||
bgColor="#ffffff"></u-swiper>
|
||||
</view>
|
||||
<!-- 设置 -->
|
||||
<u-cell-group :border='false'>
|
||||
|
|
@ -42,8 +45,10 @@
|
|||
import {
|
||||
userInfo,
|
||||
fileGet,
|
||||
|
||||
} from '@/api/login.js'
|
||||
import {
|
||||
bannerList
|
||||
} from '@/api/train.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -81,7 +86,7 @@
|
|||
|
||||
{
|
||||
icon: 'iconshezhi1',
|
||||
name: '我的设置',
|
||||
name: '修改资料',
|
||||
url: 'set'
|
||||
},
|
||||
{
|
||||
|
|
@ -97,9 +102,13 @@
|
|||
}
|
||||
],
|
||||
userInfo: {},
|
||||
flieList: {}
|
||||
flieList: {},
|
||||
swiperList: [],
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getBannerList()
|
||||
},
|
||||
onShow() {
|
||||
this.getUserInfo()
|
||||
this.getFileGet()
|
||||
|
|
@ -109,11 +118,20 @@
|
|||
this.goSet()
|
||||
},
|
||||
methods: {
|
||||
|
||||
getBannerList() {
|
||||
bannerList({
|
||||
position: 'mine',
|
||||
org_id: getApp().globalData.org_id
|
||||
}).then(res => {
|
||||
this.swiperList = res.data
|
||||
})
|
||||
},
|
||||
getFileGet() {
|
||||
fileGet().then(res => {
|
||||
this.flieList = res.data
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
getUserInfo() {
|
||||
|
|
@ -123,7 +141,7 @@
|
|||
})
|
||||
},
|
||||
goSet() {
|
||||
this.$u.route('/pages/mine/set')
|
||||
this.$u.route('/pages/mine/edit-info')
|
||||
},
|
||||
goPage(type) {
|
||||
switch (type) {
|
||||
|
|
@ -131,7 +149,7 @@
|
|||
this.$u.route('/pages/mine/' + type)
|
||||
break;
|
||||
case 'set':
|
||||
this.$u.route('/pages/mine/' + type)
|
||||
this.$u.route('/pages/mine/edit-info')
|
||||
break;
|
||||
case 'file2':
|
||||
this.downloadFile(this.flieList.file2)
|
||||
|
|
@ -227,6 +245,11 @@
|
|||
border-radius: 100%;
|
||||
}
|
||||
|
||||
.wrap-cards {
|
||||
width: 92%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.adv-img {
|
||||
height: 200rpx;
|
||||
width: 100%;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
<template>
|
||||
<view>
|
||||
<zxVideo :url="info.video_url" :isSpeed="isSpeed" :showCasting="showCasting" :lockButton="lockButton"></zxVideo>
|
||||
<u-sticky bgColor="#fff">
|
||||
<zxVideo :url="info.video_url" :isSpeed="isSpeed" :showCasting="showCasting" :lockButton="lockButton">
|
||||
</zxVideo>
|
||||
</u-sticky>
|
||||
<view class="detail">
|
||||
<view class="title">
|
||||
{{info.asset_name}}
|
||||
|
|
@ -79,7 +82,8 @@
|
|||
color: #595959;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.parse{
|
||||
|
||||
.parse {
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
<u-navbar placeholder>
|
||||
<u-icon slot="left" @click="nav" name="arrow-left" color="#000000" size="22"></u-icon>
|
||||
<view slot="center" style="margin-right: 100rpx;">
|
||||
<u-search v-model="queryParams.asset_name" placeholder="搜索新鲜事" @search='search'
|
||||
<u-search v-model="queryParams.asset_name" placeholder="搜索您想要的内容" @search='search'
|
||||
:showAction="false"></u-search>
|
||||
</view>
|
||||
</u-navbar>
|
||||
<!-- 标签 -->
|
||||
<u-sticky bgColor="#fff">
|
||||
<u-sticky customNavHeight='88px' bgColor="#fff">
|
||||
<u-tabs class="wrap-card" ref="tabs" @change="changeTab" :list="groupList" :current="tabIndex"
|
||||
lineColor="#3c9cff" keyName='group_name' :activeStyle="{color:'#3c9cff'}"
|
||||
:inactiveStyle="{color:'#909399'}" lineWidth="30" :scrollable="false">
|
||||
|
|
|
|||
|
|
@ -1,40 +1,98 @@
|
|||
// import {
|
||||
// login
|
||||
// } from '@/api/login.js'
|
||||
|
||||
// function codes() {
|
||||
// // #ifdef MP-WEIXIN
|
||||
// uni.login({
|
||||
// success: (res) => {
|
||||
// console.log(res);
|
||||
// if (res.errMsg == "login:ok") {
|
||||
// login({
|
||||
// code: res.code,
|
||||
// org_id: getApp().globalData.org_id,
|
||||
// }).then(response => {
|
||||
// //注册的 保存token
|
||||
|
||||
// if (response.data.token) {
|
||||
// uni.setStorageSync('token', response.data.token)
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/home/home'
|
||||
// })
|
||||
// }
|
||||
// else {
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/mine/edit-info?type=register'
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// uni.showToast({
|
||||
// title: '系统异常,请联系管理员!'
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// // #endif
|
||||
|
||||
// }
|
||||
// export default {
|
||||
// codes
|
||||
// }
|
||||
|
||||
|
||||
|
||||
import {
|
||||
login
|
||||
} from '@/api/login.js'
|
||||
|
||||
function codes() {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
console.log(res);
|
||||
if (res.errMsg == "login:ok") {
|
||||
login({
|
||||
code: res.code,
|
||||
org_id: getApp().globalData.org_id,
|
||||
}).then(response => {
|
||||
//注册的 保存token
|
||||
if (response.data.token) {
|
||||
uni.setStorageSync('token', response.data.token)
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/home'
|
||||
})
|
||||
}
|
||||
else {
|
||||
uni.reLaunch({
|
||||
url: '/pages/mine/edit-info?type=register' + '&code=' + res.code
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '系统异常,请联系管理员!'
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
console.log(res);
|
||||
if (res.errMsg == "login:ok") {
|
||||
login({
|
||||
code: res.code,
|
||||
org_id: getApp().globalData.org_id,
|
||||
}).then(response => {
|
||||
// 注册的保存token
|
||||
if (response.data.token) {
|
||||
uni.setStorageSync('token', response.data.token);
|
||||
resolve(response.data.token); // 返回新的 token
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/home'
|
||||
});
|
||||
} else {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先用户注册',
|
||||
success: function(res) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/mine/edit-info?type=register'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err); // 处理请求错误
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '系统异常,请联系管理员!'
|
||||
});
|
||||
reject(new Error('Login failed'));
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
reject(new Error('Login failed'));
|
||||
}
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
});
|
||||
// #endif
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
codes
|
||||
}
|
||||
|
|
@ -1,29 +1,85 @@
|
|||
// import wxCode from '@/utils/lib/code.js'
|
||||
|
||||
// export const apiResquest = (prams) => {
|
||||
|
||||
// return new Promise((resolve, reject) => {
|
||||
// let url = getApp().globalData.webApi + prams.url;
|
||||
// return uni.request({
|
||||
// url: url,
|
||||
// data: prams.query,
|
||||
// method: prams.method,
|
||||
// header: {
|
||||
// 'Authorization': uni.getStorageSync("token"),
|
||||
// },
|
||||
// success: (res) => {
|
||||
// // uni.hideLoading()
|
||||
// if (res.data.code == 1) {
|
||||
// wxCode.codes()
|
||||
// }
|
||||
// resolve(res.data);
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// reject(err);
|
||||
// },
|
||||
// complete: () => {
|
||||
// console.log('请求完成')
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
// }
|
||||
|
||||
|
||||
|
||||
import wxCode from '@/utils/lib/code.js'
|
||||
|
||||
export const apiResquest = (prams) => {
|
||||
let isRefreshing = false; // 标志位,表示是否正在刷新token
|
||||
let pendingRequests = []; // 存储等待中的请求
|
||||
|
||||
export const apiResquest = (params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let url = getApp().globalData.webApi + params.url;
|
||||
|
||||
uni.request({
|
||||
url: url,
|
||||
data: params.query,
|
||||
method: params.method,
|
||||
header: {
|
||||
'Authorization': uni.getStorageSync("token"),
|
||||
},
|
||||
success: (res) => {
|
||||
// 如果返回的 code 为 1,表示需要重新获取 token
|
||||
if (res.data.code == 1) {
|
||||
if (!isRefreshing) {
|
||||
isRefreshing = true; // 设置标志位
|
||||
wxCode.codes().then(newToken => {
|
||||
isRefreshing = false; // 请求完成,重置标志位
|
||||
// 更新所有等待中的请求的 token
|
||||
pendingRequests.forEach((req) => {
|
||||
req.resolve({ ...res.data, token: newToken });
|
||||
});
|
||||
pendingRequests = []; // 清空等待中的请求
|
||||
}).catch((err) => {
|
||||
isRefreshing = false; // 请求失败,重置标志位
|
||||
// 拒绝所有等待中的请求
|
||||
pendingRequests.forEach((req) => {
|
||||
req.reject(err);
|
||||
});
|
||||
pendingRequests = []; // 清空等待中的请求
|
||||
});
|
||||
}
|
||||
// 如果正在刷新,加入等待中的请求
|
||||
return pendingRequests.push({ resolve, reject });
|
||||
}
|
||||
|
||||
resolve(res.data); // 正常返回
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
},
|
||||
complete: () => {
|
||||
console.log('请求完成')
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let url = getApp().globalData.webApi + prams.url;
|
||||
return uni.request({
|
||||
url: url,
|
||||
data: prams.query,
|
||||
method: prams.method,
|
||||
header: {
|
||||
'Authorization': uni.getStorageSync("token"),
|
||||
},
|
||||
success: (res) => {
|
||||
// uni.hideLoading()
|
||||
if (res.data.code == 1) {
|
||||
wxCode.codes()
|
||||
}
|
||||
resolve(res.data);
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
},
|
||||
complete: () => {
|
||||
console.log('请求完成')
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
Loading…
Reference in New Issue