This commit is contained in:
2025-09-14 00:21:54 +08:00
commit d40b3bbd62
766 changed files with 36275 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
.btn-area > *{
margin: 20px 0;
}

View File

@@ -0,0 +1,91 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
data: {
alertText: '警示文案',
itemColor: '#ff0000',
itemListLength: 4,
apiData: {
content: '',
success: false,
fail: false,
complete: false
}
},
handleAlertText(e) {
this.setData({
alertText: e.detail.value
});
},
handleItemColor(e) {
this.setData({
itemColor: e.detail.value
});
},
handleItemListLength(e) {
this.setData({
itemListLength: e.detail.value
});
},
resetApiData() {
this.setData({
apiData: {
success: false,
fail: false,
complete: false,
content: ''
}
});
},
updateApiData(type, content) {
const apiData = {
...this.data.apiData
};
apiData[type] = true;
apiData.content = content;
this.setData({
apiData
});
},
onShareAppMessage() {
return {
title: '操作菜单',
path: 'packageAPI/pages/action-sheet/action-sheet'
};
},
itemList() {
return Array(this.data.itemListLength - 0).fill('item');
},
common(options) {
this.resetApiData();
xhs.showActionSheet({
...options,
success: res => {
this.updateApiData('success', res);
},
fail: res => {
this.updateApiData('fail', res);
},
complete: res => {
this.updateApiData('complete', res);
}
});
},
actionSheetTap() {
this.common({
itemList: this.itemList()
});
},
actionSheetTapAlertText() {
this.common({
alertText: this.data.alertText,
itemList: this.itemList()
});
},
actionSheetTapColor() {
this.common({
itemList: this.itemList(),
itemColor: this.data.itemColor
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "操作菜单",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,23 @@
<view class="container">
<showbox title="操作菜单">
<box>
<view class="_ui-space">
<view class="_ui-input">
<input type="text" placeholder="警示文案" bindinput="handleAlertText" />
</view>
<view class="_ui-input">
<input type="text" placeholder="itemColor: #ff0000" bindinput="handleItemColor" />
</view>
<view class="_ui-input">
<input type="text" placeholder="itemList长度" bindinput="handleItemListLength" />
</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="actionSheetTap">弹出action sheet</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="actionSheetTapAlertText">警示文案</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="actionSheetTapColor">Color</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,65 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: "",
page_data_1: "",
page_data_2: "",
page_data_3: false,
page_data_4: false,
page_data_5: false,
page_data_6: "",
},
page_fun_1(e) {
this.setData("page_data_0", e.detail.value);
},
page_fun_2(e) {
this.setData("page_data_1", e.detail.value);
},
page_fun_3(e) {
this.setData("page_data_2", e.detail.value);
},
page_fun_0() {
this.setData({
page_data_3: false,
page_data_4: false,
page_data_5: false,
});
xhs.showActionSheet({
success: (res) => {
console.log("success", res);
this.setData({
page_data_3: true,
page_data_6: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_4: true,
page_data_6: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_5: true,
});
},
alertText: this.data.page_data_0,
itemList: this.data.page_data_1,
itemColor: this.data.page_data_2,
});
},
};

View File

@@ -0,0 +1,36 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="showActionSheet演示">
<box>
<api-status
success="{{page_data_3}}"
complete="{{page_data_5}}"
fail="{{page_data_4}}"
text="{{page_data_6}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input placeholder="alertText" type="text" bindinput="page_fun_1" />
</view>
<view class="_ui-input">
<input placeholder="itemList" type="text" bindinput="page_fun_2" />
</view>
<view class="_ui-input">
<input placeholder="itemColor" type="text" bindinput="page_fun_3" />
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,3 @@
.mt-8 {
margin-top: 8px;
}

View File

@@ -0,0 +1,44 @@
Page({
data: {
authInfo: "",
showLoading: true,
},
bindInput(e) {
this.setData({
authInfo: e.detail.value
});
},
changeLoading(e) {
this.setData({
showLoading: e.detail.value
});
},
auth() {
if (!xhs.alipayAuth) {
xhs.showModal({
title: 'xhs.alipayAuth 方法不存在'
});
}
const { authInfo, showLoading } = this.data;
console.log("%c Line:19 🍆 authInfo", "color:#ffdd4d", authInfo);
console.log("%c Line:19 🌽 showLoading", "color:#ed9ec7", showLoading);
xhs.alipayAuth({
authInfo,
showLoading,
success(res) {
xhs.showModal({
title: '支付宝授权成功',
content: JSON.stringify(res),
});
},
fail(err) {
xhs.showModal({
title: '支付宝授权失败',
content: JSON.stringify(err),
});
}
});
}
});

View File

@@ -0,0 +1,7 @@
{
"navigationBarTitleText": "支付宝信息授权",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index"
}
}

View File

@@ -0,0 +1,34 @@
<view class="container">
<showbox title="支付宝信息授权">
<box>
<view class="_ui-input">
<text style="word-break:break-all;">输入的 authInfo 为: {{authInfo}}</text>
</view>
<view class="_ui-input">
<input
value="{{authInfo}}"
placeholder="填参数 authInfo类型字符串"
placeholder-style="color: #3333334D;"
bindinput="bindInput"
maxlength="3000"
/>
</view>
<view class="_ui-input">
修改 showLoading
<switch
style="transform:scale(0.7)"
checked="{{showLoading}}"
color="rgba(255, 36, 66, 1)"
bindchange="changeLoading"
/>
</view>
<view class="_ui-space mt-8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="auth"
>点击授权</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,38 @@
.card-area {
overflow: hidden;
border-radius: 8px 8px;
}
.animation-element-wrapper {
position: relative;
display: flex;
overflow: hidden;
height: 200px;
margin: 10px 17px;
border-radius: 8px 8px;
background-color: #fff;
}
.animation-element {
width: 46px;
height: 46px;
margin-top: 54px;
margin-left: 124px;
background-color: #ff2442;
}
.flexBottom {
position: fixed;
bottom: 0;
width: 100%;
}
.scroll {
height: 275px;
}
.animation-element2 {
width: 46px;
height: 46px;
background-color: #ff2442;
}

View File

@@ -0,0 +1,126 @@
Page({
data: {
isIPhoneX: false,
animation: {},
animationData: {}
},
onLoad() {
this.animation = xhs.createAnimation({
duration: 1000,
timingFunction: 'ease',
delay: 0,
transformOrigin: '50% 50% 0',
});
this.animation2 = xhs.createAnimation({
timingFunction: 'linear',
});
this.scroll();
},
rotate() {
this.animation.rotate(Math.random() * 720 - 360).step();
this.setData({
animation: this.animation.export(),
});
},
scale() {
this.animation.scale(Math.random() * 2).step();
this.setData({
animation: this.animation.export(),
});
},
translate() {
this.animation.translate(Math.random() * 100 - 50, Math.random() * 100 - 50).step();
this.setData({
animation: this.animation.export(),
});
},
skew() {
this.animation.skew(Math.random() * 90, Math.random() * 90).step();
this.setData({
animation: this.animation.export(),
});
},
rotateAndScale() {
this.animation
.rotate(Math.random() * 720 - 360)
.scale(Math.random() * 2)
.step();
this.setData({
animation: this.animation.export(),
});
},
rotateThenScale() {
this.animation
.rotate(Math.random() * 720 - 360)
.step()
.scale(Math.random() * 2)
.step();
this.setData({
animation: this.animation.export(),
});
},
all() {
this.animation
.rotate(Math.random() * 720 - 360)
.scale(Math.random() * 2)
.translate(Math.random() * 100 - 50, Math.random() * 100 - 50)
.skew(Math.random() * 90, Math.random() * 90)
.step();
this.setData({
animation: this.animation.export(),
});
},
allInQueue() {
this.animation
.rotate(Math.random() * 720 - 360)
.step()
.scale(Math.random() * 2)
.step()
.translate(Math.random() * 100 - 50, Math.random() * 100 - 50)
.step()
.skew(Math.random() * 90, Math.random() * 90)
.step();
this.setData({
animation: this.animation.export(),
});
},
reset() {
this.animation.rotate(0, 0).scale(1).translate(0, 0).skew(0, 0).step({
duration: 0,
});
this.setData({
animation: this.animation.export(),
});
},
scroll() {
this.animation.translateX(400).step({
duration: 0,
});
this.setData({
animationData: this.animation.export(),
});
setTimeout(() => {
this.animation.translateX(-700).step({
duration: 5000,
delay: 1,
});
const data = this.animation.export();
this.setData({
'animationData.commandSetQueue[0].translateX.rule.value': [-700],
'animationData.commandSetQueue[0].additionalConfiguration': {
duration: 5000,
},
});
}, 1000 / 30);
this.timer = setTimeout(() => {
this.scroll();
}, 2000);
},
});

View File

@@ -0,0 +1,7 @@
{
"navigationBarTitleText": "动画",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index"
}
}

View File

@@ -0,0 +1,32 @@
<view class="container">
<showbox>
<box>
<view class="animation-element-wrapper flexTop">
<view class="animation-element" animation="{{animation}}"></view>
</view>
</box>
</showbox>
<showbox title="展示动画">
<box>
<view class="_ui-space">
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="rotate">旋转</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="scale">缩放</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="translate">移动</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="skew">倾斜</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="rotateAndScale">旋转并缩放</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="rotateThenScale">旋转后缩放</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="all">同时展示全部动作</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="allInQueue">顺序展示全部动作</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="reset">还原</button>
</view>
</box>
</showbox>
<showbox title="无限循环动画">
<box>
<view class="animation-element2" animation="{{animationData}}"></view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,5 @@
._dflex button {
margin: 10px 0;
background-color: red;
color: white;
}

View File

@@ -0,0 +1,29 @@
Page({
onShareAppMessage() {
return {
title: 'arrayBuffer2base64/base642ArrayBuffer',
path: 'api-case/base64arraybuffer/base64arraybuffer',
};
},
data: {
value: '',
content: [],
},
handleInput(e) {
this.setData({ value: e.detail.value });
},
handleArrayBufferToBase64() {
const base64 = xhs.arrayBufferToBase64(this.data.content);
console.log(base64);
this.setData({ content: base64 });
},
handleBase64ToArrayBuffer() {
const arrayBuffer = xhs.base64ToArrayBuffer(this.data.value);
this.setData({ content: arrayBuffer });
console.log(arrayBuffer);
},
});

View File

@@ -0,0 +1,7 @@
{
"navigationBarTitleText": "arrayBufferToBase64",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index"
}
}

View File

@@ -0,0 +1,14 @@
<view class="container">
<showbox title="arrayBufferToBase64">
<box>
<view>
<view>结果:{{content}}</view>
<input class="input" placeholder="base64String" type="text" bindinput="handleInput"></input>
<view class="_dflex _fd_column">
<button bindtap="handleBase64ToArrayBuffer">base64ToArrayBuffer</button>
<button bindtap="handleArrayBufferToBase64">arrayBufferToBase64</button>
</view>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,33 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: 'canIUse',
path: 'package/API/pages/caniuse/caniuse'
};
},
data: {
value: '',
content: ''
},
onLoad() {
setTimeout(() => {
this.removeSkeleton();
}, 500);
},
bindinput(e) {
this.setData({
value: e.detail.value
});
},
click() {
this.setData({
content: '初始化'
});
const ret = xhs.canIUse(this.data.value);
this.setData({
content: ret
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "检测api能力",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,15 @@
<view class="container">
<!-- canIUse -->
<showbox title="检验api是否可用">
<box>
<view>
<text>返回值:{{content}}</text>
<view class="_ui-input _my8">
<input placeholder="输入api调用" type="text" bindinput="bindinput"></input>
</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="click">检索</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,51 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: "",
page_data_1: false,
page_data_2: false,
page_data_3: false,
page_data_4: "",
},
page_fun_1(e) {
this.setData("page_data_0", e.detail.value);
},
page_fun_0() {
this.setData({
page_data_1: false,
page_data_2: false,
page_data_3: false,
});
let res;
try {
res = xhs.canIUse(this.data.page_data_0) ?? "无返回值";
} catch (err) {
console.log("fail", res);
this.setData({
page_data_2: true,
page_data_4: JSON.stringify(res),
});
return;
}
console.log("success", res);
this.setData({
page_data_1: true,
page_data_4: JSON.stringify(res),
});
console.log("complete", res);
this.setData({
page_data_3: true,
});
},
};

View File

@@ -0,0 +1,32 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="canIUse演示">
<box>
<api-status
success="{{page_data_1}}"
complete="{{page_data_3}}"
fail="{{page_data_2}}"
text="{{page_data_4}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input
placeholder="canIUseString"
type="text"
bindinput="page_fun_1"
/>
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,25 @@
.screen_state_txt {
display: inline-block;
font-weight: bold;
font-size: 24rpx;
}
.screen_state_hidden {
color: red;
}
.screen_state_none {
color: green;
}
.recording-resp {
border: 1px solid rgba(0,0,0,.1);
background: #f2f2f2;
font-style: italic;
font-size: 24rpx;
padding: 20rpx;
margin: 16rpx;
color: rgba(0, 0, 0, 0.55);
min-height: 200rpx;
border-radius: 20px;
}

View File

@@ -0,0 +1,109 @@
const onScreenRecordingStateHandler = function (res) {
console.log('onScreenRecordingStateChanged', res?.state);
if (res?.state && this.data.recordState !== res?.state) {
this.setData({
recordState: res?.state,
screenRecordingState: res,
});
}
};
function onUserCaptureHandler(res) {
console.log('截屏回调 userCaptureHandler: ', res);
this.setData({
captureScreenTimes: this.data.captureScreenTimes + 1,
});
}
Page({
data: {
// 截屏
visualEffect: 'none',
// 查询录屏的开关状态
isRecording: 'off',
isRecordingState: null,
// 录屏状态
recordState: 'stop',
screenRecordingState: null,
onScreenRecordingStateChanged: false,
onUserCaptureScreen: false,
captureScreenTimes: 0,
},
onLoad() {
// 监听用户截屏事件
const userCaptureHandler = this.userCaptureHandler = onUserCaptureHandler.bind(this);
xhs.onUserCaptureScreen(userCaptureHandler);
// 监听用户录屏事件
const screenRecordingStateHandler = this.screenRecordingStateHandler = onScreenRecordingStateHandler.bind(this);
xhs.onScreenRecordingStateChanged(screenRecordingStateHandler);
xhs.showToast({ title: '正在监听用户截屏事件、录屏事件!!' });
},
handleSetVisualEffectOnCapture() {
const _this = this;
this.setData({
visualEffect: this.data.visualEffect === 'none' ? 'hidden' : 'none',
});
xhs.setVisualEffectOnCapture({
visualEffect: _this.data.visualEffect,
success(res) {
console.log('setVisualEffectOnCapture success', res);
},
fail(err) {
console.log('setVisualEffectOnCapture fail', err.errMsg);
},
});
},
handleGetScreenRecordingState() {
const _this = this;
xhs.getScreenRecordingState({
success(res) {
console.log('getScreenRecordingState success', res?.state);
if (res?.state === 'on') {
_this.setData({
isRecording: 'on',
isRecordingState: res
});
} else {
_this.setData({
isRecording: 'off',
isRecordingState: res
});
}
},
fail(err) {
console.log('getScreenRecordingState fail', err.errMsg);
},
});
},
// 取消「截屏」监听
handleOffCaptureScreen() {
if (this.userCaptureHandler) {
xhs.offUserCaptureScreen(this.userCaptureHandler);
this.userCaptureHandler = null;
} else {
this.userCaptureHandler = onUserCaptureHandler;
}
xhs.showToast({
title: '取消截屏监听, 接下来将无法监听到截屏事件,截屏次数不会更新!',
});
},
// 取消「录屏」监听
handleOffScreenRecordingState() {
if (this.screenRecordingStateHandler) {
xhs.offScreenRecordingStateChanged(this.screenRecordingStateHandler);
this.screenRecordingStateHandler = null;
xhs.showToast({
title: '取消录屏监听, 接下来将无法观测到录屏消息!',
});
this.setData({
screenRecordingState: null
});
}
},
});

View File

@@ -0,0 +1,7 @@
{
"navigationBarTitleText": "截屏录屏 API",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index"
}
}

View File

@@ -0,0 +1,46 @@
<view class="container">
<showbox title="设置截屏/录屏时屏幕表现">
<view class="_pa6">
当前设置: {{visualEffect}}
<view class="screen_state_txt screen_state_hidden" xhs:if="{{visualEffect === 'hidden'}}">【当前录制的屏幕内容将被隐藏】</view>
<view class="screen_state_txt screen_state_none" xhs:else>【当前录制屏幕不受限制】</view>
<button
class="_mt4 _px6 _ui-button"
bindtap="handleSetVisualEffectOnCapture"
>切换截屏/录屏时的表现</button>
</view>
</showbox>
<showbox title="监听用户主动截屏事件">
<view class="_pa6">
当前截屏次数: {{captureScreenTimes}}
<button
bindtap="handleOffCaptureScreen"
class="_mt4 _px6 _ui-button"
>点击取消截屏监听</button>
</view>
</showbox>
<showbox title="查询用户录屏信息">
<view class="_pa6">
当前录屏状态: {{isRecording}}
<button
class="_mt4 _px6 _ui-button"
bindtap="handleGetScreenRecordingState"
>查询用户录屏信息</button>
</view>
<view class="recording-resp">
{{ isRecordingState ? JSON.stringify(isRecordingState, null, 2) : '暂无返回' }}
</view>
</showbox>
<showbox title="监听用户录屏事件【注:该事件仅在 iOS 设备中生效】">
<view class="_pa6">
当前录屏状态: {{recordState}}
<button
class="_mt4 _px6 _ui-button"
bindtap="handleOffScreenRecordingState"
>点击取消录屏监听</button>
</view>
<view class="recording-resp">
{{ screenRecordingState ? JSON.stringify(screenRecordingState, null, 2) : '暂无信息' }}
</view>
</showbox>
</view>

View File

@@ -0,0 +1,29 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: '检查登录状态是否过期',
path: 'package/API/pages/check-session/check-session'
};
},
data: {
isAccess: ''
},
checkSession() {
xhs.checkSession({
success: msg => {
console.log(msg);
this.setData({
isAccess: '已登陆'
});
},
fail: msg => {
this.setData({
show: true,
isAccess: '未登陆或登陆失效'
});
}
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "检查小红书登录状态",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,11 @@
<view class="container">
<showbox title="检验登陆状态">
<box>
<view class="_ui-space">
<view>当前登陆状态:{{isAccess}}</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="checkSession">检查登录状态</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,44 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: false,
page_data_1: false,
page_data_2: false,
page_data_3: "",
},
page_fun_0() {
this.setData({
page_data_0: false,
page_data_1: false,
page_data_2: false,
});
xhs.checkSession({
success: (res) => {
console.log("success", res);
this.setData({
page_data_0: true,
page_data_3: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_1: true,
page_data_3: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_2: true,
});
},
});
},
};

View File

@@ -0,0 +1,24 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="checkSession演示">
<box>
<api-status
success="{{page_data_0}}"
complete="{{page_data_2}}"
fail="{{page_data_1}}"
text="{{page_data_3}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,26 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: '收货地址',
path: 'packageAPI/pages/choose-address/choose-address'
};
},
data: {
addressInfo: null
},
chooseAddress() {
xhs.chooseAddress({
success: res => {
console.log('res:', res);
this.setData({
addressInfo: res
});
},
fail(err) {
console.log('err:', err);
}
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "收货地址",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,38 @@
<view class="container">
<showbox title="默认">
<box>
<view class="_ui-space">
<view>
收货人姓名: {{ addressInfo.userName }}
</view>
<!-- <view>
邮编: {{ addressInfo.postalCode }}
</view> -->
<view>
地区: {{ addressInfo.provinceName }}
{{ addressInfo.cityName }}
{{ addressInfo.countyName }}
</view>
<view>
收货地址: {{ addressInfo.detailInfo }}
</view>
<!-- <view>
国家码: {{ addressInfo.nationalCode }}
</view> -->
<view>
手机号码: {{ addressInfo.telNumber }}
</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="chooseAddress">获取收货地址</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,44 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: false,
page_data_1: false,
page_data_2: false,
page_data_3: "",
},
page_fun_0() {
this.setData({
page_data_0: false,
page_data_1: false,
page_data_2: false,
});
xhs.chooseAddress({
success: (res) => {
console.log("success", res);
this.setData({
page_data_0: true,
page_data_3: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_1: true,
page_data_3: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_2: true,
});
},
});
},
};

View File

@@ -0,0 +1,24 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="chooseAddress演示">
<box>
<api-status
success="{{page_data_0}}"
complete="{{page_data_2}}"
fail="{{page_data_1}}"
text="{{page_data_3}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,6 @@
._dflex button {
margin: 10px 0;
background-color: red;
color: white;
}

View File

@@ -0,0 +1,36 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: '剪切板',
path: 'packageAPI/pages/clipboard-data/clipboard-data'
};
},
data: {
value: 'edit and copy me',
pasted: ''
},
valueChanged(e) {
this.setData({
value: e.detail.value
});
},
copy() {
xhs.setClipboardData({
data: this.data.value,
success: res => {},
fail: res => {}
});
},
paste() {
xhs.getClipboardData({
success: res => {
this.setData({
pasted: res.data
});
},
fail: res => {}
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "剪切板",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,19 @@
<view class="container">
<showbox title="剪切板操作">
<box>
<view>
<view class="_ui-space">
<view>
<view style="text-align: center;">{{pasted}}</view>
<view class="_ui-input">
<input type="text" name="key" value="{{value}}" bindinput="valueChanged"></input>
</view>
</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="copy">复制</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="paste">粘贴</button>
</view>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,90 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: "",
page_data_1: false,
page_data_2: false,
page_data_3: false,
page_data_4: "",
page_data_5: false,
page_data_6: false,
page_data_7: false,
page_data_8: "",
},
page_fun_1(e) {
this.setData("page_data_0", e.detail.value);
},
page_fun_0() {
this.setData({
page_data_1: false,
page_data_2: false,
page_data_3: false,
});
xhs.setClipboardData({
success: (res) => {
console.log("success", res);
this.setData({
page_data_1: true,
page_data_4: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_2: true,
page_data_4: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_3: true,
});
},
data: this.data.page_data_0,
});
},
page_fun_2() {
this.setData({
page_data_5: false,
page_data_6: false,
page_data_7: false,
});
xhs.getClipboardData({
success: (res) => {
console.log("success", res);
this.setData({
page_data_5: true,
page_data_8: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_6: true,
page_data_8: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_7: true,
});
},
});
},
};

View File

@@ -0,0 +1,49 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="setClipboardData演示">
<box>
<api-status
success="{{page_data_1}}"
complete="{{page_data_3}}"
fail="{{page_data_2}}"
text="{{page_data_4}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input placeholder="data" type="text" bindinput="page_fun_1" />
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="getClipboardData演示">
<box>
<api-status
success="{{page_data_5}}"
complete="{{page_data_7}}"
fail="{{page_data_6}}"
text="{{page_data_8}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_2"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,7 @@
._dflex button {
margin: 10px 0;
background-color: red;
color: white;
}

View File

@@ -0,0 +1,77 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
data: {
remoteFilePath: 'https://fe-video-qc.xhscdn.com/fe-platform/541cb4b0e802f5bdd91845e85082132453f8d4f5.pdf',
filePath: '',
fileType: ''
},
onDownload() {
this.task = xhs.downloadFile({
url: this.data.remoteFilePath,
// 文件 ID
success: res => {
console.log('【downloadFile success】:', res);
this.setData({
filePath: res.tempFilePath || res.filePath
});
},
fail: res => {
console.log('【downloadFile fail】:', res);
}
});
if (this.task) {
this.task.onHeadersReceived(res => {
console.log('【onHeadersReceived】:', res);
});
this.task.onProgressUpdate(res => {
console.log('【onProgressUpdate】:', res);
});
}
},
onAbort() {
this.task?.abort();
},
offHeadersReceived() {
this.task?.offHeadersReceived?.(() => {
console.log('【offHeadersReceived】');
});
},
offProgressUpdate() {
this.task?.offProgressUpdate?.(() => {
console.log('【offProgressUpdate】');
});
},
removeSavedFile() {
xhs.removeSavedFile({
filePath: this.data.filePath,
success: res => {
console.log('【removeSavedFile success】', res);
},
fail: res => {
console.log('【removeSavedFile fail】', res);
}
});
},
openDocument() {
xhs.openDocument({
filePath: this.data.filePath,
fileType: this.data.fileType || undefined
});
},
handleRemoteFilePath(e) {
this.setData({
remoteFilePath: e.detail.value
});
},
handleFilePath(e) {
this.setData({
filePath: e.detail.value
});
},
handleFileType(e) {
this.setData({
fileType: e.detail.value
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "下载文件",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,36 @@
<view class="container">
<showbox title="基本使用">
<box>
<view class="_ui-space">
<view>
<text>远程文件路径</text>
<view class="_ui-input">
<input placeholder="远程文件路径" value="{{remoteFilePath}}" bindinput="handleRemoteFilePath"/>
</view>
</view>
<view>
<text>本地文件路径</text>
<view class="_ui-input">
<input placeholder="本地文件路径" value="{{filePath}}" bindinput="handleFilePath"/>
</view>
</view>
<view>
<text>文件类型</text>
<view class="_ui-input">
<input placeholder="文件类型" value="{{fileType}}" bindinput="handleFileType"/>
</view>
</view>
<button bindtap="onDownload" class="_ui-button" hover-class="_ui-button-hover">下载文件</button>
<!-- <button bindtap="onAbort" class="_ui-button" hover-class="_ui-button-hover">abort</button>
<button bindtap="offHeadersReceived" class="_ui-button" hover-class="_ui-button-hover">offHeadersReceived</button>
<button bindtap="offProgressUpdate" class="_ui-button" hover-class="_ui-button-hover">offProgressUpdate</button> -->
<button bindtap="openDocument" class="_ui-button" hover-class="_ui-button-hover">打开文件</button>
<button bindtap="removeSavedFile" class="_ui-button" hover-class="_ui-button-hover">删除文件</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,171 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: "",
page_data_1: "",
page_data_2: "",
page_data_3: "",
page_data_4: false,
page_data_5: false,
page_data_6: false,
page_data_7: "",
page_data_8: "",
page_data_9: "",
page_data_10: false,
page_data_11: false,
page_data_12: false,
page_data_13: "",
page_data_14: "",
page_data_15: false,
page_data_16: false,
page_data_17: false,
page_data_18: "",
},
page_fun_1(e) {
this.setData("page_data_0", e.detail.value);
},
page_fun_2(e) {
this.setData("page_data_1", e.detail.value);
},
page_fun_3(e) {
this.setData("page_data_2", e.detail.value);
},
page_fun_4(e) {
this.setData("page_data_3", e.detail.value);
},
page_fun_0() {
this.setData({
page_data_4: false,
page_data_5: false,
page_data_6: false,
});
xhs.downloadFile({
success: (res) => {
console.log("success", res);
this.setData({
page_data_4: true,
page_data_7: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_5: true,
page_data_7: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_6: true,
});
},
url: this.data.page_data_0,
header: this.data.page_data_1,
timeout: this.data.page_data_2,
filePath: this.data.page_data_3,
});
},
page_fun_6(e) {
this.setData("page_data_8", e.detail.value);
},
page_fun_7(e) {
this.setData("page_data_9", e.detail.value);
},
page_fun_5() {
this.setData({
page_data_10: false,
page_data_11: false,
page_data_12: false,
});
xhs.openDocument({
success: (res) => {
console.log("success", res);
this.setData({
page_data_10: true,
page_data_13: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_11: true,
page_data_13: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_12: true,
});
},
filePath: this.data.page_data_8,
fileType: this.data.page_data_9,
});
},
page_fun_9(e) {
this.setData("page_data_14", e.detail.value);
},
page_fun_8() {
this.setData({
page_data_15: false,
page_data_16: false,
page_data_17: false,
});
xhs.removeSavedFile({
success: (res) => {
console.log("success", res);
this.setData({
page_data_15: true,
page_data_18: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_16: true,
page_data_18: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_17: true,
});
},
filePath: this.data.page_data_14,
});
},
};

View File

@@ -0,0 +1,94 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="downloadFile演示">
<box>
<api-status
success="{{page_data_4}}"
complete="{{page_data_6}}"
fail="{{page_data_5}}"
text="{{page_data_7}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input placeholder="url" type="text" bindinput="page_fun_1" />
</view>
<view class="_ui-input">
<input placeholder="header" type="text" bindinput="page_fun_2" />
</view>
<view class="_ui-input">
<input placeholder="timeout" type="text" bindinput="page_fun_3" />
</view>
<view class="_ui-input">
<input placeholder="filePath" type="text" bindinput="page_fun_4" />
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="openDocument演示">
<box>
<api-status
success="{{page_data_10}}"
complete="{{page_data_12}}"
fail="{{page_data_11}}"
text="{{page_data_13}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input placeholder="filePath" type="text" bindinput="page_fun_6" />
</view>
<view class="_ui-input">
<input placeholder="fileType" type="text" bindinput="page_fun_7" />
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_5"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="removeSavedFile演示">
<box>
<api-status
success="{{page_data_15}}"
complete="{{page_data_17}}"
fail="{{page_data_16}}"
text="{{page_data_18}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input placeholder="filePath" type="text" bindinput="page_fun_9" />
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_8"
>
触发
</button>
</view>
</box>
</showbox>
</view>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,51 @@
@import './assets/iconfont.css';
page > view {
max-width: 100%;
}
.container {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.ql-container {
box-sizing: border-box;
width: 100%;
height: 100%;
font-size: 16px;
line-height: 1.5;
overflow: auto;
border: 1px solid #ececec;
}
.ql-active {
color: #22c704;
}
.iconfont {
display: inline-block;
width: 30px;
height: 30px;
cursor: pointer;
font-size: 20px;
}
.toolbar {
box-sizing: border-box;
padding: 0 10px;
height: 50px;
width: 100%;
position: fixed;
left: 0;
right: 100%;
bottom: 0;
display: flex;
align-items: center;
justify-content: space-between;
border: 1px solid #ececec;
border-left: none;
border-right: none;
}

View File

@@ -0,0 +1,226 @@
const contents = {
html: `
<p>支持插入图片</p>
<br>
<p>
<img src="https://b.bdstatic.com/searchbox/icms/searchbox/img/editor-image-demo.png" data-custom="id=abcd&amp;role=god" alt="image-alt" class="imageCls" width="100%">
</p>
<hr>
<p>支持以下字符样式</p>
<p>
<b>bold粗体</b>
<em>italic斜体</em>
<u>underline下划线</u>
</p>
<p>
<sub>sub下标</sub>
<sup>super上标</sup>
</p>
<hr>
<p>支持以下列表样式</p>
<ol>
<li>有序列表</li>
<li>有序列表</li>
</ol>
<ul>
<li>无序列表</li>
</ul>
<ul>
<li>无序列表</li>
</ul>
<ul data-checked="true">
<li>选框列表</li>
</ul>
<ul data-checked="false">
<li>选框列表</li>
</ul>
<hr>
<p>支持以下字符大小</p>
<h1>H1 一级标题</h1>
<h2>H2 二级标题</h2>
<h3>H3 三级标题</h3>
<h4>H4 四级标题</h4>
<h5>H5 五级标题</h5>
<h6>H6 六级标题</h6>
<hr>
<p>支持以下对齐方式</p>
<p style="text-align:center">center中间对齐</p>
<p style="text-align:right">right 右对齐</p>
<p style="text-align:justify">justify 自动对齐</p>
<hr>
<span style="color:#00bc89;background-color:#333">color 支持设置字体及背景颜色</span>`,
};
Page({
onShareAppMessage() {
return {
title: 'editor',
path: 'page/component/pages/editor/editor',
};
},
data: {
formats: {},
readOnly: false,
placeholder: '开始输入...',
editorHeight: 300,
keyboardHeight: 0,
isIOS: false,
safeHeight: 0,
toolBarHeight: 50,
},
readOnlyChange() {
this.setData({
readOnly: !this.data.readOnly,
});
},
onLoad() {
const { platform, safeArea, model, screenHeight } = xhs.getSystemInfoSync();
let safeHeight;
if (safeArea) {
safeHeight = screenHeight - safeArea.bottom;
} else {
safeHeight = 32;
}
this._safeHeight = safeHeight;
const isIOS = platform === 'ios';
this.setData({ isIOS, safeHeight, toolBarHeight: isIOS ? safeHeight + 50 : 50 });
const that = this;
this.updatePosition(0);
let keyboardHeight = 0;
xhs.onKeyboardHeightChange?.(res => {
if (res.height === keyboardHeight) {
return;
}
const duration = res.height > 0 ? res.duration * 1000 : 0;
keyboardHeight = res.height;
setTimeout(() => {
xhs.pageScrollTo({
scrollTop: 0,
success() {
that.updatePosition(keyboardHeight);
that.editorCtx.scrollIntoView();
},
});
}, duration);
});
},
updatePosition(keyboardHeight) {
const toolbarHeight = 50;
const { windowHeight, platform } = xhs.getSystemInfoSync();
const editorHeight =
keyboardHeight > 0 ? windowHeight - keyboardHeight - toolbarHeight : windowHeight;
if (keyboardHeight === 0) {
this.setData({
editorHeight,
keyboardHeight,
toolBarHeight: this.data.isIOS ? 50 + this._safeHeight : 50,
safeHeight: this._safeHeight,
});
} else {
this.setData({
editorHeight,
keyboardHeight,
toolBarHeight: 50,
safeHeight: 0,
});
}
},
calNavigationBarAndStatusBar() {
const systemInfo = xhs.getSystemInfoSync();
const { statusBarHeight, platform } = systemInfo;
const isIOS = platform === 'ios';
const navigationBarHeight = isIOS ? 44 : 48;
return statusBarHeight + navigationBarHeight;
},
onEditorReady() {
const that = this;
that.editorCtx = xhs.createEditorContext?.('editor');
this.clear();
this.setContents();
this.removeFormat();
this.insertDivider();
setTimeout(() => {
this.editorCtx.getContents({
success: res => {
console.log('getContents success', res);
},
});
}, 1000);
},
blur() {
this.editorCtx.blur();
},
format(e) {
const { name, value } = e.target.dataset;
if (!name) return;
console.log('format', name, value);
this.editorCtx.format(name, value);
},
onStatusChange(e) {
const formats = e.detail;
console.log('onStatusChange', e);
this.setData({ formats });
},
insertDivider() {
this.editorCtx.insertDivider({
success() {
console.log('insert divider success');
},
});
},
clear() {
this.editorCtx.clear({
success(res) {
console.log('clear success', res);
},
});
},
removeFormat() {
this.editorCtx.removeFormat({
success: res => {
console.log('removeFormat success', res);
},
});
},
setContents() {
this.editorCtx.setContents({
...contents,
success: res => {
console.log('setContents success', res);
},
});
},
insertDate() {
const date = new Date();
const formatDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
this.editorCtx.insertText({
text: formatDate,
});
},
insertImage() {
const that = this;
xhs.chooseImage({
count: 1,
success(res) {
that.editorCtx.insertImage({
src: res.tempFilePaths[0],
data: {
id: 'abcd',
role: 'god',
},
width: '80%',
success() {
console.log('insert image success');
},
});
},
});
},
bindfocus(e) {
console.log('bindfocus', e);
},
bindblur(e) {
console.log('bindblur', e);
},
});

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "editor",
"disableScroll": true,
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index"
}
}

View File

@@ -0,0 +1,25 @@
<view class="container" style="height:{{editorHeight}}px;">
<showbox title="默认">
<box>
<editor id="editor" class="ql-container" placeholder="{{placeholder}}" bindstatuschange="onStatusChange" bindready="onEditorReady"
bindblur="bindblur"
bindfocus="bindfocus"
show-img-size
show-img-resize
show-img-toolbar>
</editor>
</box>
</showbox>
</view>
<view class="toolbar" catchtouchend="format" hidden="{{false}}" style="bottom: {{isIOS ? keyboardHeight : 0}}px; height: {{toolBarHeight}}px; padding-bottom: {{isIOS ? safeHeight : 0}}px">
<i class="iconfont icon-charutupian" catchtouchend="insertImage"></i>
<i class="iconfont icon-format-header-2 {{formats.header === 2 ? 'ql-active' : ''}}" data-name="header" data-value="{{2}}"></i>
<i class="iconfont icon-format-header-3 {{formats.header === 3 ? 'ql-active' : ''}}" data-name="header" data-value="{{3}}"></i>
<i class="iconfont icon-zitijiacu {{formats.bold ? 'ql-active' : ''}}" data-name="bold"></i>
<i class="iconfont icon-zitixieti {{formats.italic ? 'ql-active' : ''}}" data-name="italic"></i>
<i class="iconfont icon-zitixiahuaxian {{formats.underline ? 'ql-active' : ''}}" data-name="underline"></i>
<i class="iconfont icon--checklist" data-name="list" data-value="check"></i>
<i class="iconfont icon-youxupailie {{formats.list === 'ordered' ? 'ql-active' : ''}}" data-name="list" data-value="ordered"></i>
<i class="iconfont icon-wuxupailie {{formats.list === 'bullet' ? 'ql-active' : ''}}" data-name="list" data-value="bullet"></i>
</view>

View File

@@ -0,0 +1,7 @@
._dflex button{
margin: 10px 0;
background-color: red;
color: white;
}

View File

@@ -0,0 +1,23 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
data: {
config: ''
},
getExtConfig() {
xhs.getExtConfig({
success: res => {
this.setData({
content: JSON.stringify(res)
});
},
fail: res => {}
});
},
getExtConfigSync() {
const data = xhs.getExtConfigSync();
this.setData({
content: JSON.stringify(data)
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "第三方平台",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,12 @@
<view class="container">
<showbox title="获取第三方平台定义的数据">
<box>
<view class="_ui-space">
<view xhs:if="{{content}}">config: {{content}}</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getExtConfig">异步获取</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getExtConfigSync">同步获取</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,84 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: false,
page_data_1: false,
page_data_2: false,
page_data_3: "",
page_data_4: false,
page_data_5: false,
page_data_6: false,
page_data_7: "",
},
page_fun_0() {
this.setData({
page_data_0: false,
page_data_1: false,
page_data_2: false,
});
xhs.getExtConfig({
success: (res) => {
console.log("success", res);
this.setData({
page_data_0: true,
page_data_3: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_1: true,
page_data_3: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_2: true,
});
},
});
},
page_fun_1() {
this.setData({
page_data_4: false,
page_data_5: false,
page_data_6: false,
});
let res;
try {
res = xhs.getExtConfigSync() ?? "无返回值";
} catch (err) {
console.log("fail", res);
this.setData({
page_data_5: true,
page_data_7: JSON.stringify(res),
});
return;
}
console.log("success", res);
this.setData({
page_data_4: true,
page_data_7: JSON.stringify(res),
});
console.log("complete", res);
this.setData({
page_data_6: true,
});
},
};

View File

@@ -0,0 +1,45 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="getExtConfig演示">
<box>
<api-status
success="{{page_data_0}}"
complete="{{page_data_2}}"
fail="{{page_data_1}}"
text="{{page_data_3}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="getExtConfigSync演示">
<box>
<api-status
success="{{page_data_4}}"
complete="{{page_data_6}}"
fail="{{page_data_5}}"
text="{{page_data_7}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_1"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,14 @@
.image {
width: 100%;
height: 330px;
}
.page-body-info {
display: flex;
box-sizing: border-box;
padding: 15px;
height: 410px;
border-top: 1px solid var(--weui-FG-3);
border-bottom: 1px solid var(--weui-FG-3);
align-items: center;
justify-content: center;
}

View File

@@ -0,0 +1,133 @@
Page({
onShareAppMessage() {
return {
title: '文件',
path: 'packageAPI/pages/file/file',
};
},
onLoad() {
this.setData({
savedFilePath: xhs.getStorageSync('savedFilePath'),
});
},
data: {
tempFilePath: '',
savedFilePath: '',
dialog: {
hidden: true,
},
filePath: '',
fileType: '',
fileTypes: [
{
key: 'doc',
value: 'doc格式'
},
{
key: 'docx',
value: 'docx格式'
},
{
key: 'xls',
value: 'xls格式'
},
{
key: 'xlsx',
value: 'xlsx格式'
},
{
key: 'ppt',
value: 'ppt格式'
},
{
key: 'pptx',
value: 'pptx格式'
},
{
key: 'pdf',
value: 'pdf格式'
}
]
},
chooseImage() {
const that = this;
xhs.chooseImage({
count: 1,
success(res) {
that.setData({
tempFilePath: res.tempFilePaths[0],
});
},
});
},
saveFile() {
if (this.data.tempFilePath.length > 0) {
const that = this;
xhs.saveFile({
tempFilePath: this.data.tempFilePath,
success(res) {
that.setData({
savedFilePath: res.savedFilePath,
});
xhs.setStorageSync('savedFilePath', res.savedFilePath);
that.setData({
dialog: {
title: '保存成功',
content: '下次进入应用时,此文件仍可用',
hidden: false,
},
});
},
fail() {
that.setData({
dialog: {
title: '保存失败',
content: '应该是有 bug 吧',
hidden: false,
},
});
},
});
}
},
clear() {
xhs.setStorageSync('savedFilePath', '');
this.setData({
tempFilePath: '',
savedFilePath: '',
});
},
confirm() {
this.setData({
'dialog.hidden': true,
});
},
chooseFile() {
},
openFile() {
console.log(this.data.filePath);
console.log(this.data.fileType);
xhs.openDocument({
filePath: this.data.filePath,
fileType: this.data.fileType || undefined,
success(res) {
console.log(res);
},
fail(res) {
console.log(res);
}
});
},
handleFilePath(e) {
this.setData({ filePath: e.detail.value });
},
handleFileType(e) {
this.setData({ fileType: e.detail.value });
},
});

View File

@@ -0,0 +1,7 @@
{
"navigationBarTitleText": "文件",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index"
}
}

View File

@@ -0,0 +1,41 @@
<view class="container">
<showbox title="默认">
<box>
<!-- <view class="page-section">
<view class="page-body-info">
<block xhs:if="{{tempFilePath != ''}}">
<image src="{{tempFilePath}}" class="image" mode="aspectFit"></image>
</block>
<block xhs:if="{{tempFilePath === '' && savedFilePath != ''}}">
<image src="{{savedFilePath}}" class="image" mode="aspectFit"></image>
</block>
<block xhs:if="{{tempFilePath === '' && savedFilePath === ''}}">
<view class="image-plus image-plus-nb" bindtap="chooseImage">
<view class="image-plus-horizontal"></view>
<view class="image-plus-vertical"></view>
</view>
<view class="image-plus-text" bindtap="chooseFile">请选择文件</view>
</block>
</view>
<view class="btn-area">
<button type="primary" bindtap="saveFile">保存文件</button>
<button bindtap="clear">删除文件</button>
</view>
</view> -->
<view>文件类型:</view>
<view xhs:for="{{fileTypes}}">
{{item.key}}{{item.value}}
</view>
<view class="_ui-input">
<input placeholder="输入文件路径" value="{{filePath}}" bindinput="handleFilePath"/>
</view>
<view class="_ui-input">
<input placeholder="输入文件类型" value="{{fileType}}" bindinput="handleFileType"/>
</view>
<view>
<button class="_bcred" type="primary" bindtap="openFile">打开文件</button>
</view>
</box>
</showbox>
<modal title="{{dialog.title}}" hidden="{{dialog.hidden}}" no-cancel bindconfirm="confirm">{{dialog.content}}</modal>
</view>

View File

@@ -0,0 +1,25 @@
/* @import '../common/lib/weui.css'; */
.page-section {
margin-top: 100px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
padding: 0 25px;
box-sizing: border-box;
}
.page-body-title {
font-size: 30px;
line-height: 100px;
}
.page-body-text {
color: #bbb;
font-size: 14px;
line-height: 20px;
margin: 0 0 50px 0;
text-align: center;
}
.page-body-button {
width: 100%;
}

View File

@@ -0,0 +1,21 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: 'get-account-info-sync',
path: 'package/API/pages/get-account-info-sync/get-account-info-sync'
};
},
data: {
ret: '',
content: ''
},
getAccountInfoSync() {
const ret = xhs.getAccountInfoSync();
this.setData({
ret: JSON.stringify(ret)
});
console.log('ret', ret);
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "获取账户信息",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,12 @@
<view class="container">
<showbox title="获取账户信息">
<box>
<view class="_ui-space">
<view class="_text_wrap">账户信息:{{ret}}</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getAccountInfoSync">获取账户信息</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,84 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: false,
page_data_1: false,
page_data_2: false,
page_data_3: "",
page_data_4: false,
page_data_5: false,
page_data_6: false,
page_data_7: "",
},
page_fun_0() {
this.setData({
page_data_0: false,
page_data_1: false,
page_data_2: false,
});
let res;
try {
res = xhs.getAccountInfoSync() ?? "无返回值";
} catch (err) {
console.log("fail", res);
this.setData({
page_data_1: true,
page_data_3: JSON.stringify(res),
});
return;
}
console.log("success", res);
this.setData({
page_data_0: true,
page_data_3: JSON.stringify(res),
});
console.log("complete", res);
this.setData({
page_data_2: true,
});
},
page_fun_1() {
this.setData({
page_data_4: false,
page_data_5: false,
page_data_6: false,
});
xhs.openUserProfile({
success: (res) => {
console.log("success", res);
this.setData({
page_data_4: true,
page_data_7: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_5: true,
page_data_7: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_6: true,
});
},
});
},
};

View File

@@ -0,0 +1,45 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="getAccountInfoSync演示">
<box>
<api-status
success="{{page_data_0}}"
complete="{{page_data_2}}"
fail="{{page_data_1}}"
text="{{page_data_3}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="openUserProfile演示">
<box>
<api-status
success="{{page_data_4}}"
complete="{{page_data_6}}"
fail="{{page_data_5}}"
text="{{page_data_7}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_1"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,23 @@
Page({
onShareAppMessage() {
return {
title: '获取电池信息',
path: 'packageAPI/pages/get-battery-info/get-battery-info',
};
},
data: {
},
getBatteryInfo() {
xhs.getBatteryInfo({
complete: res => {
const msg = res.isCharging ? '充电中' : '使用电池中';
this.setData({
level: res.level,
isCharging: msg,
});
},
});
},
});

View File

@@ -0,0 +1,5 @@
{
"usingComponents": {},
"navigationBarTitleText": "获取手机设备电量"
}

View File

@@ -0,0 +1,27 @@
<view class="container">
<view class="page-body">
<view class="page-section">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_input">
<view class="weui-cell__hd">
<view class="weui-label">当前电量</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" type="text" disabled="{{true}}" placeholder="未获取" value="{{level}}"></input>
</view>
</view>
<view class="weui-cell weui-cell_input">
<view class="weui-cell__hd">
<view class="weui-label">电池模式</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" type="text" disabled="{{true}}" placeholder="未获取" value="{{isCharging}}"></input>
</view>
</view>
</view>
<button type="primary" bind:tap="getBatteryInfo" >
获取电量信息信息
</button>
</view>
</view>
</view>

View File

@@ -0,0 +1,200 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: '获取位置',
path: 'packageAPI/pages/get-location/get-location'
};
},
data: {
count: 0,
hasLocation: false,
altitude: false,
isHighAccuracy: false,
highAccuracyExpireTime: 0,
latitude: 12.1,
longitude: 12.1,
type: 'wgs84',
apiData: {
content: '',
success: false,
fail: false,
complete: false
},
choosedLocation: {
name: '',
address: '',
latitude: '',
longitude: ''
},
getLoaction: {
accuracy: '',
altitude: '',
horizontalAccuracy: '',
latitude: '',
longitude: '',
speed: '',
verticalAccuracy: ''
}
},
resetApiData() {
this.setData({
apiData: {
success: false,
fail: false,
complete: false,
content: ''
}
});
},
updateApiData(type, content) {
const apiData = {
...this.data.apiData
};
apiData[type] = true;
apiData.content = content;
this.setData({
apiData
});
},
getLocation() {
this.resetApiData();
xhs.getLocation({
success: res => {
this.setData({
getLoaction: res
});
console.log('getlocation', res);
},
fail: res => {
this.updateApiData('fail', res);
},
complete: res => {
this.updateApiData('complete', res);
}
});
},
startLocationUpdate() {
this.resetApiData();
xhs.startLocationUpdate({
success: res => {
this.updateApiData('success', res);
xhs.showToast({
title: '已开启位置服务'
});
},
fail: res => {
this.updateApiData('fail', res);
},
complete: res => {
this.updateApiData('complete', res);
}
});
},
startLocationUpdateBackground() {
this.resetApiData();
xhs.startLocationUpdateBackground({
success: res => {
this.updateApiData('success', res);
},
fail: res => {
this.updateApiData('fail', res);
},
complete: res => {
this.updateApiData('complete', res);
}
});
},
stopLocationUpdate() {
this.resetApiData();
xhs.stopLocationUpdate({
success: res => {
this.updateApiData('success', res);
xhs.showToast({
title: '已关闭位置服务'
});
},
fail: res => {
this.updateApiData('fail', res);
},
complete: res => {
this.updateApiData('complete', res);
}
});
},
chooseLocation() {
this.resetApiData();
xhs.chooseLocation({
latitude: this.data.latitude - 0,
longitude: this.data.longitude - 0,
success: res => {
this.setData({
choosedLocation: res
});
},
fail: res => {
this.updateApiData('fail', res);
},
complete: res => {
this.updateApiData('complete', res);
}
});
},
onLocationChange() {
this.resetApiData();
this.offLocation = xhs.onLocationChange(res => {
this.updateApiData('success', res);
this.setData({
count: this.data.count + 1
});
});
},
offLocationChange() {
if (this?.offLocation?.remove) {
this.offLocation.remove();
}
this.updateApiData('success');
},
handleAltitude(e) {
this.setData({
altitude: e.detail.value
});
},
handleHighAccuracy(e) {
this.setData({
isHighAccuracy: e.detail.value
});
},
handleHighAccuracyExpireTime(e) {
this.setData({
highAccuracyExpireTime: e.detail.value - 0
});
},
handleType(e) {
this.setData({
type: e.detail.value
});
},
handleLongitude(e) {
this.setData({
longitude: e.detail.value - 0
});
},
handleLatitude(e) {
this.setData({
latitude: e.detail.value - 0
});
},
openLocation() {
xhs.openLocation({
latitude: 31.215442551782044,
longitude: 121.47457688571865,
address: '上海市黄浦区马当路356号',
name: '小红书总部',
complete: res => {
console.log('【openLocation】', res);
}
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "获取位置",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,57 @@
<view class="container">
<showbox title="选择位置">
<box>
<view class="_ui-space">
<view>名称:{{choosedLocation.name}}</view>
<view>地址:{{choosedLocation.address}}</view>
<view>经度:{{choosedLocation.latitude}}</view>
<view>纬度:{{choosedLocation.longitude}}</view>
<!-- <view class="_ui-input _my8">
<input type="text" value="{{latitude}}" bindinput="handleLatitude" />
</view>
<view class="_ui-input _mb8">
<input type="text" value="{{longitude}}" bindinput="handleLongitude" />
</view> -->
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="chooseLocation">选择位置</button>
</view>
</box>
</showbox>
<showbox title="获取当前位置">
<box>
<view class="_ui-space">
<view>纬度:{{getLoaction.latitude}}</view>
<view>经度:{{getLoaction.longitude}}</view>
<view>速度:{{getLoaction.speed}}</view>
<view>位置的精确度:{{getLoaction.accuracy}}</view>
<view>高度:{{getLoaction.altitude}}</view>
<view>垂直精度:{{getLoaction.verticalAccuracy}}</view>
<view>水平精度:{{getLoaction.horizontalAccuracy}}</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getLocation">获取当前位置</button>
</view>
</box>
</showbox>
<showbox title="使用内置地图">
<box>
<view class="_ui-space">
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="openLocation">使用内置地图查看</button>
</view>
</box>
</showbox>
<showbox title="实时获取位置">
<box>
<view class="_ui-space">
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="startLocationUpdate">开启接受位置消息</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="stopLocationUpdate">关闭接受位置消息</button>
<!-- <button class="_ui-button" hover-class="_ui-button-hover" bindtap="onLocationChange">绑定监控位置事件</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="offLocationChange">取消监控位置事件</button> -->
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,295 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: "",
page_data_1: false,
page_data_2: false,
page_data_3: false,
page_data_4: "",
page_data_5: false,
page_data_6: false,
page_data_7: false,
page_data_8: "",
page_data_9: false,
page_data_10: false,
page_data_11: false,
page_data_12: "",
page_data_13: false,
page_data_14: false,
page_data_15: false,
page_data_16: "",
page_data_17: "",
page_data_18: "",
page_data_19: false,
page_data_20: false,
page_data_21: false,
page_data_22: "",
page_data_23: "",
page_data_24: "",
page_data_25: "",
page_data_26: "",
page_data_27: "",
page_data_28: false,
page_data_29: false,
page_data_30: false,
page_data_31: "",
},
page_fun_1(e) {
this.setData("page_data_0", e.detail.value);
},
page_fun_0() {
this.setData({
page_data_1: false,
page_data_2: false,
page_data_3: false,
});
xhs.getLocation({
success: (res) => {
console.log("success", res);
this.setData({
page_data_1: true,
page_data_4: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_2: true,
page_data_4: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_3: true,
});
},
type: this.data.page_data_0,
});
},
page_fun_2() {
this.setData({
page_data_5: false,
page_data_6: false,
page_data_7: false,
});
xhs.startLocationUpdate({
success: (res) => {
console.log("success", res);
this.setData({
page_data_5: true,
page_data_8: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_6: true,
page_data_8: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_7: true,
});
},
});
},
page_fun_3() {
this.setData({
page_data_9: false,
page_data_10: false,
page_data_11: false,
});
xhs.startLocationUpdateBackground({
success: (res) => {
console.log("success", res);
this.setData({
page_data_9: true,
page_data_12: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_10: true,
page_data_12: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_11: true,
});
},
});
},
page_fun_4() {
this.setData({
page_data_13: false,
page_data_14: false,
page_data_15: false,
});
xhs.stopLocationUpdate({
success: (res) => {
console.log("success", res);
this.setData({
page_data_13: true,
page_data_16: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_14: true,
page_data_16: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_15: true,
});
},
});
},
page_fun_6(e) {
this.setData("page_data_17", e.detail.value);
},
page_fun_7(e) {
this.setData("page_data_18", e.detail.value);
},
page_fun_5() {
this.setData({
page_data_19: false,
page_data_20: false,
page_data_21: false,
});
xhs.chooseLocation({
success: (res) => {
console.log("success", res);
this.setData({
page_data_19: true,
page_data_22: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_20: true,
page_data_22: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_21: true,
});
},
latitude: this.data.page_data_17,
longitude: this.data.page_data_18,
});
},
page_fun_9(e) {
this.setData("page_data_23", e.detail.value);
},
page_fun_10(e) {
this.setData("page_data_24", e.detail.value);
},
page_fun_11(e) {
this.setData("page_data_25", e.detail.value);
},
page_fun_12(e) {
this.setData("page_data_26", e.detail.value);
},
page_fun_13(e) {
this.setData("page_data_27", e.detail.value);
},
page_fun_8() {
this.setData({
page_data_28: false,
page_data_29: false,
page_data_30: false,
});
xhs.openLocation({
success: (res) => {
console.log("success", res);
this.setData({
page_data_28: true,
page_data_31: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_29: true,
page_data_31: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_30: true,
});
},
latitude: this.data.page_data_23,
longitude: this.data.page_data_24,
scale: this.data.page_data_25,
name: this.data.page_data_26,
address: this.data.page_data_27,
});
},
};

View File

@@ -0,0 +1,161 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="getLocation演示">
<box>
<api-status
success="{{page_data_1}}"
complete="{{page_data_3}}"
fail="{{page_data_2}}"
text="{{page_data_4}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input placeholder="type" type="text" bindinput="page_fun_1" />
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="startLocationUpdate演示">
<box>
<api-status
success="{{page_data_5}}"
complete="{{page_data_7}}"
fail="{{page_data_6}}"
text="{{page_data_8}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_2"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="startLocationUpdateBackground演示">
<box>
<api-status
success="{{page_data_9}}"
complete="{{page_data_11}}"
fail="{{page_data_10}}"
text="{{page_data_12}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_3"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="stopLocationUpdate演示">
<box>
<api-status
success="{{page_data_13}}"
complete="{{page_data_15}}"
fail="{{page_data_14}}"
text="{{page_data_16}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_4"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="chooseLocation演示">
<box>
<api-status
success="{{page_data_19}}"
complete="{{page_data_21}}"
fail="{{page_data_20}}"
text="{{page_data_22}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input placeholder="latitude" type="text" bindinput="page_fun_6" />
</view>
<view class="_ui-input">
<input placeholder="longitude" type="text" bindinput="page_fun_7" />
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_5"
>
触发
</button>
</view>
</box>
</showbox>
<showbox title="openLocation演示">
<box>
<api-status
success="{{page_data_28}}"
complete="{{page_data_30}}"
fail="{{page_data_29}}"
text="{{page_data_31}}"
>
</api-status>
<view class="_ui-space _mt8">
<view class="_ui-input">
<input placeholder="latitude" type="text" bindinput="page_fun_9" />
</view>
<view class="_ui-input">
<input placeholder="longitude" type="text" bindinput="page_fun_10" />
</view>
<view class="_ui-input">
<input placeholder="scale" type="text" bindinput="page_fun_11" />
</view>
<view class="_ui-input">
<input placeholder="name" type="text" bindinput="page_fun_12" />
</view>
<view class="_ui-input">
<input placeholder="address" type="text" bindinput="page_fun_13" />
</view>
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_8"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,31 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: '获取手机网络状态',
path: 'packageAPI/pages/get-network-type/get-network-type'
};
},
data: {
hasNetworkType: false
},
getNetworkType() {
const that = this;
xhs.getNetworkType({
success(res) {
console.log(res);
that.setData({
hasNetworkType: true,
networkType: res.subtype || res.networkType
});
}
});
},
clear() {
this.setData({
hasNetworkType: false,
networkType: ''
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "获取手机网络状态",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,11 @@
<view class="container">
<showbox title="获取手机网络状态">
<box>
<view class="_ui-space">
<view class="_my8">网络状态:{{networkType}}</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getNetworkType">获取手机网络状态</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,44 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: false,
page_data_1: false,
page_data_2: false,
page_data_3: "",
},
page_fun_0() {
this.setData({
page_data_0: false,
page_data_1: false,
page_data_2: false,
});
xhs.getNetworkType({
success: (res) => {
console.log("success", res);
this.setData({
page_data_0: true,
page_data_3: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_1: true,
page_data_3: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_2: true,
});
},
});
},
};

View File

@@ -0,0 +1,24 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="getNetworkType演示">
<box>
<api-status
success="{{page_data_0}}"
complete="{{page_data_2}}"
fail="{{page_data_1}}"
text="{{page_data_3}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,8 @@
._dflex button {
margin: 10px 0;
}
._dflex > view {
margin: 6px 0;
}

View File

@@ -0,0 +1,30 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: '获取手机系统信息',
path: '/api-case/get-system-info/get-system-info'
};
},
data: {
systemInfo: {}
},
getSystemInfo() {
xhs.getSystemInfo({
success: res => {
this.setData({
systemInfo: res
});
},
fail: res => {},
complete: res => {}
});
},
getSystemInfoSync() {
const data = xhs.getSystemInfoSync();
this.setData({
systemInfo: data
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "获取手机系统信息",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,18 @@
<view class="container">
<showbox title="获取手机信息">
<box>
<view class="_ui-space">
<view>手机品牌:{{systemInfo.brand}}</view>
<view>手机型号:{{systemInfo.model}}</view>
<view>小红书语言:{{systemInfo.language}}</view>
<view>小红书版本:{{systemInfo.version}}</view>
<view>屏幕宽度:{{systemInfo.windowWidth}}</view>
<view>屏幕高度:{{systemInfo.windowHeight}}</view>
<view>DPR{{systemInfo.pixelRatio}}</view>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getSystemInfo">获取手机系统信息</button>
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getSystemInfoSync">同步获取手机系统信息</button>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,44 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: false,
page_data_1: false,
page_data_2: false,
page_data_3: "",
},
page_fun_0() {
this.setData({
page_data_0: false,
page_data_1: false,
page_data_2: false,
});
xhs.getSystemInfo({
success: (res) => {
console.log("success", res);
this.setData({
page_data_0: true,
page_data_3: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_1: true,
page_data_3: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_2: true,
});
},
});
},
};

View File

@@ -0,0 +1,24 @@
<!-- 以下内容为自动生成,请勿手动修改 -->
<view class="container">
<showbox title="getSystemInfo演示">
<box>
<api-status
success="{{page_data_0}}"
complete="{{page_data_2}}"
fail="{{page_data_1}}"
text="{{page_data_3}}"
>
</api-status>
<view class="_ui-space _mt8">
<button
class="_ui-button"
hover-class="_ui-button-hover"
bindtap="page_fun_0"
>
触发
</button>
</view>
</box>
</showbox>
</view>

View File

@@ -0,0 +1,44 @@
const __templateJs = require("./templates.js");
const __mergePageOptions = require("../../util/mergePageOptions.js");
Page(__mergePageOptions({
onShareAppMessage() {
return {
title: '获取用户信息',
path: 'packageAPI/pages/get-user-info/get-user-info'
};
},
data: {
apiData: {
content: '',
success: false,
fail: false,
complete: false
},
info: ''
},
resetApiData() {
this.setData({
apiData: {
success: false,
fail: false,
complete: false,
content: ''
}
});
},
updateApiData(type, content) {
const apiData = {
...this.data.apiData
};
apiData[type] = true;
apiData.content = content;
this.setData({
apiData
});
},
getUserInfo(e) {
this.setData({
info: JSON.stringify(e)
});
}
}, __templateJs));

View File

@@ -0,0 +1,8 @@
{
"navigationBarTitleText": "获取用户信息",
"usingComponents": {
"showbox": "../../common/component/showbox/index",
"box": "../../common/component/container/index",
"api-status": "../../common/component/api-status/index"
}
}

View File

@@ -0,0 +1,16 @@
<view class="container">
<showbox title="获取用户信息">
<box>
<view class="_ui-space">
<view class="_text_wrap">
用户信息:
{{info}}
</view>
<view>
<button class="_ui-button" hover-class="_ui-button-hover" open-type="getUserInfo" bindgetuserinfo="getUserInfo">获取用户信息</button>
</view>
</view>
</box>
</showbox>
</view>
<include src="templates.xhsml" />

View File

@@ -0,0 +1,44 @@
/** 以下内容为自动生成,请勿手动修改 */
module.exports = {
data: {
page_data_0: false,
page_data_1: false,
page_data_2: false,
page_data_3: "",
},
page_fun_0() {
this.setData({
page_data_0: false,
page_data_1: false,
page_data_2: false,
});
xhs.getUserProfile({
success: (res) => {
console.log("success", res);
this.setData({
page_data_0: true,
page_data_3: JSON.stringify(res),
});
},
fail: (res) => {
console.log("fail", res);
this.setData({
page_data_1: true,
page_data_3: JSON.stringify(res),
});
},
complete: (res) => {
console.log("complete", res);
this.setData({
page_data_2: true,
});
},
});
},
};

Some files were not shown because too many files have changed in this diff Show More