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

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.config.productionTip = false
Vue.prototype.$bus = new Vue();
// #ifdef H5
import {
parseQuery

View File

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

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -7,6 +7,7 @@ import {
} from '@/config/app';
const mp = uni.requireNativePlugin('uniMP');
import store from "@/store/modules/app.js"
import { Toast } from "../libs/uniApi";
let appid = ''; // 应用id
let wgtFile = ''; // 应用文件地址
@ -28,6 +29,72 @@ function compareVersions(version1, version2) {
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) => {
appid = id;
@ -56,7 +123,7 @@ const loadMP = async (id) => {
mask: true
})
else uni.showLoading({
title: '初始化中...100%',
title: '初始化中...99%',
mask: true
})
}, 600)
@ -65,7 +132,11 @@ const loadMP = async (id) => {
success(res) {
wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile);
setTimeout(() => {
installMP();
clearInterval(timer);
timer = null;
}, 700)
},
fail(res) {
clearInterval(timer);
@ -117,7 +188,7 @@ const loadMPx = async (id) => {
mask: true
})
else uni.showLoading({
title: '初始化中...100%',
title: '初始化中...99%',
mask: true
})
}, 600)
@ -127,7 +198,11 @@ const loadMPx = async (id) => {
success(res) {
wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile);
setTimeout(() => {
installMP();
clearInterval(timer);
timer = null;
}, 700)
},
fail(res) {
clearInterval(timer);
@ -169,7 +244,8 @@ const loadMPurl = async (e) => {
} else {
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) {
let count = 0;
timer = setInterval(() => {
@ -178,7 +254,7 @@ const loadMPurl = async (e) => {
mask: true
})
else uni.showLoading({
title: '初始化中...100%',
title: '初始化中...99%',
mask: true
})
}, 600)
@ -187,7 +263,11 @@ const loadMPurl = async (e) => {
success(res) {
wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile);
setTimeout(() => {
installMP();
clearInterval(timer);
timer = null;
}, 700)
},
fail(res) {
clearInterval(timer);
@ -231,7 +311,7 @@ const loadMPdns = async (e) => {
mask: true
})
else uni.showLoading({
title: '初始化中...100%',
title: '初始化中...99%',
mask: true
})
}, 600)
@ -240,7 +320,11 @@ const loadMPdns = async (e) => {
success(res) {
wgtFile = res.tempFilePath;
console.log('初始化完成', wgtFile);
setTimeout(() => {
installMP();
clearInterval(timer);
timer = null;
}, 700)
},
fail(res) {
clearInterval(timer);
@ -298,6 +382,7 @@ const doInstallMP = () => {
const open = (id = null) => {
let token = uni.getStorageSync('LOGIN_STATUS_TOKEN');
console.log(token);
if (!token) return uni.showToast({
icon: 'none',
title: '请先登录'
@ -324,6 +409,7 @@ const open = (id = null) => {
}
export default {
loadMPcenter,
loadMP,
loadMPurl,
loadMPx,