123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <script>
- import request from '/common/request.js';
- export default {
- onLaunch: function() {
- // #ifdef APP-PLUS || APP-PLUS-NVUE
- const ua = uni.getSystemInfoSync().platform;
- if (/ios/i.test(ua)) {
- // 苹果
- } else {
- this.checkVersion();
- }
- // #endif
- },
- onShow: function() {
- console.log('App Show');
-
- },
- onHide: function() {
- console.log('App Hide');
- },
- data() {
- return { fastOrderTimer: {} };
- },
- mounted() {
- uni.$on('startPlayVoiceBroadcast', (res) => {
- clearInterval(this.fastOrderTimer);
- if (res) {
- this.startPlayVoiceBroadcast();
- }
- });
- },
- methods: {
- startPlayVoiceBroadcast() {
- const _this = this;
- this.fastOrderTimer = setInterval(function() {
- _this.getFastOrderNum();
- }, 3000);
- },
- getFastOrderNum() {
- request({
- url: '/api/jsOrder/getSeizeOrder',
- data: {},
- success: (res) => {
- console.log('抢单订单数量', res);
- if (res.data.data?.fast_number) {
- uni.setTabBarBadge({ index: 3, text: res.data.data?.fast_number + '' });
- }
- if (!res.data.data?.count) {
- // 没有认证
- console.log('结束');
- uni.removeTabBarBadge({ index: 3 });
- clearInterval(this.fastOrderTimer);
- }
- },
- fail: () => {},
- complete: () => {}
- });
- },
- // #ifdef APP-PLUS || APP-PLUS-NVUE
- // app更新检测
- checkVersion() {
- // 获取应用版本号
- let version = plus.runtime.version;
- //检测当前平台,如果是安卓则启动安卓更新
- uni.getSystemInfo({
- success: res => {
- this.updateHandler(res.platform, version);
- }
- })
- },
- // 更新操作
- updateHandler(platform, version) {
- let data = {
- platform: platform,
- version: version
- }
- let _this = this;
- request({
- url: '/api/getdow',
- data: { data },
- success: res => {
- console.log('版本检测', res)
- if (res.data.data.version_num) {
- const info = res.data.data.version_num;
- var downUrl = res.data.data.url
- let version_num_d = info.split('.').join('');
- let version_d = version.split('.').join('');
- if (info !== '' && version_num_d > version_d) {
- uni.showModal({
- //提醒用户更新
- title: '更新提示',
- content: `发现新版本,是否更新`,
- success: (res) => {
- if (res.confirm) {
- if (platform == 'android') {
- plus.runtime.openURL(downUrl)
- } else if (platform == 'ios') {
- const appleId = 1628804508; //app对应的appleId
- plus.runtime.launchApplication({
- action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
- },
- function(e) {
- console.log(
- 'Open system default browser failed:' +
- e.message);
- }
- );
- }
- } else {
- // plus.runtime.quit();
- }
- }
- });
- }
- }
- },
- fail: () => {},
- complete: () => {
- // uni.hideLoading();
- }
- });
- }
- // #endif
- }
- };
- </script>
- <style>
- /*每个页面公共css */
- </style>
|