diff --git a/App.vue b/App.vue
index 42a70c28aca7bf240fba373db156227623bc9486..15e70b16533ecae46e985fd793d9243d9375a381 100644
--- a/App.vue
+++ b/App.vue
@@ -1,7 +1,9 @@
+
+
diff --git a/components/uni-popup/message.js b/components/uni-popup/message.js
new file mode 100644
index 0000000000000000000000000000000000000000..0ff9a0242c1a2ed1899a36629cf6067f13ed29df
--- /dev/null
+++ b/components/uni-popup/message.js
@@ -0,0 +1,22 @@
+export default {
+ created() {
+ if (this.type === 'message') {
+ // 不显示遮罩
+ this.maskShow = false
+ // 获取子组件对象
+ this.childrenMsg = null
+ }
+ },
+ methods: {
+ customOpen() {
+ if (this.childrenMsg) {
+ this.childrenMsg.open()
+ }
+ },
+ customClose() {
+ if (this.childrenMsg) {
+ this.childrenMsg.close()
+ }
+ }
+ }
+}
diff --git a/components/uni-popup/popup.js b/components/uni-popup/popup.js
new file mode 100644
index 0000000000000000000000000000000000000000..14d4b778dab2417b1170ba261a0d8010efe97f3c
--- /dev/null
+++ b/components/uni-popup/popup.js
@@ -0,0 +1,25 @@
+import message from './message.js';
+// 定义 type 类型:弹出类型:top/bottom/center
+const config = {
+ // 顶部弹出
+ top:'top',
+ // 底部弹出
+ bottom:'bottom',
+ // 居中弹出
+ center:'center',
+ // 消息提示
+ message:'top',
+ // 对话框
+ dialog:'center',
+ // 分享
+ share:'bottom',
+}
+
+export default {
+ data(){
+ return {
+ config:config
+ }
+ },
+ mixins: [message]
+}
diff --git a/components/uni-popup/share.js b/components/uni-popup/share.js
new file mode 100644
index 0000000000000000000000000000000000000000..462bb83ab3cbf468e41f4faa3463e1a68d3d6941
--- /dev/null
+++ b/components/uni-popup/share.js
@@ -0,0 +1,16 @@
+export default {
+ created() {
+ if (this.type === 'share') {
+ // 关闭点击
+ this.mkclick = false
+ }
+ },
+ methods: {
+ customOpen() {
+ console.log('share 打开了');
+ },
+ customClose() {
+ console.log('share 关闭了');
+ }
+ }
+}
diff --git a/components/uni-popup/uni-popup.vue b/components/uni-popup/uni-popup.vue
new file mode 100644
index 0000000000000000000000000000000000000000..0a509c5889db714464b6778d8e80f68677f28995
--- /dev/null
+++ b/components/uni-popup/uni-popup.vue
@@ -0,0 +1,296 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/uni-transition/uni-transition.vue b/components/uni-transition/uni-transition.vue
new file mode 100644
index 0000000000000000000000000000000000000000..ad1cb556d0c8891290e4e5344a1bf2a28b3ae8ed
--- /dev/null
+++ b/components/uni-transition/uni-transition.vue
@@ -0,0 +1,279 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages.json b/pages.json
index acf7166c3b0d9969073addd317ec593385bd0d5c..33ecda36cb15ffb82541a5657314065d8a9481b7 100644
--- a/pages.json
+++ b/pages.json
@@ -52,7 +52,78 @@
"style":{
"navigationBarTitleText":"注册"
}
- }],
+ },{
+ "path":"pages/uni-feedback/uni-feedback",
+ "style":{
+ "navigationBarTitleText":"问题反馈"
+ }
+ } ,{
+ "path" : "pages/about/about",
+ "style" :
+ {
+ "navigationBarTitleText": "关于"
+ }
+
+ },{
+ "path" : "pages/agree-list/agree-list",
+ "style" :
+ {
+ "navigationBarTitleText": "政策与协议"
+ }
+
+ }
+ ,{
+ "path" : "pages/agree-list/privacy/privacy",
+ "style" :
+ {
+ "navigationBarTitleText": "隐私政策"
+ }
+
+ }
+ ,{
+ "path" : "pages/agree-list/service/service",
+ "style" :
+ {
+ "navigationBarTitleText": "服务协议"
+ }
+
+ },{
+ "path": "uni_modules/uni-upgrade-center-app/pages/upgrade-popup",
+ "style": {
+ "disableScroll": true,
+ "app-plus": {
+ "backgroundColorTop": "transparent",
+ "background": "transparent",
+ "titleNView": false,
+ "scrollIndicator": false,
+ "popGesture": "none",
+ "animationType": "fade-in",
+ "animationDuration": 200
+
+ }
+ }
+ }
+ ,{
+ "path" : "pages/settings/settings",
+ "style" :
+ {
+ "navigationBarTitleText": "设置"
+ }
+
+ }
+ ,{
+ "path" : "pages/ucenter/edit/edit",
+ "style" :
+ {
+ "navigationBarTitleText": "编辑资料"
+ }
+ },{
+ "path":"pages/ucenter/edit/uploadCutImageToUnicloud",
+ "style":{
+ "navigationStyle":"custom"
+ }
+ }
+ ],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "base-app",
diff --git a/pages/about/about.vue b/pages/about/about.vue
new file mode 100644
index 0000000000000000000000000000000000000000..5436278d5d67f6b4cd300c5291c543d4b361dafc
--- /dev/null
+++ b/pages/about/about.vue
@@ -0,0 +1,217 @@
+
+
+
+
+
+ 扫码体验uni-app
+
+
+ uni-app
+ 是一个使用 Vue.js 开发跨平台应用的前端框架。
+
+
+ 本示例源码获取方式:
+
+
+ 1.
+ 下载 HBuilderX,新建 uni-app 项目时选择 Hello uni-app 模板。
+
+
+ 2.
+
+
+
+
+
+
+
+
+
+
+ 当前版本:{{version}}
+
+
+
+
+
+
+
+
diff --git a/pages/agree-list/agree-list.nvue b/pages/agree-list/agree-list.nvue
new file mode 100644
index 0000000000000000000000000000000000000000..591eeb347e104a5ca0f0585d9ee0ca597e232083
--- /dev/null
+++ b/pages/agree-list/agree-list.nvue
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/agree-list/privacy/privacy.vue b/pages/agree-list/privacy/privacy.vue
new file mode 100644
index 0000000000000000000000000000000000000000..544b5329325246dc847316ccd0cc71db4701d837
--- /dev/null
+++ b/pages/agree-list/privacy/privacy.vue
@@ -0,0 +1,22 @@
+
+
+ 隐私政策相关文本内容
+
+
+
+
+
+
diff --git a/pages/agree-list/service/service.vue b/pages/agree-list/service/service.vue
new file mode 100644
index 0000000000000000000000000000000000000000..665729b11093e9332f8557f6c08d76901a9f937c
--- /dev/null
+++ b/pages/agree-list/service/service.vue
@@ -0,0 +1,22 @@
+
+
+ 服务协议相关文本内容
+
+
+
+
+
+
diff --git a/pages/login/login.vue b/pages/login/login.vue
index 6c516c7139a95975a5241204b75702a3a6a5b1c7..4273ef928d2c5fc631dc80d5260a16219de1bb8c 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -48,8 +48,10 @@
- 暂无法使用苹果登录,请查阅
- Apple登录集成教程
+ 登录/注册即表示您同意
+ 隐私政策
+ 和
+ 服务协议
@@ -122,6 +124,16 @@
login:'user/login',
logout:'user/logout'
}),
+ toPrivacy(){
+ uni.navigateTo({
+ url:'/pages/agree-list/privacy/privacy'
+ })
+ },
+ toService(){
+ uni.navigateTo({
+ url:'/pages/agree-list/service/service'
+ })
+ },
initProvider() {
const filters = ['weixin', 'qq', 'sinaweibo', 'univerify'];
uni.getProvider({
diff --git a/pages/settings/settings.nvue b/pages/settings/settings.nvue
new file mode 100644
index 0000000000000000000000000000000000000000..6483f3e24198a7ba3e440d493e54aad877df7a28
--- /dev/null
+++ b/pages/settings/settings.nvue
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/ucenter/edit/edit.nvue b/pages/ucenter/edit/edit.nvue
new file mode 100644
index 0000000000000000000000000000000000000000..57ae647195142da18634a82344998c6e510dcbe4
--- /dev/null
+++ b/pages/ucenter/edit/edit.nvue
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/ucenter/edit/limeClipper/images/photo.svg b/pages/ucenter/edit/limeClipper/images/photo.svg
new file mode 100644
index 0000000000000000000000000000000000000000..7b4b59058376794d6e6a78035f627678102f96ad
--- /dev/null
+++ b/pages/ucenter/edit/limeClipper/images/photo.svg
@@ -0,0 +1,19 @@
+
+
+
diff --git a/pages/ucenter/edit/limeClipper/images/rotate.svg b/pages/ucenter/edit/limeClipper/images/rotate.svg
new file mode 100644
index 0000000000000000000000000000000000000000..0143706ca7adea484ed38339980c2cc23559595e
--- /dev/null
+++ b/pages/ucenter/edit/limeClipper/images/rotate.svg
@@ -0,0 +1,15 @@
+
+
+
diff --git a/pages/ucenter/edit/limeClipper/index.styl b/pages/ucenter/edit/limeClipper/index.styl
new file mode 100644
index 0000000000000000000000000000000000000000..8168258f1d1b06f87bb4932a7732984de8850656
--- /dev/null
+++ b/pages/ucenter/edit/limeClipper/index.styl
@@ -0,0 +1,134 @@
+$edge-border-width = 6rpx
+.flex-auto
+ flex auto
+.bg-transparent
+ background-color rgba(0, 0, 0, 0.9)
+ transition-duration 0.35s
+.l-clipper
+ width 100vw
+ height calc( 100vh - var(--window-top))
+ background-color rgba(0, 0, 0, 0.9)
+ position fixed
+ top var(--window-top)
+ left 0
+ z-index 1
+ &-mask
+ position relative
+ z-index 2
+ pointer-events: none
+ &__content
+ pointer-events: none;
+ position absolute
+ border 1rpx solid rgba(255,255,255,.3)
+ box-sizing border-box
+ box-shadow: rgba(0, 0, 0, 0.5) 0 0 0 80vh;
+ background: transparent;
+ &::before,&::after
+ content ''
+ position absolute
+ border 1rpx dashed rgba(255,255,255,.3)
+ &::before
+ width 100%
+ top 33.33%
+ height 33.33%
+ border-left none
+ border-right none
+ &::after
+ width 33.33%
+ left 33.33%
+ height 100%
+ border-top none
+ border-bottom none
+ &__edge
+ position absolute
+ // left 6rpx
+ width 34rpx
+ height 34rpx
+ border $edge-border-width solid #ffffff
+ pointer-events auto
+ &::before
+ content ''
+ position absolute
+ width 40rpx
+ height 40rpx
+ background-color transparent
+ &:nth-child(1)
+ left: - $edge-border-width
+ top: - $edge-border-width
+ border-bottom-width 0 !important
+ border-right-width 0 !important
+ &:before
+ top -50%
+ left -50%
+ &:nth-child(2)
+ right: - $edge-border-width
+ top: - $edge-border-width
+ border-bottom-width 0 !important
+ border-left-width 0 !important
+ &:before
+ top -50%
+ left 50%
+ &:nth-child(3)
+ left: - $edge-border-width
+ bottom: - $edge-border-width
+ border-top-width 0 !important
+ border-right-width 0 !important
+ &:before
+ bottom -50%
+ left -50%
+ &:nth-child(4)
+ right: - $edge-border-width
+ bottom: - $edge-border-width
+ border-top-width 0 !important
+ border-left-width 0 !important
+ &:before
+ bottom -50%
+ left 50%
+ &-image
+ width 100%
+ border-style none
+ position absolute
+ top 0
+ left 0
+ z-index 1
+ -webkit-backface-visibility hidden
+ backface-visibility hidden
+ transform-origin center
+ &-canvas
+ position fixed
+ z-index 10
+ left -200vw
+ top -200vw
+ pointer-events none
+ &-tools
+ position fixed
+ left 0
+ bottom 10px
+ width 100%
+ z-index 99
+ color #fff
+ &__btns
+ font-weight bold
+ display flex
+ align-items center
+ justify-content space-between
+ width 100%
+ padding 20rpx 40rpx
+ box-sizing border-box
+ .cancel
+ width 112rpx
+ height 60rpx
+ text-align center
+ line-height 60rpx
+ .confirm
+ width 112rpx
+ height 60rpx
+ line-height 60rpx
+ background-color #07c160
+ border-radius 6rpx
+ text-align center
+ image
+ display block
+ width 60rpx
+ height 60rpx
+
diff --git a/pages/ucenter/edit/limeClipper/limeClipper.vue b/pages/ucenter/edit/limeClipper/limeClipper.vue
new file mode 100644
index 0000000000000000000000000000000000000000..5eb630d430afc46a18cca7a9e92f067dbc01914d
--- /dev/null
+++ b/pages/ucenter/edit/limeClipper/limeClipper.vue
@@ -0,0 +1,694 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+
+
+
+
+
+
+
+
+
+
+ 确定
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/ucenter/edit/limeClipper/utils.js b/pages/ucenter/edit/limeClipper/utils.js
new file mode 100644
index 0000000000000000000000000000000000000000..39f07cfffc313b9f174f475cb01bfa36f5440594
--- /dev/null
+++ b/pages/ucenter/edit/limeClipper/utils.js
@@ -0,0 +1,280 @@
+
+/**
+ * h5网络地址转base64
+ */
+export function pathToBase64(path) {
+ // #ifdef H5
+ return new Promise((resolve, reject) => {
+ const _fileReader = (blob) => {
+ const fileReader = new FileReader();
+ fileReader.onload = (e) => {
+ resolve(e.target.result);
+ };
+ fileReader.readAsDataURL(blob);
+ fileReader.onerror = (error) => {
+ console.error('blobToBase64 error:', JSON.stringify(error))
+ reject(new Error('blobToBase64 error'));
+ };
+ }
+ if (/^(http|\/\/)/.test(path) && typeof FileReader === 'function') {
+ window.URL = window.URL || window.webkitURL;
+ const xhr = new XMLHttpRequest();
+ xhr.open("get", path, true);
+ xhr.timeout = 2000;
+ xhr.responseType = "blob";
+ xhr.onload = function() {
+ if (this.status == 200) {
+ _fileReader(this.response)
+ }
+ }
+ xhr.send();
+ }
+ })
+ // #endif
+}
+
+/**
+ * 判断手指触摸位置
+ */
+export function determineDirection(cutX, cutY, clipWidth, clipHeight, currentX, currentY) {
+ const EXPAND_SIZE = 24;
+
+ let leftx1 = cutX - EXPAND_SIZE;
+ let leftx2 = cutX + EXPAND_SIZE;
+
+ let topy1 = cutY - EXPAND_SIZE;
+ let topy2 = cutY + EXPAND_SIZE;
+
+ let rightx1 = cutX + clipWidth - EXPAND_SIZE;
+ let rightx2 = cutX + clipWidth + EXPAND_SIZE;
+
+ let bottomy1 = cutY + clipHeight - EXPAND_SIZE;
+ let bottomy2 = cutY + clipHeight + EXPAND_SIZE;
+ let corner;
+ const isRight = currentX > rightx1 && currentX < rightx2;
+ const isLeft = currentX > leftx1 && currentX < leftx2;
+ const isBottom = currentY > bottomy1 && currentY < bottomy2;
+ const isTop = currentY > topy1 && currentY < topy2;
+ if (isRight && isBottom) {
+ corner = 1;
+ } else if (isRight && isTop) {
+ corner = 2;
+ } else if (isLeft && isTop) {
+ corner = 3;
+ } else if (isLeft && isBottom) {
+ corner = 4;
+ }
+ return corner;
+}
+
+/**
+ * 图片边缘检测检测时,计算图片偏移量
+ */
+export function calcImageOffset(data, scale) {
+ let {
+ imageLeft: left,
+ imageTop: top,
+ imageWidth,
+ imageHeight,
+ cutX,
+ clipWidth,
+ cutY,
+ clipHeight
+ } = data
+ scale = scale || data.scale;
+ if ((data.angle / 90) % 2) {
+ imageWidth = mageHeight;
+ imageHeight = mageWidth;
+ }
+
+ // 当前图片宽度/高度
+ const currentImageSize = (size) => (size * scale) / 2;
+ const currentImageWidth = currentImageSize(imageWidth);
+ const currentImageHeight = currentImageSize(imageHeight);
+
+ left = cutX + currentImageWidth >= left ? left : cutX + currentImageWidth;
+ left = cutX + clipWidth - currentImageWidth <= left ? left : cutX + clipWidth - currentImageWidth;
+ top = cutY + currentImageHeight >= top ? top : cutY + currentImageHeight;
+ top = cutY + clipHeight - currentImageHeight <= top ? top : cutY + clipHeight - currentImageHeight;
+ return {
+ left,
+ top,
+ scale
+ };
+}
+
+/**
+ * 图片边缘检测时,计算图片缩放比例
+ */
+export function calcImageScale(data, scale) {
+ scale = scale || data.scale;
+ let {
+ imageWidth,
+ imageHeight,
+ clipWidth,
+ clipHeight,
+ angle
+ } = data
+ if ((angle / 90) % 2) {
+ imageWidth = imageHeight;
+ imageHeight = imageWidth;
+ }
+ if (imageWidth * scale < clipWidth) {
+ scale = clipWidth / imageWidth;
+ }
+ if (imageHeight * scale < clipHeight) {
+ scale = Math.max(scale, clipHeight / imageHeight);
+ }
+ return scale;
+}
+
+/**
+ * 计算图片尺寸
+ */
+export function calcImageSize(width, height, data) {
+ let imageWidth = width,
+ imageHeight = height;
+ let {
+ clipWidth,
+ clipHeight,
+ sysinfo,
+ width: oWidth,
+ height: oHeight
+ } = data
+ if (imageWidth && imageHeight) {
+ if (imageWidth / imageHeight > (clipWidth || oWidth) / (clipWidth || oHeight)) {
+ imageHeight = clipHeight || oHeight;
+ imageWidth = (width / height) * imageHeight;
+ } else {
+ imageWidth = clipWidth || oWidth;
+ imageHeight = (height / width) * imageWidth;
+ }
+ } else {
+ let sys = sysinfo || uni.getSystemInfoSync();
+ imageWidth = sys.windowWidth;
+ imageHeight = 0;
+ }
+ return {
+ imageWidth,
+ imageHeight
+ };
+}
+
+/**
+ * 勾股定理求斜边
+ */
+export function calcPythagoreanTheorem(width, height) {
+ return Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
+}
+
+/**
+ * 拖动裁剪框时计算
+ */
+export function clipTouchMoveOfCalculate(data, event) {
+ const clientX = event.touches[0].clientX;
+ const clientY = event.touches[0].clientY;
+
+ const {
+ clipWidth,
+ clipHeight,
+ cutY: oldCutY,
+ cutX: oldCutX,
+ cutstart,
+ isLockRatio
+ } = data;
+ let {
+ maxWidth,
+ minWidth,
+ maxHeight,
+ minHeight
+ } = data;
+ maxWidth = maxWidth / 2;
+ minWidth = minWidth / 2;
+ minHeight = minHeight / 2;
+ maxHeight = maxHeight / 2;
+
+ let width = clipWidth,
+ height = clipHeight,
+ cutY = oldCutY,
+ cutX = oldCutX,
+ sizecorrect = () => {
+ width = width <= maxWidth ? (width >= minWidth ? width : minWidth) : maxWidth;
+ height = height <= maxHeight ? (height >= minHeight ? height : minHeight) : maxHeight;
+ },
+ sizeinspect = () => {
+ sizecorrect();
+ if ((width > maxWidth || width < minWidth || height > maxHeight || height < minHeight) && isLockRatio) {
+ return false;
+ } else {
+ return true;
+ }
+ };
+ if (cutstart.corner) {
+ height = cutstart.height + (cutstart.corner > 1 && cutstart.corner < 4 ? 1 : -1) * (cutstart.y - clientY);
+ }
+ switch (cutstart.corner) {
+ case 1:
+ width = cutstart.width - cutstart.x + clientX;
+ if (isLockRatio) {
+ height = width / (clipWidth / clipHeight);
+ }
+ if (!sizeinspect()) return;
+ break;
+ case 2:
+ width = cutstart.width - cutstart.x + clientX;
+ if (isLockRatio) {
+ height = width / (clipWidth / clipHeight);
+ }
+ if (!sizeinspect()) {
+ return;
+ } else {
+ cutY = cutstart.cutY - (height - cutstart.height);
+ }
+
+ break;
+ case 3:
+ width = cutstart.width + cutstart.x - clientX;
+ if (isLockRatio) {
+ height = width / (clipWidth / clipHeight);
+ }
+ if (!sizeinspect()) {
+ return;
+ } else {
+ cutY = cutstart.cutY - (height - cutstart.height);
+ cutX = cutstart.cutX - (width - cutstart.width);
+ }
+
+ break;
+ case 4:
+ width = cutstart.width + cutstart.x - clientX;
+ if (isLockRatio) {
+ height = width / (clipWidth / clipHeight);
+ }
+ if (!sizeinspect()) {
+ return;
+ } else {
+ cutX = cutstart.cutX - (width - cutstart.width);
+ }
+ break;
+ default:
+ break;
+ }
+ return {
+ width,
+ height,
+ cutX,
+ cutY
+ };
+}
+
+/**
+ * 单指拖动图片计算偏移
+ */
+export function imageTouchMoveOfCalcOffset(data, clientXForLeft, clientYForLeft) {
+ let left = clientXForLeft - data.touchRelative[0].x,
+ top = clientYForLeft - data.touchRelative[0].y;
+ return {
+ left,
+ top
+ };
+}
diff --git a/pages/ucenter/edit/main.js b/pages/ucenter/edit/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..30c951a6bd42c95733220ffdb5b9275ca5367d18
--- /dev/null
+++ b/pages/ucenter/edit/main.js
@@ -0,0 +1,19 @@
+export default (callback,options)=>{
+ options = options||{"width":600,"height":600};
+ uni.chooseImage({
+ sizeType:['original'],
+ count:1,
+ ...options,
+ complete:({tempFiles:[{path}]})=> {
+ uni.navigateTo({
+ url:'/common/uploadCutImageToUnicloud/uploadCutImageToUnicloud?path='+path+"&options="+JSON.stringify(options),
+ animationType:'fade-in',
+ events:{
+ url(url){
+ callback(url)
+ }
+ }
+ })
+ }
+ })
+}
\ No newline at end of file
diff --git a/pages/ucenter/edit/uploadCutImageToUnicloud.vue b/pages/ucenter/edit/uploadCutImageToUnicloud.vue
new file mode 100644
index 0000000000000000000000000000000000000000..9a94d3a56864ceee9ea448ee0360a39a88caa5c9
--- /dev/null
+++ b/pages/ucenter/edit/uploadCutImageToUnicloud.vue
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/ucenter/ucenter.nvue b/pages/ucenter/ucenter.nvue
index 2f098c250ebd112cd62c09c1e04ded7fee716bbb..d09f27bc867e245bbc3ba450ee2a74636cf922e0 100644
--- a/pages/ucenter/ucenter.nvue
+++ b/pages/ucenter/ucenter.nvue
@@ -1,7 +1,7 @@
-
+
Hi,{{login ? userInfo.username : '您未登录'}}
@@ -9,8 +9,8 @@
-
+
|
@@ -27,6 +27,7 @@
mapGetters,
mapMutations
} from 'vuex';
+ import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
export default {
data() {
return {
@@ -38,24 +39,27 @@
title: '我的积分'
}],
[{
- title: '政策与协议'
+ title: '政策与协议',
+ to:'/pages/agree-list/agree-list'
}, {
title: '关于',
- link: 'asd'
+ to: '/pages/about/about'
},
//#ifdef APP-PLUS
{
title: '检查更新',
- rightText: `V${plus.runtime.version}_${plus.runtime.versionCode}`
+ rightText: `V${getApp().appVersion.finall.version}_${getApp().appVersion.finall.versionCode}`,
+ event:'checkVersion'
}
//#endif
],
[
{
- title: '反馈'
+ title: '反馈',
+ to:'/pages/uni-feedback/uni-feedback'
},{
title: '设置',
- link: './setting'
+ to: '/pages/settings/settings'
}
]
]
@@ -68,7 +72,7 @@
})
},
onReady() {
- this.logout();
+
},
onShow(){
console.log(this.userInfo);
@@ -77,6 +81,17 @@
...mapMutations({
logout:'user/logout'
}),
+ /**
+ * 个人中心项目列表点击事件
+ */
+ ucenterListClick(item){
+ if(!item.to && item.event){
+ this[item.event]();
+ }
+ },
+ checkVersion(){
+ checkUpdate();
+ },
goLogin() {
if (!this.login) {
console.log('点击前往登录');
@@ -86,6 +101,9 @@
}
else {
console.log('点击编辑信息');
+ uni.navigateTo({
+ url:'./edit/edit'
+ })
}
}
}
diff --git a/pages/uni-feedback/uni-feedback.vue b/pages/uni-feedback/uni-feedback.vue
new file mode 100644
index 0000000000000000000000000000000000000000..301af2710567ea82cfb031735bfd4f540c8b256f
--- /dev/null
+++ b/pages/uni-feedback/uni-feedback.vue
@@ -0,0 +1,230 @@
+
+
+
+ 问题和意见
+ 快速键入
+
+
+ 图片(选填,提供问题截图,总大小10M以下)
+
+
+
+ 点击预览图片
+ {{ imageList.length }}/5
+
+
+
+
+
+
+ x
+
+
+
+
+
+
+
+
+
+ 联系方式
+
+
+ 应用评分
+
+
+
+
+
+ 用户反馈的结果可在app打包后于DCloud开发者中心查看
+
+
+
+
+
+
diff --git a/static/images/top_2.png b/static/images/top_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..7282b7cd7bc48407f46ecd8462ca62f6e520dc64
Binary files /dev/null and b/static/images/top_2.png differ
diff --git a/uniCloud-aliyun/database/opendb-app-versions.schema.json b/uniCloud-aliyun/database/opendb-app-versions.schema.json
new file mode 100644
index 0000000000000000000000000000000000000000..a24c2d34d647ce7d19d173c316c152c004764cd1
--- /dev/null
+++ b/uniCloud-aliyun/database/opendb-app-versions.schema.json
@@ -0,0 +1,124 @@
+{
+ "bsonType": "object",
+ "required": ["appid", "platform", "version", "url", "contents", "type"],
+ "permission": {
+ "read": false,
+ "create": false,
+ "update": false,
+ "delete": false
+ },
+ "properties": {
+ "_id": {
+ "description": "记录id,自动生成"
+ },
+ "appid": {
+ "bsonType": "string",
+ "trim": "both",
+ "description": "应用的AppID",
+ "label": "AppID",
+ "componentForEdit": {
+ "name": "uni-easyinput",
+ "props": {
+ "disabled": true
+ }
+ }
+ },
+ "name": {
+ "bsonType": "string",
+ "trim": "both",
+ "description": "应用名称",
+ "label": "应用名称",
+ "componentForEdit": {
+ "name": "uni-easyinput",
+ "props": {
+ "disabled": true
+ }
+ }
+ },
+ "title": {
+ "bsonType": "string",
+ "description": "更新标题",
+ "label": "更新标题"
+ },
+ "contents": {
+ "bsonType": "string",
+ "description": "更新内容",
+ "label": "更新内容",
+ "componentForEdit": {
+ "name": "textarea"
+ },
+ "componentForShow": {
+ "name": "textarea",
+ "props": {
+ "disabled": true
+ }
+ }
+ },
+ "platform": {
+ "bsonType": "array",
+ "enum": [{
+ "value": "Android",
+ "text": "安卓"
+ }, {
+ "value": "iOS",
+ "text": "苹果"
+ }],
+ "description": "更新平台,Android || iOS || [Android, iOS]",
+ "label": "平台"
+ },
+ "type": {
+ "bsonType": "string",
+ "enum": [{
+ "value": "native_app",
+ "text": "原生App安装包"
+ }, {
+ "value": "wgt",
+ "text": "Wgt资源包"
+ }],
+ "description": "安装包类型,native_app || wgt",
+ "label": "安装包类型"
+ },
+ "version": {
+ "bsonType": "string",
+ "description": "当前包版本号,必须大于当前线上发行版本号",
+ "label": "版本号"
+ },
+ "min_uni_version": {
+ "bsonType": "string",
+ "description": "原生App最低版本",
+ "label": "原生App最低版本"
+ },
+ "url": {
+ "bsonType": "string",
+ "description": "可下载安装包地址",
+ "label": "包地址"
+ },
+ "stable_publish": {
+ "bsonType": "bool",
+ "description": "是否上线发行",
+ "label": "上线发行"
+ },
+ "is_silently": {
+ "bsonType": "bool",
+ "description": "是否静默更新",
+ "label": "静默更新",
+ "defaultValue": false
+ },
+ "is_mandatory": {
+ "bsonType": "bool",
+ "description": "是否强制更新",
+ "label": "强制更新",
+ "defaultValue": false
+ },
+ "create_date": {
+ "bsonType": "timestamp",
+ "label": "上传时间",
+ "forceDefaultValue": {
+ "$env": "now"
+ },
+ "componentForEdit": {
+ "name": "uni-dateformat"
+ }
+ }
+ }
+}
diff --git a/uniCloud-aliyun/database/opendb-feedback.schema.json b/uniCloud-aliyun/database/opendb-feedback.schema.json
new file mode 100644
index 0000000000000000000000000000000000000000..c3d23928d8861523373f6425a709e023715d244b
--- /dev/null
+++ b/uniCloud-aliyun/database/opendb-feedback.schema.json
@@ -0,0 +1,54 @@
+{
+ "bsonType": "object",
+ "permission": {
+ "read": "doc.uid == auth.uid && doc.article_status == 0 || doc.article_status == 1",
+ "create": true,
+ "update": "doc.uid == auth.uid",
+ "delete": "doc.uid == auth.uid"
+ },
+ "properties": {
+ "_id": {
+ "description": "ID,系统自动生成"
+ },
+ "user_id": {
+ "bsonType": "string",
+ "description": "留言反馈用户ID\/回复留言用户ID,参考uni-id-users表",
+ "foreignKey": "uni-id-users._id"
+ },
+ "create_date": {
+ "bsonType": "timestamp",
+ "description": "留言时间\/回复留言时间"
+ },
+ "content": {
+ "bsonType": "string",
+ "description": "留言内容\/回复内容",
+ "trim": "right"
+ },
+ "imgs": {
+ "bsonType": "array",
+ "description": "图片列表"
+ },
+ "is_reply": {
+ "bsonType": "bool",
+ "description": "是否是回复类型"
+ },
+ "feedback_id": {
+ "bsonType": "string",
+ "description": "被回复留言ID"
+ },
+ "contact": {
+ "bsonType": "string",
+ "description": "联系人",
+ "trim": "both"
+ },
+ "mobile": {
+ "bsonType": "string",
+ "description": "联系电话",
+ "trim": "both"
+ },
+ "reply_count": {
+ "bsonType": "int",
+ "description": "被回复条数"
+ }
+ }
+}
diff --git a/uniCloud-aliyun/database/uni-id-users.schema.json b/uniCloud-aliyun/database/uni-id-users.schema.json
index 854eb1748536a70268b545e49723d6da37250d26..d990f78f1dd15c38f8ea75d7238f457698ce735a 100644
--- a/uniCloud-aliyun/database/uni-id-users.schema.json
+++ b/uniCloud-aliyun/database/uni-id-users.schema.json
@@ -3,7 +3,7 @@
"permission": {
"read": true,
"create": false,
- "update": false,
+ "update": "doc.uid == auth.uid",
"delete": false
},
"properties": {
diff --git a/uni_modules/uni-upgrade-center-app/changelog.md b/uni_modules/uni-upgrade-center-app/changelog.md
new file mode 100644
index 0000000000000000000000000000000000000000..65d92778c8c486ded0e34272100f325ca2282d8a
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/changelog.md
@@ -0,0 +1,17 @@
+## 0.0.6(2021-04-01)
+- 兼容旧版本安卓
+## 0.0.5(2021-04-01)
+- 修复低版本安卓上进度条错位
+## 0.0.4(2021-04-01)
+- 更新readme
+- 修复check-update语法错误
+## 0.0.3(2021-04-01)
+- 新增前台更新弹框,详见readme
+- 更新前台检查更新方法
+
+## 0.0.2(2021-03-29)
+- 更新文档
+- 移除 dependencies
+
+## 0.0.1(2021-03-25)
+- 升级中心前台检查更新
diff --git a/uni_modules/uni-upgrade-center-app/package.json b/uni_modules/uni-upgrade-center-app/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..fe0caf719d84747a4059682562386fac3a132eae
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/package.json
@@ -0,0 +1,80 @@
+{
+ "id": "uni-upgrade-center-app",
+ "displayName": "升级中心 uni-upgrade-center - App",
+ "version": "0.0.6",
+ "description": "升级中心前台检查更新",
+ "keywords": [
+ "uniCloud",
+ "admin",
+ "update",
+ "升级",
+ "wgt"
+],
+ "repository": "https://gitee.com/dcloud/uni-upgrade-center/tree/master/uni_modules/uni-upgrade-center-app",
+ "engines": {
+ "HBuilderX": "^3.1.0"
+ },
+ "dcloudext": {
+ "category": [
+ "uniCloud",
+ "云端一体页面模板"
+ ],
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "插件不采集任何数据",
+ "permissions": "无"
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y"
+ },
+ "client": {
+ "App": {
+ "app-vue": "u",
+ "app-nvue": "u"
+ },
+ "H5-mobile": {
+ "Safari": "u",
+ "Android Browser": "u",
+ "微信浏览器(Android)": "u",
+ "QQ浏览器(Android)": "u"
+ },
+ "H5-pc": {
+ "Chrome": "u",
+ "IE": "u",
+ "Edge": "u",
+ "Firefox": "u",
+ "Safari": "u"
+ },
+ "小程序": {
+ "微信": "u",
+ "阿里": "u",
+ "百度": "u",
+ "字节跳动": "u",
+ "QQ": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
diff --git a/uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue b/uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
new file mode 100644
index 0000000000000000000000000000000000000000..0b70fa08d7ceee2243b1084fc16987d37df853c5
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue
@@ -0,0 +1,457 @@
+
+
+
+
+ {{title}}
+
+
+
+
+
+
+ {{subTitle}}
+
+
+
+
+
+ {{contents}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-upgrade-center-app/readme.md b/uni_modules/uni-upgrade-center-app/readme.md
new file mode 100644
index 0000000000000000000000000000000000000000..a1582b24aede31a491294fabe1cdf0c082dc7720
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/readme.md
@@ -0,0 +1,94 @@
+# uni-upgrade-center - App
+
+### 概述
+
+> 统一管理App及App在`Android`、`iOS`平台上`App安装包`和`wgt资源包`的发布升级
+
+> 本插件为升级中心前台检查更新,后台Admin管理系统请点击查看 [uni-upgrade-center](https://ext.dcloud.net.cn/plugin?id=4470)
+
+### 基于uni-upgrade-center的App前台检查升级插件
+ - 一键式检查更新,统一整包与wgt资源包更新
+ - 好看、实用、可自定义、可拓展的前台更新弹框
+
+## 安装指引
+
+1. 使用`HBuilderX 3.1.0+`,因为要使用到`uni_modules`
+
+3. 在插件市场打开本插件页面,在右侧点击`使用 HBuilderX 导入插件`,选择要导入的项目点击确定
+
+5. 找到`/uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version`,右键上传部署
+
+6. 在`pages.json`中添加页面路径
+```json
+"pages": [
+ // ……其他页面配置
+ {
+ "path": "uni_modules/uni-upgrade-center-app/pages/upgrade-popup",
+ "style": {
+ "disableScroll": true,
+ "app-plus": {
+ "backgroundColorTop": "transparent",
+ "background": "transparent",
+ "titleNView": false,
+ "scrollIndicator": false,
+ "popGesture": "none",
+ "animationType": "fade-in",
+ "animationDuration": 200
+
+ }
+ }
+ }
+]
+```
+
+7. 将`/uni_modules/uni-upgrade-center-app/utils/check-update`import到需要用到的地方,调用一下即可
+
+### 更新下载安装`check-update.js`
+
+*该函数在utils目录下*
+
+1. 如果是静默更新,则不会打开更新弹框,会在后台下载后安装,下次启动应用生效
+
+2. 如果是 iOS,则会直接打开AppStore的链接
+
+3. 其他情况,会将`check-version`返回的结果保存在localStorage中,并跳转进入`upgrade-popup.vue`打开更新弹框
+
+### 检查更新函数`check-version`
+
+*该函数在uniCloud/cloudfunctions目录下*
+
+1. 使用检查更新需要传递三个参数 `appid`、`appVersion`、`wgtVersion`
+
+2. `appid` 使用 plus.runtime.appid 获取,*注:真机运行时为固定值HBuilder,在调试的时候请使用本地调试云函数*
+
+3. `appVersion` 使用 plus.runtime.version 获取
+
+4. `wgtVersion` 使用 plus.runtime.getProperty(plus.runtime.appid,(wgtInfo) => { wgtInfo.version }) 获取
+
+5. `check-version`云函数内部会自动获取 App 平台
+
+6. 检查更新前端使用示例:`uni_modules/uni-upgrade-center-app/utils/check-update.js`,在要用的地方导入调用即可
+
+
+## 项目代码说明
+
+### 更新弹框
+- `upgrade-popup.vue` - 更新应用:
+ - 如果`check-version`返回的参数表明需要更新,则将参数保存在localStorage中,带着键值跳转该页面
+ - 进入时会先从localStorage中尝试取出之前存的安装包路径(此包不会是强制安装类型的包)
+ - 如果有已经保存的包,则和传进来的 `version` 进行比较,如果相等则安装。大于和小于都不进行安装,因为admin端可能会调整包的版本。不符合更新会将此包删除
+ - 如果本地没有包或者包不符合安装条件,则进行下载安装包
+ - 点击下载会有进度条、已下载大小和下载包的大小
+ - 下载完成会提示安装:
+ - 如果是 wgt 包,安装时则会提示 正在安装…… 和 安装完成。安装完成会提示是否重启
+ - 如果是 原生安装包,则直接跳出去覆盖安装
+ - 下载过程中,如果退出会提示是否取消下载。如果是强制更新,则只会提示正在下载请稍后,此时不可退出
+ - 如果是下载完成了没有安装就退出,则会将下载完成的包保存在本地。将包的本地路径和包version保存在localStorage中
+
+### 云函数
+- `check-version` - 检查应用更新:
+ - 根据传参,先检测传参是否完整,appid appVersion wgtVersion 必传
+ - 先从数据库取出所有该平台(会从上下文读取平台信息)的所有线上发行更新
+ - 再从所有线上发行更新中取出版本最大的一版。如果可以,尽量先检测wgt的线上发行版更新
+ - 使用上一步取出的版本包的版本号 和传参 appVersion、wgtVersion 来检测是否有更新。必须同时大于这两项,因为上一次可能是wgt热更新,否则返回暂无更新
+ - 如果库中 wgt包 版本大于传参 appVersion,但是不满足 min_uni_version < appVersion,则不会使用wgt更新,会接着判断库中 app包version 是否大于 appVersion
\ No newline at end of file
diff --git a/uni_modules/uni-upgrade-center-app/static/app_update_close.png b/uni_modules/uni-upgrade-center-app/static/app_update_close.png
new file mode 100644
index 0000000000000000000000000000000000000000..8b2ffe62cba2466f184ea9f8ee4f9395ed8cf37a
Binary files /dev/null and b/uni_modules/uni-upgrade-center-app/static/app_update_close.png differ
diff --git a/uni_modules/uni-upgrade-center-app/static/bg_top.png b/uni_modules/uni-upgrade-center-app/static/bg_top.png
new file mode 100644
index 0000000000000000000000000000000000000000..015f698cdd8c8caa63486a2bd87f5a96f17df630
Binary files /dev/null and b/uni_modules/uni-upgrade-center-app/static/bg_top.png differ
diff --git a/uni_modules/uni-upgrade-center-app/static/button_bg.png b/uni_modules/uni-upgrade-center-app/static/button_bg.png
new file mode 100644
index 0000000000000000000000000000000000000000..cab1d23195c951b2c82050f8811fc780ea51a230
Binary files /dev/null and b/uni_modules/uni-upgrade-center-app/static/button_bg.png differ
diff --git a/uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version/check-version.param.json b/uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version/check-version.param.json
new file mode 100644
index 0000000000000000000000000000000000000000..78ff505f4cd874db1cbc419a0a8605238817b31d
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version/check-version.param.json
@@ -0,0 +1,9 @@
+// 本文件中的json内容将在云函数【运行】时作为参数传给云函数。
+
+// 配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
+
+{
+ "appid": "__YOUR_APPID__",
+ "appVersion": "2.2.0",
+ "wgtVersion": "2.2.2"
+}
diff --git a/uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version/index.js b/uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..db92a9b44324a041a853de770ed8b6985bfb3973
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/uniCloud/cloudfunctions/check-version/index.js
@@ -0,0 +1,137 @@
+'use strict';
+exports.main = async (event, context) => {
+ /**
+ * 检测升级 使用说明
+ * 上传包:
+ * 1. 根据传参,先检测传参是否完整,appid appVersion wgtVersion 必传
+ * 2. 先从数据库取出所有该平台(从上下文读取平台信息,默认 Andriod)的所有线上发行更新
+ * 3. 再从所有线上发行更新中取出版本最大的一版。如果可以,尽量先检测wgt的线上发行版更新
+ * 4. 使用上步取出的版本包的版本号 和传参 appVersion、wgtVersion 来检测是否有更新,必须同时大于这两项,否则返回暂无更新
+ * 5. 如果库中 wgt包 版本大于传参 appVersion,但是不满足 min_uni_version < appVersion,则不会使用wgt更新,会接着判断库中 app包version 是否大于 appVersion
+ */
+
+ let {
+ appid,
+ appVersion,
+ wgtVersion,
+ } = event;
+
+ const platform_Android = 'Android';
+ const platform_iOS = 'iOS';
+ const package_app = 'native_app';
+ const package_wgt = 'wgt';
+ const app_version_db_name = 'opendb-app-versions'
+
+ let platform = platform_Android;
+
+ // 云函数URL化请求
+ if (event.headers) {
+ let body;
+ try {
+ if (event.httpMethod.toLocaleLowerCase() === 'get') {
+ body = event.queryStringParameters;
+ } else {
+ body = JSON.parse(event.body);
+ }
+ } catch (e) {
+ return {
+ code: 500,
+ msg: '请求错误'
+ };
+ }
+
+ appid = body.appid;
+ appVersion = body.appVersion;
+ wgtVersion = body.wgtVersion;
+
+ platform = /iPhone|iPad/.test(event.headers) ? platform_iOS : platform_Android;
+ } else if (context.OS) {
+ platform = context.OS === 'android'
+ ? platform_Android
+ : context.OS === 'ios'
+ ? platform_iOS
+ : platform_Android;
+ }
+
+ if (appid && appVersion && wgtVersion && platform) {
+ const collection = uniCloud.database().collection(app_version_db_name);
+
+ const record = await collection.where({
+ appid,
+ platform,
+ stable_publish: true
+ })
+ .orderBy('create_date', 'desc')
+ .get();
+
+ if (record && record.data && record.data.length > 0) {
+ const appVersionInDb = record.data.find(item => item.type === package_app) || {};
+ const wgtVersionInDb = record.data.find(item => item.type === package_wgt) || {};
+ const hasAppPackage = !!Object.keys(appVersionInDb).length;
+ const hasWgtPackage = !!Object.keys(wgtVersionInDb).length;
+
+ // 取两个版本中版本号最大的包,版本一样,使用wgt包
+ let stablePublishDb = hasAppPackage
+ ? hasWgtPackage
+ ? compare(wgtVersionInDb.version, appVersionInDb.version) >= 0
+ ? wgtVersionInDb
+ : appVersionInDb
+ : appVersionInDb
+ : wgtVersionInDb;
+
+ const {
+ version,
+ min_uni_version
+ } = stablePublishDb;
+
+ // 库中的version必须满足同时大于appVersion和wgtVersion才行,因为上次更新可能是wgt更新
+ const appUpdate = compare(version, appVersion) === 1; // app包可用更新
+ const wgtUpdate = compare(version, wgtVersion) === 1; // wgt包可用更新
+
+ if (Object.keys(stablePublishDb).length && appUpdate && wgtUpdate) {
+ // 判断是否可用wgt更新
+ if (min_uni_version && compare(min_uni_version, appVersion) < 1) {
+ return {
+ code: 101,
+ message: 'wgt更新',
+ ...stablePublishDb
+ };
+ } else if (hasAppPackage && compare(appVersionInDb.version, appVersion) === 1) {
+ return {
+ code: 102,
+ message: '整包更新',
+ ...appVersionInDb
+ };
+ }
+ }
+
+ return {
+ code: 0,
+ message: '当前版本已经是最新的,不需要更新'
+ };
+ }
+
+ return {
+ code: -101,
+ message: '暂无更新或检查appid是否填写正确'
+ };
+ }
+
+ return {
+ code: -102,
+ message: '请检查传参是否填写正确'
+ };
+};
+
+/**
+ * 对比版本号,如需要,请自行修改判断规则
+ * @param {Object} v1
+ * @param {Object} v2
+ * v1 > v2 return 1
+ * v1 < v2 return -1
+ * v1 == v2 return 0
+ */
+function compare(v1 = 0, v2 = 0) {
+ // '1.2.5' > '1.2.4' 类似的版本号可以直接对比
+ return v1 > v2 ? 1 : v1 < v2 ? -1 : 0;
+}
diff --git a/uni_modules/uni-upgrade-center-app/utils/check-update.js b/uni_modules/uni-upgrade-center-app/utils/check-update.js
new file mode 100644
index 0000000000000000000000000000000000000000..64872e2feaf699e955c2ac501fa47b0de198d554
--- /dev/null
+++ b/uni_modules/uni-upgrade-center-app/utils/check-update.js
@@ -0,0 +1,71 @@
+// 推荐再App.vue中使用
+const PACKAGE_INFO_KEY = '__package_info__'
+
+export default function() {
+ // #ifdef APP-PLUS
+ plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
+ uniCloud.callFunction({
+ name: 'check-version',
+ data: {
+ appid: plus.runtime.appid,
+ appVersion: plus.runtime.version,
+ wgtVersion: widgetInfo.version
+ },
+ success: (e) => {
+ if (!e.result) return;
+ const {
+ code,
+ message,
+ is_silently, // 是否静默更新
+ url, // 安装包下载地址
+ platform, // 安装包平台
+ type // 安装包类型
+ } = e.result;
+ // 此处逻辑仅为实例,可自行编写
+ if (code > 0) {
+ // 静默更新,只有wgt有
+ if (is_silently) {
+ downloadTask = uni.downloadFile({
+ url: this.url,
+ success: res => {
+ if (res.statusCode == 200) {
+ // 下载好直接安装,下次启动生效
+ plus.runtime.install(res.tempFilePath, {
+ force: false
+ });
+ }
+ }
+ });
+ return;
+ }
+
+ if (type === 'native_app' && platform.includes('iOS')) {
+ // iOS 跳转 AppStore 商店
+ plus.runtime.openURL(url);
+ return;
+ }
+
+ uni.setStorageSync(PACKAGE_INFO_KEY, e.result)
+
+ // 跳转更新页面
+ uni.navigateTo({
+ url: '/uni_modules/uni-upgrade-center-app/pages/upgrade-popup?local_storage_key=' +
+ PACKAGE_INFO_KEY,
+ fail: (err) => {
+ console.error('更新弹框跳转失败', err)
+ uni.removeStorageSync(PACKAGE_INFO_KEY)
+ }
+ })
+ } else if (code < 0) {
+ // TODO 云函数报错处理
+ console.error(message)
+ }
+ },
+ fail: (err) => {
+ // TODO 云函数报错处理
+ console.error(err.message)
+ }
+ })
+ });
+ // #endif
+}