codeDownload.js 1.25 KB
// 支付授权-二维码下载
(function (angular) {
    function codeDownload($scope, data) {
        const {
            appId,
            scene,
            request
        } = data.defaultData
        $scope.handleDownload = function (width, type = 'QR_WXA_LIMIT') {
            var params = {
                appId: appId,
                type: type,
                width: width
            }
            if(scene) {
//                type === 'QR_WXA_LIMIT' && (params.type = 'QR_WXA_UNLIMIT')
                params.scene = scene
            }
            request('qrcodeCreate', params).then(function (result) {
                // window.location.href=result
                // console.log(result)
                var a = document.createElement('a')
                a.setAttribute('href', result)
                a.setAttribute('download', result.split('/')[result.split('/').length - 1])
                a.setAttribute('target', '_black')
                a.setAttribute('id', 'code-download')
                document.body.appendChild(a)
                a.click()
                document.body.removeChild(document.getElementById('code-download'))
            })
        }
    }
    angular.module('wechatauth').controller('codeDownload', codeDownload);
})(angular);