appCenterCtrl.js 2.07 KB
(function(angular) {
    function appCenterCtrl($scope, $state, toaster) {
        $scope.style = {
            height: `${document.body.clientHeight - 90}px`
        }
        $scope.appList = [
            {
                iconImg: 'icon-applet',
                name: '小程序',
                explain: '高频触达,维系客户',
                url: 'wechatauth.scan-auth',
                router: '小程序授权',
                targetName: 'wechatauth'
            },
            {
                iconImg: 'icon-message',
                name: '活动',
                explain: '创建活动、线上营销',
                url: 'marketing.shopactivity.shoplist',
                router: '活动列表',
                targetName: 'shopList'
            },
            {
                iconImg: 'icon-coupon',
                name: '优惠券',
                explain: '创建优惠券、促进客户返店',
                url: 'marketing.coupon.list',
                router: '优惠券列表',
                targetName: 'couponList'
            }
        ]
        $scope.wechatauth = false
        $scope.shopList = false
        $scope.couponList = false

        $scope.jumpLink = function(name, target,url) {
            checkPermission(name, $scope.menuList, target)
            if ($scope[target]) {
              $state.go(url)
            } else {
              toaster.pop({
                type: 'error',
                body: '您暂未开通该服务,请联系客服处理',
                showCloseButton: true,
                timeout: 3000
              })
            }
          }
      
        function checkPermission(pageTitle, data, name) {
            angular.forEach(data, function(e) {
                if (e.children) {
                checkPermission(pageTitle, e.children, name)
                } else {
                if (e.pageTitle == pageTitle) {
                    $scope[name] = true
        
                }
                }
            })
        }
    }

    angular.module('appCenter').controller('appCenterCtrl', appCenterCtrl)
})(angular);