第一步:在app.js或utils.js中添加以下两个方法:
// 拿到需要返回的页面路径和参数并保存 (跳转之前调用此方法)
setCallbackUrl: function(mode) {
return new Promise((resolve,reject) => {
let pages = getCurrentPages(); //获取历史页面记录
let currentPage = pages[pages.length - 1]; //获取当前页面
let urlPage = '';
let url = currentPage.route; //拿到当前页面url
let argumentsStr = '';
let options = currentPage.options; //拿到参数对象
for (let key in options) {
let value = options[key];
argumentsStr += key + '=' + value + '&';
}
if(argumentsStr) {
argumentsStr = argumentsStr.substring(0, argumentsStr.length - 1);
urlPage = url + '?' + argumentsStr;
} else {
urlPage = url;
}
let callbackObj = {