This commit is contained in:
lxz 2023-12-27 19:21:26 +08:00
parent 1e613b409c
commit cc884926cd
9 changed files with 915 additions and 35 deletions

37
api/enroll.js Normal file
View File

@ -0,0 +1,37 @@
import oahttp from "@/utils/pubblicHttp.js";
/**
* 获取市
*/
export const commonCity = (data) => oahttp.get('/common/city', data)
/**
* 获取省
*/
export const commonProvince = (data) => oahttp.get('/common/province', data)
/**
* 获取区县
*/
export const commonArea = (data) => oahttp.get('/common/area', data)
/**
* 获取城镇
*/
export const commonStreet = (data) => oahttp.get('/common/street', data)
/**
* 获取村
*/
export const commonVillage = (data) => oahttp.get('/common/village', data)
/**
* 获取小队
*/
export const commonBrigade = (data) => oahttp.get('/common/brigade', data)
/**
* 注册
*/
export const register = (data) => oahttp.post('/new.user/register', data)

View File

@ -3,12 +3,17 @@ import oahttp from "@/utils/oahttp.js";
/**
* 登录
*/
export const loginAccount = (data, onReLogin = false) => oahttp.post('/login/account', data, { noAuth: true, onReLogin: onReLogin })
export const loginAccount = (data, onReLogin = false) => oahttp.post('/login/account', data, {
noAuth: true,
onReLogin: onReLogin
})
/**
* cesi
*/
export const test = (data) => oahttp.post('/index/config', data, { noAuth: true })
export const test = (data) => oahttp.post('/index/config', data, {
noAuth: true
})
/**
* 个人中心
@ -68,9 +73,13 @@ export const destroyAccount = (data) => oahttp.post('/user/destroy_account', dat
/**
* 商城登录
*/
export const loginShopAccount = (data) => oahttp.post('/login/shop_account', data, { noAuth: true })
export const loginShopAccount = (data) => oahttp.post('/login/shop_account', data, {
noAuth: true
})
/**
* 中台登录
*/
export const loginParseToken = (data) => oahttp.post('/login/parseToken', data, { noAuth: true })
export const loginParseToken = (data) => oahttp.post('/login/parseToken', data, {
noAuth: true
})

0
api/register.js Normal file
View File

View File

@ -3,7 +3,8 @@
<!-- <view class="title">地区信息</view> -->
<u--form labelPosition="left" :model="formData" :rules="rules" ref="districtForm">
<u-form-item label="地址" :required="!readonly" prop="street" @click="changeCity('street', true)" borderBottom>
<u-form-item label="地址" :required="!readonly" prop="street" @click="changeCity('street', true)"
borderBottom>
<u--textarea :value="nowAddress" autoHeight readonly disabled></u--textarea>
</u-form-item>
<u-form-item v-if="!formDataRead.street" label="乡镇" :required="!readonly" prop="street"
@ -17,8 +18,10 @@
placeholder="请选择村"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item v-if="$store.state.app.userInfo.company.company_type==18" label="小队" :required="!readonly" prop="brigade" @click="changeCity('brigade')" borderBottom>
<u--input :value="formDataText.brigade" style="pointer-events: none;" disabled disabledColor="#fff" placeholder="请选择小队"></u--input>
<u-form-item v-if="$store.state.app.userInfo.company.company_type==18" label="小队" :required="!readonly"
prop="brigade" @click="changeCity('brigade')" borderBottom>
<u--input :value="formDataText.brigade" style="pointer-events: none;" disabled disabledColor="#fff"
placeholder="请选择小队"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
</u--form>
@ -36,9 +39,9 @@
commonVillage,
commonBrigade
} from "@/api/oaPbulic.js"
import {
userCompanyBrigade
} from "@/api/oaUser.js"
import {
userCompanyBrigade
} from "@/api/oaUser.js"
import {
Toast
} from "../../libs/uniApi"
@ -125,6 +128,7 @@
} else {
this.rules = {};
}
this.commonProvince()
},
computed: {
nowAddress() {
@ -163,13 +167,13 @@
})
},
//
changeCity(type, toast=false) {
if(toast) return Toast('不可修改该区域')
if (this.$props.readonly) return ;
changeCity(type, toast = false) {
if (toast) return Toast('不可修改该区域')
if (this.$props.readonly) return;
if (this[type + 'List'].length == 0) {
if(type=='brigade') return Toast('小队已经建立完毕');
return Toast('请先选择上一级地区');
}
if (type == 'brigade') return Toast('小队已经建立完毕');
return Toast('请先选择上一级地区');
}
this.changeType = type;
this.showProvince = true;
},
@ -235,20 +239,20 @@
commonBrigade({
brigade: code
}).then(res => {
// ,
let f_arr = this.$store.state.app.userInfo.company?.responsible_area?.split(',')||[];
this.brigadeList = res.data.filter(item=>{
return f_arr.find(t=>item.id==t);
});
//
userCompanyBrigade().then((e)=>{
this.brigadeList = this.brigadeList.filter(item=>{
return !e.data.find(t=>t==item.id);
})
this.formData.brigade = '';
this.formDataRead.brigade = '';
this.formDataText.brigade = '';
})
// ,
let f_arr = this.$store.state.app.userInfo.company?.responsible_area?.split(',') || [];
this.brigadeList = res.data.filter(item => {
return f_arr.find(t => item.id == t);
});
//
userCompanyBrigade().then((e) => {
this.brigadeList = this.brigadeList.filter(item => {
return !e.data.find(t => t == item.id);
})
this.formData.brigade = '';
this.formDataRead.brigade = '';
this.formDataText.brigade = '';
})
})
},
}

View File

@ -3,9 +3,9 @@ let httpApi; // 总域名
let httpApiTwo; // 物流系统域名
// const env = 'dev'; // 开发
const env = 'prod'; // 生产
// const env = 'prod'; // 生产
// const env = 'prew'; // 预上线
// const env = 'local'; // 本地
const env = 'local'; // 本地
switch (env) {
case 'prod':
@ -19,9 +19,9 @@ switch (env) {
httpApiTwo = 'https://preview-logistics.lihaink.cn' //预上线
break;
case 'local':
httpApi = 'http://192.168.1.20:8000' //预上线
httpApiThree = 'http://192.168.1.20:8000' //预上线
httpApiTwo = 'http://192.168.1.20:8000' //预上线
httpApi = 'http://192.168.1.21:8083' //预上线
httpApiThree = 'http://192.168.1.21:8083' //预上线
httpApiTwo = 'http://192.168.1.21:8083' //预上线
break;
default:
httpApi = 'https://ceshi-worker-task.lihaink.cn' //测试

View File

@ -24,6 +24,16 @@
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/oaLogin/oaEnroll",
"style": {
"navigationBarTitleText": "账号注册",
"enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#0122C7",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/business/business",

692
pages/oaLogin/oaEnroll.vue Normal file
View File

@ -0,0 +1,692 @@
<template>
<view class="" style="width: 100vw; overflow: hidden;">
<view class="card">
<u--form labelPosition="left" :model="formData" :rules="rules" ref="uForm">
<view class="cards">
<view class="avter">
<view class="">
<text style="color: #f76c7f;font-weight: bold;">*</text>用户头像:
</view>
<view class="">
<view class="" v-if="formData.avatar">
<!-- {{formData.avatar}} -->
<image :src="formData.avatar" alt="" style="width:150rpx;height:150rpx;">
</image>
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
上传头像
<view class="up" style="opacity: 0;">
<u-upload :fileList="formData.avatar?[{url:formData.avatar}]:[]"
@afterRead="afterReadAvatar" @delete="formData.avatar=''" :maxCount="1">
</u-upload>
</view>
</view>
</view>
</view>
</view>
<view class="cards">
<u-form-item label="电话" required prop="account" borderBottom>
<u--input v-model="formData.account" placeholder="请输入手机号" type="number"></u--input>
</u-form-item>
<u-form-item label="姓名" required prop="nickname" borderBottom>
<u--input v-model="formData.nickname" placeholder="请输入姓名"></u--input>
</u-form-item>
<u-form-item label="用户角色" labelWidth="auto" required prop="formData.group_id" borderBottom
@click="showRole=true" ref="item1">
<!-- <u--input v-model="formData.group_id" disabled disabledColor="#ffffff" placeholder="请选择性别"
border="none"></u--input> -->
<u--input v-model="formData.group_name" placeholder="请选择"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item labelWidth="auto" label="身份证号" required prop="id_card" borderBottom>
<u--input v-model="formData.id_card" placeholder="请输入身份证号" @input="c_idcard"
type="idcard"></u--input>
</u-form-item>
<u-form-item label="省" required prop="province" @click="changeCity('province')" borderBottom>
<u--input :value="formData.province" disabled disabledColor="#fff"
placeholder="请选择省"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item label="市" required prop="city" @click="changeCity('city')" borderBottom>
<u--input :value="formData.city" disabled disabledColor="#fff" placeholder="请选择市"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item label="区县" required prop="area" @click="changeCity('area')" borderBottom>
<u--input :value="formData.area" disabled disabledColor="#fff" placeholder="请选择区县"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item label="乡镇" required prop="street" @click="changeCity('street')" borderBottom>
<u--input :value="formData.street" disabled disabledColor="#fff" placeholder="请选择镇"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item label="村社" required prop="village" @click="changeCity('village')" borderBottom>
<u--input :value="formData.village" type="text" disabled disabledColor="#fff"
placeholder="请选择村"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item label="小队" required prop="brigade" @click="changeCity('brigade')" borderBottom>
<u--input :value="formData.brigade" disabled disabledColor="#fff"
placeholder="请选择小队"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
</view>
<view class="cards">
<view style="margin-bottom:30rpx ;">
<text style="color: #f76c7f;font-weight: bold;">*</text>身份证照:
</view>
<view class="up_list">
<view class="" v-if="formData.qualification.id_card">
<image :src="formData.qualification.id_card" alt="" style="width:243.57rpx;height:150rpx;">
</image>
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
身份证正面
<view class="up" style="opacity: 0;">
<u-upload
:fileList="formData.qualification.id_card?[{url:formData.qualification.id_card}]:[]"
@afterRead="afterRead" @delete="formData.qualification.id_card=''" name="id_card"
:maxCount="1" width="300rpx" height="200rpx" style="margin-top: 10rpx;">
</u-upload>
</view>
</view>
<view class="" v-if="formData.qualification.id_card_b">
<!-- {{formData.avatar}} -->
<image :src="formData.qualification.id_card_b" alt=""
style="width:243.57rpx;height:150rpx;">
</image>
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
身份证反面
<view class="up" style="opacity: 0;">
<u-upload
:fileList="formData.qualification.id_card_b?[{url:formData.qualification.id_card_b}]:[]"
@afterRead="afterRead" @delete="formData.qualification.id_card_b=''"
name="id_card_b" :maxCount="1" width="300rpx" height="200rpx"
style="margin-top: 10rpx;">
</u-upload>
</view>
</view>
</view>
</view>
<view class="cards">
<view style="margin-bottom:30rpx ;">
<text style="color: #f76c7f;font-weight: bold;">*</text>银行卡照:
</view>
<view class="up_list">
<view class="" v-if="formData.qualification.bank_account">
<!-- {{formData.avatar}} -->
<image :src="formData.qualification.bank_account" alt=""
style="width:243.57rpx;height:150rpx;">
</image>
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
银行卡正面
<view class="up" style="opacity: 0;">
<u-upload
:fileList="formData.qualification.bank_account?[{url:formData.qualification.bank_account}]:[]"
@afterRead="afterRead" @delete="formData.qualification.bank_account=''"
name="bank_account" :maxCount="1" width="300rpx" height="200rpx"
style="margin-top: 10rpx;">
</u-upload>
</view>
</view>
<view class="" v-if="formData.qualification.bank_account_b">
<!-- {{formData.avatar}} -->
<image :src="formData.qualification.bank_account_b" alt=""
style="width:243.57rpx;height:150rpx;">
</image>
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
银行卡反面
<view class="up" style="opacity: 0;">
<u-upload
:fileList="formData.qualification.bank_account_b?[{url:formData.qualification.bank_account_b}]:[]"
@afterRead="afterRead" @delete="formData.qualification.bank_account_b=''"
name="bank_account_b" :maxCount="1" width="300rpx" height="200rpx"
style="margin-top: 10rpx;">
</u-upload>
</view>
</view>
</view>
</view>
<view class="cards">
<view style="margin-bottom:30rpx ;">
驾驶证照:
</view>
<view class="up_list">
<view class="" v-if="formData.qualification.car_card">
<!-- {{formData.avatar}} -->
<image :src="formData.qualification.car_card" alt="" style="width:243.57rpx;height:150rpx;">
</image>
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
驾驶证一页
<view class="up" style="opacity: 0;">
<u-upload
:fileList="formData.qualification.car_card?[{url:formData.qualification.car_card}]:[]"
@afterRead="afterRead" @delete="formData.qualification.car_card=''" name="car_card"
:maxCount="1" width="300rpx" height="200rpx" style="margin-top: 10rpx;">
</u-upload>
</view>
</view>
<view class="" v-if="formData.qualification.car_card_b">
<!-- {{formData.avatar}} -->
<image :src="formData.qualification.car_card_b" alt=""
style="width:243.57rpx;height:150rpx;">
</image>
</view>
<view class="uplode" v-else>
<u-icon name="plus-circle-fill" color="#0022C7" size="28"></u-icon>
驾驶证二页
<view class="up" style="opacity: 0;">
<u-upload
:fileList="formData.qualification.car_card_b?[{url:formData.qualification.car_card_b}]:[]"
@afterRead="afterRead" @delete="formData.qualification.car_card_b=''"
name="car_card_b" :maxCount="1" width="300rpx" height="200rpx"
style="margin-top: 10rpx;">
</u-upload>
</view>
</view>
</view>
</view>
</u--form>
<button @click="modelShow=true" type="primary" class="btn" style="margin: 28rpx;">创建</button>
</view>
<u-modal :show="modelShow" title="提示" content='请确认人员信息无误后再创建' closeOnClickOverlay showCancelButton
@close="modelShow=false" @cancel="modelShow=false" @confirm="$u.throttle(addAcountNum, 2000)"></u-modal>
<u-action-sheet :show="showRole" :actions="actions" title="请选择性别" @close="showRole = false" @select="sexSelect">
</u-action-sheet>
<u-picker @close='showPicker=false' @cancel='showPicker=false' :show="showPicker" ref="uPicker"
:columns="columns" :keyName='keyName' @confirm="confirm"></u-picker>
<!-- <u-picker :show="showPicker" :columns="columns" keyName="province_name"></u-picker> -->
</view>
</template>
<script>
import {
commonProvince,
commonCity,
commonArea,
commonStreet,
commonVillage,
commonBrigade,
register
} from "@/api/enroll.js"
import {
upLoadImage
} from "@/api/file.js"
import {
loginAdd,
} from "@/api/oaUser.js"
import districtSelector from "@/components/districtSelector/districtSelector.vue" //
import {
Toast
} from "../../libs/uniApi"
export default {
components: {
districtSelector,
},
data() {
return {
keyName: 'province_name',
showRole: false,
showPicker: false,
areaList: [],
proList: [],
cityList: [],
streetList: [],
villageList: [],
brigadeList: [],
columns: [],
actions: [{
name: '镇/街合伙人',
id: 22
},
{
name: '社区合伙人',
id: 21
},
{
name: '小区队长',
id: 20
},
{
name: '村合伙人',
id: 19
},
{
name: '生产队长',
id: 18
},
],
modelShow: false,
formData: {
account: '', //
password: '123456', //
password_confirm: '', //
// channel: 6, //[1- 2- 3-H5 4-PC 5-APP 6-APP]
id_card: '',
is_captain: '', //
// is_service_manager: '', //
sex: '',
avatar: '',
nickname: '',
address: '',
group_id: "",
group_name: "",
province: "",
city: "",
area: "",
street: "",
village: "",
brigade: "",
provinceCode: "",
cityCode: "",
areaCode: "",
streetCode: "",
villageCode: "",
brigadeCode: "",
qualification: {
id_card: "",
id_card_b: "",
car_card: "",
car_card_b: "",
bank_account: "",
bank_account_b: ""
},
},
rules: {
account: {
required: true,
pattern: /^(1[3456789]\d{9})$/,
message: '请输入正确的手机号码',
trigger: ['change', 'blur']
},
id_card: {
required: true,
pattern: /^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dxX]$/,
message: '请输入正确的身份证号',
trigger: ['change', 'blur']
},
sex: {
validator: (rule, value, callback) => {
typeof value === 'number' ? callback() : callback('请选择男或女')
},
trigger: ['change', 'blur']
},
avatar: {
type: 'string',
required: true,
message: '头像不能为空',
trigger: ['change', 'blur']
},
nickname: {
type: 'string',
required: true,
message: '姓名不能为空',
trigger: ['change', 'blur']
},
'qualification.id_card': {
type: 'string',
required: true,
message: '不能为空',
trigger: ['change', 'blur']
},
'qualification.id_card_b': {
type: 'string',
required: true,
message: '不能为空',
trigger: ['change', 'blur']
},
'qualification.bank_account': {
type: 'string',
required: true,
message: '不能为空',
trigger: ['change', 'blur']
},
'qualification.bank_account_b': {
type: 'string',
required: true,
message: '不能为空',
trigger: ['change', 'blur']
},
},
}
},
onLoad() {
commonProvince().then(res => {
this.proList = res.data
this.columns = [this.proList]
console.log(res.data)
})
},
onReady() {
//setRules
this.$refs.uForm.setRules(this.rules)
},
onShow() {},
methods: {
confirm(e) {
if (this.keyName == 'province_name') {
this.formData.province = e.value[0].province_name
this.formData.province_code = e.value[0].province_code
commonCity({
city: this.formData.province_code
}).then(res => {
this.cityList = res.data
})
}
if (this.keyName == 'city_name') {
this.formData.city = e.value[0].city_name
this.formData.cityCode = e.value[0].city_code
commonArea({
area: this.formData.cityCode
}).then(res => {
this.areaList = res.data
})
}
if (this.keyName == 'area_name') {
this.formData.area = e.value[0].area_name
this.formData.areaCode = e.value[0].area_code
commonStreet({
street: this.formData.areaCode
}).then(res => {
this.streetList = res.data
})
}
if (this.keyName == 'street_name') {
this.formData.street = e.value[0].street_name
this.formData.streetCode = e.value[0].street_code
commonVillage({
village: this.formData.streetCode
}).then(res => {
this.villageList = res.data
})
}
if (this.keyName == 'village_name') {
console.log(e.value)
this.formData.village = e.value[0].village_name
this.formData.villageCode = e.value[0].village_code
console.log(this.formData.villageCode, "vill")
commonBrigade({
brigade: this.formData.villageCode
}).then(res => {
this.brigadeList = res.data
})
}
if (this.keyName == 'brigade_name') {
this.formData.brigade = e.value[0].brigade_name
this.formData.brigadeCode = e.value[0].id
console.log(this.formData)
}
this.showPicker = false
},
changeCity(type, toast = false) {
this.showPicker = true
if (type == 'role') {
this.actionList = this.actions
}
if (type == 'province') {
this.columns = [this.proList]
console.log(this.proList)
}
if (type == 'city') {
this.keyName = 'city_name'
this.columns = [this.cityList]
}
if (type == 'area') {
this.keyName = 'area_name'
this.columns = [this.areaList]
}
if (type == 'street') {
this.keyName = 'street_name'
this.columns = [this.streetList]
}
if (type == 'village') {
this.keyName = 'village_name'
this.columns = [this.villageList]
}
if (type == 'brigade') {
this.keyName = 'brigade_name'
this.columns = [this.brigadeList]
}
// this.actionList=
// if (this[type + 'List'].length == 0) {
// if (type == 'brigade') return Toast('');
// return Toast('');
// }
// this.changeType = type;
// this.showProvince = true;
},
sexSelect(e) {
this.formData.group_id = e.id
this.formData.group_name = e.name
this.showRole = false
},
c_idcard(e) {
this.$nextTick(() => {
this.formData.id_card = e.replace(/[^0-9X]/g, '')
})
},
//
async afterReadAvatar(event) {
uni.showLoading({
title: '上传中'
})
upLoadImage({
filePath: event.file.url,
name: 'file'
}).then(res => {
this.formData.avatar = res.data.uri;
}).finally(() => {
uni.hideLoading();
})
},
//
async afterRead(event) {
this.upLoad(event.file.url, event.name)
},
//
upLoad(url, type) {
uni.showLoading({
title: '上传中请稍后'
})
upLoadImage({
filePath: url,
name: 'file'
}).then(res => {
this.formData.qualification[type] = res.data.uri
}).finally(() => {
uni.hideLoading();
})
},
//
async addAcountNum() {
this.modelShow = false;
await this.$nextTick();
if (!this.formData.avatar) return Toast('头像未上传');
let flag = this.$refs.districtSelectorRef.validate();
if (!this.formData.qualification.id_card || !this.formData.qualification.id_card_b) return Toast(
'身份证未上传');
if (!this.formData.qualification.bank_account || !this.formData.qualification.bank_account_b)
return Toast(
'银行卡未上传');
this.$refs.uForm.validate().then(async (e) => {
if (e && flag) {
uni.showLoading()
let res = await register({
...this.formData,
});
console.log(res, 4545)
uni.hideLoading()
uni.showToast({
icon: "none",
title: "添加成功",
success: () => {
// setTimeout(() => {
// uni.$emit('initPersonnel');
// uni.navigateBack();
// }, 1000)
}
})
}
})
},
},
onPullDownRefresh() {
uni.stopPullDownRefresh()
}
}
</script>
<style lang="scss">
.card {
// background-color: #fff;
// margin: 28rpx;
// padding: 28rpx;
// border-radius: 14rpx;
.cards {
margin: 28rpx;
padding: 28rpx;
border-radius: 14rpx;
background-color: #fff;
.avter {
display: flex;
justify-content: space-between;
// line-height: 150rpx;
align-items: center;
}
.up_list {
display: flex;
justify-content: space-between;
}
.uplode {
width: 243.57rpx;
height: 173.48rpx;
box-sizing: border-box;
padding-top: 30rpx;
border-radius: 15rpx;
border: 1px solid $theme-oa-color;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
color: $theme-oa-color;
position: relative;
.up {
position: absolute;
color: transparent;
}
}
}
.title {
font-weight: 500;
font-size: 34rpx;
margin-top: 30rpx;
&:nth-child(1) {
margin-top: 0;
}
&::before {
width: 8rpx;
height: 26rpx;
border-radius: 4rpx;
background-color: #0122c7;
content: "";
display: inline-block;
margin-right: 8rpx;
}
}
.btn {
margin-top: 32rpx;
// margin-bottom: 40rpx;
// width: 100%;
height: 84rpx;
background: $theme-oa-color;
border-radius: 42rpx 42rpx 42rpx 42rpx;
color: #fff;
line-height: 80rpx;
text-align: center;
}
}
</style>

View File

@ -30,7 +30,11 @@
</view>
<view class="btn">
</view> -->
<view class="">
还没有账号? <text class="enroll-text" @click="navgo('/pages/oaLogin/oaEnroll')">点击注册</text>
</view>
</view>
<button class="submit_btn" @click="login">登录</button>
</view>
</view>
@ -215,6 +219,11 @@
//
forgetPWD() {
Toast('暂未开放')
},
navgo(url) {
uni.navigateTo({
url
})
}
},
}
@ -343,4 +352,9 @@
}
}
}
.enroll-text {
color: $theme-oa-color;
margin-left: 5px;
}
</style>

114
utils/pubblicHttp.js Normal file
View File

@ -0,0 +1,114 @@
import {
HTTP_REQUEST_URL_THREE,
HEADER,
TOKENNAME,
} from '@/config/app';
import {
Toast
} from '../libs/uniApi';
// import { checkLogin } from '../libs/login';
import store from '../store';
function toLogin() {
uni.showToast({
title: '请先登录',
icon: 'none',
duration: 1000
});
}
function baseRequestTwo(url, method, data, {
noAuth = false,
noVerify = false,
onReLogin = false
}) {
let Url = HTTP_REQUEST_URL_THREE,
header = HEADER;
// if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
if (store.state.app.token) header[TOKENNAME] = store.state.app.token;
// header[TOKENNAME] = 'Bearer sdjflidshjgfkbdasgjmasbgvhauuiavhkesvndkaesbvkjsdbv';
return new Promise((reslove, reject) => {
// uni.showLoading({
// title: '加载中'
// })
uni.request({
// url: Url + '/api/v1' + url,
url: Url + '/api' + url,
method: method || 'GET',
header: {
...header
},
data: method != 'GET' ? data || {} : {},
params: method == 'GET' ? data : {},
success: (res) => {
if (noVerify)
reslove(res.data);
else if (res.data.code == -1) {
if (onReLogin) {
store.commit('LOGOUT');
return reject();
}
// 如果登录超时,自动重新登录并且继续发送请求
store.dispatch("RE_LOGIN", {
url: url,
method: method,
data: data,
opt: {
noAuth,
noVerify
}
}).then((e) => {
reslove(e);
}).catch((err) => {
reject(res.data);
})
// store.commit("SET_REQUEST", false);
} else if (res.data.code == 0) {
if (res.data.msg != '无登录信息') {
uni.showToast({
title: res.data.msg || '请检查网络',
icon: 'none',
})
}
reject(res.data);
} else if (res.data.code == 1) {
store.commit("SET_REQUEST");
reslove(res.data);
} else if (res.data.code == 200) {
store.commit("SET_REQUEST");
reslove(res.data.data);
} else if ([410000, 410001, 410002, 40000].indexOf(res.data.code) !== -1) {
toLogin();
reject(res.data);
} else if (res.data.code == 501) {
reject(res.data);
} else {
uni.showToast({
title: res.data.msg || '请检查网络',
icon: 'none'
})
reject(res.data.msg || '请检查网络');
}
},
fail: (message) => {
// uni.hideLoading()
uni.showToast({
title: '网络错误',
icon: 'none'
})
reject('请求失败');
}
})
});
}
const oahttp = {};
['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
oahttp[method] = (api, data, opt) => baseRequestTwo(api, method, data, opt || {})
});
export default oahttp;