Commit f4109888 by liangjianmin

feat(login): 添加获取公司列表接口及默认数据处理

在登录页面中添加获取公司列表的接口,避免在接口未返回前 picker 报错。
同时,更新默认数据为兜底数据,确保用户体验流畅。
parent c96bfd67
Showing with 25 additions and 9 deletions
......@@ -59,15 +59,7 @@
data() {
return {
index: 0,
array: [
{ name: '深圳市猎芯科技有限公司', value: 1 },
{ name: '深贸电子有限公司', value: 2 },
{ name: '深圳华云数智工业科技有限公司', value: 3 },
{ name: '深圳市粤丰实工业有限公司', value: 9 },
{ name: '深圳工品数字科技有限公司', value: 10 },
{ name: '深圳市猎芯技术有限公司', value: 7 },
{ name: '深圳市易天下电子有限公司', value: 13 }
],
array: [{ name: '深圳市猎芯科技有限公司', value: 1 }], // 兜底数据,避免接口未返回前 picker 报错;实际列表由 getCompanyList 接口渲染
name: '',
passwd: '',
org_id: 1,
......@@ -102,8 +94,28 @@
// 页面加载时静默检查更新
this.silentCheckUpdate();
// 拉取公司列表(无需鉴权)
this.getCompanyList();
},
methods: {
/**
* 获取组织(公司)列表,用于登录页 picker
* 接口返回 res.data.list = [{ name, value }]
*/
getCompanyList() {
this.request(API.getCompanyList, 'POST', {}, false).then(res => {
if (res.code === 0 && res.data && res.data.list && res.data.list.length) {
this.array = res.data.list;
// 接口返回后重置选中项为首项,保证 org_id 与展示一致
this.index = 0;
this.org_id = this.array[0].value;
}
}).catch(err => {
console.log('获取公司列表失败:', err);
});
},
onKeyInput(e) {
var value = e.target.value || e.detail.value || '';
if (value) {
......
......@@ -38,6 +38,10 @@ const API = {
* */
login: API_BASE_USER + '/api/login',
/**
* 获取公司列表(登录页组织选择,无需鉴权)
* */
getCompanyList: API_BASE + '/open/getCompanyList',
/**
* 小程序审核数量统计
* */
getStatisticsInfo: API_BASE_PUR + '/api/approve/getStatisticsInfo',
......
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 sign in to comment