2024-05-02 15:59:36 +08:00
|
|
|
|
<script>
|
2024-08-30 18:03:10 +08:00
|
|
|
|
let platform = ""
|
2025-04-18 14:53:38 +08:00
|
|
|
|
let SystemVersion = ""
|
2024-05-02 15:59:36 +08:00
|
|
|
|
export default {
|
2024-06-13 18:03:50 +08:00
|
|
|
|
data() {
|
2025-04-30 16:47:18 +08:00
|
|
|
|
return {
|
|
|
|
|
|
list: [{
|
|
|
|
|
|
key: "en",
|
|
|
|
|
|
value: "en"
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: "zh",
|
|
|
|
|
|
value: "zh-Hans"
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2024-06-13 18:03:50 +08:00
|
|
|
|
},
|
2024-05-02 15:59:36 +08:00
|
|
|
|
onLaunch: function() {
|
2024-08-30 18:03:10 +08:00
|
|
|
|
let that = this
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #ifdef APP-PLUS
|
2025-04-18 14:53:38 +08:00
|
|
|
|
// 获取设备信息
|
2024-08-30 18:03:10 +08:00
|
|
|
|
uni.getSystemInfo({
|
|
|
|
|
|
success(e) {
|
|
|
|
|
|
platform = e.platform
|
|
|
|
|
|
that.$store.commit('changePhoneInfo', {
|
|
|
|
|
|
platform: e.platform
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-11-14 14:07:14 +08:00
|
|
|
|
if (platform === 'ios') { // ios首次安装没有网络
|
2024-08-30 18:03:10 +08:00
|
|
|
|
uni.onNetworkStatusChange(function(res) {
|
|
|
|
|
|
if (res.isConnected == true) {
|
2025-05-07 09:26:24 +08:00
|
|
|
|
that.handleoginversion()
|
|
|
|
|
|
that.handleCityList()
|
|
|
|
|
|
that.handleCooperationUrl()
|
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
|
// uni.reLaunch({
|
|
|
|
|
|
// url: '/pageTwo/login/login'
|
|
|
|
|
|
// })
|
|
|
|
|
|
// }, 500)
|
2024-08-30 18:03:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-04-18 14:53:38 +08:00
|
|
|
|
plus.runtime.getProperty(plus.runtime.appid, function(info) {
|
|
|
|
|
|
uni.setStorageSync('VERSION', info.version)
|
|
|
|
|
|
SystemVersion = info.version
|
|
|
|
|
|
that.$store.commit('changePhoneInfo', {
|
|
|
|
|
|
info: info
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #endif
|
2024-12-14 09:42:21 +08:00
|
|
|
|
// #ifdef MP-WEIXIN
|
2025-04-18 14:53:38 +08:00
|
|
|
|
that.updataWeiXin() //小程序版本更新
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
//订阅登录成功事件
|
|
|
|
|
|
uni.$on('login-sucesss', function() {
|
|
|
|
|
|
console.log('on login-sucesss')
|
|
|
|
|
|
that.handleUserList()
|
|
|
|
|
|
that.handleBannerList()
|
2025-04-30 16:47:18 +08:00
|
|
|
|
that.handleTabBarItem()
|
2025-04-18 14:53:38 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: '/pages/home/home'
|
|
|
|
|
|
})
|
|
|
|
|
|
}, 500)
|
|
|
|
|
|
})
|
|
|
|
|
|
//订阅需要登录事件
|
|
|
|
|
|
uni.$on('need-login', function() {
|
|
|
|
|
|
uni.setStorageSync('token', null)
|
|
|
|
|
|
uni.setStorageSync('aan_id', null)
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: '/pageTwo/login/login'
|
|
|
|
|
|
})
|
|
|
|
|
|
}, 500);
|
|
|
|
|
|
})
|
|
|
|
|
|
that.handleoginversion()
|
2024-11-12 15:38:28 +08:00
|
|
|
|
that.handleCityList()
|
2024-12-07 10:41:48 +08:00
|
|
|
|
that.handleCooperationUrl()
|
2024-05-02 15:59:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
onShow: function() {
|
2025-04-30 16:47:18 +08:00
|
|
|
|
let that = this
|
|
|
|
|
|
that.handleTabBarItem()
|
2024-05-02 15:59:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
onHide: function() {
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #ifdef APP-PLUS
|
2024-08-30 18:03:10 +08:00
|
|
|
|
uni.offNetworkStatusChange(function(res) {
|
|
|
|
|
|
console.log("取消网络监听")
|
|
|
|
|
|
})
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #endif
|
2024-06-13 18:03:50 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2024-08-30 18:03:10 +08:00
|
|
|
|
// 版本信息
|
2025-04-18 14:53:38 +08:00
|
|
|
|
handleoginversion() {
|
2024-08-30 18:03:10 +08:00
|
|
|
|
let that = this
|
2025-04-29 17:29:44 +08:00
|
|
|
|
that.$model.getloginversion({
|
|
|
|
|
|
is_wechat: uni.getSystemInfoSync().uniPlatform == 'app' ? false : true
|
|
|
|
|
|
}).then(res => {
|
2025-04-26 13:35:30 +08:00
|
|
|
|
that.$store.commit('changeLanguage', res.data.language_arr)
|
2025-04-18 14:53:38 +08:00
|
|
|
|
if (res.code == 0) {
|
2025-04-30 16:47:18 +08:00
|
|
|
|
that.$i18n.locale = res.data.language
|
2025-04-29 17:29:44 +08:00
|
|
|
|
uni.setStorageSync('language', res.data.language)
|
2025-04-30 16:47:18 +08:00
|
|
|
|
that.$store.commit('changeLocale', res.data.language)
|
2025-04-18 14:53:38 +08:00
|
|
|
|
uni.$emit('login-sucesss');
|
2025-04-29 17:29:44 +08:00
|
|
|
|
console.log("已登录手机语言", res.data.language)
|
2025-04-18 14:53:38 +08:00
|
|
|
|
} else {
|
2025-04-29 17:29:44 +08:00
|
|
|
|
uni.getSystemInfo({
|
|
|
|
|
|
success(e) {
|
2025-04-30 16:47:18 +08:00
|
|
|
|
let locale = ""
|
|
|
|
|
|
that.list.forEach(ite => {
|
|
|
|
|
|
if (e.language.indexOf(ite.key) != -1) {
|
|
|
|
|
|
locale = ite.value
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2025-05-07 09:26:24 +08:00
|
|
|
|
let language = uni.getStorageSync('language') ? uni.getStorageSync(
|
|
|
|
|
|
'language') : locale
|
2025-04-30 16:47:18 +08:00
|
|
|
|
that.$i18n.locale = language
|
2025-04-29 17:29:44 +08:00
|
|
|
|
uni.setStorageSync('language', language)
|
2025-04-30 16:47:18 +08:00
|
|
|
|
that.$store.commit('changeLocale', language)
|
2025-04-29 17:29:44 +08:00
|
|
|
|
uni.$emit('need-login');
|
2025-04-30 16:47:18 +08:00
|
|
|
|
console.log("未登录手机语言", language, uni.getStorageSync('language'), locale)
|
2025-04-29 17:29:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2025-04-30 16:47:18 +08:00
|
|
|
|
|
2025-04-18 14:53:38 +08:00
|
|
|
|
}
|
2025-03-19 17:05:37 +08:00
|
|
|
|
// #ifdef APP-PLUS||APP
|
2024-08-30 18:03:10 +08:00
|
|
|
|
that.$store.commit('changePhoneInfo', {
|
|
|
|
|
|
versionUrl: res.data
|
|
|
|
|
|
})
|
|
|
|
|
|
// 比对版本号
|
2025-04-18 14:53:38 +08:00
|
|
|
|
let version = that.$tools.compareVersions(SystemVersion, res.data.version)
|
|
|
|
|
|
console.log("是否登录及版本号", res.data.version, SystemVersion, version)
|
2024-09-12 11:20:52 +08:00
|
|
|
|
if (version == -1) { // 0版本号相通,1,:第一个版本号大于第二个版本号,-1:第一个版本号小于第二个版本号
|
2024-08-30 18:03:10 +08:00
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: '发现新版本',
|
|
|
|
|
|
content: '检查到新版本' + res.data.version + ',是否更新?',
|
2025-04-18 14:53:38 +08:00
|
|
|
|
cancelText: that.$t('tips.btnSancellation'),
|
|
|
|
|
|
confirmText: that.$t('tips.btnConfirm'),
|
2024-08-30 18:03:10 +08:00
|
|
|
|
success: (modalRes) => {
|
2024-09-03 09:52:19 +08:00
|
|
|
|
if (modalRes.confirm) { //确定更新
|
2025-03-19 17:05:37 +08:00
|
|
|
|
if (platform === 'android') { //安卓更新
|
|
|
|
|
|
uni.setStorageSync('VERSION', res.data.version)
|
2025-03-19 17:14:21 +08:00
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: "/pageTwo/my/about"
|
|
|
|
|
|
})
|
2025-03-19 17:05:37 +08:00
|
|
|
|
} else { //ios跳转
|
|
|
|
|
|
plus.runtime.launchApplication({
|
|
|
|
|
|
action: `itms-apps://itunes.apple.com/cn/app/id6654906497?mt=8`
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2024-08-30 18:03:10 +08:00
|
|
|
|
} else {
|
2025-03-19 17:05:37 +08:00
|
|
|
|
that.$tools.msg("稍后可在'关于我们'内更新程序!")
|
2024-06-13 18:03:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-30 18:03:10 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2024-10-11 10:04:19 +08:00
|
|
|
|
// #endif
|
2024-06-13 18:03:50 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2025-04-18 14:53:38 +08:00
|
|
|
|
// 成员列表
|
|
|
|
|
|
handleUserList() {
|
2024-09-03 09:52:19 +08:00
|
|
|
|
let that = this
|
2025-04-18 14:53:38 +08:00
|
|
|
|
that.$model.getUserList({
|
|
|
|
|
|
type: 2
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res.code != 0) {
|
|
|
|
|
|
that.$tools.msg(res.msg)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
that.$store.commit('changeFamilay', res.data)
|
|
|
|
|
|
if (res.data.length) {
|
|
|
|
|
|
let userid = ""
|
|
|
|
|
|
if (uni.getStorageSync('userid')) {
|
|
|
|
|
|
let found = res.data.find(e => e.id == uni.getStorageSync('userid'));
|
|
|
|
|
|
if (found !== undefined) {
|
|
|
|
|
|
userid = found.id
|
|
|
|
|
|
} else {
|
|
|
|
|
|
userid = res.data[0].id
|
|
|
|
|
|
uni.setStorageSync('userid', res.data[0].id)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
userid = res.data[0].id
|
|
|
|
|
|
uni.setStorageSync('userid', res.data[0].id)
|
|
|
|
|
|
}
|
|
|
|
|
|
that.$store.dispatch('getUserInfo', {
|
|
|
|
|
|
aud_id: userid
|
2024-09-03 09:52:19 +08:00
|
|
|
|
})
|
2025-04-18 14:53:38 +08:00
|
|
|
|
that.$store.dispatch("getResult", {
|
|
|
|
|
|
aud_id: userid
|
|
|
|
|
|
})
|
|
|
|
|
|
that.handleLabelList(userid)
|
|
|
|
|
|
that.handlePublicRecord(userid)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 公共卡片列表
|
|
|
|
|
|
handleLabelList(id) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.$model.getLabelList({
|
|
|
|
|
|
aud_id: id
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
|
that.$store.commit('changeLabelList', res.data)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 公共手动记录内容
|
|
|
|
|
|
handlePublicRecord(id) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.$model.getPublicRecord({
|
|
|
|
|
|
aud_id: id
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
|
that.$store.commit('changePublicRecord', res.data)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// banner
|
|
|
|
|
|
handleBannerList() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.$model.getBannerList({}).then(res => {
|
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
|
that.$store.commit('changeBannerAll', res.data)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-09-03 09:52:19 +08:00
|
|
|
|
},
|
2024-11-12 15:38:28 +08:00
|
|
|
|
// 地区
|
|
|
|
|
|
handleCityList() {
|
2024-09-26 09:18:27 +08:00
|
|
|
|
let that = this
|
2024-11-12 15:38:28 +08:00
|
|
|
|
that.$model.getGradeList({}).then((res) => {
|
|
|
|
|
|
if (res.code != 0) return
|
|
|
|
|
|
that.$store.commit('changeCityList', res.data.area_list)
|
|
|
|
|
|
that.$store.commit('changeGradeList', res.data.grade_list)
|
|
|
|
|
|
that.$store.commit('changeIdentityList', res.data.identity_list)
|
2024-09-26 09:18:27 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-12-07 10:41:48 +08:00
|
|
|
|
// 合作服务
|
|
|
|
|
|
handleCooperationUrl() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.$model.getCooperationUrl({}).then((res) => {
|
|
|
|
|
|
if (res.code != 0) return
|
|
|
|
|
|
this.$store.commit("changeCooperationUrl", res.data);
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2024-12-14 09:42:21 +08:00
|
|
|
|
// 微信小程序更新
|
|
|
|
|
|
updataWeiXin() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
const updateManager = uni.getUpdateManager()
|
|
|
|
|
|
updateManager.onUpdateReady(function() {
|
|
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: '更新提示',
|
|
|
|
|
|
content: '新版本已经准备好,是否重启应用?',
|
2025-04-18 14:53:38 +08:00
|
|
|
|
cancelText: that.$t('tips.btnSancellation'),
|
|
|
|
|
|
confirmText: that.$t('tips.btnConfirm'),
|
2024-12-14 09:42:21 +08:00
|
|
|
|
success: function(res) {
|
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
|
updateManager.applyUpdate()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
updateManager.onUpdateFailed(function() {
|
|
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: '新版本更新失败',
|
|
|
|
|
|
content: '请退出并移除小程序,重新打开...',
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2025-04-26 13:35:30 +08:00
|
|
|
|
},
|
2025-04-30 16:47:18 +08:00
|
|
|
|
handleTabBarItem() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
uni.setTabBarItem({
|
|
|
|
|
|
index: 0,
|
|
|
|
|
|
text: that.$t('common.titleHome')
|
|
|
|
|
|
})
|
|
|
|
|
|
uni.setTabBarItem({
|
|
|
|
|
|
index: 1,
|
|
|
|
|
|
text: that.$t('common.titleNews')
|
|
|
|
|
|
})
|
|
|
|
|
|
uni.setTabBarItem({
|
|
|
|
|
|
index: 2,
|
|
|
|
|
|
text: that.$t('common.titleMe')
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2024-05-02 15:59:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
/*每个页面公共css */
|
2024-05-29 16:35:45 +08:00
|
|
|
|
/* #ifndef APP-NVUE */
|
|
|
|
|
|
@import "/uni.scss";
|
2024-08-22 09:48:00 +08:00
|
|
|
|
@import "/scss/common.scss";
|
|
|
|
|
|
@import "/scss/iconfont.css";
|
|
|
|
|
|
@import "/scss/iconfont-weapp-icon.css";
|
2024-05-02 15:59:36 +08:00
|
|
|
|
|
2024-05-29 16:35:45 +08:00
|
|
|
|
/* #endif*/
|
2024-05-02 15:59:36 +08:00
|
|
|
|
</style>
|