绿满眶商城微信小程序-uniapp
peng
2025-07-17 5066d336f5a78debfbcdacc69b71aeab6d2b58e5
解决主包过大问题
4个文件已修改
2个文件已添加
236 ■■■■■ 已修改文件
config/api.js 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/cusbar/my-tag.vue 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/cusbar/video/video.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/mine/address/add.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/mine/uniMap.vue 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/tabbar/user/utils/tool.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/api.js
@@ -4,17 +4,17 @@
 */
// 开发环境
const dev = {
  // im: "http://192.168.0.15:8885",
  // common: "http://192.168.0.15:8890",
  // buyer: "http://192.168.0.15:8888",
  // store: "http://192.168.0.15:8889",
  im: "http://192.168.0.15:8885",
  common: "http://192.168.0.15:8890",
  buyer: "http://192.168.0.15:8888",
  store: "http://192.168.0.15:8889",
  // common: "http://192.168.0.113:8890",
  // buyer: "http://192.168.0.113:8888",
  // im: "http://192.168.0.113:8885",
  im: "http://1.95.67.54:888",
  common: "http://1.95.67.54:888",
  buyer: "http://1.95.67.54:888",
  store: "http://1.95.67.54:888",
  // im: "http://1.95.67.54:888",
  // common: "http://1.95.67.54:888",
  // buyer: "http://1.95.67.54:888",
  // store: "http://1.95.67.54:888",
};
// 生产环境
const prod = {
pages/cusbar/my-tag.vue
New file
@@ -0,0 +1,100 @@
<template>
  <view>
    <view class="my-tab-warp" :class="[`my-tab-${type}`]">
      <text class="my-tab-text" @click="clickTab">{{text}}</text>
      <view
        v-if="closeable"
        @click="close"
        class="iconfont my-tab-close"
      >
        <text v-if="type == 'error'">&#xe6ea;</text>
        <text v-else-if="type == 'primary'">&#xe7f9;</text>
        <text v-else-if="type == 'success'">&#xe7fa;</text>
        <text v-else-if="type == 'warning'">&#xe7fb;</text>
      </view>
    </view>
  </view>
</template>
<script>
export default {
  name: "my-tag",
  props: {
    text: {
      type: String
    },
    // 关闭、点击时的回传参数
    index: {
      type: Number
    },
    closeable: {
      type: Boolean,
      default: true
    },
    type: {
      type: String,
      default: 'error',
      validator: (value) => ['primary', 'success', 'error', 'warning'].includes(value)
    }
  },
  methods: {
    close() {
      this.$emit('close', this.index)
    },
    clickTab() {
      this.$emit('click', this.index)
    }
  }
}
</script>
<style>
.my-tab-warp {
  display: inline-flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  height: 22px;
  line-height: 22px;
  border-radius: 3px;
  padding: 0 8px;
  font-size: 12px;
  margin-right: 3px;
  border: 1px solid;
}
.my-tab-text {
  color: inherit;
}
.my-tab-close {
  font-size: 12px !important;
  margin-left: 4px;
  cursor: pointer;
}
/* 不同类型样式 */
.my-tab-primary {
  color: #2d8cf0;
  border-color: #2d8cf0;
  background-color: rgba(45, 140, 240, 0.1);
}
.my-tab-success {
  color: #19be6b;
  border-color: #19be6b;
  background-color: rgba(25, 190, 107, 0.1);
}
.my-tab-error {
  color: #ed4014;
  border-color: #ed4014;
  background-color: rgba(237, 64, 20, 0.1);
}
.my-tab-warning {
  color: #ff9900;
  border-color: #ff9900;
  background-color: rgba(255, 153, 0, 0.1);
}
</style>
pages/cusbar/video/video.vue
@@ -206,7 +206,7 @@
<script>
import '@/components/uview-components/uview-ui';
import MyTag from '@/pages/subComponents/my-tag.vue'
import MyTag from '@/pages/cusbar/my-tag.vue'
import { getSTSToken } from "@/api/common.js";
import { publish } from "@/api/video.js";
pages/mine/address/add.vue
@@ -44,7 +44,7 @@
import { addAddress, editAddress, getAddressDetail } from "@/api/address.js";
import city from "@/pages/mine/m-city/m-city.vue";
import uniMap from "@/pages/subComponents/uniMap.vue";
import uniMap from "@/pages/mine/uniMap.vue";
import permision from "@/js_sdk/wa-permission/permission.js";
export default {
  components: {
pages/mine/uniMap.vue
New file
@@ -0,0 +1,111 @@
<template></template>
<script>
import { getAddressCode } from "@/api/address";
import config from '@/config/config'
export default {
  data() {
    return {
      config
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    // 初始化地图并且调用
    initMap() {
      let that = this;
      uni.chooseLocation({
        success: function (res) {
          /**获取地址详情地址 */
          that.posToCity(res.latitude, res.longitude).then((val) => {
            /**获取地址code */
            getAddressCode(
              val.regeocode.addressComponent.citycode,
              val.regeocode.addressComponent.township
            ).then((code) => {
              that.$emit("callback", { ...val, ...res, ...code });
              that.$emit("close");
            });
          });
        },
        fail(e) {
          console.log(e)
          that.$emit("close");
        },
      });
    },
    // 根据当前客户端判断展示不同类型数据
    init() {
      // #ifdef MP-WEIXIN
      this.wechatMap();
      // #endif
      // #ifndef MP-WEIXIN
      this.initMap();
      // #endif
    },
    // 如果是微信小程序单独走微信小程序授权模式
    wechatMap() {
      let that = this;
      uni.authorize({
        scope: "scope.userLocation",
        success() {
          // 允许授权
          that.initMap();
        },
        fail() {
          //拒绝授权
          uni.showModal({
            content: "检测到您没打开获取地址功能权限,是否去设置打开?",
            confirmText: "确认",
            cancelText: "取消",
            success: (res) => {
              if (res.confirm) {
                // 打开设置好后重新刷新地图
                uni.openSetting({
                  success: (res) => {
                    that.initMap();
                  },
                });
              } else {
                // 取消后关闭
                that.$emit("close");
                return false;
              }
            },
          });
          return false;
        },
      });
    },
    // 获取城市的数据
    posToCity(latitude, longitude) {
      return new Promise((resolve, reject) => {
        uni.request({
          url: `https://restapi.amap.com/v3/geocode/regeo`,
          method: "GET",
          data: {
            key: config.aMapKey, //web服务的key
            location: `${longitude},${latitude}`,
          },
          success: ({ data }) => {
            const { status, info } = data;
            if (status === "1") {
              resolve(data);
            } else {
              reject(info);
            }
          },
          fail: (err) => {
            reject(err);
          },
        });
      });
    },
  },
};
</script>
<style lang="scss" scoped>
</style>
pages/tabbar/user/utils/tool.vue
@@ -3,7 +3,7 @@
        <!-- 常用工具 -->
        <view class="interact-tools" style="margin-bottom: 15px">
            <div class="paddingBox">
            <view class="paddingBox">
                <view class="interact-container">
                    <view class="interact-item" @click="navigateTo('/pages/mine/address/addressManage')">
                        <image src="/static/mine/myaddress.png" mode=""></image>
@@ -51,7 +51,6 @@
                        <image src="/static/mine/shensu.png" mode=""></image>
                        <view>我的活动</view>
                    </view> -->
                    </view>
                    <view class="interact-item" @click="navigateTo('/pages/mine/activity/applayActivityList')">
                        <image src="/static/mine/shensu.png" mode=""></image>
@@ -138,7 +137,7 @@
                    </view>
                </view>
            </div>
            </view>
        </view>
    </view>
</template>