新增了农业咨询小程序

This commit is contained in:
weipengfei 2023-09-25 19:14:13 +08:00
parent 5934f3b81a
commit c225f36309
5 changed files with 40 additions and 12 deletions

View File

@ -141,7 +141,6 @@
},
prefix: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/11/',
isShow: false,
isFshow: false,
street: '',
//
@ -162,7 +161,10 @@
{
name: '农业咨询',
icon: '/static/applet/ny.png',
data: '__UNI__9620511',
data: {
id: '__UNI__9620511',
url: '/static/wgt/__UNI__9620511.wgt',
},
type: 1,
}
],
@ -295,7 +297,6 @@
this.getUniMp(data);
break;
case 2:
this.navigator(data);
break;
}
@ -319,10 +320,13 @@
this.editFlag = false;
uni.setStorageSync('gatherNowMenuList', JSON.stringify(this.nowMenuList));
},
getUniMp(appid) {
console.log('点击供销平台');
getUniMp(data) {
// #ifdef APP-PLUS
uniMP.loadMP(appid);
console.log(data, typeof data == 'string');
if(typeof data == 'string') uniMP.loadMP(data);
else uniMP.loadMPurl(data);
// uniMP.loadMPurl(data);
// uniMP.open(data.id);
return;
// #endif
uni.showToast({

View File

@ -594,6 +594,7 @@
that.is_promoter = res.data.is_promoter;
that.extension_status = res.data.extension_status;
that.getMyMenus();
that.$store.commit('SET_USERINFO', that.userInfo);
});
},
//

Binary file not shown.

View File

@ -4,12 +4,10 @@ import {
} from "../../api/user.js";
import {
LOGIN_STATUS,
UID
UID,
USER_INFO
} from '../../config/cache';
import Cache from '../../utils/cache';
import {
USER_INFO
} from '../../config/cache';
// #ifdef APP-PLUS
import Updater from '@/uni_modules/guyue-updater/index';
// #endif
@ -18,7 +16,7 @@ const state = {
location: Cache.get('LOCATION_DATA', true) || {},
token: Cache.get(LOGIN_STATUS) || null,
backgroundColor: "#fff",
userInfo: null,
userInfo: Cache.get(USER_INFO)||null,
uid: Cache.get(UID) || null,
globalData: uni.getStorageSync('GLOBAL_DATA') || {},
homeActive: false,
@ -39,6 +37,10 @@ const mutations = {
Cache.set(LOGIN_STATUS, opt.token, opt.time);
uni.removeStorageSync('auth_token');
},
SET_USERINFO(state, opt){
state.userInfo = opt;
Cache.set(USER_INFO, opt);
},
SETUID(state, val) {
state.uid = val;
Cache.set(UID, val);

View File

@ -5,6 +5,7 @@ import {
HTTP_REQUEST_URL
} from '@/config/app';
const mp = uni.requireNativePlugin('uniMP');
import store from "@/store/modules/app.js"
let appid = ''; // 应用id
let wgtFile = ''; // 应用文件地址
@ -84,6 +85,23 @@ const loadMP = async (id) => {
}
});
};
// 按URL加载小程序
const loadMPurl = async (e) => {
appid = e.id;
mp.getUniMPVersion(appid, (ret) => {
console.log('当前版本', ret);
wgtFile = e.url;
doInstallMP();
// if (0 != ret.code) {
// wgtFile = e.url;
// installMP();
// } else {
// open()
// }
});
};
// 小程序版本信息
const getVersion = (id) => {
appid = id;
@ -117,7 +135,7 @@ const doInstallMP = () => {
showCancel: false
});
}
console.log('初始化供销: ' + JSON.stringify(r));
console.log('初始化: ' + JSON.stringify(r));
});
};
@ -127,11 +145,13 @@ const open = (id = null) => {
icon: 'none',
title: '请先登录'
})
let avatar = store?.state?.userInfo?.avatar;
mp.openUniMP({
appid: id || appid,
extraData: {
uniMP: true,
token: token,
avatar: avatar,
}
}, (ret) => {
uni.hideLoading();
@ -148,6 +168,7 @@ const open = (id = null) => {
export default {
loadMP,
loadMPurl,
installMP,
doInstallMP,
getVersion,