[fix]商户号管理页面优化

master
hellolujian 6 years ago
parent e26849f36b
commit 16d881bca1

@ -21,7 +21,9 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
$scope.toShow = false; $scope.toShow = false;
$scope.client_loading = true; $scope.client_loading = true;
// 前端渲染的end索引
$scope.endIndexMap = {}; $scope.endIndexMap = {};
// 初始化索引是60
const initEndIndex = 60; const initEndIndex = 60;
$scope.loadClient = function () { $scope.loadClient = function () {
$http.get('/sys/merchant_id').then(function (resp) { $http.get('/sys/merchant_id').then(function (resp) {
@ -29,31 +31,44 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
$scope.client_loading = false; $scope.client_loading = false;
// 加入对应项的end索引值 // 加入对应项的end索引值
for (var k in $scope.clientsMap) { // 如果数据小于60索引值为数据长度
var length = $scope.clientsMap[k].length; // 否则设置为60
if (length <= initEndIndex) { for (var key in $scope.clientsMap) {
$scope.endIndexMap[k] = length; $scope.endIndexMap[key] = initEndIndex;
} var length = $scope.clientsMap[key].length;
else if (length <= initEndIndex)
$scope.endIndexMap[k] = initEndIndex; $scope.endIndexMap[key] = length;
} }
}); });
}; };
$scope.loadClient(); $scope.loadClient();
/**
* 点击更多加载
* 判断加60后的索引是否超出数组长度
* @param key
*/
$scope.more = function(key) { $scope.more = function(key) {
var endIndex = $scope.endIndexMap[key] + initEndIndex; var endIndex = $scope.endIndexMap[key] + initEndIndex;
// 判断加60后的索引是否超出数组长度 $scope.endIndexMap[key] = endIndex;
if (endIndex > $scope.clientsMap[key].length) { if (endIndex > $scope.clientsMap[key].length) {
$scope.endIndexMap[key] = $scope.clientsMap[key].length; $scope.endIndexMap[key] = $scope.clientsMap[key].length;
} }
else
$scope.endIndexMap[key] = endIndex;
}; };
/**
* 收起
* @param key
*/
$scope.packup = function(key) { $scope.packup = function(key) {
$scope.endIndexMap[key] = initEndIndex; $scope.endIndexMap[key] = initEndIndex;
var length = $scope.clientsMap[key].length;
if (length <= initEndIndex)
$scope.endIndexMap[key] = length;
}; };
$scope.showClient = function (sub_merchant_id) { $scope.showClient = function (sub_merchant_id) {

Loading…
Cancel
Save