You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

334 lines
9.1 KiB
Vue

8 months ago
<script>
8 months ago
import RootStore from '@xkit-yx/im-store'
import { NimKitCore } from '@xkit-yx/core-kit/dist/uniapp-nim-core'
import { getMsgContentTipByType } from './pages/NEUIKit/utils/msg'
import { getUniPlatform } from './pages/NEUIKit/utils'
// #ifdef APP-PLUS
const nimPushPlugin = uni.requireNativePlugin('NIMUniPlugin-PluginModule')
// #endif
8 months ago
export default {
8 months ago
onLaunch: function () {
const isWeixinApp = getUniPlatform() === 'mp-weixin'
let resData = {
appkey: "146010bdfe390e4893c854f0c50b4214",
accid :'test_user_002',
token : '9d46fc00f15b93e3d0894fc5df733fc1'
}
// @ts-ignore
const nim = uni.$UIKitNIM = new NimKitCore({
initOptions: {
"appkey": resData.appkey, // 请填写您的 appkey
"account": resData.accid, // 请填写您的 account
"token": resData.token, // 请填写您的 token
"lbsUrls": isWeixinApp ? [
"https://lbs.netease.im/lbs/wxwebconf.jsp"
] : [
"https://lbs.netease.im/lbs/webconf.jsp"
],
"linkUrl": isWeixinApp ? 'wlnimsc0.netease.im' : 'weblink.netease.im',
"needReconnect": true,
/**
* 使用固定设备 ID
*/
isFixedDeviceId: true,
// "reconnectionAttempts": 5,
debugLevel: 'debug',
},
platform: 'UniApp',
})
// @ts-ignore
const store = uni.$UIKitStore = new RootStore(nim, {
addFriendNeedVerify: false,
teamBeInviteMode: 'noVerify',
teamJoinMode: 'noVerify',
teamUpdateExtMode: 'all',
teamUpdateTeamMode: 'all',
teamInviteMode: 'all',
sendMsgBefore: async (options, type) => {
const pushContent = getMsgContentTipByType({ body: options.body, type })
const yxAitMsg = options.ext ? options.ext.yxAitMsg : { forcePushIDsList: '[]', needForcePush: false }
// 如果是 at 消息,需要走离线强推
const { forcePushIDsList, needForcePush } = yxAitMsg
// @ts-ignore
? store.msgStore._formatExtAitToPushInfo(yxAitMsg, options.body)
: { forcePushIDsList: '[]', needForcePush: false }
console.log('forcePushIDsList: ', forcePushIDsList)
// 不同产商的推送消息体
const { scene, to } = options
const pushPayload = JSON.stringify({
// oppo
oppoField: {
"click_action_type": 4, // 参考 oppo 官网
"click_action_activity": '', // 各端不一样 TODO
"action_parameters": { "sessionId": scene, "sessionType": to } // 自定义
},
// vivo
vivoField: {
"pushMode": 0 //推送模式 0正式推送。1测试推送不填默认为 0。
},
// huawei
hwField: {
click_action: {
'type': 1,
'action': '' // 各端不一样 TODO
},
androidConfig: {
'category': 'IM',
'data': JSON.stringify({ 'sessionId': to, 'sessionType': scene })
}
},
// 通用
sessionId: to,
sessionType: scene
})
const pushInfo = {
needPush: true,
needPushBadge: true,
pushPayload: '{}',
pushContent,
needForcePush,
forcePushIDsList,
forcePushContent: pushContent,
}
return { ...options, pushInfo }
},
})
// #ifdef APP-PLUS
// 注册推送
nim.getNIM().offlinePush.setOfflinePushConfig({
plugin: nimPushPlugin,
authConfig: {
// xiaomi
xmAppId: "",
xmAppKey: "",
xmCertificateName: "KIT_UNIAPP_MI_PUSH",
// huawei
hwAppId: "",
hwCertificateName: "KIT_UNIAPP_HW_PUSH",
// oppo
oppoAppId: "",
oppoAppKey: "",
oppoAppSecret: "",
oppoCertificateName: "KIT_UNIAPP_OPPO_PUSH",
/**
* 注意 vivo appid appkey 需要同时在此处以及 manifest.json(即插件参数配置)中配置
*/
vivoAppId: "",
vivoAppKey: "",
vivoCertificateName: "KIT_UNIAPP_VIVO_PUSH",
// fcm
fcmCertificateName: "KIT_UNIAPP_FCM_PUSH",
// meizu
mzAppId: "",
mzAppKey: "",
mzCertificateName: "KIT_UNIAPP_MZ_PUSH",
// iOS
apnsCertificateName: "dis_im_uniapp"
}
})
// #endif
nim.connect()
},
8 months ago
globalData: {
isUseNewJob: true,
// #ifdef MP-WEIXIN
"g-open-env": "MP-MINI",
appId: uni.getAccountInfoSync().miniProgram.appId,
title: "",
themeColor: "",
logo: "",
// #endif
// #ifdef MP-TOUTIAO
"g-open-env": "MP-TOUTIAO",
appId: tt.getEnvInfoSync().microapp.appId,
title: "",
themeColor: "",
logo: "",
// #endif
// #ifdef MP-KUAISHOU
"g-open-env": "MP-KUAISHOU",
appId: uni.getAccountInfoSync().miniProgram.appId,
title: "",
themeColor: "",
logo: "",
// #endif
},
onShow: function (options) {
let that = this;
uni.onNetworkStatusChange((res) => {
console.log("res", res);
console.log("网络状态改变");
});
// 小程序版本的判断(正式:release, 体验:trial, 开发:develop)
uni.setStorageSync("ENV_VERSION", __wxConfig.envVersion);
if (that.globalData.appId == "wxb0dea4d11428c6a5") {
that.globalData.title = "伯才供应链";
8 months ago
that.globalData.themeColor = "#3578f6";
that.globalData.logo = uni.getStorageSync("miniApp-info").logo || "https://matripe-cms.oss-cn-beijing.aliyuncs.com/pugongying/renhailaowu.png";
} else if (that.globalData.appId == "wxe431e0b3abd9ae0b") {
8 months ago
that.globalData.title = "伯才工作";
8 months ago
that.globalData.themeColor = "#3578f6";
8 months ago
that.globalData.logo = uni.getStorageSync("miniApp-info").logo || "https://matripe-cms.oss-cn-beijing.aliyuncs.com/pugongying/renhailaowu.png";
} else if (that.globalData.appId == "wxb0c590fd696b79be") {
that.globalData.title = "稻田工作";
that.globalData.themeColor = "#0dcc91";
that.globalData.logo = uni.getStorageSync("miniApp-info").logo || "https://matripe-cms.oss-cn-beijing.aliyuncs.com/pugongying/yicaiLogoBgf913.png";
}
8 months ago
if (options.query.id) {
uni.setStorageSync("apply-jobdetail-id", options.query.id);
} else {
uni.setStorageSync("apply-jobdetail-id", 0);
}
if (options.query.scene) {
let str = decodeURIComponent(options.query.scene);
uni.setStorageSync(
"apply-invite-code",
JSON.stringify({
key: str.split("=")[0],
value: str.split("=")[1],
})
);
} else {
uni.setStorageSync("apply-invite-code", "");
}
// 获取小程序权限信息
if (uni.getStorageSync("apply-token")) {
that.G.Get(
that.api.user_checkPermission,
{},
(res) => {
console.log(res);
uni.setStorageSync("HAS_PERMISSION", 1); // 1.有权限 2.无权限
},
(err) => {
console.log(err);
if (err) {
uni.setStorageSync("HAS_PERMISSION", 2);
}
}
);
}
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
console.log("检测是否有新版本:", res.hasUpdate);
});
updateManager.onUpdateReady(function (res) {
uni.showModal({
title: "更新提示",
content: "新版本已经准备好,需重启应用",
showCancel: false,
success(res) {
if (res.confirm) {
console.log("新版本已经准备好,需重启应用");
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function (res) {
uni.showModal({
title: "更新提示",
content: "新版本下载异常,需重启应用",
showCancel: false,
success(res) {
if (res.confirm) {
console.log("新版本下载异常,需重启应用");
updateManager.applyUpdate();
}
},
});
});
this.G.getAgencyInfo();
this.G.getServiceQRCode();
if (uni.getStorageSync("apply-token")) {
that.G.checkToken();
}
this.$forceUpdate();
},
onLoad() {
this.getAgencyInfo();
},
onHide: function () {},
methods: {
getAgencyInfo() {
let that = this;
// that.G.Get("/yishoudan/agency/getInfo", "", (res) => {
// console.log("res12312312312312", res);
// });
},
},
};
</script>
<style lang="scss">
@import "./static/css/iconfont.css";
@import "uview-ui/index.scss";
@import "./static/css/base.scss";
@import "./static/font/iconfont-weapp-icon.wxss";
// #ifdef MP-WEIXIN
page {
width: 100vw;
height: 100vh;
}
// #endif
// #ifdef H5 || APP-PLUS || MP-TOUTIAO || MP-KUAISHOU
page {
width: 100vw;
height: calc(100% - 0px);
--color-ysd: #ff4400;
--color-hover: #ff4400cc;
--color-be: #ff4400;
--color-027: #ff4400;
--color-href: #576b95;
}
// #endif
// uview默认样式覆盖
.u-badge-mini {
top: 22rpx !important;
right: 102rpx !important;
color: transparent !important;
width: 10px !important;
height: 10px !important;
border-radius: 50% !important;
}
.u-radio {
&:last-child {
.u-radio__label {
margin-right: 0;
}
}
}
.g-apply-tab {
.u-tab-bar {
bottom: -2px !important;
}
}
.home-swiper {
.u-notice-bar {
border-radius: 6px;
}
}
</style>