/* ** 下载文件 */ function downloadFile(url) { return new Promise((resolve, reject) => { wx.downloadFile({ url, success: ({ statusCode, tempFilePath }) => { if (statusCode === 200) resolve(tempFilePath) else reject() }, fail: () => reject() }) }) } /* ** 打开协议 */ function openAgreement(url) { return new Promise((resolve, reject) => { downloadFile(url).then(filePath => { wx.openDocument({ filePath, success: () => resolve(), fail: () => reject() }) }).catch(() => reject()) }) } module.exports = {openAgreement }