提交 ce6c6e9e 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

fix: 修改ext-api的测试页面

上级 23f789b1
...@@ -2,61 +2,13 @@ ...@@ -2,61 +2,13 @@
<view> <view>
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-common-mt"> <view class="uni-common-mt">
<view class="uni-list"> <view class="uni-list">
<view class="uni-list-cell"> <view class="uni-list-cell" v-for="(item,_) in items" style="align-items: center;">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">AppId</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="appId"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd"> <view class="uni-pd">
<view class="uni-label" style="width:180px;">AppName</view> <view class="uni-label" style="width:180px;">{{item.label}}</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="appName"/> <textarea :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" />
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">App版本名</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="appVersion"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">App版本号VersionCode</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="appVersionCode"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">引擎版本号</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="version"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">应用设置的语言</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="appLanguage"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否uni-app x</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="isUniAppX"/>
</view> </view>
</view> </view>
</view> </view>
...@@ -69,17 +21,15 @@ ...@@ -69,17 +21,15 @@
</view> </view>
</template> </template>
<script> <script>
type Item = {
label : string,
value : string,
}
export default { export default {
data() { data() {
return { return {
title: 'getAppBaseInfo', title: 'getAppBaseInfo',
appId:"", items: [] as Item[],
appName:"",
appVersion:"",
appVersionCode:"",
appLanguage:"",
isUniAppX:"",
version:"",
} }
}, },
onUnload:function(){ onUnload:function(){
...@@ -87,13 +37,15 @@ ...@@ -87,13 +37,15 @@
methods: { methods: {
getAppBaseInfo: function () { getAppBaseInfo: function () {
const res = uni.getAppBaseInfo(); const res = uni.getAppBaseInfo();
this.appId = res.appId ?? ""; const json = JSON.stringify(res);
this.appName = res.appName ?? ""; const result = JSON.parse<Map<string, any>>(json);
this.appVersion = res.appVersion ?? ""; result.forEach((value, key) => {
this.appVersionCode = res.appVersionCode ?? ""; const item = {
this.appLanguage = res.appLanguage ?? ""; label: key,
this.isUniAppX = res.isUniAppX ? "是": "否"; value: "" + value
this.version = res.version ?? ""; } as Item;
this.items.push(item);
})
} }
} }
} }
......
...@@ -3,68 +3,14 @@ ...@@ -3,68 +3,14 @@
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-common-mt"> <view class="uni-common-mt">
<view class="uni-list"> <view class="uni-list">
<view class="uni-list-cell"> <view class="uni-list">
<view class="uni-pd"> <view class="uni-list-cell" v-for="(item,_) in items" style="align-items: center;">
<view class="uni-label" style="width:180px;">设备品牌</view> <view class="uni-pd">
</view> <view class="uni-label" style="width:180px;">{{item.label}}</view>
<view class="uni-list-cell-db"> </view>
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="deviceBrand"/> <view class="uni-list-cell-db">
</view> <textarea :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" />
</view> </view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">设备 id </view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="deviceId"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">设备型号</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="deviceModel"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">设备类型</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="deviceType"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">设备方向</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="deviceOrientation"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">设备像素比</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="devicePixelRatio"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">操作系统及版本</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="system"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">客户端平台</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="platform"/>
</view> </view>
</view> </view>
</view> </view>
...@@ -77,18 +23,15 @@ ...@@ -77,18 +23,15 @@
</view> </view>
</template> </template>
<script> <script>
type Item = {
label : string,
value : string,
}
export default { export default {
data() { data() {
return { return {
title: 'getDeviceInfo', title: 'getDeviceInfo',
deviceBrand:"", items: [] as Item[],
deviceId:"",
deviceModel:"",
deviceType:"",
deviceOrientation:"",
devicePixelRatio:"",
system:"",
platform:""
} }
}, },
onUnload:function(){ onUnload:function(){
...@@ -96,14 +39,15 @@ ...@@ -96,14 +39,15 @@
methods: { methods: {
getDeviceInfo: function () { getDeviceInfo: function () {
const res = uni.getDeviceInfo(); const res = uni.getDeviceInfo();
this.deviceBrand = res.deviceBrand ?? ""; const json = JSON.stringify(res);
this.deviceId = res.deviceId ?? ""; const result = JSON.parse<Map<string, any>>(json);
this.deviceModel = res.deviceModel ?? ""; result.forEach((value, key) => {
this.deviceType = res.deviceType ?? ""; const item = {
this.deviceOrientation = res.deviceOrientation ?? ""; label: key,
this.devicePixelRatio = res.devicePixelRatio + ""; value: "" + value
this.system = res.system ?? ""; } as Item;
this.platform = res.platform ?? ""; this.items.push(item);
})
} }
} }
} }
......
...@@ -3,100 +3,12 @@ ...@@ -3,100 +3,12 @@
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-common-mt"> <view class="uni-common-mt">
<view class="uni-list"> <view class="uni-list">
<view class="uni-list-cell"> <view class="uni-list-cell" v-for="(item,_) in items" style="align-items: center;">
<view class="uni-pd"> <view class="uni-pd">
<view class="uni-label" style="width:180px;">设备型号</view> <view class="uni-label" style="width:180px;">{{item.label}}</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="model"/> <textarea :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" />
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">客户端平台</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="platform"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">操作系统版本</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="system"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">语言</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="language"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">版本</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="version"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">屏幕宽度</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="screenWidth"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">屏幕高度</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="screenHeight"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">可使用窗口高度</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="windowHeight"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">可使用窗口的顶部位置</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="windowTop"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">可使用窗口的底部位置</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="windowBottom"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">状态栏的高度</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="statusBarHeight"/>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">DPI</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="pixelRatio"/>
</view> </view>
</view> </view>
</view> </view>
...@@ -108,52 +20,34 @@ ...@@ -108,52 +20,34 @@
</view> </view>
</view> </view>
</template> </template>
<script> <script>
type Item = {
label : string,
value : string,
}
export default { export default {
data() { data() {
return { return {
title: 'getSystemInfo', title: 'getSystemInfo',
model:"", items: [] as Item[],
platform:"",
system:"",
language:"",
version:"",
screenWidth:"",
screenHeight:"",
windowHeight:"",
windowTop:"",
windowBottom:"",
statusBarHeight:"",
pixelRatio:"",
SDKVersion:""
} }
}, },
onUnload:function(){ onUnload: function () {
}, },
methods: { methods: {
getSystemInfo: function () { getSystemInfo: function () {
uni.getSystemInfo({ uni.getSystemInfo({
success: (res) => { success: (res) => {
console.log('SystemInfo: ',res); const json = JSON.stringify(res);
this.model = res.model; const result = JSON.parse<Map<string, any>>(json);
this.platform = res.platform; result.forEach((value, key) => {
this.system = res.system; const item = {
this.language = res.language ?? ""; label: key,
this.version = res.version; value: "" + value
this.screenWidth = res.screenWidth + ""; } as Item;
this.screenHeight = res.screenHeight + ""; this.items.push(item);
this.windowHeight = res.windowHeight + ""; })
this.windowTop = res.windowTop + ""; },
this.windowBottom = res.windowBottom + "";
const statusBarHeight = res.statusBarHeight;
if (statusBarHeight == null){
this.statusBarHeight = "";
}else{
this.statusBarHeight = statusBarHeight + "";
}
this.pixelRatio = res.pixelRatio + "";
this.SDKVersion = res.SDKVersion;
}
}) })
} }
} }
...@@ -164,4 +58,4 @@ ...@@ -164,4 +58,4 @@
.uni-pd { .uni-pd {
padding-left: 30rpx; padding-left: 30rpx;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册