uni.getProvider(OBJECT) -36
//发起支付请求时,获取服务供应商。
publicPaymentApi(restParams, appGetParams).then(res => { //发起支付请求
let resInfo = res.data; //暂时待定
uni.getProvider({
service: 'payment',
success: (res) => {
if (~res.provider.indexOf('alipay')) {
uni.requestPayment({
provider: 'alipay',
orderInfo: resInfo, //微信、支付宝订单数据
success: (result) => { //处理业务逻辑
if (this.payBusinessType == 3) { //筑基卡购买流程
this.redirectTo(
'./paySuccess?orderNum=' +
this.orderNum + '&payWay=' +
payWay +
'&payBusinessType=' + this
.payBusinessType, true);
} else if (this.payBusinessType == 7) {
this.redirectTo(
'/pages/doumei/project/supportSuccess?projectId=' +
this.projectId
);
} else {
this.redirectTo(
'./paySuccess?orderNum=' +
this.orderNum + '&payWay=' +
payWay + '&cardId=' + this
.cardId +
'&payBusinessType=' + this
.payBusinessType, true);
}
},
fail: (error) => {
this.disabled = false; //可以点击
}
});
}
}
});
}).catch(err => {
this.$msg.toast(err.msg);
this.disabled = false; //可以点击
});
登录
uni.login(OBJECT)
登录
uni.getLoginCode(OBJECT)
获取宿主 App 登录凭证(Authorization Code)
uni.checkSession
检查登录状态是否过期
uni.getUserInfo(OBJECT)
获取用户信息。
uni.getUserProfile(OBJECT)
获取用户信息。每次请求都会弹出授权窗口,用户同意后返回 userInfo。
uni.preLogin(OBJECT)
预登录。用于App手机号一键登录。
uni.closeAuthView()
关闭一键登录页面。
uni.getCheckBoxState(OBJECT)
获取一键登录条款勾选框状态。
uni.getUniverifyManager(OBJECT)
获取全局唯一的一键登录管理器 univerifyManager
分享
uni.share(OBJECT)
uni-app的App引擎已经封装了微信、QQ、微博的分享SDK,开发者可以直接调用相关功能。
分享文字
uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 1,
summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
分享图片
uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 2,
imageUrl: "https://web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
分享图文
uni.share({
provider: "weixin",
scene: "WXSceneSession",
type: 0,
href: "http://uniapp.dcloud.io/",
title: "uni-app分享",
summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
imageUrl: "https://web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
分享到朋友圈-文字
uni.share({
provider: "weixin",
scene: "WXSceneTimeline",
type: 1,
summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
success: function (res) {
console.log("success:" + JSON.stringify(res));
},
fail: function (err) {
console.log("fail:" + JSON.stringify(err));
}
});
分享图片、分享图文、App分享为微信小程序
还需在manifest.js中配置
uni.share 在App端各社交平台分享配置说明
- 第一步,打开 manifest.json -> App模块权限配置,勾选 Share(分享);
- 第二步,按如下文档具体配置微信、微博、QQ的参数。
#微信分享
在 manifest.json 的 App SDK 配置里,勾选微信消息及朋友圈,并填写 appid,如需在iOS平台使用还需要配置通用链接。
uni.shareWithSystem(OBJECT)
调用系统分享组件发送分享消息,不需要配置分享SDK
uni.shareWithSystem({
summary: '',
href: 'https://uniapp.dcloud.io',
success(){
// 分享完成,请注意此时不一定是成功分享
},
fail(){
// 分享失败
}
})
plus.share.sendWithSystem(msg, successCB, errorCB)
Android和iOS都有应用注册分享接口的机制,基本上所有有接收分享内容功能的应用,都会注册分享接口。
onShareAppMessage(OBJECT)
小程序中用户点击分享后,在 js 中定义 onShareAppMessage 处理函数(和 onLoad 等生命周期函数同级),设置该页面的分享信息。
uni.showShareMenu(OBJECT)
小程序的原生菜单中显示分享按钮
uni.hideShareMenu(OBJECT)
小程序的原生菜单中隐藏分享按钮