diff --git a/teamwork/components/c-userinfo/c-userinfo.vue b/teamwork/components/c-userinfo/c-userinfo.vue new file mode 100644 index 0000000000000000000000000000000000000000..7f700d5b8b62b670181c074a4b04f0fcf45ed997 --- /dev/null +++ b/teamwork/components/c-userinfo/c-userinfo.vue @@ -0,0 +1,390 @@ + + + + + diff --git a/teamwork/js_sdk/mmmm-image-tools/index.js b/teamwork/js_sdk/mmmm-image-tools/index.js new file mode 100644 index 0000000000000000000000000000000000000000..acf40bc87f76346c39eed90d603d5af884ca81e4 --- /dev/null +++ b/teamwork/js_sdk/mmmm-image-tools/index.js @@ -0,0 +1,196 @@ +function getLocalFilePath(path) { + if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path.indexOf('_downloads') === 0) { + return path + } + if (path.indexOf('file://') === 0) { + return path + } + if (path.indexOf('/storage/emulated/0/') === 0) { + return path + } + if (path.indexOf('/') === 0) { + var localFilePath = plus.io.convertAbsoluteFileSystem(path) + if (localFilePath !== path) { + return localFilePath + } else { + path = path.substr(1) + } + } + return '_www/' + path +} + +function dataUrlToBase64(str) { + var array = str.split(',') + return array[array.length - 1] +} + +var index = 0 +function getNewFileId() { + return Date.now() + String(index++) +} + +function biggerThan(v1, v2) { + var v1Array = v1.split('.') + var v2Array = v2.split('.') + var update = false + for (var index = 0; index < v2Array.length; index++) { + var diff = v1Array[index] - v2Array[index] + if (diff !== 0) { + update = diff > 0 + break + } + } + return update +} + +export function pathToBase64(path) { + return new Promise(function(resolve, reject) { + if (typeof window === 'object' && 'document' in window) { + if (typeof FileReader === 'function') { + var xhr = new XMLHttpRequest() + xhr.open('GET', path, true) + xhr.responseType = 'blob' + xhr.onload = function() { + if (this.status === 200) { + let fileReader = new FileReader() + fileReader.onload = function(e) { + resolve(e.target.result) + } + fileReader.onerror = reject + fileReader.readAsDataURL(this.response) + } + } + xhr.onerror = reject + xhr.send() + return + } + var canvas = document.createElement('canvas') + var c2x = canvas.getContext('2d') + var img = new Image + img.onload = function() { + canvas.width = img.width + canvas.height = img.height + c2x.drawImage(img, 0, 0) + resolve(canvas.toDataURL()) + canvas.height = canvas.width = 0 + } + img.onerror = reject + img.src = path + return + } + if (typeof plus === 'object') { + plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), function(entry) { + entry.file(function(file) { + var fileReader = new plus.io.FileReader() + fileReader.onload = function(data) { + resolve(data.target.result) + } + fileReader.onerror = function(error) { + reject(error) + } + fileReader.readAsDataURL(file) + }, function(error) { + reject(error) + }) + }, function(error) { + reject(error) + }) + return + } + if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) { + wx.getFileSystemManager().readFile({ + filePath: path, + encoding: 'base64', + success: function(res) { + resolve('data:image/png;base64,' + res.data) + }, + fail: function(error) { + reject(error) + } + }) + return + } + reject(new Error('not support')) + }) +} + +export function base64ToPath(base64) { + return new Promise(function(resolve, reject) { + if (typeof window === 'object' && 'document' in window) { + base64 = base64.split(',') + var type = base64[0].match(/:(.*?);/)[1] + var str = atob(base64[1]) + var n = str.length + var array = new Uint8Array(n) + while (n--) { + array[n] = str.charCodeAt(n) + } + return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], { type: type }))) + } + var extName = base64.split(',')[0].match(/data\:\S+\/(\S+);/) + if (extName) { + extName = extName[1] + } else { + reject(new Error('base64 error')) + } + var fileName = getNewFileId() + '.' + extName + if (typeof plus === 'object') { + var basePath = '_doc' + var dirPath = 'uniapp_temp' + var filePath = basePath + '/' + dirPath + '/' + fileName + if (!biggerThan(plus.os.name === 'Android' ? '1.9.9.80627' : '1.9.9.80472', plus.runtime.innerVersion)) { + plus.io.resolveLocalFileSystemURL(basePath, function(entry) { + entry.getDirectory(dirPath, { + create: true, + exclusive: false, + }, function(entry) { + entry.getFile(fileName, { + create: true, + exclusive: false, + }, function(entry) { + entry.createWriter(function(writer) { + writer.onwrite = function() { + resolve(filePath) + } + writer.onerror = reject + writer.seek(0) + writer.writeAsBinary(dataUrlToBase64(base64)) + }, reject) + }, reject) + }, reject) + }, reject) + return + } + var bitmap = new plus.nativeObj.Bitmap(fileName) + bitmap.loadBase64Data(base64, function() { + bitmap.save(filePath, {}, function() { + bitmap.clear() + resolve(filePath) + }, function(error) { + bitmap.clear() + reject(error) + }) + }, function(error) { + bitmap.clear() + reject(error) + }) + return + } + if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) { + var filePath = wx.env.USER_DATA_PATH + '/' + fileName + wx.getFileSystemManager().writeFile({ + filePath: filePath, + data: dataUrlToBase64(base64), + encoding: 'base64', + success: function() { + resolve(filePath) + }, + fail: function(error) { + reject(error) + } + }) + return + } + reject(new Error('not support')) + }) +} \ No newline at end of file diff --git a/teamwork/js_sdk/mmmm-image-tools/package.json b/teamwork/js_sdk/mmmm-image-tools/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e8b9c0a6bb7d96529c53dc75e3563d52d8e505c3 --- /dev/null +++ b/teamwork/js_sdk/mmmm-image-tools/package.json @@ -0,0 +1,11 @@ +{ + "id": "mmmm-image-tools", + "name": "image-tools", + "version": "1.4.0", + "description": "图像转换工具,可用于图像和base64的转换", + "keywords": [ + "base64", + "保存", + "图像" + ] +} \ No newline at end of file diff --git a/teamwork/package.json b/teamwork/package.json index d9fa66621b9118b9c0594b5adf2e35d2704f1936..56ae330963435707eda331773f4d4388661c66e3 100644 --- a/teamwork/package.json +++ b/teamwork/package.json @@ -1,33 +1,11 @@ { - "id": "helang-tabBar", - "displayName": "底部导航栏(有动画的)", - "version": "1.0.0", - "description": "本开源代码分享了5款有动画切换效果的 底部导航栏 组件", - "keywords": [ - "底部导航栏", - "动画" - ], - "engines": {}, - "dcloudext": { - "contact": { - "qq": "" - }, - "declaration": { - "ads": "无", - "data": "无", - "permissions": "无" - }, - "npmurl": "" - }, - "dependencies": { - "@dcloudio/uni-ui": "^1.4.27", - "element-ui": "^2.15.13" - }, - "name": "teamwork", - "main": "main.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC" -} + "id": "c-userinfo", + "name": "个人信息编辑表单", + "version": "1.0.1", + "description": "通用个人中心表单,包含获取用户信息,授权手机号,上传头像等", + "keywords": [ + "表单", + "用户信息", + "手机号" + ] +} \ No newline at end of file diff --git a/teamwork/pages/my/main.vue b/teamwork/pages/my/main.vue index 1bc5c47dcd6f02c6f1976dfb2e1726077a695ae3..8429e9462cce41d8b442c6e25c9e46f087d61912 100644 --- a/teamwork/pages/my/main.vue +++ b/teamwork/pages/my/main.vue @@ -1,5 +1,8 @@ \ No newline at end of file diff --git a/teamwork/pages/my/my-resetpassword.vue b/teamwork/pages/my/my-resetpassword.vue index 297a9ec05a8f85de9f61cb00384ad3cea4ef9550..8fc325f3ae773024696bbd016c43502c0f5d5322 100644 --- a/teamwork/pages/my/my-resetpassword.vue +++ b/teamwork/pages/my/my-resetpassword.vue @@ -1,7 +1,13 @@