提交 9bfefe59 作者: wk

应用名称长度处理

父级 ef2efdfe
const stringUtils = {
stringLength(text, length) {
if (text) {
if (text.length > length) {
return text.substr(0, length) + "..."
} else {
return text
}
}
return ""
}
}
export default stringUtils
......@@ -48,10 +48,12 @@
appList: [{}],
current: 0,
tabs: ["生活服务", "综合办公", "岗位工作"],
groups: []
}
},
onLoad() {
//获取当前设置常用应用
this.getDefaultApp()
//获取所有的应用
},
methods: {
......@@ -59,10 +61,12 @@
this.current = e
},
getDefaultApp() {
Api.getNormalApp({
}).then((result) => {
Api.getNormalApp().then((result) => {
if (result.code == 0) {
this.selList = result.data.list
} else {
this.$toast.showToast(result.msg)
}
})
},
sureConfig() {
......@@ -79,7 +83,89 @@
},
toDef() {
this.getDefaultApp()
}
},
getAppGroup() {
Api.getCodeList({
data: {
"code_type": "applicationGroup"
}
}).then((result) => {
if (result.code == 0) {
let list = result.data[0].sub_data
this.groups = []
for (var i = 0; i < list.length; i++) {
this.groups.push({
"key": list[i].value,
"val": list[i].name
})
}
this.groups.push({
"key": "0",
"val": "其他"
})
this.getAppList()
} else {
this.origin_data = []
if (result.code == 10201) {
this.refreshToken()
} else {
this.$toast.showToast(result.msg)
}
}
})
},
getAppList: function() {
let that = this
Api.getAppList({
data: this.requestParam
}).then((result) => {
if (result.code === 0) {
let list = result.data.list
that.apps = that.sortGroup(list)
console.log(that.apps);
if (that.groups.length > 0) {
for (var i = 0; i < that.apps.length; i++) {
for (var j = 0; j < that.groups.length; j++) {
if (that.groups[j].key == that.apps[i].app_group) {
that.apps[i].group_name = that.groups[j].val
}
}
}
}
} else {
if (result.code === -1) {
this.$toast.showToast(result.msg)
if (result.action === 'Laravel_public_permission_fail') {
that.refreshToken()
}
}
}
})
},
sortGroup: function(arr) {
var map = {},
dest = [];
for (var i = 0; i < arr.length; i++) {
var app = arr[i];
if (!map[app.app_group]) {
dest.push({
app_group: app.app_group,
data: [app]
});
map[app.app_group] = app;
} else {
for (var j = 0; j < dest.length; j++) {
var dj = dest[j];
if (dj.app_group == app.app_group) {
dj.data.push(app);
break;
}
}
}
}
return dest
},
}
}
</script>
......
......@@ -50,7 +50,8 @@
<uni-grid column="2" v-if="isOrg">
<uni-grid-item v-for="(app,index) in appList" :key="index">
<view class="app-item" @click="toLink(app)">
<view :class="isLineVisil(index)?'app-name-left':'app-name-right'">{{app.app_name}}</view>
<view :class="isLineVisil(index)?'app-name-left':'app-name-right'">
{{nameLengthDeal(app.app_name)}}</view>
<image class="app-logo" src="../../static/ic-score-logo.png"></image>
<view class="line" v-if="isLineVisil(index)"></view>
</view>
......@@ -112,6 +113,7 @@
import App from "../../api/mta.js"
import qqmapsdk from "../../common/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js"
import Api from "../../api/api.js"
import StringUtils from "../../common/stringUtils.js"
export default {
data() {
return {
......@@ -157,6 +159,8 @@
uni.$once("refreshApp", res => {
if (this.isCommonSel) {
this.getCommonApp()
} else {
this.getRecentlyApp()
}
})
},
......@@ -475,6 +479,9 @@
})
}
})
},
nameLengthDeal(name) {
return StringUtils.stringLength(name, 5)
}
}
}
......
......@@ -26,6 +26,7 @@
</template>
<script>
import Api from "../../../api/api.js"
export default {
data() {
return {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment