提交 04cc769b 编写于 作者: zhaofengliang920817's avatar zhaofengliang920817

Merge branch 'dev' of gitcode.net:dcloud/hello-uni-app-x into dev

...@@ -618,6 +618,54 @@ ...@@ -618,6 +618,54 @@
"navigationBarTitleText": "图片" "navigationBarTitleText": "图片"
} }
}, },
// #ifdef APP-ANDROID
{
"path" : "pages/API/get-image-info/get-image-info",
"style" :
{
"navigationBarTitleText" : "获取图片信息"
}
},
{
"path" : "pages/API/compress-image/compress-image",
"style" :
{
"navigationBarTitleText" : "压缩图片"
}
},
// #endif
// #ifdef APP
// {
// "path" : "pages/API/choose-video/choose-video",
// "style" :
// {
// "navigationBarTitleText" : "拍摄视频或从相册中选择视频"
// }
// },
{
"path" : "pages/API/save-video-to-photos-album/save-video-to-photos-album",
"style" :
{
"navigationBarTitleText" : "保存视频到相册"
}
},
// #endif
// #ifdef APP-ANDROID
{
"path" : "pages/API/get-video-info/get-video-info",
"style" :
{
"navigationBarTitleText" : "获取视频信息"
}
},
// {
// "path" : "pages/API/compress-video/compress-video",
// "style" :
// {
// "navigationBarTitleText" : "压缩视频"
// }
// },
// #endif
{ {
"path": "pages/API/get-network-type/get-network-type", "path": "pages/API/get-network-type/get-network-type",
"style": { "style": {
...@@ -1236,6 +1284,7 @@ ...@@ -1236,6 +1284,7 @@
"navigationBarTitleText": "nested-scroll-body" "navigationBarTitleText": "nested-scroll-body"
} }
}, },
// #ifdef APP || WEB
{ {
"path": "pages/API/request-payment/request-payment", "path": "pages/API/request-payment/request-payment",
"style": { "style": {
...@@ -1280,6 +1329,7 @@ ...@@ -1280,6 +1329,7 @@
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8"
} }
}, },
// #endif
{ {
"path" : "pages/template/custom-long-list/custom-long-list", "path" : "pages/template/custom-long-list/custom-long-list",
"style" : { "style" : {
...@@ -1302,13 +1352,13 @@ ...@@ -1302,13 +1352,13 @@
"navigationBarTitleText" : "", "navigationBarTitleText" : "",
"backgroundColorContent": "#fffae8" "backgroundColorContent": "#fffae8"
} }
} },
// #ifdef APP-ANDROID // #ifdef APP-ANDROID || WEB
,{ {
"path" : "pages/API/resize-observer/resize-observer", "path" : "pages/API/resize-observer/resize-observer",
"style" : "style" :
{ {
"navigationBarTitleText" : "resize0bserver" "navigationBarTitleText" : "resize observer"
} }
}, },
// #endif // #endif
......
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="image-container">
<image class="image" :src="beforeCompressPath" mode="aspectFit"></image>
<image class="image" :src="afterCompressPath" mode="aspectFit"></image>
</view>
<view class="uni-title">
<text class="uni-subtitle-text">压缩前图片信息</text>
</view>
<text>{{beforeCompressImageInfo}}</text>
<view class="uni-title">
<text class="uni-subtitle-text">压缩后图片信息</text>
</view>
<text>{{afterCompressImageInfo}}</text>
<view class="uni-btn-v">
<button type="primary" @click="chooseImage">从相册中选取待压缩的图片</button>
</view>
<view class="uni-btn-v">
<button type="primary" @click="compressImage">压缩图片</button>
</view>
</view>
<input-data defaultValue="80" title="压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)" type="number"
@confirm="onQualityInputConfirm"></input-data>
<input-data title="压缩后图片的宽度,单位px" type="number" @confirm="onCompressedWidthInputConfirm"></input-data>
<input-data title="压缩后图片的高度,单位px" type="number" @confirm="onCompressedHeightInputConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的宽度,支持px、%、auto" type="string"
@confirm="onWidthInputConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的高度,支持px、%、auto" type="string"
@confirm="onHeightInputConfirm"></input-data>
<input-data defaultValue="0" title="旋转度数,范围0~360" type="number" @confirm="onRotateInputConfirm"></input-data>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: "compressImage",
beforeCompressImageInfo: "",
afterCompressImageInfo: "",
beforeCompressPath: "",
afterCompressPath: "",
quality: 80,
compressedWidth: null as number | null,
compressedHeight: null as number | null,
width: "auto",
height: "auto",
rotate: 0
}
},
methods: {
compressImage() {
uni.compressImage({
src: this.beforeCompressPath,
quality: this.quality,
compressedWidth: this.compressedWidth,
compressedHeight: this.compressedHeight,
width: this.width,
height: this.height,
rotate: this.rotate,
success: (_res) => {
this.afterCompressPath = _res.tempFilePath;
uni.showToast({
title: "压缩成功",
icon: null
});
uni.getImageInfo({
src: _res.tempFilePath,
success: (res) => {
this.afterCompressImageInfo = `图片宽度: ${res.width}, 图片高度: ${res.height}`;
}
});
},
fail: (err) => {
uni.showModal({
title: "压缩失败",
content: JSON.stringify(err)
})
}
})
},
chooseImage() {
uni.chooseImage({
count: 1,
sizeType: ["original"],
sourceType: ["album"],
success: (_res) => {
this.beforeCompressPath = _res.tempFilePaths[0];
uni.getImageInfo({
src: _res.tempFilePaths[0],
success: (res) => {
this.beforeCompressImageInfo = `图片宽度: ${res.width}, 图片高度: ${res.height}`;
}
});
}
});
},
onQualityInputConfirm(value : number) {
this.quality = value;
},
onCompressedWidthInputConfirm(value : number) {
this.compressedWidth = value;
},
onCompressedHeightInputConfirm(value : number) {
this.compressedHeight = value;
},
onWidthInputConfirm(value : string) {
this.width = value;
},
onHeightInputConfirm(value : string) {
this.height = value;
},
onRotateInputConfirm(value : number) {
this.rotate = value;
}
}
}
</script>
<style>
.image {
flex: 1;
}
.image-container {
flex-direction: row;
}
</style>
...@@ -10,6 +10,16 @@ describe('ExtApi-GetAppBaseInfo', () => { ...@@ -10,6 +10,16 @@ describe('ExtApi-GetAppBaseInfo', () => {
] ]
const numberProperties = [ const numberProperties = [
'uniCompilerVersionCode', 'uniRuntimeVersionCode' 'uniCompilerVersionCode', 'uniRuntimeVersionCode'
]
const booleanProperties = [
'isUniAppX'
]
const requiredProperties = [
'uniCompilerVersion',
'uniCompilerVersionCode',
'uniRuntimeVersion',
'uniRuntimeVersionCode',
'isUniAppX'
] ]
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
...@@ -28,6 +38,16 @@ describe('ExtApi-GetAppBaseInfo', () => { ...@@ -28,6 +38,16 @@ describe('ExtApi-GetAppBaseInfo', () => {
expect(value).not.toBeNull(); expect(value).not.toBeNull();
expect(value).toBeGreaterThanOrEqual(3.90); expect(value).toBeGreaterThanOrEqual(3.90);
} }
if (booleanProperties.indexOf(key) != -1) {
expect(value).not.toBeNull();
expect(typeof value).toBe('boolean');
}
} }
}); });
it('Check GetSystemInfoSync required properties', async () => {
for (let i = 0; i < requiredProperties.length; i++) {
const key = requiredProperties[i]
expect(`${key} not null: ${res[key] != null}`).toBe(`${key} not null: true`)
}
})
}); });
...@@ -38,8 +38,11 @@ describe('getCurrentPages', () => { ...@@ -38,8 +38,11 @@ describe('getCurrentPages', () => {
await page.callMethod('getPageStyle') await page.callMethod('getPageStyle')
await page.waitFor(200) await page.waitFor(200)
const isEnablePullDownRefresh2 = (await page.data()).currentPageStyle.enablePullDownRefresh const data2 = await page.data()
const isEnablePullDownRefresh2 = data2.currentPageStyle.enablePullDownRefresh
const currentPageStyleIsUTSJSONObject2 = data2.currentPageStyleIsUTSJSONObject
expect(isEnablePullDownRefresh2).toBe(false) expect(isEnablePullDownRefresh2).toBe(false)
expect(currentPageStyleIsUTSJSONObject2).toBe(true)
await page.callMethod('startPullDownRefresh') await page.callMethod('startPullDownRefresh')
await page.waitFor(500) await page.waitFor(500)
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
checked: false, checked: false,
pages: [] as Page[], pages: [] as Page[],
currentPageStyle: {} as UTSJSONObject, currentPageStyle: {} as UTSJSONObject,
currentPageStyleIsUTSJSONObject: true,
// TODO // TODO
enablePullDownRefreshStatus: true enablePullDownRefreshStatus: true
} }
...@@ -65,7 +66,8 @@ ...@@ -65,7 +66,8 @@
getPageStyle() { getPageStyle() {
const pages = getCurrentPages(); const pages = getCurrentPages();
const currentPage = pages[pages.length - 1]; const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle(); this.currentPageStyle = currentPage.$getPageStyle();
this.currentPageStyleIsUTSJSONObject = this.currentPageStyle instanceof UTSJSONObject
}, },
setPageStyle(enable : boolean) { setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh // 目前仅支持 enablePullDownRefresh
......
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-title">
<text class="uni-subtitle-text">获取本地相对路径图片信息</text>
</view>
<image class="image" :src="relativeImagePath" mode="aspectFit"></image>
<text class="margin-top-10">{{absoluteImageInfo}}</text>
<view class="uni-title">
<text class="uni-subtitle-text">获取网络路径图片信息</text>
</view>
<image class="image" :src="remoteImagePath" mode="aspectFit"></image>
<text class="margin-top-10">{{remoteImageInfo}}</text>
<view class="uni-title">
<text class="uni-subtitle-text">获取本地绝对路径图片信息</text>
</view>
<image class="image" :src="absoluteImagePath" mode="aspectFit"></image>
<text class="margin-top-10">{{relativeImageInfo}}</text>
<view class="uni-btn-v">
<button type="primary" @click="chooseImage">拍摄照片或从相册中选择照片</button>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: "getImageInfo",
relativeImagePath: "/static/test-image/logo.png",
relativeImageInfo: "",
absoluteImagePath: "",
absoluteImageInfo: "",
remoteImagePath: "https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/img/building.jpg",
remoteImageInfo: "",
}
},
methods: {
chooseImage() {
uni.chooseImage({
count: 1,
success: (_res) => {
this.absoluteImagePath = _res.tempFilePaths[0];
uni.getImageInfo({
src: _res.tempFilePaths[0],
success: (res) => {
this.relativeImageInfo = `图片宽度: ${res.width}\n图片高度: ${res.height}\n图片路径: ${res.path}\n图片方向: ${res.orientation}\n图片格式: ${res.type}`;
}
});
}
});
}
},
onReady() {
uni.getImageInfo({
src: this.relativeImagePath,
success: (res) => {
this.absoluteImageInfo = `图片宽度: ${res.width}\n图片高度: ${res.height}\n图片路径: ${res.path}\n图片方向: ${res.orientation}\n图片格式: ${res.type}`;
}
});
uni.getImageInfo({
src: this.remoteImagePath,
success: (res) => {
this.remoteImageInfo = `图片宽度: ${res.width}\n图片高度: ${res.height}\n图片路径: ${res.path}\n图片方向: ${res.orientation}\n图片格式: ${res.type}`;
}
});
}
}
</script>
<style>
.image {
align-self: center;
}
.margin-top-10 {
margin-top: 10px;
}
</style>
...@@ -15,6 +15,16 @@ describe('ExtApi-GetSystemInfo', () => { ...@@ -15,6 +15,16 @@ describe('ExtApi-GetSystemInfo', () => {
'windowWidth', 'windowWidth',
'windowHeight', 'windowTop', 'windowBottom', 'screenTop', 'windowHeight', 'windowTop', 'windowBottom', 'screenTop',
'uniCompilerVersionCode', 'uniRuntimeVersionCode' 'uniCompilerVersionCode', 'uniRuntimeVersionCode'
]
const booleanProperties = [
'isUniAppX'
]
const requiredProperties = [
'uniCompilerVersion',
'uniCompilerVersionCode',
'uniRuntimeVersion',
'uniRuntimeVersionCode',
'isUniAppX'
] ]
beforeAll(async () => { beforeAll(async () => {
...@@ -34,6 +44,10 @@ describe('ExtApi-GetSystemInfo', () => { ...@@ -34,6 +44,10 @@ describe('ExtApi-GetSystemInfo', () => {
expect(value).not.toBeNull(); expect(value).not.toBeNull();
expect(value).toBeGreaterThanOrEqual(0); expect(value).toBeGreaterThanOrEqual(0);
} }
if (booleanProperties.indexOf(key) != -1) {
expect(value).not.toBeNull();
expect(typeof value).toBe('boolean');
}
if (key == 'deviceOrientation') { if (key == 'deviceOrientation') {
expect(['portrait', 'landscape']).toContain(value); expect(['portrait', 'landscape']).toContain(value);
} }
...@@ -41,5 +55,11 @@ describe('ExtApi-GetSystemInfo', () => { ...@@ -41,5 +55,11 @@ describe('ExtApi-GetSystemInfo', () => {
expect(['light', 'dark']).toContain(value); expect(['light', 'dark']).toContain(value);
} }
} }
}); });
it('Check GetSystemInfoSync required properties', async () => {
for (let i = 0; i < requiredProperties.length; i++) {
const key = requiredProperties[i]
expect(`${key} not null: ${res[key] != null}`).toBe(`${key} not null: true`)
}
})
}); });
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-title">
<text class="uni-subtitle-text">获取本地绝对路径视频信息</text>
</view>
<video class="video" :src="absoluteVideoPath"></video>
<text class="margin-top-10">{{absoluteVideoInfo}}</text>
<view class="uni-btn-v">
<button type="primary" @click="chooseVideo">拍摄视频或从相册中选择视频</button>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: "getVideoInfo",
absoluteVideoPath: "",
absoluteVideoInfo: "",
}
},
methods: {
chooseVideo() {
uni.chooseVideo({
compressed: false,
success: (_res) => {
this.absoluteVideoPath = _res.tempFilePath;
uni.getVideoInfo({
src: _res.tempFilePath,
success: (res) => {
this.absoluteVideoInfo = `视频画面方向: ${res.orientation}\n视频格式: ${res.type}\n视频长度: ${res.duration}s\n视频大小: ${Math.ceil(res.size / 1024)}kB\n视频宽度: ${res.width}\n视频高度: ${res.height}\n视频帧率: ${res.fps}fps\n视频码率: ${res.bitrate}kbps`;
}
});
}
});
}
}
}
</script>
<style>
.video {
align-self: center;
}
.margin-top-10 {
margin-top: 10px;
}
</style>
describe('api-resize-observer', () => { describe('api-resize-observer', () => {
if (!process.env.uniTestPlatformInfo.startsWith('android')) { if (
!process.env.uniTestPlatformInfo.startsWith('android') &&
!process.env.uniTestPlatformInfo.startsWith('web')
) {
it('dummyTest', async () => { it('dummyTest', async () => {
expect(1).toBe(1) expect(1).toBe(1)
}) })
......
...@@ -70,14 +70,14 @@ ...@@ -70,14 +70,14 @@
methods: { methods: {
innerBoxClick() { innerBoxClick() {
if (this.innerBoxElement != null) { if (this.innerBoxElement != null) {
this.innerBoxElement!.style.setProperty("width", this.innerBoxElement!.offsetWidth + this.offset) this.innerBoxElement!.style.setProperty("width", this.innerBoxElement!.offsetWidth + this.offset + 'px')
this.innerBoxElement!.style.setProperty("height", this.innerBoxElement!.offsetWidth + this.offset) this.innerBoxElement!.style.setProperty("height", this.innerBoxElement!.offsetWidth + this.offset + 'px')
} }
}, },
outBoxClick() { outBoxClick() {
if (this.outBoxElement != null) { if (this.outBoxElement != null) {
this.outBoxElement!.style.setProperty("width", this.outBoxElement!.offsetWidth + this.offset) this.outBoxElement!.style.setProperty("width", this.outBoxElement!.offsetWidth + this.offset + 'px')
this.outBoxElement!.style.setProperty("height", this.outBoxElement!.offsetWidth + this.offset) this.outBoxElement!.style.setProperty("height", this.outBoxElement!.offsetWidth + this.offset + 'px')
} }
}, },
revertBoxSize() { revertBoxSize() {
......
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view style="flex:1"> <scroll-view style="flex:1">
<!-- #endif --> <!-- #endif -->
<image src="/static/uni.png" style="margin: 15px 100px;height:196px;width:196px;"></image> <page-head :title="title"></page-head>
<button style="margin: 15px;" @click="saveImage">将图片保存到手机相册</button> <view class="uni-padding-wrap">
<image class="image" src="/static/uni.png"></image>
<button class="margin-top-10" type="primary" @click="saveImage">将图片保存到手机相册</button>
</view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
<!-- #endif --> <!-- #endif -->
...@@ -13,6 +16,7 @@ ...@@ -13,6 +16,7 @@
export default { export default {
data() { data() {
return { return {
title: "saveImageToPhotosAlbum"
} }
}, },
methods: { methods: {
...@@ -39,4 +43,13 @@ ...@@ -39,4 +43,13 @@
</script> </script>
<style> <style>
.margin-top-10 {
margin-top: 10px;
}
.image {
width: 196px;
height: 196px;
align-self: center;
}
</style> </style>
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<video class="video" :src="src"></video>
<button type="primary" class="margin-top-10" @click="saveVideo">将视频保存到手机相册</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: 'saveVideoToPhotosAlbum',
src: ''
}
},
methods: {
saveVideo() {
uni.saveVideoToPhotosAlbum({
filePath: this.src,
success: (_) => {
uni.showToast({
position: "center",
icon: "none",
title: "视频保存成功,请到手机相册查看"
});
},
fail: (e) => {
uni.showModal({
content: "保存相册失败,errCode:" + e.errCode + ",errMsg:" + e.errMsg + ",errSubject:" + e.errSubject,
showCancel: false
});
}
});
}
},
onReady() {
uni.showLoading({
title: '视频下载中'
});
uni.downloadFile({
url: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mp4',
success: (res) => {
console.log("download video success", res.tempFilePath);
this.src = res.tempFilePath;
uni.hideLoading();
}
});
}
}
</script>
<style>
.video {
align-self: center;
}
.margin-top-10 {
margin-top: 10px;
}
</style>
...@@ -7,7 +7,12 @@ describe('set-page-backgroundColorContent', () => { ...@@ -7,7 +7,12 @@ describe('set-page-backgroundColorContent', () => {
it('check_backgroundColorContent_red', async () => { it('check_backgroundColorContent_red', async () => {
await page.callMethod('changeColor', "") await page.callMethod('changeColor', "")
page.waitFor(100) page.waitFor(200)
const color = (await page.data()).currentBackgroundColorContent
expect(color).toBe("red")
const image = await program.screenshot({fullPage: true}); const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot(); expect(image).toSaveImageSnapshot();
}) })
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
export default { export default {
data() { data() {
return { return {
isChange : false isChange : false,
currentBackgroundColorContent: "" as any | null
} }
}, },
methods: { methods: {
...@@ -17,6 +18,9 @@ ...@@ -17,6 +18,9 @@
let page = pages[pages.length - 1] let page = pages[pages.length - 1]
page.$setPageStyle({"backgroundColorContent" : this.isChange ? "" : "red"}) page.$setPageStyle({"backgroundColorContent" : this.isChange ? "" : "red"})
this.isChange = !this.isChange this.isChange = !this.isChange
let pageJson = page.$getPageStyle()
this.currentBackgroundColorContent = pageJson["backgroundColorContent"]
} }
} }
} }
......
...@@ -17,6 +17,7 @@ describe('unicloud-database', () => { ...@@ -17,6 +17,7 @@ describe('unicloud-database', () => {
await page.callMethod('dbGetWithCommand') await page.callMethod('dbGetWithCommand')
await page.callMethod('dbUpdate') await page.callMethod('dbUpdate')
await page.callMethod('dbRemove') await page.callMethod('dbRemove')
await page.callMethod('dbMultiSend')
const { const {
addId, addId,
...@@ -26,6 +27,7 @@ describe('unicloud-database', () => { ...@@ -26,6 +27,7 @@ describe('unicloud-database', () => {
getData, getData,
getWithCommandData, getWithCommandData,
removeDeleted, removeDeleted,
multiSendSuccessCount,
} = await page.data() } = await page.data()
expect(addId !== '').toBe(true) expect(addId !== '').toBe(true)
...@@ -35,6 +37,7 @@ describe('unicloud-database', () => { ...@@ -35,6 +37,7 @@ describe('unicloud-database', () => {
expect(getWithCommandData.length).toBe(1) expect(getWithCommandData.length).toBe(1)
expect(updateUpdated).toBe(3) expect(updateUpdated).toBe(3)
expect(removeDeleted).toBe(3) expect(removeDeleted).toBe(3)
expect(multiSendSuccessCount).toBe(2)
}) })
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<button type="primary" @click="dbRemove">删除数据</button> <button type="primary" @click="dbRemove">删除数据</button>
<button type="primary" @click="dbLookupInit">初始化联表查询数据</button> <button type="primary" @click="dbLookupInit">初始化联表查询数据</button>
<button type="primary" @click="dbLookup">联表查询</button> <button type="primary" @click="dbLookup">联表查询</button>
<button type="primary" @click="dbMultiSend">合并查询查询</button>
</view> </view>
</view> </view>
</view> </view>
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
getWithCommandData: [] as Array<UTSJSONObject>, getWithCommandData: [] as Array<UTSJSONObject>,
removeDeleted: 0, removeDeleted: 0,
lookupData: [] as Array<UTSJSONObject>, lookupData: [] as Array<UTSJSONObject>,
multiSendSuccessCount: 0,
isUniTest: false isUniTest: false
} }
}, },
...@@ -278,6 +280,39 @@ ...@@ -278,6 +280,39 @@
const error = err as UniCloudError const error = err as UniCloudError
this.notify(error.errMsg, '错误') this.notify(error.errMsg, '错误')
}) })
},
dbMultiSend() {
const db = uniCloud.databaseForJQL()
const temp1 = db.collection('type')
.where(
'tag == "default-tag"'
).getTemp()
const temp2 = db.collection('type')
.where(
'tag == "default-tag"'
).getTemp()
db.multiSend(temp1, temp2)
.then<void>(res => {
uni.hideLoading()
let successCount = 0
for (let i = 0; i < res.dataList.length; i++) {
const item = res.dataList[i]
if(item.errCode == 0) {
console.log(`第${i}个请求查询到${item.data!.length}条数据`)
successCount++
} else {
console.error(`第${i}个请求查询失败,错误信息:${item.data!.length}`)
}
}
this.multiSendSuccessCount = successCount
this.notify(`合并查询成功,成功查询的语句条数为:${successCount}`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
console.error(err)
this.notify(error.errMsg, '错误')
})
} }
} }
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<text class="reserve-text">转变前位置</text> <text class="reserve-text">转变前位置</text>
</view> </view>
<view class="base reserve"> <view class="base reserve">
<text class="reserve-text">translate(-50%, 50%)</text> <text class="reserve-text">translate(-50%,50%)</text>
<text class="reserve-text">转变前位置</text> <text class="reserve-text">转变前位置</text>
</view> </view>
</view> </view>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<list-view v-show="list_show" id="listview" style="flex: 1;" show-scrollbar=false @scrolltolower="onScrollTolower"> <list-view v-show="list_show" id="listview" style="flex: 1;" show-scrollbar=false @scrolltolower="onScrollTolower">
<list-item v-for="index in item_count" class="item" @click="itemClick(index)"> <list-item v-for="index in item_count" class="item" @click="itemClick(index)">
<text >item-------<text>{{index}}</text></text> <text >item-------<text>{{index}}</text></text>
<text v-if="displayArrow" >item-------<text>{{index}}</text></text> <text v-show="displayArrow" >item-------<text>{{index}}</text></text>
</list-item> </list-item>
</list-view> </list-view>
</view> </view>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
:refresher-enabled="refresher_enabled_boolean" :refresher-triggered="refresher_triggered_boolean" :refresher-enabled="refresher_enabled_boolean" :refresher-triggered="refresher_triggered_boolean"
@refresherrefresh="list_view_refresherrefresh"> @refresherrefresh="list_view_refresherrefresh">
<list-item type=1> <list-item type=1>
<swiper indicator-dots="true" circular="true"> <swiper indicator-dots="true" circular="true" style="height: 240px;">
<swiper-item v-for="i in 3" :item-id="i + ''"> <swiper-item v-for="i in 3" :item-id="i + ''">
<image src="/static/shuijiao.jpg" style="height: 240px; width: 100%;"></image> <image src="/static/shuijiao.jpg" style="height: 240px; width: 100%;"></image>
<text style="position: absolute;">{{i}}</text> <text style="position: absolute;">{{i}}</text>
......
...@@ -6,7 +6,8 @@ describe('component-native-sticky-section', () => { ...@@ -6,7 +6,8 @@ describe('component-native-sticky-section', () => {
}) })
//检测吸顶上推效果 //检测吸顶上推效果
it('check_sticky_section', async () => { it('check_sticky_section', async () => {
page.waitFor(300)
await page.callMethod('listViewScrollByY', 1000) await page.callMethod('listViewScrollByY', 1000)
const image = await program.screenshot({fullPage: true}); const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot(); expect(image).toSaveImageSnapshot();
......
<template> <template>
<page-head title="sticky-section"></page-head> <page-head title="sticky-section"></page-head>
<button style="position: fixed; width: 50px; height: 50px;" @click="listViewScrollByY(1000)">测试</button>
<list-view id="list-view" ref="list-view" show-scrollbar=false class="page" :scroll-into-view="scrollIntoView" <list-view id="list-view" ref="list-view" show-scrollbar=false class="page" :scroll-into-view="scrollIntoView"
@scroll="onScroll" @scrollend="onScrollEnd" rebound="false"> @scroll="onScroll" @scrollend="onScrollEnd" rebound="false">
<!-- #ifdef APP -->
<list-item style="padding: 10px; margin: 5px 0;align-items: center;" :type = 20> <list-item style="padding: 10px; margin: 5px 0;align-items: center;" :type = 20>
<button @click="gotoStickyHeader('C')" size="mini">跳转到id为C的sticky-header位置上</button> <button @click="gotoStickyHeader('C')" size="mini">跳转到id为C的sticky-header位置上</button>
</list-item> </list-item>
<!-- #endif -->
<sticky-section v-for="(sectionText) in data" :padding="sectionPadding" :push-pinned-header="true"> <sticky-section v-for="(sectionText) in data" :padding="sectionPadding" :push-pinned-header="true">
<sticky-header :header-id="sectionText" :id="sectionText"> <sticky-header :header-id="sectionText" :id="sectionText">
<text class="sticky-header-text">{{sectionText}}</text> <text class="sticky-header-text">{{sectionText}}</text>
...@@ -40,10 +39,16 @@ ...@@ -40,10 +39,16 @@
//用于自动化测试 //用于自动化测试
listViewScrollByY(y : number) { listViewScrollByY(y : number) {
const listview = this.$refs["list-view"] as UniElement const listview = this.$refs["list-view"] as UniElement
listview.scrollBy(0, y) // listview.scrollBy(0, y)
listview.scrollTop = y
}, },
gotoStickyHeader(id : string) { gotoStickyHeader(id : string) {
this.scrollIntoView = id // #ifdef APP
this.scrollIntoView = id
// #endif
// #ifdef WEB
console.log("web端不支持该功能")
// #endif
}, },
onScroll() { onScroll() {
this.scrolling = true this.scrolling = true
...@@ -53,7 +58,7 @@ ...@@ -53,7 +58,7 @@
//滚动后重置scrollIntoView = "" //滚动后重置scrollIntoView = ""
if(this.scrollIntoView != "") { if(this.scrollIntoView != "") {
this.scrollIntoView = "" this.scrollIntoView = ""
} }
} }
} }
} }
......
...@@ -90,54 +90,54 @@ export default { ...@@ -90,54 +90,54 @@ export default {
<view class="content"> <view class="content">
<boolean-data <boolean-data
:defaultValue="false" :defaultValue="false"
title="键盘弹起时,是否自动上推页面(限非 Web 平台)" title="键盘弹起时,是否自动上推页面(限非 Web 平台)"
@change="change_adjust_position_boolean" @change="change_adjust_position_boolean"
></boolean-data> ></boolean-data>
<boolean-data
:defaultValue="false"
title="是否显示键盘上方带有“完成”按钮那一栏(仅限小程序平台)"
@change="change_show_confirm_bar_boolean"
></boolean-data>
<boolean-data
:defaultValue="false"
title="如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true(仅限小程序平台)"
@change="change_fixed_boolean"
></boolean-data>
<boolean-data <boolean-data
:defaultValue="false" :defaultValue="false"
title="是否自动增高,设置auto-height时,style.height不生效" title="是否自动增高,设置auto-height时,style.height不生效"
@change="change_auto_height_boolean" @change="change_auto_height_boolean"
></boolean-data> ></boolean-data>
<boolean-data <boolean-data
:defaultValue="false" :defaultValue="focus_boolean"
title="点击键盘右下角按钮时是否保持键盘不收起" title="获取焦点"
@change="change_confirm_hold_boolean" @change="change_focus_boolean"
></boolean-data> ></boolean-data>
<boolean-data <boolean-data
:defaultValue="focus_boolean" :defaultValue="true"
title="获取焦点" title="首次自动获取焦点"
@change="change_focus_boolean" @change="change_auto_focus_boolean"
></boolean-data>
<boolean-data
:defaultValue="true"
title="首次自动获取焦点"
@change="change_auto_focus_boolean"
></boolean-data> ></boolean-data>
<boolean-data <boolean-data
:defaultValue="false" :defaultValue="false"
title="改变光标颜色为透明" title="改变光标颜色为透明"
@change="change_cursor_color_boolean" @change="change_cursor_color_boolean"
></boolean-data> ></boolean-data>
<enum-data
:items="inputmode_enum"
title="是一个枚举属性,它提供了用户在编辑元素或其内容时可能输入的数据类型的提示。(仅限 Web 平台符合条件的高版本浏览器或webview)。"
@change="radio_change_inputmode_enum"
></enum-data>
<enum-data <enum-data
:items="confirm_type_list" :items="confirm_type_list"
title="枚举属性,可以设置键盘右下角按钮。(仅限 Web、iOS 平台)。" title="confirm-type,设置键盘右下角按钮。(Android仅支持return)"
@change="radio_change_confirm_type" @change="radio_change_confirm_type"
></enum-data> ></enum-data>
<boolean-data
:defaultValue="false"
title="点击软键盘右下角按钮时是否保持键盘不收起(confirm-type为return时必然不收起)"
@change="change_confirm_hold_boolean"
></boolean-data>
<enum-data
:items="inputmode_enum"
title="input-mode,控制软键盘类型。(仅限 Web 平台符合条件的高版本浏览器或webview)。"
@change="radio_change_inputmode_enum"
></enum-data>
<boolean-data
:defaultValue="false"
title="是否显示键盘上方带有“完成”按钮那一栏(仅限小程序平台)"
@change="change_show_confirm_bar_boolean"
></boolean-data>
<boolean-data
:defaultValue="false"
title="如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true(仅限小程序平台)"
@change="change_fixed_boolean"
></boolean-data>
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
</scroll-view> </scroll-view>
......
...@@ -164,7 +164,7 @@ ...@@ -164,7 +164,7 @@
api: ["Element.takeSnapshot"] api: ["Element.takeSnapshot"]
}, },
// #endif // #endif
// #ifdef APP-ANDROID // #ifdef APP-ANDROID || WEB
{ {
name: 'element大小变化监听', name: 'element大小变化监听',
url: 'resize-observer' url: 'resize-observer'
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
name: '媒体', name: '媒体',
pages: [ pages: [
{ {
name: "拍照和相册选择", name: "拍摄图片或从相册中选择图片",
url: 'choose-image' url: 'choose-image'
}, },
{ {
...@@ -348,6 +348,36 @@ ...@@ -348,6 +348,36 @@
url: 'save-image-to-photos-album' url: 'save-image-to-photos-album'
}, },
// #endif // #endif
// #ifdef APP-ANDROID
{
name: "获取图片信息",
url: 'get-image-info'
},
{
name: "压缩图片",
url: 'compress-image'
},
// #endif
// #ifdef APP
// {
// name: "拍摄视频或从相册中选择视频",
// url: 'choose-video'
// },
{
name: "保存视频到相册",
url: 'save-video-to-photos-album'
},
// #endif
// #ifdef APP-ANDROID
{
name: "获取视频信息",
url: 'get-video-info'
},
// {
// name: "压缩视频",
// url: 'compress-video'
// },
// #endif
/* { /* {
name: "图片选择和拍照", name: "图片选择和拍照",
url: "image", url: "image",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册