|
|
@@ -1,102 +1,93 @@
|
|
|
+<import name="loading-progress" src="../../../components/loading-progress"></import>
|
|
|
<template>
|
|
|
<div class="content">
|
|
|
- <!-- <div style="padding-top: {{statusBarHeight}}px">
|
|
|
<div class="flex w ai_center jc_center fd_c mgt-20">
|
|
|
- <image src="/static/image/source/jiasu.png" if="{{!status}}"
|
|
|
- style="width: 350px;height: 350px;"></image>
|
|
|
- <stack if="{{status}}" class="circle-progress">
|
|
|
- <progress type="circular"
|
|
|
- class="progress"
|
|
|
- percent="{{percent}}"
|
|
|
- style="width: 350px; height: 350px; color: #44ebd9; stroke-width: 30px; background-color: #d0effd;">
|
|
|
- </progress>
|
|
|
- <text class="percent-text">{{percent}}%</text>
|
|
|
- </stack>
|
|
|
-
|
|
|
+ <!-- 快应用不支持 vue 组件,iCircle 需自定义或用原生canvas实现 -->
|
|
|
+ <image src="/assets/images/source/jiasu.png" if="{{!status}}"
|
|
|
+ style="width: 175px;height: 175px;"></image>
|
|
|
+ <!-- iCircle 组件需快应用自定义实现,这里用占位 -->
|
|
|
+ <div if="{{status}}" class="fd_c">
|
|
|
+ <loading-progress
|
|
|
+ color="#ea9f8a">
|
|
|
+ </loading-progress>
|
|
|
+ <text style="font-size:36px; color: #333;font-weight: bold;margin-left: 5px;">{{ percent }}%</text>
|
|
|
+ <!-- canvas 需快应用自定义实现 -->
|
|
|
+ </div>
|
|
|
<text class="text-24 mgt-20">发现大量垃圾</text>
|
|
|
<text class="text-888 text-22 mgt-20">占用大量手机内存,急需清理</text>
|
|
|
- <div class="mgt-50 clean_btn cursor" @click="sureClean">
|
|
|
+ <text class="mgt-50 clean_btn cursor" @click="sureClean">
|
|
|
{{ status ? '正在清理中' : '立即清理' }}
|
|
|
- </div>
|
|
|
+ </text>
|
|
|
</div>
|
|
|
-
|
|
|
- <div class="w bg-white h-320 mgt-80 radio-30 pd-20">
|
|
|
- <div for="{{infoList}}" class="bg-eee h-80 radio-20 mgb-20 flex jc_between ai_center pdx-20">
|
|
|
+ <div class="w bg-white mgt-40 radio-30 pd-20 fd_c box_content">
|
|
|
+ <div for="(index,item) in infoArr" class="box_item">
|
|
|
<div>
|
|
|
- <text class="icon" style="color: #42aa87;">
|
|
|
- {{ $item.icon }}
|
|
|
- </text>
|
|
|
- {{ $item.key }}
|
|
|
+ <text if="{{item.key == '剩余内存'}}" style="color: #42aa87;">◕</text>
|
|
|
+ <text if="{{item.key == '总计内存'}}" style="color: #42aa87;">◕</text>
|
|
|
+ <text if="{{item.key == '已使用'}}" style="color: #42aa87;">◔</text>
|
|
|
+ <text style="margin-left:10px;">{{ item.key }}</text>
|
|
|
</div>
|
|
|
<text style="color: #42aa87;">
|
|
|
- {{ $item.value }}GB
|
|
|
+ {{ item.value }}GB
|
|
|
</text>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div> -->
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import device from '@system.device'
|
|
|
+import prompt from '@system.prompt'
|
|
|
+import storage from '@system.storage'
|
|
|
+
|
|
|
export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- statusBarHeight: 0,
|
|
|
- info: {
|
|
|
- '剩余内存': 20.99,
|
|
|
- '总计内存': 50.12,
|
|
|
- '已使用': 29.13,
|
|
|
- },
|
|
|
- // 将 info 对象转换为数组,方便快应用遍历
|
|
|
- infoList: [
|
|
|
- { key: '剩余内存', value: 20.99, icon: '\uf135' }, // rocket
|
|
|
- { key: '总计内存', value: 50.12, icon: '\uf15b' }, // file
|
|
|
- { key: '已使用', value: 29.13, icon: '\uf200' }, // pie-chart
|
|
|
- ],
|
|
|
- percent: 0,
|
|
|
- status: false,
|
|
|
- timer: null
|
|
|
+ data: {
|
|
|
+ statusBarHeight: 0,
|
|
|
+ info: {
|
|
|
+ '剩余内存': 20.99,
|
|
|
+ '总计内存': 50.12,
|
|
|
+ '已使用': 29.13
|
|
|
+ },
|
|
|
+ percent: 0,
|
|
|
+ status: false,
|
|
|
+ timer: null
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ infoArr() {
|
|
|
+ // 快应用 for 只能遍历数组
|
|
|
+ let arr = []
|
|
|
+ for (let key in this.info) {
|
|
|
+ arr.push({ key, value: this.info[key] })
|
|
|
+ }
|
|
|
+ return arr
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
onInit() {
|
|
|
- device.getInfo({
|
|
|
- success: function(ret) {
|
|
|
- console.log(`handling success, brand = ${JSON.stringify(ret)}`)
|
|
|
- console.log(`handling success, brand = ${ret.brand}`)
|
|
|
+ let that = this
|
|
|
+ storage.get({
|
|
|
+ key: 'statusBarHeight',
|
|
|
+ success: function(data) {
|
|
|
+ that.statusBarHeight = data
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
onDestroy() {
|
|
|
- // 组件销毁时清除定时器
|
|
|
- if (this.timer) {
|
|
|
- clearInterval(this.timer);
|
|
|
- this.timer = null;
|
|
|
- }
|
|
|
+ if (this.timer) clearInterval(this.timer)
|
|
|
},
|
|
|
sureClean() {
|
|
|
- if (this.status) return;
|
|
|
-
|
|
|
- this.status = true;
|
|
|
- this.startCleaning();
|
|
|
- },
|
|
|
-
|
|
|
- startCleaning() {
|
|
|
- this.timer = setInterval(() => {
|
|
|
- if (this.percent < 100) {
|
|
|
- let num = Math.ceil(Math.random() * 3);
|
|
|
- this.percent += (this.percent + num > 100) ? 1 : num;
|
|
|
- this.$update(); // 手动触发更新
|
|
|
+ console.log('status sureClean',this.status)
|
|
|
+ if (this.status) return
|
|
|
+ this.status = true
|
|
|
+ let that = this
|
|
|
+ this.timer = setInterval(function() {
|
|
|
+ if (that.percent < 100) {
|
|
|
+ let num = Math.ceil(Math.random() * 3)
|
|
|
+ that.percent += (that.percent + num > 100) ? 1 : num
|
|
|
} else {
|
|
|
- clearInterval(this.timer);
|
|
|
- this.timer = null;
|
|
|
- this.percent = 0;
|
|
|
- this.status = false;
|
|
|
- this.$update();
|
|
|
+ clearInterval(that.timer)
|
|
|
+ that.percent = 0
|
|
|
+ that.status = false
|
|
|
}
|
|
|
- }, 200);
|
|
|
+ }, 200)
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
@@ -104,125 +95,71 @@ export default {
|
|
|
<style lang="less">
|
|
|
.content {
|
|
|
padding: 28px;
|
|
|
+ flex-direction: column;
|
|
|
background: linear-gradient(to bottom, #a5eed0, #dcefaf);
|
|
|
+ .clean_btn {
|
|
|
+ width: 400px;
|
|
|
+ text-align: center;
|
|
|
+ background-color: #fff;
|
|
|
+ height: 80px;
|
|
|
+ line-height: 80px;
|
|
|
+ color: #42aa87;
|
|
|
+ border-radius: 40px;
|
|
|
+ border: 1px solid;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-.clean_btn {
|
|
|
- width: 400px;
|
|
|
- text-align: center;
|
|
|
+.box_content{
|
|
|
+ width: 100%;
|
|
|
background-color: #fff;
|
|
|
- height: 80px;
|
|
|
- line-height: 80px;
|
|
|
- color: #42aa87;
|
|
|
- border-radius: 40px;
|
|
|
- border: 1px solid;
|
|
|
-}
|
|
|
-
|
|
|
-.circle-progress {
|
|
|
- position: relative;
|
|
|
- width: 350px;
|
|
|
- height: 350px;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
-}
|
|
|
-
|
|
|
-.progress {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- left: 0;
|
|
|
-}
|
|
|
-
|
|
|
-.percent-text {
|
|
|
- font-size: 48px;
|
|
|
- color: #333;
|
|
|
- font-weight: bold;
|
|
|
-}
|
|
|
-.icon {
|
|
|
- font-family: fontawesome;
|
|
|
- margin-right: 10px;
|
|
|
-}
|
|
|
-.text-24 {
|
|
|
- font-size: 24px;
|
|
|
-}
|
|
|
-
|
|
|
-.text-22 {
|
|
|
- font-size: 22px;
|
|
|
-}
|
|
|
-
|
|
|
-.text-888 {
|
|
|
- color: #888;
|
|
|
-}
|
|
|
-
|
|
|
-.mgt-20 {
|
|
|
- margin-top: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.mgt-50 {
|
|
|
- margin-top: 50px;
|
|
|
-}
|
|
|
-
|
|
|
-.mgt-80 {
|
|
|
- margin-top: 80px;
|
|
|
+ height: 320px;
|
|
|
+ margin-top: 40px;
|
|
|
+ border-radius: 30px;
|
|
|
+ padding: 10px;
|
|
|
+ flex-direction: column;
|
|
|
}
|
|
|
-
|
|
|
-.mgb-20 {
|
|
|
+.box_item{
|
|
|
+ background-color: #eee;
|
|
|
+ height: 80px;
|
|
|
+ border-radius: 20px;
|
|
|
margin-bottom: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.pdx-20 {
|
|
|
- padding-left: 20px;
|
|
|
- padding-right: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.pd-20 {
|
|
|
- padding: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.flex {
|
|
|
- display: flex;
|
|
|
-}
|
|
|
-
|
|
|
-.jc_between {
|
|
|
justify-content: space-between;
|
|
|
-}
|
|
|
-
|
|
|
-.ai_center {
|
|
|
align-items: center;
|
|
|
+ padding: 0 20px;
|
|
|
+ /* flex-direction: column; */
|
|
|
}
|
|
|
-
|
|
|
-.jc_center {
|
|
|
- justify-content: center;
|
|
|
-}
|
|
|
-
|
|
|
-.fd_c {
|
|
|
- flex-direction: column;
|
|
|
-}
|
|
|
-
|
|
|
-.w {
|
|
|
+.CanvasBox {
|
|
|
width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ position: absolute;
|
|
|
+ top: 0px;
|
|
|
+ left: 0px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
}
|
|
|
+/* 其他样式按需补充 */
|
|
|
+.flex { display: flex; }
|
|
|
+.w { width: 100%; }
|
|
|
+.ai_center { align-items: center; }
|
|
|
+.jc_center { justify-content: center; }
|
|
|
+.fd_c { flex-direction: column; }
|
|
|
+.mgt-20 { margin-top: 20px; }
|
|
|
+.mgt-40 { margin-top: 40px; }
|
|
|
+.mgt-50 { margin-top: 50px; }
|
|
|
+.mgb-10 { margin-bottom: 10px; }
|
|
|
+.bg-white { background-color: #fff; }
|
|
|
+.bg-eee { background-color: #eee; }
|
|
|
+.h-40 { height: 40px; }
|
|
|
+.h-160 { height: 160px; }
|
|
|
+.h-320 { height: 320px; }
|
|
|
+.radio-20 { border-radius: 20px; }
|
|
|
+.radio-30 { border-radius: 30px; }
|
|
|
+.pd-10 { padding: 10px; }
|
|
|
+.pd-20 { padding: 20px; }
|
|
|
+.pdx-10 { padding-left: 10px; padding-right: 10px; }
|
|
|
+.pdx-20 { padding-left: 20px; padding-right: 20px; }
|
|
|
+.text-24 { font-size: 24px; }
|
|
|
+.text-22 { font-size: 22px; }
|
|
|
+.text-888 { color: #888; }
|
|
|
|
|
|
-.h-320 {
|
|
|
- height: 320px;
|
|
|
-}
|
|
|
-
|
|
|
-.h-80 {
|
|
|
- height: 80px;
|
|
|
-}
|
|
|
-
|
|
|
-.bg-white {
|
|
|
- background-color: #fff;
|
|
|
-}
|
|
|
-
|
|
|
-.bg-eee {
|
|
|
- background-color: #eee;
|
|
|
-}
|
|
|
-
|
|
|
-.radio-30 {
|
|
|
- border-radius: 30px;
|
|
|
-}
|
|
|
-
|
|
|
-.radio-20 {
|
|
|
- border-radius: 20px;
|
|
|
-}
|
|
|
</style>
|