| 1234567891011121314151617181920212223242526272829303132 |
- /*
- ** 下载文件
- */
- 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 }
|