绿满眶商城微信小程序-uniapp
xiangpei
2025-07-04 d7b8298e174d39256beb3803d120de191b60621f
上传调整
11个文件已修改
121 ■■■■ 已修改文件
api/common.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/goods-manager/addGoods/addGoods.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/mine/set/feedBack.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/mine/set/personMsg.vue 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/order/afterSales/afterSalesDetail.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/order/complain/complain.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/order/evaluate/releaseEvaluate.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/passport/entry/seller/step1.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/passport/entry/seller/step3.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tabbar/user/my.vue 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tabbar/video/video.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/common.js
@@ -50,4 +50,5 @@
 * 文件上传地址
 * @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";
pages/goods-manager/addGoods/addGoods.vue
@@ -77,12 +77,13 @@
<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,
@@ -101,7 +102,7 @@
            let images = [];
            lists.forEach((item) => {
                images.push(item.response.result);
                images.push(item.response.data.fileKey);
            });
            this.form.images = images;
        },
pages/mine/set/feedBack.vue
@@ -67,7 +67,7 @@
    onUploaded(lists) {
      let images = [];
      lists.forEach((item) => {
        images.push(item.response.result);
        images.push(item.response.data.fileKey);
      });
      this.feedBack.images = images.join(",");
    },
pages/mine/set/personMsg.vue
@@ -1,7 +1,8 @@
<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">
@@ -42,20 +43,25 @@
</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, //性别
@@ -79,7 +85,31 @@
      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
          })
      },
      /**
       * 退出登录
       */
@@ -135,21 +165,30 @@
     */
    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;
               }
           });
        },
      });
    },
@@ -178,12 +217,8 @@
        url: '/pages/mine/set/securityCenter/bindMobile' + '?username=' + username,
      });
    },
  },
  }
  /**
   * 加载数据
   */
  onLoad() {},
};
</script>
<style>
pages/order/afterSales/afterSalesDetail.vue
@@ -269,7 +269,7 @@
      let images = [];
      lists.forEach((item) => {
        images.push(item.response.result);
        images.push(item.response.data.fileKey);
      });
      this.form.images = images;
    },
pages/order/complain/complain.vue
@@ -103,7 +103,7 @@
    onUploaded(lists) {
      let images = [];
      lists.forEach((item) => {
        images.push(item.response.result);
        images.push(item.response.data.fileKey);
      });
      this.images = images;
    },
pages/order/evaluate/releaseEvaluate.vue
@@ -160,7 +160,7 @@
    onUploaded(lists) {
      let images = [];
      lists.forEach((item) => {
        images.push(item.response.result);
        images.push(item.response.data.fileKey);
      });
      this.form.images = images;
    },
pages/passport/entry/seller/step1.vue
@@ -315,9 +315,10 @@
  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;
    },
pages/passport/entry/seller/step3.vue
@@ -288,7 +288,7 @@
    onUploaded(lists, key) {
      let images = [];
      lists.forEach((item) => {
        images.push(item.response.result);
        images.push(item.response.data.fileKey);
      });
      this.form[key] = images;
    },
pages/tabbar/user/my.vue
@@ -6,7 +6,8 @@
    </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>
@@ -111,6 +112,7 @@
<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'
@@ -121,6 +123,7 @@
  },
  data() {
    return {
      endpoint: '',
      configs,
      userImage:configs.defaultUserPhoto,
      coverTransform: "translateY(0px)",
@@ -132,7 +135,9 @@
      walletNum: "",
    };
  },
  onLoad() { },
  onLoad() {
      this.initCOS()
  },
  onShow() {
    this.userInfo = this.$options.filters.isLogin() || {};
    if (this.$options.filters.isLogin("auth")) {
@@ -158,6 +163,14 @@
  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
pages/tabbar/video/video.vue
@@ -208,7 +208,7 @@
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";
@@ -488,7 +488,7 @@
              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({