请选择 进入手机版 | 继续访问电脑版
帖子
帖子
用户
博客
课程
显示全部楼层
2
帖子
0
勋章
33
Y币

[云开发] SMSSDK使用遇到问题

[复制链接]
发表于 2022-1-13 15:27:19
本帖最后由 哼都 于 2022-1-13 15:31 编辑




<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
        label {
            margin: 10px;
            font-size: 24px;
        }

        ul {
            margin-bottom: 10px;
        }

        ul li {
            margin: 5px 10px;
            padding: 5px;
            color: #000;
            word-wrap: break-word;
        }
    </style>
</head>

<body>
    <label>Hello APP</label>
    <div>
        <input type="text" name="myPhone" id="myPhone">
        <input type="button" value="获取验证码" id="code_btn" topmode>
        <input type="text" name="code" id="code">
    </div>
    <div id='sys-info'></div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">

    var mobcommonlib = null;
    var moduleSMSSDK = null;

    apiready = function() {

        var mobcommonlib = api.require('mobcommonlib');
        var moduleSMSSDK = api.require('smssdk');

        // param中的key命名不能改变,{1:URL,2:富文本}
        var param = {type:1};

        mobcommonlib.getPrivacyPolicyAsync(param, function(ret, err){
            if (err !== null && err !== undefined && err !== '') {
                alert("错");
                // 错误消息示例:{"msg":"MobTech policy not granted.","code":600}
                alert("eTitle" + JSON.stringify(err));
            } else {
                // 正常消息示例:{"content":"http://www.mob.com/privacy/policy/index.html", "title":"服务协议", "ppVersion":1, "timestamp":23124353131}
                alert("sTitle" + JSON.stringify(ret));

                // param中的key命名不能改变,{true:同意,false:拒绝}
                var param = {granted:true};
                mobcommonlib.submitPolicyGrantResult(param, function(ret, err){
                    if (err !== null && err !== undefined && err !== '') {
                        // 错误消息示例:{"msg":"Service not found.","code":404}
                        alert("eTitle" + JSON.stringify(err));
                    } else {
                        // 正常消息示例:{"result":"success"}
                        alert("sTitle" + JSON.stringify(ret));

                    }
                });

            }
        });

    };

    function fnGetCode(){
        var myPhone = $api.byId("myPhone");
        var vMyPhone = $api.val(myPhone);
        console.log(vMyPhone);

        alert(vMyPhone);
        var param = {zone:'86', phoneNumber:vMyPhone,tempCode:"1"};
        alert(JSON.stringify(param));
        moduleSMSSDK.getTextCode(param, function(ret, err){
            alert("验证码");
            if (err !== null && err !== undefined && err !== '') {
                alert("cuo");
                // 错误消息示例:{"msg":"Template not exist.","code":484}
                alert("Error:\n" + JSON.stringify(err));
            } else {
                alert("dui");
                // 正常消息示例:{"smart":false}
                alert("Success:\n" + JSON.stringify(ret));
            }
        });

    }
</script>

</html>







Screenshot_2022-01-13-15-23-23-913_com.b243355129.jpg
image-20220113153101422.png
127
帖子
7
勋章
2万+
Y币
mobcommonlib = api.require('mobcommonlib');
moduleSMSSDK = api.require('smssdk');

前边的var 去掉
2
帖子
0
勋章
33
Y币
问题解决了,谢谢
520707liu【模块开发者 · 2022-1-13 15:30mobcommonlib = api.require('mobcommonlib');
moduleSMSSDK = api.require('smssdk');

这个问题就厉害了
您需要登录后才可以回帖 登录

本版积分规则