diff --git a/common/config.js b/common/config.js index a0d20c5..6a8ef20 100644 --- a/common/config.js +++ b/common/config.js @@ -1,2 +1,2 @@ -export const $apiLinks = "https://qg.njrenzhou.cn/" // api 接口地址 -export const baseUrl = "https://qg.njrenzhou.cn/" \ No newline at end of file +export const $apiLinks = "https://qg2.njrenzhou.cn/" // api 接口地址 +export const baseUrl = "https://qg2.njrenzhou.cn/" \ No newline at end of file diff --git a/manifest.json b/manifest.json index 42a21c1..c8420ba 100644 --- a/manifest.json +++ b/manifest.json @@ -120,7 +120,7 @@ }, "title" : "商城", "devServer" : { - "https" : true + "https" : false }, "domain" : "" }, diff --git a/pages/home/sign.vue b/pages/home/sign.vue index 17144fe..79dab2a 100644 --- a/pages/home/sign.vue +++ b/pages/home/sign.vue @@ -31,15 +31,15 @@ export default{ } }, methods: { - // base64toBlob(base64, type = 'application/octet-stream') { - // const bstr = atob(base64); - // let n = bstr.length; - // const u8arr = new Uint8Array(n); - // while (n--) { - // u8arr[n] = bstr.charCodeAt(n); - // } - // return new Blob([u8arr], { type }); - // }, + base64toBlob(base64, type = 'application/octet-stream') { + const bstr = atob(base64); + let n = bstr.length; + const u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + return new Blob([u8arr], { type }); + }, onClick(type) { if(type == 'openSmooth') { @@ -51,43 +51,39 @@ export default{ success: (res) => { // 是否为空画板 无签名 console.log(res.isEmpty) - console.log(res) - let base64 = res.tempFilePath.split(',')[1] - - // this.base64ToBlob({b64data: base64, contentType: 'image/png'}).then(res => { - // // 转后后的blob对象 - // console.log('blob', res) - // console.log(URL.createObjectURL(res)) - // uni.uploadFile({ - // url: this.baseUrl+'api/common/upload', - // filePath: URL.createObjectURL(res), - // name: 'file', - // header:{ - // token:getToken() - // }, - // formData: { - // }, - // success: (res) => { - // console.log(res) - // // if(JSON.parse(res.data).code==1){ - // // setTimeout(() => { - // // // this.finishImageList.push({url:JSON.parse(res.data).data.fullurl,path:JSON.parse(res.data).data.url}) - // // // resolve(res.data) - // // console.log(res) - // // }, 1000) - // // }else{ - // // uni.$u.toast(JSON.parse(res.data).msg) - - // // resolve(res.data) - // // } - // }, - // fail: (res) => { - // console.log(res,"rrr") - // } - // }); - // // console.log(new File([blob],filename,{ type })) - // }) + const base64String = res.tempFilePath.replace("data:image/png;base64,",''); + const blob = this.base64toBlob(base64String, 'image/jpg') + console.log(blob) + let path = URL.createObjectURL(blob); + console.log(path,"999") + uni.uploadFile({ + url: this.baseUrl+'api/common/upload', + filePath: path, + name: 'file', + header:{ + token:getToken() + }, + formData: { + }, + success: (res) => { + console.log(res) + // if(JSON.parse(res.data).code==1){ + // setTimeout(() => { + // // this.finishImageList.push({url:JSON.parse(res.data).data.fullurl,path:JSON.parse(res.data).data.url}) + // // resolve(res.data) + // console.log(res) + // }, 1000) + // }else{ + // uni.$u.toast(JSON.parse(res.data).msg) + + // resolve(res.data) + // } + }, + fail: (res) => { + console.log(res,"rrr") + } + }); // this.saveSignPic() } }) @@ -103,34 +99,33 @@ export default{ }) }, // 原理:利用URL.createObjectURL为blob对象创建临时的URL - - base64ToBlob ({b64data = '', contentType = '', sliceSize = 512} = {}) { - return new Promise((resolve, reject) => { - // 使用 atob() 方法将数据解码 - let byteCharacters = atob(b64data); - let byteArrays = []; - for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { - let slice = byteCharacters.slice(offset, offset + sliceSize); - let byteNumbers = []; - for (let i = 0; i < slice.length; i++) { - byteNumbers.push(slice.charCodeAt(i)); - } - // 8 位无符号整数值的类型化数组。内容将初始化为 0。 - // 如果无法分配请求数目的字节,则将引发异常。 - byteArrays.push(new Uint8Array(byteNumbers)); - } - let result = new Blob(byteArrays, { - type: contentType - }) - result = Object.assign(result,{ - // jartto: 这里一定要处理一下 URL.createObjectURL - preview: URL.createObjectURL(result), - name: `图片示例.png` - }); - resolve(result) - }) - } - + + // base64ToBlob ({b64data = '', contentType = '', sliceSize = 512} = {}) { + // return new Promise((resolve, reject) => { + // // 使用 atob() 方法将数据解码 + // let byteCharacters = atob(b64data); + // let byteArrays = []; + // for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { + // let slice = byteCharacters.slice(offset, offset + sliceSize); + // let byteNumbers = []; + // for (let i = 0; i < slice.length; i++) { + // byteNumbers.push(slice.charCodeAt(i)); + // } + // // 8 位无符号整数值的类型化数组。内容将初始化为 0。 + // // 如果无法分配请求数目的字节,则将引发异常。 + // byteArrays.push(new Uint8Array(byteNumbers)); + // } + // let result = new Blob(byteArrays, { + // type: contentType + // }) + // result = Object.assign(result,{ + // // jartto: 这里一定要处理一下 URL.createObjectURL + // preview: URL.createObjectURL(result), + // name: `图片示例.png` + // }); + // resolve(result) + // }) + // } } } diff --git a/unpackage/dist/build/h5/index.html b/unpackage/dist/build/h5/index.html index 21b7355..3fee513 100644 --- a/unpackage/dist/build/h5/index.html +++ b/unpackage/dist/build/h5/index.html @@ -1,2 +1,2 @@