<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:ns1="leaf.application.action" xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
    <a:init-procedure>
        <s:server-script><![CDATA[
            function app_login() {
                var app_user_login_bm = $bm('app.Login.sys_user_login_with_userid');
                app_user_login_bm.update({
                    user_name: $ctx.parameter.user_name,
                    user_password: $ctx.parameter.user_password,
                    user_language: $ctx.parameter.user_language
                });
                var result = {
                    result: $ctx.parameter.return_status,
                    message: $ctx.parameter.return_message,
                    user_id: $ctx.parameter.user_id,
                    role_code: $ctx.parameter.role_code,
                    mobile: $ctx.parameter.return_mobile || 'underfined',
                    access_token: $ctx.parameter.return_access_token,
                    position_code: $ctx.parameter.position_code || 'underfined',
                    unit_code: $ctx.parameter.unit_code || 'underfined'
                };
                $ctx.parameter.json = JSON.stringify(result);
            }
            
            app_login();
        ]]></s:server-script>
    </a:init-procedure>
    <a:service-output output="/parameter/@json"/>
</a:service>
