feat(global): fix error when build with app-plus

This commit is contained in:
appleyou 2025-04-16 18:00:45 +08:00
parent e89e3ac5e8
commit ee473854f9
19 changed files with 449 additions and 685 deletions

View File

@ -7,9 +7,7 @@
-->
<script>
export default {
onLaunch: function () {
let url = window.location.href.split('/#/')[1].split('?')[0]
onLaunch: function (options) {
//
const whiteList = [
// 'pages/shareRegist/index',
@ -21,7 +19,7 @@ export default {
// 'pages/shareArea/hiOrder',
// 'pages/pay/hiPay'
]
if (whiteList.indexOf(url) !== -1) {
if (whiteList.indexOf(options.path) !== -1) {
} else {
this.$store.dispatch('GetInfo')
this.$store.dispatch('getCarLength')

View File

@ -8,8 +8,9 @@
<view>
<view class="quan"
@click.stop="goCart">
<img :src="smallCarLength>0?img1:img2"
<image :src="smallCarLength>0?img1:img2"
alt="">
<view class="qiu"
v-show="smallCarLength > 0">{{ smallCarLength }}</view>
@ -37,8 +38,8 @@ export default {
data() {
return {
downShow: false,
img1: require('@/static/images/cartBall1.png'),
img2: require('@/static/images/cartBall.png'),
img1: require('static/images/cartBall1.png'),
img2: require('static/images/cartBall.png'),
}
},
computed: {
@ -108,7 +109,7 @@ export default {
justify-content: center;
align-items: center;
z-index: 10;
img {
image {
width: 60rpx;
height: 60rpx;
position: relative;

View File

@ -10,11 +10,28 @@ const TokenKey = 'Admin-Token'
const TokenMi = 'Mi-token'
export function getToken() {
return Cookies.get(TokenKey)
let cookie = ''
// #ifdef H5
cookie = Cookies.get(TokenKey)
// #endif
// #ifdef APP-PLUS
cookie = uni.getStorageSync(TokenKey)
// #endif
return cookie
}
export function setToken(token, expires) {
return Cookies.set(TokenKey, token)
// #ifdef H5
Cookies.set(TokenKey, token)
// #endif
// #ifdef APP-PLUS
uni.setStorageSync(TokenKey, token)
// #endif
}
export function removeToken() {
return Cookies.remove(TokenKey)
// #ifdef H5
Cookies.remove(TokenKey)
// #endif
// #ifdef APP-PLUS
uni.removeStorageSync(TokenKey)
// #endif
}

View File

@ -8,17 +8,17 @@ import { getToken, removeToken } from '@/config/auth.js'
module.exports = (vm) => {
// 初始化请求配置
uni.$u.http.setConfig((config) => {
// config.baseURL = 'https://p1.hzs413.com/inter-api';
config.baseURL = 'http://localhost:8080'
// 192.168.0.100:8080
//#ifdef DEV_SERVER
console.log('DEV_SERVER')
config.baseURL = '/prod-api';
// config.baseURL = '/prod-api';
//#endif
//#ifdef QA_SERVER
console.log('QA_SERVER')
config.baseURL = '/prod-api';
// config.baseURL = '/prod-api';
//#endif
config.timeout = 30000;
return config
@ -48,17 +48,7 @@ module.exports = (vm) => {
// 响应拦截
uni.$u.http.interceptors.response.use((response) => {
const data = response.data
// uni.$u.toast(data.msg)
// if (data.code == 200) {
// return data;
// } else {
// token过期,清除token重新获取
if (data.code == 400 || data.code == 401 || data.code == 402) {
// uni.showToast({
// title: '登录超时',
// icon: 'none',
// duration: 1500,
// })
removeToken();
// 跳转到登录
setTimeout(() => {

View File

@ -8,24 +8,24 @@
<html lang="en">
<head>
<meta charset="UTF-8"/>
<script>
<!-- <script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
</script> -->
<title></title>
<!--preload-links-->
<!--app-context-->
<link rel="stylesheet" href="<%= BASE_URL %>static/index.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0 viewport-fit=cover"/>
<script src="https://bd-qd.oss-cn-beijing.aliyuncs.com/test_01/language/zh-CN.js"></script>
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
<script type="module" src="static/cdn/echarts.min.js"></script>
<!-- <script type="module" src="static/cdn/echarts.min.js"></script> -->
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
</body>
</html>

14
main.js
View File

@ -19,10 +19,10 @@ import store from '@/store/index.js'
import Vue2OrgTree from 'vue-tree-color'
import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts;
import 'static/styles/index.css'
Vue.use(Vue2OrgTree)
import axios from 'axios';
import { saveAs } from 'file-saver';
window.wx = {}
// import { saveAs } from 'file-saver';
// window.wx = {}
/*底部数据*/
@ -37,7 +37,7 @@ const app = new Vue({
Vue.config.ignoredElements = [...Vue.config.ignoredElements, 'wx-open-launch-weapp']
// 复制
// // 复制
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)
@ -50,14 +50,14 @@ Vue.filter('numberToCurrency', numberToCurrencyNo)
Vue.filter('toThousandthAndKeepDecimal', toThousandthAndKeepDecimal)
// 配置全局过滤器,实现数字千分位格式
Vue.filter('isLocal', isLocal)
import i18n from '@/util/i18n/index'
Vue.prototype._i18n = i18n
// import i18n from '@/util/i18n/index'
// Vue.prototype._i18n = i18n
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.use(i18n)
// app.use(i18n)
return {
app,
store

19
mixins/deviceSafeArea.js Normal file
View File

@ -0,0 +1,19 @@
export default {
data() {
return {
safeAreaTop: 0,
safeAreaBottom: 0,
safeAreaLeft: 0,
safeAreaRight: 0
}
},
onLoad() {
// #ifdef APP-PLUS
const {top, bottom, left, right} = uni.getSystemInfoSync().safeAreaInsets
this.safeAreaTop = top
this.safeAreaBottom = bottom
this.safeAreaLeft = left
this.safeAreaRight = right
// #endif
}
}

11
package-lock.json generated
View File

@ -15,8 +15,9 @@
"glob": "^11.0.1",
"html2canvas": "^1.4.1",
"js-cookie": "^3.0.5",
"qrcodejs2": "0.0.2",
"qrcodejs2": "^0.0.2",
"swiper": "^3.4.2",
"uqrcodejs": "^4.0.7",
"vue-clipboard2": "^0.3.3",
"vue-i18n": "^9.2.2",
"vue-tree-color": "^2.3.2",
@ -3915,7 +3916,7 @@
},
"node_modules/qrcodejs2": {
"version": "0.0.2",
"resolved": "https://registry.npmmirror.com/qrcodejs2/-/qrcodejs2-0.0.2.tgz",
"resolved": "https://registry.npmjs.org/qrcodejs2/-/qrcodejs2-0.0.2.tgz",
"integrity": "sha512-+Y4HA+cb6qUzdgvI3KML8GYpMFwB24dFwzMkS/yXq6hwtUGNUnZQdUnksrV1XGMc2mid5ROw5SAuY9XhI3ValA==",
"license": "MIT"
},
@ -5101,6 +5102,12 @@
"yarn": "*"
}
},
"node_modules/uqrcodejs": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/uqrcodejs/-/uqrcodejs-4.0.7.tgz",
"integrity": "sha512-84+aZmD2godCVI+93lxE3YUAPNY8zAJvNA7xRS7R7U+q57KzMDepBSfNCwoRUhWOfR6eHFoAOcHRPwsP6ka1cA==",
"license": "Apache-2.0"
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://mirrors.cloud.tencent.com/npm/uri-js/-/uri-js-4.4.1.tgz",

View File

@ -10,8 +10,9 @@
"glob": "^11.0.1",
"html2canvas": "^1.4.1",
"js-cookie": "^3.0.5",
"qrcodejs2": "0.0.2",
"qrcodejs2": "^0.0.2",
"swiper": "^3.4.2",
"uqrcodejs": "^4.0.7",
"vue-clipboard2": "^0.3.3",
"vue-i18n": "^9.2.2",
"vue-tree-color": "^2.3.2",

View File

@ -5,7 +5,6 @@
"style": {
"navigationBarTitleText": "首页",
"navigationBarBackgroundColor": "#fff",
// "enablePullDownRefresh": true,
"navigationBarHidden": true,
"navigationStyle": "custom"
}
@ -174,13 +173,6 @@
"navigationBarBackgroundColor": "#fff"
}
},
{
"path": "pages/email/index",
"style": {
"navigationBarTitleText": "公告列表",
"navigationBarBackgroundColor": "#fff"
}
},
{
"path": "pages/shoppingCar/index",
"style": {
@ -228,7 +220,7 @@
"style": {
"navigationBarTitleText": "会员专区",
"app-plus": {
"titleNView": false
"titleNView": true
}
}
},

View File

@ -5,40 +5,33 @@
* @Date: 2022-11-21 15:11:22
-->
<template>
<view :class="userInfo.skin ? 'content1' : 'content'">
<view class="content_a">
<!-- 商品专区入口 先别删 -->
<!-- <view @tap="goSpecialArea">会员专区</view> -->
<view :class="userInfo.skin ? 'index-top1' : 'index-top'">
<view
:class="userInfo.skin ? 'content1' : 'content'"
>
<view
class="content_a"
>
<view
:class="userInfo.skin ? 'index-top1' : 'index-top'"
:style="{
paddingTop: safeAreaTop + 'rpx',
}"
>
<view class="index_t">
<view class="index-left">
<view class="english">GLOBALIZATION</view>
<view class="text">{{ '全球一体化' }}</view>
</view>
<!-- <view class="index-right">
</view>
</view>
<view
class="changeLanguages"
v-if="isEmpty(getLanguageList) == false"
v-if="!isEmpty(goodsList.advertBannerList)"
class="banner"
:style="{
paddingTop: 140 + safeAreaTop + 'rpx'
}"
>
<picker
:range="getLanguageList"
:value="index"
range-key="label"
@change="bindPickerChange"
>
<view class="select-text">
<view class="texts">{{ getLanguageList[index].label }}</view>
<view class="">
</view>
</view>
</picker>
</view>
</view> -->
</view>
</view>
<view class="banner" v-if="isEmpty(goodsList.advertBannerList) == false">
<view class="uni-margin-wrap">
<swiper
class="swiper"
@ -102,28 +95,11 @@
</view>
</view>
<view class="goods_content">
<!-- banner图!-->
<!-- <view class="goods-lists"-->
<!-- v-if="isEmpty(goodsList.waresCoverInfoList)==false">-->
<!-- <view class="uni-margin-wrap"-->
<!-- v-if="goodsList.waresCoverInfoList[0]">-->
<!-- <swiper class="swiper swiper-s"-->
<!-- circular-->
<!-- :indicator-dots="indicatorDots"-->
<!-- :autoplay="autoplay"-->
<!-- :interval="interval"-->
<!-- :duration="duration">-->
<!-- <swiper-item v-for="item in goodsList.waresCoverInfoList[0].coverList">-->
<!-- <view class="swiper-items uni-bg-red">-->
<!-- <image :src="item"></image>-->
<!-- </view>-->
<!-- </swiper-item>-->
<!-- </swiper>-->
<!-- </view>-->
<!-- </view>-->
<view
class="goods-center-lists"
v-for="item in goodsList.waresVoList"
v-for="(item, idx) in goodsList.waresVoList"
:key="idx"
@click="goDetails(item)"
>
<view
@ -214,8 +190,10 @@ import clTabbar from "@/components/cl-tabbar.vue";
import noticePopup from "@/components/noticePopup.vue";
import getTree from "@/components/getTree.vue";
import znNewsPopup from "@/components/znNewsPopup.vue";
import deviceSafeArea from '@/mixins/deviceSafeArea.js'
// import directrankPopup from "@/components/directrankPopup.vue";
export default {
mixins: [deviceSafeArea],
components: {
noticePopup,
znNewsPopup,
@ -437,10 +415,8 @@ export default {
uni.getStorageSync("showInfo") == undefined ||
uni.getStorageSync("showInfo") == 0
) {
this.getRepurchase();
}
this.getGoodsInfo();
// this.getLanguage();
this.getService();
},
onShow() {
@ -454,23 +430,6 @@ export default {
}, 1000);
},
methods: {
getRepurchase() {
// api.index_repurchase().then((res) => {
// if (res.msg) {
// uni.showModal({
// title: "",
// content: res.msg,
// showCancel: false,
// confirmColor: "#f82c1a",
// success: function (res) {
// if (res.confirm) {
// uni.setStorageSync("showInfo", 1);
// }
// },
// });
// }
// });
},
// index_repurchase
goAreaUrl() {
ban.agreementName().then((res) => {
@ -581,12 +540,6 @@ export default {
this.goodsList = res.data;
});
},
bindPickerChange(e) {
this.index = e.detail.value;
uni.setStorageSync("lang", this.getLanguageList[e.detail.value].field);
this.$i18n.locale = this.getLanguageList[e.detail.value].field;
window.location.reload();
},
goUrl(item) {
ban.agreementName().then((res) => {
if (res.data == 0) {
@ -680,29 +633,6 @@ export default {
}
}
},
goSpecialArea() {
uni.navigateTo({
url: "/pages/index/specialArea/index",
});
},
getLanguage() {
api.getLanguages().then((res) => {
if (res.code == 200) {
res.data.forEach((item, index) => {
if (item.field == uni.getStorageSync("lang")) {
this.index = index;
}
});
if (
uni.getStorageSync("lang") == undefined ||
uni.getStorageSync("lang") == "undefined"
) {
uni.setStorageSync("lang", "zh-CN");
}
this.getLanguageList = res.data;
}
});
},
},
};
</script>
@ -989,7 +919,6 @@ header {
}
.banner {
padding: 140rpx 0 0 0;
text-align: center;
width: 100%;
}
@ -1055,6 +984,8 @@ page {
.index-top1 {
background: url("~@/static/images/tBgd.jpg") no-repeat;
background-size: 100% 100%;
padding-top: constant(safe-area-inset-top);
padding-top: env(safe-area-inset-top);
// padding: 30rpx 20rpx; // height: 100rpx;
// background-color: #fff;
display: flex;

View File

@ -125,8 +125,8 @@ export default {
changeFlag: true,
isLoading: false,
loginForm: {
username: '',
password: '',
username: 'CN123456789',
password: '111111',
code: '',
uuid: '',
},
@ -166,8 +166,8 @@ export default {
})
},
toLogin() {
this.isLoading = true
api.login(this.loginForm).then((res) => {
this.isLoading = false
if (!res) {
// uni.showToast({
// title: res.msg,
@ -182,6 +182,8 @@ export default {
setToken(res.data.access_token)
this.getUseInfo()
}
}).finally(() => {
this.isLoading = false
})
},
urlToBase64(url) {
@ -198,7 +200,9 @@ export default {
})
},
getUseInfo() {
store.dispatch('GetInfo').then((res) => {
uni.switchTab({ url: '/pages/index/index' })
//
// if (res.data.loginType == 1) {
@ -213,6 +217,8 @@ export default {
// uni.switchTab({ url: '/pages/index/index' })
// }
// }
}).catch((err) => {
uni.$u.toast(err)
})
// api.getInfo().then((res) => {
// uni.setStorage('User', res.data)

File diff suppressed because it is too large Load Diff

View File

@ -102,7 +102,7 @@
<img
class="kong"
v-show="shopCarList.length == 0"
src="@/static/images/kong.png"
src="static/images/kong.png"
alt=""
/></view>
<view class="zhan"></view>

View File

@ -85,10 +85,10 @@
</view>
<img @click.stop="addCar(item)"
v-show="item.preSaleStatus != 3 && item.isSale != 1&&specialArea != 31"
src="@/static/images/cart.png" alt="" />
src="static/images/cart.png" alt="" />
<img @click.stop="addCar(item)"
v-show="item.preSaleStatus != 3 && item.isSale != 1&&specialArea == 31&&userInfo.isMakerSpace == 0"
src="@/static/images/cart.png" alt="" />
src="static/images/cart.png" alt="" />
</view>
<!-- <view class="pv" v-show="specialArea == 31"> 统一零售价:{{ item.retailPrice| numberToCurrency | isLocal}} </view> -->
</view>

File diff suppressed because one or more lines are too long

6
static/styles/index.css Normal file
View File

@ -0,0 +1,6 @@
body {
padding-top: env(safe-area-inset-top);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
}

View File

@ -58,6 +58,7 @@ const actions = {
GetInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getInfo().then(res => {
// uni.$u.toast(res)
if (res) {
commit('SET_USER', res.data)
uni.setStorageSync("User", res.data);

View File

@ -316,7 +316,7 @@ export default {
uni.navigateTo({
url: href,
fail() {
wx.switchTab({
uni.switchTab({
url: href
})
}