From 92e403fe67fb4280e4e8f19e92988d4962285dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=AE=8F=E6=9D=B0?= <1943105267@qq.com> Date: Fri, 22 Nov 2024 19:46:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E8=92=B2=E5=85=AC=E8=8B=B1?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8D=87=E7=BA=A7=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 19 --- api/pgy.js | 23 +++ manifest.json | 4 +- pages.json | 35 ++-- pages/mine/index.vue | 38 ++--- store/getters.js | 1 + store/modules/user.js | 50 +++++- utils/pgyRequest.js | 27 +++ .../u-full-screen/u-full-screen.vue | 161 ++++++++++++++++-- 9 files changed, 284 insertions(+), 74 deletions(-) create mode 100644 api/pgy.js create mode 100644 utils/pgyRequest.js diff --git a/App.vue b/App.vue index 9ddfcab..29e81bd 100644 --- a/App.vue +++ b/App.vue @@ -27,25 +27,6 @@ //版本验证 const version = await getVersions() const systemData = this.$u.sys() - if (systemData.appVersion != version) { - uni.showModal({ - title: '发现新版本', - content: '版本:V ' + version, - cancelText: '暂不更新', - confirmText: '立即更新', - success: (res) => { - if (res.confirm) { - const urlAndorid = 'https://www.pgyer.com/9B4d' - if (plus) plus.runtime.openURL(urlAndorid) - // 更新版本 - else window.open(urlAndorid) - } - - } - }) - - } - console.log(systemData.appVersion, '当前版本', version, "最新版本") }, checkLogin() { diff --git a/api/pgy.js b/api/pgy.js new file mode 100644 index 0000000..5df5ab3 --- /dev/null +++ b/api/pgy.js @@ -0,0 +1,23 @@ +//蒲公英API文档地址 -> https://static.pgyer.com/doc/view/api#installApp + +import { + request +} from '@/utils/pgyRequest.js' //导入封装好的js文件 + + +//获取App是否有更新 +export function getAppCheck(data) { + return request({ + url: '/app/check', + method: 'post', + data: data + }) +} +//获取APP详细信息 +export function getAppInfo(data) { + return request({ + url: '/app/view', + method: 'post', + data: data + }) +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 252ec90..223d3e2 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "娄东人口管理", "appid" : "__UNI__5B81E88", "description" : "太仓娄东人口管理", - "versionName" : "1.2.1", - "versionCode" : 121, + "versionName" : "1.2.0", + "versionCode" : 120, "transformPx" : false, "app-plus" : { "usingComponents" : true, diff --git a/pages.json b/pages.json index 6f725b6..a526cdc 100644 --- a/pages.json +++ b/pages.json @@ -93,25 +93,34 @@ } }, { - "path" : "pages/house/addAndEdit", - "style" : - { - "navigationBarTitleText" : "" + "path": "pages/house/addAndEdit", + "style": { + "navigationBarTitleText": "" + } + }, + { + "path": "pages/house/houseGather", + "style": { + "navigationBarTitleText": "" } }, { - "path" : "pages/house/houseGather", - "style" : - { - "navigationBarTitleText" : "" + "path": "pages/building/map", + "style": { + "navigationBarTitleText": "", + "enablePullDownRefresh": false } }, { - "path" : "pages/building/map", - "style" : - { - "navigationBarTitleText" : "", - "enablePullDownRefresh" : false + "path": "uview-ui/components/u-full-screen/u-full-screen", + "style": { + "navigationStyle": "custom", // 取消本页面的导航栏 + "app-plus": { + "animationType": "fade-in", // 设置fade-in淡入动画,为最合理的动画类型 + "background": "transparent", // 背景透明 + "backgroundColor": "rgba(0,0,0,0)", // 背景透明 + "popGesture": "none" // 关闭IOS屏幕左边滑动关闭当前页面的功能 + } } } ], diff --git a/pages/mine/index.vue b/pages/mine/index.vue index 27488d2..f38c730 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -40,15 +40,13 @@ 版本更新 - 发现新版本 + 发现新版本 退出登录 - - @@ -58,6 +56,9 @@ import { getVersions } from '@/utils/handlerColor.js' + import { + mapGetters + } from 'vuex' export default { data() { return { @@ -71,11 +72,15 @@ }, onLoad() { const systemData = this.$u.sys() - this.localityVersion = systemData.appVersion + this.localityVersion = systemData.appVersionCode this.boxTop = systemData.statusBarHeight - this.getVersion() + // this.getVersion() }, computed: { + ...mapGetters([ + 'appCheck', + + ]), avatar() { return this.$store.state.user.avatar }, @@ -85,27 +90,8 @@ }, methods: { updateVersion() { - if (this.showVersion) { - uni.showModal({ - title: '发现新版本', - content: '版本:V ' + this.version, - cancelText: '暂不更新', - confirmText: '立即更新', - success: (res) => { - if (res.confirm) { - const urlAndorid = 'https://www.pgyer.com/9B4d' - if (plus) plus.runtime.openURL(urlAndorid) - // 更新版本 - else window.open(urlAndorid) - } - - } - }) - } else { - uni.showToast({ - title: '已是最新版本', - icon: 'none' - }) + if (this.localityVersion != this.appCheck.buildVersionNo) { + this.$u.route(`/uview-ui/components/u-full-screen/u-full-screen`); } }, async getVersion() { diff --git a/store/getters.js b/store/getters.js index 8accd64..09796ce 100644 --- a/store/getters.js +++ b/store/getters.js @@ -7,5 +7,6 @@ const getters = { dept: state => state.user.dept, deptId: state => state.user.deptId, userId: state => state.user.userId, + appCheck: state => state.user.app.check } export default getters \ No newline at end of file diff --git a/store/modules/user.js b/store/modules/user.js index e4fa262..2ecea45 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -1,6 +1,10 @@ import config from '@/config' import storage from '@/utils/storage' import constant from '@/utils/constant' +import { + getAppCheck, + getAppInfo +} from '@/api/pgy.js' import { login, logout, @@ -15,10 +19,12 @@ import { removeToken } from '@/utils/auth' + const baseUrl = config.baseUrl const user = { state: { + app: {}, userId: null, dept: {}, deptId: null, @@ -31,6 +37,10 @@ const user = { mutations: { + SET_APP: (state, data) => { + state.app.check = data + }, + SET_DEPT_ID: (state, deptId) => { state.deptId = deptId }, @@ -99,13 +109,13 @@ const user = { } else { commit('SET_ROLES', ['ROLE_DEFAULT']) } + const app = await AppCheck() + commit('SET_APP', app) commit('SET_NAME', username) commit('SET_USER_ID', user.userId) commit('SET_DEPT_ID', user.dept.deptId) commit('SET_DEPT', user.dept) commit('SET_AVATAR', avatar) - - resolve(res) }).catch(error => { reject(error) @@ -149,10 +159,46 @@ const user = { reject(error) }) }) + }, + + //检测是否有新版本 + checkApp({ + commit, + state + }) { + AppCheck() } } } +async function AppCheck() { + const appKey = 'e4c51352c1a5a46cb49b44ae24edea32' + const res = await getAppCheck({ + appKey: appKey + }) + // uni.getSystemInfo({ + // success: async function(it) { + // //有新版本 + // if (it.appVersionCode != res.data.buildVersionNo) { + // // const info = await getAppInfo({ + // // appKey: appKey, + // // buildKey: res.data.buildKey + // // }) + // // let megabytes = info.data.buildFileSize / (1024 * 1024); + // // uni.showModal({ + // // title: '发现新版本!', + // // content: `新版本号:V${info.data.buildVersion}\n软件体积:${megabytes.toFixed(1)}MB`, + // // cancelText: '暂不更新', + // // confirmText: '立即更新', + // // success: (res) => { + // // if (res.confirm) {} + // // } + // // }) + // } + // } + // }) + return res.data +} export default user \ No newline at end of file diff --git a/utils/pgyRequest.js b/utils/pgyRequest.js new file mode 100644 index 0000000..48dcc77 --- /dev/null +++ b/utils/pgyRequest.js @@ -0,0 +1,27 @@ +const BASE_URL = 'http://www.pgyer.com/apiv2' +export const request = (options) => { + return new Promise((resolve, reject) => { + // 获取用户令牌 + let token = '' + // 设置请求头 + const header = { + 'Content-Type': 'application/x-www-form-urlencoded', + // Authorization: `Bearer ${token}`, + ...options.header // 可以传入额外的请求头参数 + } + // ⭐在发送请求之前执行拦截操作 + options.data._api_key = '0b9b69b071c1baa43015b841534e9001' + uni.request({ + url: BASE_URL + options.url, //接收请求的API + method: options.method || 'GET', //接收请求的方式,如果不传默认为GET + data: options.data || {}, //接收请求的data,不传默认为空 + header: header, //接收请求的header + success(res) { + resolve(res.data) // 使用resolve将数据传递出去 + }, + fail: (err) => { + reject(err) + } + }) + }) +} \ No newline at end of file diff --git a/uview-ui/components/u-full-screen/u-full-screen.vue b/uview-ui/components/u-full-screen/u-full-screen.vue index 4f7e7d9..28b1b0f 100644 --- a/uview-ui/components/u-full-screen/u-full-screen.vue +++ b/uview-ui/components/u-full-screen/u-full-screen.vue @@ -1,52 +1,189 @@ + + + .row-item { + font-size: 29rpx; + font-weight: 500; + } + + .progress { + position: relative; + background-color: #e6effb; + height: 40rpx; + + .progress-num { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + text-align: center; + line-height: 40rpx; + font-size: 28rpx; + font-weight: 500; + color: #fff; + } + + &>view { + width: 0; + height: 100%; + background-color: #2d8cf0; + } + } + \ No newline at end of file