| | |
| | | * 文件上传地址 |
| | | * @type {string} |
| | | */ |
| | | export const upload = api.common + "/common/upload/file"; |
| | | export const upload = api.common + "/lmk/file/upload"; |
| | | export const multiUpload = api.common + "/lmk/file/multi/upload"; |
| | |
| | | <script> |
| | | import '@/components/uview-components/uview-ui'; |
| | | |
| | | |
| | | import { upload } from "@/api/common.js"; |
| | | import storage from "@/utils/storage.js"; |
| | | import * as API_GOODS from "@/api/goods.js"; |
| | | export default { |
| | | data() { |
| | | return { |
| | | action: upload, |
| | | c_index: 0, |
| | | b_index: 0, |
| | | u_index: 0, |
| | |
| | | let images = []; |
| | | |
| | | lists.forEach((item) => { |
| | | images.push(item.response.result); |
| | | images.push(item.response.data.fileKey); |
| | | }); |
| | | this.form.images = images; |
| | | }, |
| | |
| | | onUploaded(lists) { |
| | | let images = []; |
| | | lists.forEach((item) => { |
| | | images.push(item.response.result); |
| | | images.push(item.response.data.fileKey); |
| | | }); |
| | | this.feedBack.images = images.join(","); |
| | | }, |
| | |
| | | <template> |
| | | <view class="person-msg"> |
| | | <view class="head c-content" @click="changeFace"> |
| | | <image :src="form.face || '/static/missing-face.png'" mode=""></image> |
| | | <image v-if="form.face" :src="endpoint + '/' + form.face" mode=""></image> |
| | | <image v-else :src="'/static/missing-face.png'" mode=""></image> |
| | | <view>点击修改头像</view> |
| | | </view> |
| | | <u-form :model="form" ref="uForm" class="form"> |
| | |
| | | </template> |
| | | <script> |
| | | import '@/components/uview-components/uview-ui'; |
| | | |
| | | import { getSTSToken } from "@/api/common.js"; |
| | | import { saveUserInfo, getUserInfo } from "@/api/members.js"; |
| | | import { upload } from "@/api/common.js"; |
| | | import { getFileKey } from "@/utils/file.js"; |
| | | import storage from "@/utils/storage.js"; |
| | | import city from "@/components/m-city/m-city.vue"; |
| | | export default { |
| | | components: { "m-city": city }, |
| | | data() { |
| | | return { |
| | | cosClient: null, |
| | | bucket: '', |
| | | region: '', |
| | | endpoint: '', |
| | | lightColor: this.$lightColor, //高亮颜色 |
| | | form: { |
| | | nickName: storage.getUserInfo().nickName || "", |
| | | birthday: storage.getUserInfo().birthday || "", |
| | | face: storage.getUserInfo().face || "/static/missing-face.png", //默认头像 |
| | | face: storage.getUserInfo().face, //默认头像 |
| | | regionId: [], //地址Id |
| | | region: storage.getUserInfo().region || [], //地址 |
| | | sex: storage.getUserInfo().sex, //性别 |
| | |
| | | showBirthday: false, //显示生日日期 |
| | | }; |
| | | }, |
| | | onLoad() { |
| | | this.initCOS() |
| | | }, |
| | | methods: { |
| | | // 初始化腾讯云cos客户端 |
| | | initCOS() { |
| | | // 调用后端获取sts临时访问凭证 |
| | | getSTSToken().then(res => { |
| | | const COS = require('@/lib/cos-wx-sdk-v5.js'); // 开发时使用 |
| | | // const COS = require('./lib/cos-wx-sdk-v5.min.js'); // 上线时使用压缩包 |
| | | |
| | | // console.log(COS.version); sdk 版本需要不低于 1.7.2 |
| | | this.cosClient = new COS({ |
| | | SecretId: res.data.data.tmpSecretId, // sts 服务下发的临时 secretId |
| | | SecretKey: res.data.data.tmpSecretKey, // sts 服务下发的临时 secretKey |
| | | SecurityToken: res.data.data.sessionToken, // sts 服务下发的临时 SessionToken |
| | | StartTime: res.data.data.stsStartTime, // 建议传入服务端时间,可避免客户端时间不准导致的签名错误 |
| | | ExpiredTime: res.data.data.stsEndTime, // 临时密钥过期时间 |
| | | SimpleUploadMethod: 'putObject', // 强烈建议,高级上传、批量上传内部对小文件做简单上传时使用 putObject,sdk 版本至少需要v1.3.0 |
| | | }); |
| | | this.bucket = res.data.data.bucket |
| | | this.region = res.data.data.region |
| | | this.endpoint = res.data.data.endpoint |
| | | }) |
| | | }, |
| | | /** |
| | | * 退出登录 |
| | | */ |
| | |
| | | */ |
| | | changeFace(index) { |
| | | uni.chooseImage({ |
| | | count: 1, |
| | | sizeType: ['compressed'], |
| | | sourceType: ['album'], |
| | | success: (chooseImageRes) => { |
| | | const tempFilePaths = chooseImageRes.tempFilePaths; |
| | | uni.uploadFile({ |
| | | url: upload, |
| | | filePath: tempFilePaths[0], |
| | | name: "file", |
| | | header: { |
| | | accessToken: storage.getAccessToken(), |
| | | }, |
| | | success: (uploadFileRes) => { |
| | | let data = JSON.parse(uploadFileRes.data); |
| | | |
| | | this.form.face = data.result; |
| | | }, |
| | | }); |
| | | const tempFilePath = chooseImageRes.tempFilePaths[0]; |
| | | let fileName = tempFilePath.substring(tempFilePath.lastIndexOf('/') + 1); |
| | | // 处理安卓可能的URI编码 |
| | | if(fileName.indexOf('%') > -1) { |
| | | fileName = decodeURIComponent(fileName); |
| | | } |
| | | const fileKey = getFileKey(fileName); |
| | | this.cosClient.uploadFile({ |
| | | Bucket: this.bucket, |
| | | Region: this.region, |
| | | Key: fileKey, |
| | | FilePath: tempFilePath, |
| | | SliceSize: 1024 * 1024 * 5 /* 触发分块上传的阈值,5M */ |
| | | }, (err, data) => { |
| | | if (err) { |
| | | console.log('上传失败', err); |
| | | } else { |
| | | this.form.face = fileKey; |
| | | } |
| | | }); |
| | | }, |
| | | }); |
| | | }, |
| | |
| | | url: '/pages/mine/set/securityCenter/bindMobile' + '?username=' + username, |
| | | }); |
| | | }, |
| | | }, |
| | | } |
| | | |
| | | /** |
| | | * 加载数据 |
| | | */ |
| | | onLoad() {}, |
| | | }; |
| | | </script> |
| | | <style> |
| | |
| | | let images = []; |
| | | |
| | | lists.forEach((item) => { |
| | | images.push(item.response.result); |
| | | images.push(item.response.data.fileKey); |
| | | }); |
| | | this.form.images = images; |
| | | }, |
| | |
| | | onUploaded(lists) { |
| | | let images = []; |
| | | lists.forEach((item) => { |
| | | images.push(item.response.result); |
| | | images.push(item.response.data.fileKey); |
| | | }); |
| | | this.images = images; |
| | | }, |
| | |
| | | onUploaded(lists) { |
| | | let images = []; |
| | | lists.forEach((item) => { |
| | | images.push(item.response.result); |
| | | images.push(item.response.data.fileKey); |
| | | }); |
| | | this.form.images = images; |
| | | }, |
| | |
| | | methods: { |
| | | // 图片上传 |
| | | onUploaded(lists, key) { |
| | | console.log("上传结果",lists); |
| | | let images = []; |
| | | lists.forEach((item) => { |
| | | images.push(item.response.result); |
| | | images.push(item.response.data.fileKey); |
| | | }); |
| | | this.form[key] = images; |
| | | }, |
| | |
| | | onUploaded(lists, key) { |
| | | let images = []; |
| | | lists.forEach((item) => { |
| | | images.push(item.response.result); |
| | | images.push(item.response.data.fileKey); |
| | | }); |
| | | this.form[key] = images; |
| | | }, |
| | |
| | | </view> |
| | | <view class="header" @click="userDetail"> |
| | | <view class="head-1"> |
| | | <image :src="userInfo.face || userImage"></image> |
| | | <image v-if="userInfo.face" :src="endpoint + '/' + userInfo.face"></image> |
| | | <image v-else :src="userImage"></image> |
| | | </view> |
| | | <view class="head-2" v-if="userInfo.id"> |
| | | <view class="user-name">{{ userInfo.nickName }}</view> |
| | |
| | | <script> |
| | | import '@/components/uview-components/uview-ui'; |
| | | import tool from "@/pages/tabbar/user/utils/tool.vue"; |
| | | import { getSTSToken } from "@/api/common.js"; |
| | | import { getCouponsNum, getFootprintNum } from "@/api/members.js"; |
| | | import { getUserWallet } from "@/api/members"; |
| | | import configs from '@/config/config' |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | endpoint: '', |
| | | configs, |
| | | userImage:configs.defaultUserPhoto, |
| | | coverTransform: "translateY(0px)", |
| | |
| | | walletNum: "", |
| | | }; |
| | | }, |
| | | onLoad() { }, |
| | | onLoad() { |
| | | this.initCOS() |
| | | }, |
| | | onShow() { |
| | | this.userInfo = this.$options.filters.isLogin() || {}; |
| | | if (this.$options.filters.isLogin("auth")) { |
| | |
| | | |
| | | mounted() { }, |
| | | methods: { |
| | | // 初始化腾讯云cos客户端 |
| | | initCOS() { |
| | | // 调用后端获取sts临时访问凭证 |
| | | getSTSToken().then(res => { |
| | | this.endpoint = res.data.data.endpoint |
| | | }) |
| | | }, |
| | | // 跳转视频主页 |
| | | jumpToVideoHome() { |
| | | uni.navigateTo({ |
| | | url: '/pages/video/home-page?authorId=' + storage.getUserInfo().id |
| | |
| | | import '@/components/uview-components/uview-ui'; |
| | | import MyTag from '@/components/my-tag.vue' |
| | | |
| | | import { getSTSToken, getFilePreviewUrl } from "@/api/common.js"; |
| | | import { getSTSToken } from "@/api/common.js"; |
| | | import { publish } from "@/api/video.js"; |
| | | import { getRecommendTag3 } from "@/api/video-tag.js"; |
| | | import { getFileKey } from "@/utils/file.js"; |
| | |
| | | let fileName = tmpImg.substring(tmpImg.lastIndexOf('/') + 1); |
| | | // 处理安卓可能的URI编码 |
| | | if(fileName.indexOf('%') > -1) { |
| | | fileName = decodeURIComponent(fileName); |
| | | fileName = decodeURIComponent(fileName); |
| | | } |
| | | const fileKey = getFileKey(fileName); |
| | | this.cosClient.uploadFile({ |