1 2 3 4 | <span class = "lake-preview-line" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ><span class = "lake-preview-line-number lake-lm-pad-level-0" style= "color: rgb(191, 191, 191); margin: 0px 8px 0px 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ></span><span class = "lake-preview-codeblock-content" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ><span class = "cm-variable" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" >exports</span>.<span class = "cm-property" style= "color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" >main</span> <span class = "cm-operator" style= "color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" >=</span> <span class = "cm-keyword" style= "color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" >async</span> <span class = "cm-keyword" style= "color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" >function</span>(<span class = "cm-def" style= "color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" >context</span>) { </span></span><span class = "lake-preview-line" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ><span class = "lake-preview-line-number lake-lm-pad-level-0" style= "color: rgb(191, 191, 191); margin: 0px 8px 0px 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ></span><span class = "lake-preview-codeblock-content" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" > <span class = "cm-comment" style= "color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" > //do something</span> </span></span><span class = "lake-preview-line" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ><span class = "lake-preview-line-number lake-lm-pad-level-0" style= "color: rgb(191, 191, 191); margin: 0px 8px 0px 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ></span><span class = "lake-preview-codeblock-content" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" > <span class = "cm-keyword" style= "color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" > return </span> <span class = "cm-string" style= "color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" > "success" </span>; </span></span><span class = "lake-preview-line" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ><span class = "lake-preview-line-number lake-lm-pad-level-0" style= "color: rgb(191, 191, 191); margin: 0px 8px 0px 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" ></span><span class = "lake-preview-codeblock-content" style= "color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);" >}</span></span> |
字段名 | 类型 | 说明 |
appkey | string | 运行时使用的appkey, 1,如果是BC模式,那么这里是B端appkey; 2,如果是模板开发模式,这里是模板的appkey; 3,如果是插件开发模式,这里是宿主小程序的appkey; |
sourceAppKey |
string | 当前调用小程序的appkey 1,如果是BC模式,那么这里是C端appkey; 2,如果是模板开发模式,这里是实例的appkey; 3,如果是插件开发模式,这里是插件的appkey; |
userNick |
string | 当前用户的昵称。 若在小程序中未调用授权API,则无此字段 |
mixNick | string | 当前用户的mixNick |
miniappId |
string | 运行时使用的小程序ID, 1,如果是BC模式,那么这里是B端小程序ID; 2,如果是模板开发模式,这里是模板的小程序ID; 3,如果是插件开发模式,这里是宿主小程序的小程序ID; |
sourceMiniAppId | string | 当前调用小程序的小程序ID 1,如果是BC模式,那么这里是C端小程序ID; 2,如果是模板开发模式,这里是实例的小程序ID; 3,如果是插件开发模式,这里是插件的小程序ID; |
accessToken |
string | 当前用户授权产生的sessionKey, 主要用于调用TOP-API。 若在小程序中未调用授权API,则无此字段 |
openId |
string | 当前使用用户的openId |
env | string | 当前云函数环境 |
traceId | string | 云函数调用唯一ID |
fcName | string | 当前被调用的云函数名称 |
handler |
string | 当前被调用的云函数中的Handler |
appOwnerOpenId |
string | 当前小程序的拥有者的openId,用于BC打通。 对于BC打通场景,在B端,openId是当前登录用户ID,由于是商家使用B端,这里openId即为商家ID; 在C端,小程序拥有者为商家,appOwnerOpenId即为商家Id ; |
data |
JSON |
函数的业务参数 |
B端应用会存在使用商家子账号授权登录的情况,获取到的userNick为子账号nick。
若需要通过该nick查询主账号nick,可以使用正则表达式匹配。 淘宝子账号的命名规则是 “主账号:xxx” ,冒号前面的为店铺主账号名,冒号后面的值可以由店铺自定义; 例如:店铺主账号nick为 “淘宝官方旗舰店” ,子账号nick就会是 "淘宝官方旗舰店:张三" 。