This commit is contained in:
weipengfei 2023-11-22 11:47:40 +08:00
parent b8d52b9602
commit 19c30008ca
9 changed files with 402 additions and 282 deletions

View File

@ -1,3 +1,3 @@
{ {
"prompt": "template" "prompt" : "template"
} }

12
api/menu.js Normal file
View File

@ -0,0 +1,12 @@
import request from "@/utils/request.js";
/**
* 小程序列表
* @param object
*/
export function indexMiniapp(data) {
return request.get(`index/miniapp`, data, {noAuth: true});
}

View File

@ -22,6 +22,7 @@ Vue.prototype.$Cache = Cache;
Vue.prototype.$eventHub = new Vue(); Vue.prototype.$eventHub = new Vue();
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$bus = new Vue(); Vue.prototype.$bus = new Vue();
// #ifdef H5 // #ifdef H5
import { import {
parseQuery parseQuery

View File

@ -1,6 +1,7 @@
{ {
"name" : "里海中台", "name" : "里海中台",
"appid" : "__UNI__3A527D1", "appid" : "__UNI__BBF059D",
// "appid" : "__UNI__3A527D1",
"description" : "", "description" : "",
"versionName" : "0.0.1", "versionName" : "0.0.1",
"versionCode" : 1, "versionCode" : 1,
@ -12,6 +13,9 @@
"nvueCompiler" : "uni-app", "nvueCompiler" : "uni-app",
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3, "compilerVersion" : 3,
"compatible" : {
"ignoreVersion" : true //trueHBuilderX1.9.0
},
"splashscreen" : { "splashscreen" : {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender" : true,
"waiting" : true, "waiting" : true,
@ -70,7 +74,7 @@
"<uses-permission android:name=\"android.permission.BLUETOOTH\"/>", "<uses-permission android:name=\"android.permission.BLUETOOTH\"/>",
"<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>" "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>"
], ],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ], "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ],
"permissionExternalStorage" : { "permissionExternalStorage" : {
"request" : "none", "request" : "none",
"prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。" "prompt" : "应用保存运行状态等信息,需要获取读写手机存储(系统提示为访问设备上的照片、媒体内容和文件)权限,请允许。"
@ -157,7 +161,8 @@
} }
}, },
"splashscreen" : { "splashscreen" : {
"useOriginalMsgbox" : true "useOriginalMsgbox" : true,
"androidStyle" : "common"
} }
}, },
"nativePlugins" : { "nativePlugins" : {

View File

@ -12,7 +12,7 @@
<block v-if="nowMenuList.length > 0"> <block v-if="nowMenuList.length > 0">
<u-transition v-for="(item, index) in nowMenuList" :key="item.name" show> <u-transition v-for="(item, index) in nowMenuList" :key="item.name" show>
<view class="examine" @click=" <view class="examine" @click="
editFlag ? removeMenu(item) : clickMenu(item.type, item.data) editFlag ? removeMenu(item) : clickMenu(item.type||0, item.data, item)
"> ">
<image class="icon_img" :src="item.icon" mode="aspectFit"> <image class="icon_img" :src="item.icon" mode="aspectFit">
</image> </image>
@ -53,11 +53,15 @@
getStoreList, getStoreList,
getUserInfo getUserInfo
} from '@/api/user.js' } from '@/api/user.js'
import{
indexMiniapp
} from "@/api/menu.js"
import { import {
Toast Toast
} from '@/libs/uniApi'; } from '@/libs/uniApi';
// #ifdef APP-PLUS // #ifdef APP-PLUS
import uniMP from '@/utils/uniMP.js'; import uniMP from '@/utils/uniMP.js';
import parse from '../../uni_modules/uview-ui/libs/config/props/parse';
// #endif // #endif
export default { export default {
@ -198,7 +202,6 @@
this.emptyText = '请登录' this.emptyText = '请登录'
this.jurisdiction = true this.jurisdiction = true
} }
console.log(this.jurisdiction);
}, },
onPullDownRefresh() { onPullDownRefresh() {
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
@ -291,18 +294,28 @@
}, },
// //
initMenu() { initMenu() {
let now = uni.getStorageSync('gatherNowMenuList'); indexMiniapp().then((res)=>{
this.$set(this, 'AllMenuList', res.data)
// console.log({...this.AllMenuList[0]});
try { try {
this.nowMenuList = JSON.parse(now); let now = uni.getStorageSync('gatherNowMenuList');
now = JSON.parse(now);
this.AllMenuList.forEach(item=>{
if(now.find(e=>e.name==item.name)){
this.nowMenuList.push(item);
}
})
this.AllMenuList = this.AllMenuList.filter((item) => { this.AllMenuList = this.AllMenuList.filter((item) => {
return this.nowMenuList.find(t => t.name == item.name)?.name != item.name; return this.nowMenuList.find(t => t.name == item.name)?.name != item.name;
}) })
} catch (e) { } catch (e) {
this.nowMenuList = []; this.nowMenuList = [];
} }
})
}, },
clickMenu(e, data) { clickMenu(e, data, item) {
this.getUniMp(e, data); this.getUniMp(e, data, item);
}, },
// //
pushMenu(data) { pushMenu(data) {
@ -323,10 +336,13 @@
this.editFlag = false; this.editFlag = false;
uni.setStorageSync('gatherNowMenuList', JSON.stringify(this.nowMenuList)); uni.setStorageSync('gatherNowMenuList', JSON.stringify(this.nowMenuList));
}, },
getUniMp(type, data) { getUniMp(type, data, item) {
let that = this; let that = this;
// #ifdef APP-PLUS // #ifdef APP-PLUS
switch (type) { switch (type) {
case 0:
uniMP.loadMPcenter(item);
break;
case 1: case 1:
uniMP.loadMP(data); uniMP.loadMP(data);
break; break;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,6 +7,7 @@ import {
} from '@/config/app'; } from '@/config/app';
const mp = uni.requireNativePlugin('uniMP'); const mp = uni.requireNativePlugin('uniMP');
import store from "@/store/modules/app.js" import store from "@/store/modules/app.js"
import { Toast } from "../libs/uniApi";
let appid = ''; // 应用id let appid = ''; // 应用id
let wgtFile = ''; // 应用文件地址 let wgtFile = ''; // 应用文件地址
@ -28,6 +29,72 @@ function compareVersions(version1, version2) {
return 0; return 0;
} }
// 加载中台小程序
const loadMPcenter = async (info) => {
console.log(info);
if(info.app_id[0]!='_'){
console.log(`app_id:${info.app_id}不合法`);
return Toast('APPID不合法');
}
appid = info.app_id;
try{
uni.showLoading({
title: '初始化中...',
mask: true
})
mp.getUniMPVersion(appid, (ret) => {
console.log('当前版本', ret);
let flag;
if (HTTP_REQUEST_URL == 'https://middle.lihaink.cn') {
flag = false
} else {
flag = true
}
if (0 != ret.code || compareVersions(info.app_version, ret.versionInfo.name) == 1 ||
flag ==
true) {
let count = 0;
timer = setInterval(() => {
if (count < 100) uni.showLoading({
title: `初始化中... ${count}%`,
mask: true
})
else uni.showLoading({
title: '初始化中...100%',
mask: true
})
}, 600)
let downloadTask = uni.downloadFile({
url: info.down_url,
success(res) {
wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile);
installMP();
},
fail(res) {
clearInterval(timer);
timer = null;
uni.hideLoading();
}
});
downloadTask.onProgressUpdate((res) => {
// console.log('初始化进度' + res.progress);
if (res.progress > count) count += 10;
if (count >= 90) {
clearInterval(timer);
timer = null;
}
});
} else {
open()
}
});
}catch(e){
uni.hideLoading()
}
};
// 加载供销小程序 // 加载供销小程序
const loadMP = async (id) => { const loadMP = async (id) => {
appid = id; appid = id;
@ -56,7 +123,7 @@ const loadMP = async (id) => {
mask: true mask: true
}) })
else uni.showLoading({ else uni.showLoading({
title: '初始化中...100%', title: '初始化中...99%',
mask: true mask: true
}) })
}, 600) }, 600)
@ -65,7 +132,11 @@ const loadMP = async (id) => {
success(res) { success(res) {
wgtFile = res.tempFilePath; wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile); console.log('初始化完成', wgtFile);
setTimeout(() => {
installMP(); installMP();
clearInterval(timer);
timer = null;
}, 700)
}, },
fail(res) { fail(res) {
clearInterval(timer); clearInterval(timer);
@ -117,7 +188,7 @@ const loadMPx = async (id) => {
mask: true mask: true
}) })
else uni.showLoading({ else uni.showLoading({
title: '初始化中...100%', title: '初始化中...99%',
mask: true mask: true
}) })
}, 600) }, 600)
@ -127,7 +198,11 @@ const loadMPx = async (id) => {
success(res) { success(res) {
wgtFile = res.tempFilePath; wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile); console.log('初始化完成', wgtFile);
setTimeout(() => {
installMP(); installMP();
clearInterval(timer);
timer = null;
}, 700)
}, },
fail(res) { fail(res) {
clearInterval(timer); clearInterval(timer);
@ -169,7 +244,8 @@ const loadMPurl = async (e) => {
} else { } else {
flag = true flag = true
} }
if (0 != ret.code || compareVersions(fileInfo.data?.data?.version, ret.versionInfo.name) == 1 || flag == if (0 != ret.code || compareVersions(fileInfo.data?.data?.version, ret.versionInfo.name) == 1 ||
flag ==
true) { true) {
let count = 0; let count = 0;
timer = setInterval(() => { timer = setInterval(() => {
@ -178,7 +254,7 @@ const loadMPurl = async (e) => {
mask: true mask: true
}) })
else uni.showLoading({ else uni.showLoading({
title: '初始化中...100%', title: '初始化中...99%',
mask: true mask: true
}) })
}, 600) }, 600)
@ -187,7 +263,11 @@ const loadMPurl = async (e) => {
success(res) { success(res) {
wgtFile = res.tempFilePath; wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile); console.log('初始化完成', wgtFile);
setTimeout(() => {
installMP(); installMP();
clearInterval(timer);
timer = null;
}, 700)
}, },
fail(res) { fail(res) {
clearInterval(timer); clearInterval(timer);
@ -209,7 +289,7 @@ const loadMPurl = async (e) => {
}); });
}, },
fail:(err)=> { fail: (err) => {
console.log('错误:', err); console.log('错误:', err);
} }
}) })
@ -231,7 +311,7 @@ const loadMPdns = async (e) => {
mask: true mask: true
}) })
else uni.showLoading({ else uni.showLoading({
title: '初始化中...100%', title: '初始化中...99%',
mask: true mask: true
}) })
}, 600) }, 600)
@ -240,7 +320,11 @@ const loadMPdns = async (e) => {
success(res) { success(res) {
wgtFile = res.tempFilePath; wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile); console.log('初始化完成', wgtFile);
setTimeout(() => {
installMP(); installMP();
clearInterval(timer);
timer = null;
}, 700)
}, },
fail(res) { fail(res) {
clearInterval(timer); clearInterval(timer);
@ -298,6 +382,7 @@ const doInstallMP = () => {
const open = (id = null) => { const open = (id = null) => {
let token = uni.getStorageSync('LOGIN_STATUS_TOKEN'); let token = uni.getStorageSync('LOGIN_STATUS_TOKEN');
console.log(token);
if (!token) return uni.showToast({ if (!token) return uni.showToast({
icon: 'none', icon: 'none',
title: '请先登录' title: '请先登录'
@ -324,6 +409,7 @@ const open = (id = null) => {
} }
export default { export default {
loadMPcenter,
loadMP, loadMP,
loadMPurl, loadMPurl,
loadMPx, loadMPx,