调试完成中英文切换;完成自动更新功能
This commit is contained in:
parent
327da6f04c
commit
6c63f59aad
@ -126,4 +126,11 @@ export const fullTextSearchApi = (params) => {
|
|||||||
**/
|
**/
|
||||||
export const appInfoApi = () => {
|
export const appInfoApi = () => {
|
||||||
return request.get('/web/footerInfo')
|
return request.get('/web/footerInfo')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function 获取最新的app版本
|
||||||
|
**/
|
||||||
|
export const newAppApi = () => {
|
||||||
|
return request.get('/web/getNewApp')
|
||||||
}
|
}
|
BIN
src/assets/images/icon/language.png
Normal file
BIN
src/assets/images/icon/language.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
@ -13,8 +13,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<slot name="footer">
|
<slot name="footer">
|
||||||
<view class="footer">
|
<view class="footer">
|
||||||
<view v-if="processLoad.showCancel" class="confirm-btn1 cancel" @click="close" type="primary">取消</view>
|
<view v-if="processLoad.showCancel" class="confirm-btn1 cancel" @click="close" type="primary"></view>
|
||||||
<button :loading="confirmLoading" class="confirm-btn1" @click="confirm" type="primary">{{processLoad.confirmMsg}}</button>
|
<button v-if="processLoad.showConfirm" :loading="confirmLoading" class="confirm-btn1" @click="confirm" type="primary">{{processLoad.confirmMsg}}</button>
|
||||||
</view>
|
</view>
|
||||||
</slot>
|
</slot>
|
||||||
</view>
|
</view>
|
||||||
@ -24,7 +24,10 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref,computed } from 'vue';
|
import { ref,computed } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
const popup = ref()
|
const popup = ref()
|
||||||
const confirmLoading = ref(false)
|
const confirmLoading = ref(false)
|
||||||
const params = ref({})
|
const params = ref({})
|
||||||
@ -33,9 +36,11 @@
|
|||||||
const {
|
const {
|
||||||
isHtml=false, // 是否为html
|
isHtml=false, // 是否为html
|
||||||
showCancel=true, // 是否显示取消按钮
|
showCancel=true, // 是否显示取消按钮
|
||||||
|
showConfirm=true, // 是否显示确认按钮
|
||||||
isMaskClick=false, //点击遮罩层是否关闭弹窗
|
isMaskClick=false, //点击遮罩层是否关闭弹窗
|
||||||
isLoading=false, // 确认按钮是否加loading
|
isLoading=false, // 确认按钮是否加loading
|
||||||
confirmMsg='确定', // 确认按钮的文字
|
cancelMsg=t('common.cancel'),
|
||||||
|
confirmMsg=t('common.confirm'), // 确认按钮的文字
|
||||||
close=()=>{}, // 弹窗关闭回调
|
close=()=>{}, // 弹窗关闭回调
|
||||||
confirm=()=>{}, // 弹窗确认回调
|
confirm=()=>{}, // 弹窗确认回调
|
||||||
contentStyle // content样式
|
contentStyle // content样式
|
||||||
@ -44,9 +49,11 @@
|
|||||||
return {
|
return {
|
||||||
isHtml,
|
isHtml,
|
||||||
showCancel,
|
showCancel,
|
||||||
|
showConfirm,
|
||||||
isMaskClick,
|
isMaskClick,
|
||||||
isLoading,
|
isLoading,
|
||||||
confirmMsg,
|
confirmMsg,
|
||||||
|
cancelMsg,
|
||||||
close,
|
close,
|
||||||
confirm,
|
confirm,
|
||||||
contentStyle
|
contentStyle
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import { ref, nextTick } from 'vue';
|
import { ref, nextTick } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
// 公共弹窗hooks
|
// 公共弹窗hooks
|
||||||
export const useComfirmPopup = () => {
|
export const useComfirmPopup = () => {
|
||||||
const popupShow = ref(false)
|
const popupShow = ref(false)
|
||||||
const comfirmPopupRef = ref()
|
const comfirmPopupRef = ref()
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
const openPopup = (row = {}) => {
|
const openPopup = (row = {}) => {
|
||||||
popupShow.value = true
|
popupShow.value = true
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
comfirmPopupRef.value.setParams({
|
comfirmPopupRef.value.setParams({
|
||||||
title: row.title || '温馨提示',
|
title: row.title || t('common.KindReminder'),
|
||||||
content: row.content || '',
|
content: row.content || '',
|
||||||
load: row.load || {}
|
load: row.load || {}
|
||||||
})
|
})
|
||||||
|
@ -6,13 +6,19 @@
|
|||||||
<SuspensionBtn @ClickTop="ClickTop" @clickMsg="onlineModalShow=true"/>
|
<SuspensionBtn @ClickTop="ClickTop" @clickMsg="onlineModalShow=true"/>
|
||||||
<OnlineModal v-if="onlineModalShow" @close="onlineModalShow=false" />
|
<OnlineModal v-if="onlineModalShow" @close="onlineModalShow=false" />
|
||||||
</template>
|
</template>
|
||||||
|
<ConfirmPopup ref="comfirmPopupRef" v-if="popupShow" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onShow } from "@dcloudio/uni-app";
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { ref, watch, computed } from 'vue';
|
import { ref, watch, computed } from 'vue';
|
||||||
import { useScroll } from '@/stores/index.js';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useScroll, useAppUpdate } from '@/stores/index.js';
|
||||||
|
import { useComfirmPopup } from '@/hooks/utils.js';
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const { comfirmPopupRef, popupShow, openPopup } = useComfirmPopup()
|
||||||
|
|
||||||
const currentPage = computed(() => {
|
const currentPage = computed(() => {
|
||||||
let arr = getCurrentPages()
|
let arr = getCurrentPages()
|
||||||
@ -35,10 +41,29 @@
|
|||||||
useScroll().sendCallback()
|
useScroll().sendCallback()
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow(() => {
|
const updateText = computed(() => {
|
||||||
let locale = uni.getLocale()
|
let progress = useAppUpdate().progress
|
||||||
console.log(locale)
|
return `${t('common.appUpdate')}:${progress}%`
|
||||||
uni.setLocale(locale === 'zh-Hans' ? 'zh-Hans' : 'en')
|
})
|
||||||
|
const updateModal = () => {
|
||||||
|
openPopup({
|
||||||
|
content: updateText,
|
||||||
|
load: {
|
||||||
|
showCancel: false,
|
||||||
|
showConfirm: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => useAppUpdate().progress, (val) => {
|
||||||
|
if (Number(val) >= 100) {
|
||||||
|
popupShow.value = false
|
||||||
|
}
|
||||||
|
}, {deep: true})
|
||||||
|
|
||||||
|
onLoad(() => {
|
||||||
|
useAppUpdate().callback = updateModal
|
||||||
|
useAppUpdate().getAppInfo()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -52,7 +52,11 @@
|
|||||||
"Reset": "Reset",
|
"Reset": "Reset",
|
||||||
"Sure": "Sure",
|
"Sure": "Sure",
|
||||||
"Newdetail": "Newdetail",
|
"Newdetail": "Newdetail",
|
||||||
"Allloaded": "All loaded"
|
"Allloaded": "All loaded",
|
||||||
|
"appUpdate": "Updating",
|
||||||
|
"confirm": "confirm",
|
||||||
|
"cancel": "cancel",
|
||||||
|
"KindReminder": "KindReminder"
|
||||||
},
|
},
|
||||||
"menu": {
|
"menu": {
|
||||||
"Home": "Home",
|
"Home": "Home",
|
||||||
|
@ -52,7 +52,11 @@
|
|||||||
"Reset": "重置",
|
"Reset": "重置",
|
||||||
"Sure": "确认",
|
"Sure": "确认",
|
||||||
"Newdetail": "文章详情",
|
"Newdetail": "文章详情",
|
||||||
"Allloaded": "已全部加载"
|
"Allloaded": "已全部加载",
|
||||||
|
"appUpdate": "更新中",
|
||||||
|
"confirm": "确认",
|
||||||
|
"cancel": "取消",
|
||||||
|
"KindReminder": "温馨提示"
|
||||||
},
|
},
|
||||||
"menu": {
|
"menu": {
|
||||||
"Home": "首页",
|
"Home": "首页",
|
||||||
|
@ -30,7 +30,6 @@ const messages = {
|
|||||||
en,
|
en,
|
||||||
'zh-Hans': zh,
|
'zh-Hans': zh,
|
||||||
}
|
}
|
||||||
uni.setLocale('en')
|
|
||||||
let i18nConfig = {
|
let i18nConfig = {
|
||||||
locale: uni.getLocale(),// 获取已设置的语言
|
locale: uni.getLocale(),// 获取已设置的语言
|
||||||
messages
|
messages
|
||||||
|
@ -41,7 +41,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
/* ios打包配置 */
|
/* ios打包配置 */
|
||||||
"ios" : {},
|
"ios" : {
|
||||||
|
"dSYMs" : false
|
||||||
|
},
|
||||||
/* SDK配置 */
|
/* SDK配置 */
|
||||||
"sdkConfigs" : {},
|
"sdkConfigs" : {},
|
||||||
"icons" : {
|
"icons" : {
|
||||||
|
@ -31,6 +31,12 @@
|
|||||||
</image>
|
</image>
|
||||||
</template>
|
</template>
|
||||||
</uni-easyinput>
|
</uni-easyinput>
|
||||||
|
<image
|
||||||
|
class="language"
|
||||||
|
src="@/assets/images/icon/language.png"
|
||||||
|
@click="language"
|
||||||
|
>
|
||||||
|
</image>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="panel">
|
<view class="panel">
|
||||||
@ -144,6 +150,7 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app';
|
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app';
|
||||||
import dayJs from 'dayjs';
|
import dayJs from 'dayjs';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
import {
|
import {
|
||||||
homeBannberApi,
|
homeBannberApi,
|
||||||
hotProductApi,
|
hotProductApi,
|
||||||
@ -151,6 +158,8 @@
|
|||||||
hotNewsApi
|
hotNewsApi
|
||||||
} from '@/api/index.js';
|
} from '@/api/index.js';
|
||||||
|
|
||||||
|
const { locale } = useI18n()
|
||||||
|
|
||||||
const bannerList = ref([])
|
const bannerList = ref([])
|
||||||
const getBannerList = () => {
|
const getBannerList = () => {
|
||||||
return homeBannberApi().then(({data:res}) => {
|
return homeBannberApi().then(({data:res}) => {
|
||||||
@ -201,6 +210,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const language = () => {
|
||||||
|
let language = uni.getLocale()
|
||||||
|
let setLanguage = language === 'zh-Hans' ? 'en' : 'zh-Hans'
|
||||||
|
locale.value = setLanguage
|
||||||
|
uni.setLocale(setLanguage)
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/pages/index/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onPullDownRefresh(async() => {
|
onPullDownRefresh(async() => {
|
||||||
try {
|
try {
|
||||||
await getBannerList()
|
await getBannerList()
|
||||||
@ -241,6 +260,8 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
top: -40rpx;
|
top: -40rpx;
|
||||||
.search-box {
|
.search-box {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
::v-deep .uni-easyinput {
|
::v-deep .uni-easyinput {
|
||||||
border-radius: 32rpx;
|
border-radius: 32rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -253,6 +274,11 @@
|
|||||||
height: 24rpx;
|
height: 24rpx;
|
||||||
margin-right: 16rpx;
|
margin-right: 16rpx;
|
||||||
}
|
}
|
||||||
|
.language {
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.panel {
|
.panel {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
<view class="company-information">
|
<view class="company-information">
|
||||||
<view class="main-box">
|
<view class="main-box">
|
||||||
<image class="logo" src="@/assets/images/company-logo.png"></image>
|
<image class="logo" :src="useIndex().appInfo.mobileLogo"></image>
|
||||||
<image class="badge" src="@/assets/images/company-badge.png"></image>
|
<!-- <image class="badge" src="@/assets/images/company-badge.png"></image> -->
|
||||||
<view class="desc">
|
<view class="desc">
|
||||||
<view>
|
<view>
|
||||||
<label>{{$t('contactUs.contact')}}: </label>
|
<label>{{$t('contactUs.contact')}}: </label>
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { menuCategoryApi, msgListApi, saveMsg, appInfoApi } from '@/api/index.js';
|
import {
|
||||||
|
menuCategoryApi,
|
||||||
|
msgListApi,
|
||||||
|
saveMsg,
|
||||||
|
appInfoApi,
|
||||||
|
newAppApi
|
||||||
|
} from '@/api/index.js';
|
||||||
import { getUuid } from '@/utils/tool.js';
|
import { getUuid } from '@/utils/tool.js';
|
||||||
|
|
||||||
export const useIndex = defineStore('index',()=>{
|
export const useIndex = defineStore('index',()=>{
|
||||||
@ -161,4 +167,55 @@ export const useScoketMsg = defineStore('scoketMsg', () => {
|
|||||||
send,
|
send,
|
||||||
msgCallback
|
msgCallback
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
export const useAppUpdate = defineStore('appUpdate', () => {
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const progress = ref(0)
|
||||||
|
const callback = ref(null)
|
||||||
|
|
||||||
|
const getAppInfo = () => {
|
||||||
|
if (loading.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return newAppApi().then(({data:res}) => {
|
||||||
|
let appConfig = uni.getSystemInfoSync()
|
||||||
|
if (String(res.data.version) !== appConfig.appVersion) {
|
||||||
|
callback.value && callback.value()
|
||||||
|
loading.value = true
|
||||||
|
const downloadTask = uni.downloadFile({
|
||||||
|
url: res.data.apkUrl,
|
||||||
|
// url: 'https://114.132.197.85:26035/down/0JjTqTl4atsE.apk',
|
||||||
|
success: res1 => {
|
||||||
|
loading.value = false
|
||||||
|
if (res1.statusCode===200) {
|
||||||
|
plus.runtime.install(res1.tempFilePath, false, (installSuccess) => {
|
||||||
|
console.log(installSuccess,'installSuccess');
|
||||||
|
}, (installErrorCB) => {
|
||||||
|
console.log(installErrorCB);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
downloadTask.onProgressUpdate((res1) => {
|
||||||
|
progress.value = res1.progress
|
||||||
|
if (res1.progress===100) {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
getAppInfo,
|
||||||
|
progress,
|
||||||
|
callback
|
||||||
|
}
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user