1. uniapp 小程序支付
uni.request({
url: "http://xxxxxx/payOrder", // 后端接口 返回調(diào)起支付需要的參數(shù)
data: {
userId:1, // 此接口需要的參數(shù) 一般有多個(gè) 此僅為示例
},
method: "POST",
success: (res) => {
console.log(res.data, "這是調(diào)起支付的參數(shù)");
// 調(diào)起小程序支付api 下面參數(shù)為必傳
uni.requestPayment({
provider: "wxpay", //支付類型(小程序)
...res.data, // 前面接口返回的數(shù)據(jù)
success: (res) => {
if (res.errMsg === "requestPayment:ok") {
console.log("支付成功", res)
}
},
fail: (err) => {
console.log("支付失敗", err)
}
})
}
})
2. uniapp保存圖片到相冊
saveImage(url) {
uni.showLoading({
title:'下載中...'
})
uni.downloadFile({
url: url,
success(res) {
if (res) {
console.log('下載成功', res)
uni.hideLoading();
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success(res) {
console.log(res);
},
fail(res) {
console.log(res);
},
});
}
},
fail: (err) => {
if (err) {
console.log('下載失敗', err)
uni.hideLoading();
}
}
});
}
3. uniapp返回刷新
let pages = getCurrentPages(); // 當(dāng)前頁面
let beforePage = pages[pages.length - 2]; //上一個(gè)頁面
uni.navigateBack({
success: function() {
beforePage.$vm.getlist();
}
})
4. uniapp 小程序分享
//發(fā)送給朋友
onShareAppMessage(){
return {
title: '',//分享標(biāo)題
path: ''//分享頁面路徑
imageUrl: '',//分享圖標(biāo)
desc:'',//自定義分享描述
}
},
//分享朋友圈
onShareTimeline() {},