From bc87f30948d8e9b6dc7de89ae5aef63378e0c2e8 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Fri, 29 Dec 2023 18:00:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/product.js | 2 +- api/public.js | 8 ++ pages/gather/gather.vue | 185 +++++----------------------------- pages/store/settled/index.vue | 1 - utils/uniMP.js | 60 ++++++++++- 5 files changed, 90 insertions(+), 166 deletions(-) diff --git a/api/product.js b/api/product.js index 28dcaf2..382b0ab 100644 --- a/api/product.js +++ b/api/product.js @@ -320,4 +320,4 @@ export function intention(data) { */ export function intentionbus(data) { return request.post(`intention/business`, data); -} \ No newline at end of file +} diff --git a/api/public.js b/api/public.js index 723b7d3..18a095a 100644 --- a/api/public.js +++ b/api/public.js @@ -141,4 +141,12 @@ export function getNavigation(data) { return request.get("navigation", data, { noAuth: true }); +} + + +/* + 小程序 -- 小程序列表 +*/ +export function applet(data) { + return request.get(`applet`, data); } \ No newline at end of file diff --git a/pages/gather/gather.vue b/pages/gather/gather.vue index f32397e..34fec64 100644 --- a/pages/gather/gather.vue +++ b/pages/gather/gather.vue @@ -39,9 +39,9 @@ - + {{ item.name }} @@ -60,7 +60,7 @@ - + {{ item.name }} @@ -116,6 +116,9 @@ import { getDiy } from '@/api/api.js'; + import { + applet + } from '@/api/public.js'; import { ENV } from "@/config/app.js" @@ -147,139 +150,11 @@ // 编辑中标记 editFlag: false, // 所有菜单的按钮 - AllMenuList: [{ - name: '商户平台', - icon: '/static/applet/shop_app.png', - data: "__UNI__1EE148C", - type: 2, - }, - { - name: '供销平台', - icon: '/static/applet/gx_app.png', - data: '__UNI__B5B1EDD', - type: 1, - }, - { - name: '农业咨询', - icon: '/static/applet/ny.png', - data: { - id: '__UNI__9620511', - url: 'https://ceshi-worker-task.lihaink.cn/api/common/getMiniProgramInfo?name=nongye', - }, - type: 3, - }, - { - name: '教育咨询', - icon: '/static/applet/jy.png', - data: { - id: '__UNI__7AA205C', - url: 'https://ceshi-worker-task.lihaink.cn/api/common/getMiniProgramInfo?name=jiaoyu', - }, - type: 3, - }, - { - name: '法律咨询', - icon: '/static/applet/fl.png', - data: { - id: '__UNI__358D505', - url: 'https://ceshi-worker-task.lihaink.cn/api/common/getMiniProgramInfo?name=falv', - }, - type: 3, - }, - { - name: '情感咨询', - icon: '/static/applet/qg.png', - data: { - id: '__UNI__8080F14', - url: 'https://ceshi-worker-task.lihaink.cn/api/common/getMiniProgramInfo?name=qinggan', - }, - type: 3, - }, - { - name: '种植分析', - icon: '/static/applet/zz.png', - data: { - id: '__UNI__9EDFE40', - url: 'https://ceshi-worker-task.lihaink.cn/api/common/getMiniProgramInfo?name=zhongzhi', - }, - type: 3, - }, - { - name: '养殖分析', - icon: '/static/applet/yz.png', - data: { - id: '__UNI__EEA7DC9', - url: 'https://ceshi-worker-task.lihaink.cn/api/common/getMiniProgramInfo?name=yangzhi', - }, - type: 3, - }, - { - name: '里海直播', - icon: '/static/applet/live.png', - data: { - id: "__UNI__0E46DAD", - url: "https://lihai001.oss-cn-chengdu.aliyuncs.com/app/__UNI__0E46DAD.wgt", - - }, - type: 4, - - }, - { - name: 'oa小程序', - icon: '/static/applet/oa.png', - data: { - id: "__UNI__40723E1", - url: "https://lihai001.oss-cn-chengdu.aliyuncs.com/app/__UNI__40723E1.wgt", - }, - type: 4 - }, - { - name: '种植溯源', - icon: '/static/applet/icons.png', - data: { - // id: "__UNI__9B6D67A", - // url: "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/ce21c202312251443415370.wgt", - id: "__UNI__D087881", - url: "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/3b1b1202312230957197588.wgt", - }, - type: 4 - } - // { - // name: '农业智能感知平台', - // icon: '/static/applet/icons.png', - // data: { - // id: '__UNI__3A527D1', - // url: 'https://ceshi-worker-task.lihaink.cn/uploads/files/20231019/20231019151519e8f484737.wgt', - // }, - // type: 4, - // }, - - // { - // name: '里海直播', - // icon: '/static/applet/live.png', - // data: { - // id: "__UNI__0E46DAD", - // url:'https://lihai001.oss-cn-chengdu.aliyuncs.com/app/__UNI__0E46DAD.wgt', - - // }, - // type: 4, - - // } - // { - // name: '大屏控制', - // icon: '/static/applet/dp.png', - // data: { - // id: '__UNI__83ABA97', - // url: 'https://ceshi-worker-task.lihaink.cn/uploads/files/20231016/20231016112144fac6d9128.wgt', - // }, - // type: 4, - // } - ], + AllMenuList: [], nowMenuList: [], street: '', showPicker: false, columnData: [], - isFshow: false, backColor: 'rgba(252, 252, 252, 0)' }; @@ -289,20 +164,8 @@ }, created() {}, onLoad() { - if(ENV=='prod'){ - this.AllMenuList = this.AllMenuList.filter(item=>{ - return item.name!='里海直播'&&item.name!='oa小程序' - }) - // 正式 - this.AllMenuList.forEach(item=>{ - if(item.name=='种植溯源'){ - item.data.url = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/97568202312201457561882.wgt' - } - }) - } - this.showControllerAllLet(); + this.initAllAppLet(); this.Area(); - this.initMenu(); }, onShow() { if (this.isLogin) { @@ -408,6 +271,15 @@ }, + initAllAppLet(){ + applet().then(res=>{ + this.AllMenuList = res.data; + this.initMenu(); + this.showControllerAllLet(); + }).catch(e=>{ + console.log(e); + }) + }, // 根据类型来判断是否显示 showControllerAllLet() { let user; @@ -438,8 +310,8 @@ this.nowMenuList = []; } }, - clickMenu(e, data) { - this.getUniMp(e, data); + clickMenu(data) { + this.getUniMp(data); }, // 添加菜单 pushMenu(data) { @@ -460,28 +332,23 @@ this.editFlag = false; uni.setStorageSync('gatherNowMenuList', JSON.stringify(this.nowMenuList)); }, - getUniMp(type, data) { + getUniMp(data) { let that = this; // #ifdef APP-PLUS - switch (type) { + if(data.version) return uniMP.loadAppletMP(data); + else switch (data.type) { case 1: - uniMP.loadMP(data); + uniMP.loadMP(data.data); break; case 2: - uniMP.loadMPx(data); + uniMP.loadMPx(data.data); break; - // case 2: - // // this.navigator(data); - // // uniMP.loadMPx(data); - // that.navigator(`/pages/moreProject/moreProject`); - // break; - case 3: - uniMP.loadMPurl(data); + uniMP.loadMPurl(data.data); break; case 4: - uniMP.loadMPdns(data); + uniMP.loadMPdns(data.data); break; } return; diff --git a/pages/store/settled/index.vue b/pages/store/settled/index.vue index b7414fb..b4cb8c6 100644 --- a/pages/store/settled/index.vue +++ b/pages/store/settled/index.vue @@ -962,7 +962,6 @@ import { Toast } from '../../../libs/uniApi'; that.validate = true; }, 1000) } - }).catch(res => { this.isshow = false that.validate = true; diff --git a/utils/uniMP.js b/utils/uniMP.js index b3cacf2..8ebfd45 100644 --- a/utils/uniMP.js +++ b/utils/uniMP.js @@ -3,7 +3,7 @@ import { miniapp } from "@/api/uniMP.js"; import { - HTTP_REQUEST_URL + ENV } from '@/config/app'; const mp = uni.requireNativePlugin('uniMP'); import store from "@/store/modules/app.js" @@ -33,13 +33,12 @@ const loadMP = async (id) => { appid = id; let info = await getGXconfig(); console.log('最新版本', info.data); - console.log(mp, uni); // return ; uni.$emit('showLoading', true, '初始化中'); mp.getUniMPVersion(id, (ret) => { console.log('当前版本', ret); let flag; - if (HTTP_REQUEST_URL == 'https://shop.lihaink.cn') { + if (ENV == 'prod') { flag = false } else { flag = true @@ -94,7 +93,7 @@ const loadMPx = async (id) => { mp.getUniMPVersion(id, (ret) => { console.log('当前版本', ret); let flag; - if (HTTP_REQUEST_URL == 'https://shop.lihaink.cn') { + if (ENV == 'prod') { flag = false } else { flag = true @@ -151,7 +150,7 @@ const loadMPurl = async (e) => { mp.getUniMPVersion(appid, (ret) => { console.log('当前版本', ret); let flag; - if (HTTP_REQUEST_URL == 'https://shop.lihaink.cn') { + if (ENV == 'prod') { flag = false } else { flag = true @@ -201,6 +200,56 @@ const loadMPurl = async (e) => { }; +// 商城配置的小程序 +const loadAppletMP = async (data) => { + appid = data.app_id; + // return ; + uni.$emit('showLoading', true, '初始化中'); + mp.getUniMPVersion(appid, (ret) => { + let flag; + if (ENV == 'prod') { + flag = false + } else { + flag = true + } + if (0 != ret.code || compareVersions(data.version, ret.versionInfo.name) == 1 || flag == + true) { + let count = 0; + timer = setInterval(() => { + if (count < 100 && count > 0) uni.$emit('showLoading', true, `初始化中... ${count}%`) + else uni.$emit('showLoading', true, `初始化中... 99%`) + }, 200) + let downloadTask = uni.downloadFile({ + url: data.url, + success(res) { + wgtFile = res.tempFilePath; + console.log('初始化完成', wgtFile); + setTimeout(()=>{ + installMP(); + clearInterval(timer); + timer = null; + }, 700) + }, + 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() + } + }); +}; + // 按远程文件地址加载小程序 const loadMPdns = async (e) => { appid = e.id; @@ -310,6 +359,7 @@ export default { loadMPx, loadMPdns, installMP, + loadAppletMP, doInstallMP, getVersion, open