获取当前 page
const page = getCurrentPages()[getCurrentPages().length - 1];小程序
页面、存储、分享、列表与 Tab 等小程序片段。 — 共 15 条
共 15 条代码片段
const page = getCurrentPages()[getCurrentPages().length - 1];const value = e.currentTarget.dataset.value;<view class="mask" catchtouchmove="true"></view>const sys = wx.getSystemInfoSync();
this.setData({
iPhoneX: sys.model.indexOf("iPhone X") !== -1,
});data: {
iPhoneX: app.sysinfo.isIphoneX,
},wx.getStorageSync("key");
wx.setStorageSync("key", val);wx.showShareMenu({
withShareTicket: true,
});const animation = wx.createAnimation({
duration: 600,
timingFunction: "ease",
});
this.animation = animation;const animation = this.animation;
animation.translateY(0).step();
this.setData({
animation: animation.export(),
});onShareAppMessage() {
return {
title: title,
path: "/pages/play/index?id=" + this.roomId + "&isShare=1",
imageUrl: "",
};
}wx.chooseImage({
count: 1,
success: (res) => {
const tempFilePaths = res.tempFilePaths;
wx.showLoading({ mask: true });
tempFilePaths.map((item) => {
// 上传逻辑
app.upimage(item, (res) => {});
});
},
});previewImage(e) {
const src = e.currentTarget.dataset.src;
wx.previewImage({
current: src,
urls: [src],
});
}wx.chooseAddress({
success: (res) => {
this.setData({
addressInfo: {
userName: res.userName,
telNumber: res.telNumber,
provinceName: res.provinceName,
cityName: res.cityName,
countyName: res.countyName,
detailInfo: res.detailInfo,
postalCode: res.postalCode,
},
});
},
});"onReachBottomDistance": 400"usingComponents": {
"topbanner": "/components/topbanner/index",
"login": "/components/login/index",
"w-modal": "/components/handle/modal/index"
}<view class="list" wx:if="{{list.length}}">
<view class="item" wx:for="{{list}}" wx:key="id">
<!-- ... -->
</view>
</view>
<view class="no-data" wx:if="{{isLoading && !list.length}}">暂无信息</view>data: {
list: [],
page: 1,
isEnd: false,
isLoading: false,
},
onPullDownRefresh() {
this.setData({ list: [], page: 1, isEnd: false });
this.getList();
},
onReachBottom() {
this.getList();
},<view class="tab-head">
<view
wx:for="{{tabMenu}}"
class="item {{tabType == item.type ? 'on' : ''}}"
bindtap="changeTab"
data-type="{{item.type}}"
data-name="{{item.name}}"
>{{item.name}}</view>
</view>data: {
tabMenu: [
{ name: "待接单", type: 0 },
{ name: "已接单", type: 2 },
{ name: "已退款", type: 1 },
],
tabType: 0,
},
changeTab(e) {
this.setData({
tabType: e.currentTarget.dataset.type,
list: [],
isEnd: false,
page: 1,
});
this.getList();
},