|
@@ -0,0 +1,86 @@
|
|
|
+/* import {
|
|
|
+ ApiModel
|
|
|
+} from './api'
|
|
|
+const _Http = new ApiModel();
|
|
|
+
|
|
|
+class {
|
|
|
+ changeUserImg() {
|
|
|
+ wx.chooseMedia({
|
|
|
+ count: 1,
|
|
|
+ mediaType: ['image'],
|
|
|
+ sourceType: ['album', 'camera'],
|
|
|
+ camera: 'back',
|
|
|
+ success(res) {
|
|
|
+ const file = res.tempFiles[0];
|
|
|
+ var index = file.tempFilePath.lastIndexOf(".");
|
|
|
+ var ext = file.tempFilePath.substr(index + 1);
|
|
|
+ var timestamp = Date.parse(new Date());
|
|
|
+ wx.getFileSystemManager().readFile({
|
|
|
+ filePath: file.tempFilePath,
|
|
|
+ // encoding:'utf-8',
|
|
|
+ success: result => {
|
|
|
+ //返回临时文件路径
|
|
|
+ const fileData = result.data
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('token'),
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "getFileName",
|
|
|
+ "content": {
|
|
|
+ "filename": 'wx' + timestamp,
|
|
|
+ "filetype": ext,
|
|
|
+ "ownertable": "tenterprise_users",
|
|
|
+ // "ownerid": getApp().globalData.accountList[0].userid,
|
|
|
+ "ftype": "headportrait",
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ // 删除之前头像
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('token'),
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "deleteDoc",
|
|
|
+ "content": {
|
|
|
+ "ownertable": "tnotice",
|
|
|
+ "ownerid": that.data.fobsurl.ownerid,
|
|
|
+ "tattachmentid": that.data.fobsurl.tattachmentid
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 上次并查询头像
|
|
|
+ that.uploadFile(res, fileData)
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: console.error
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ uploadFile(res, data) {
|
|
|
+ var that = this
|
|
|
+ wx.request({
|
|
|
+ url: res.data.obsuploadurl,
|
|
|
+ method: "PUT",
|
|
|
+ data: data,
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/octet-stream' // 默认值
|
|
|
+ },
|
|
|
+ success() {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('token'),
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "uploadSuccsess",
|
|
|
+ "content": {
|
|
|
+ "obsfilename": res.data.obsfilename
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ that.setData({
|
|
|
+ fobsurl: res.data[0]
|
|
|
+ })
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+} */
|