123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- import HomeApi from '../../services/home'
- import { share } from '../../utils/http'
- // pages/atphotos/index.ts
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- cid: -1,
- idx: 0,
- loading: false,
- tabs: [] as {
- title: string
- acname: string
- acid: number
- }[],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad({ id }: { id: string }) {
- this.setData({
- loading: true,
- })
- HomeApi.GetExtraItemDetail({
- id,
- })
- .then((rsp) => {
- const result = rsp.result
- this.setData({
- tabs: result.albums,
- idx: 0,
- cid: result.albums[0].acid,
- loading: false,
- })
- // this.setData({
- // loading: false,
- // wait: false,
- // allItems: items,
- // idx: -1,
- // cates,
- // total: currentItems.length,
- // items: currentItems,
- // views: takes,
- // viewcnt: takes.length,
- // })
- wx.setNavigationBarTitle({
- // @ts-ignore
- title: result.title,
- })
- })
- .catch(() => {
- this.setData({
- loading: false,
- })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {},
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- // 当页面触底时触发的事件
- const myComponent = this.selectComponent('#nlist')
- if (myComponent) {
- myComponent.fetchNext() // 调用组件的加载数据方法
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- let pages = getCurrentPages(); //获取所有页面栈实例列表
- let nowPage = pages[pages.length - 1]; //当前页页面实例
- return {
- title: share.title,
- path: `/${nowPage.route}`,
- imageUrl: share.imageUrl,
- success(res) {
- console.log('success(res)==', res);
- },
- fail(res) {
- console.log('fail(res)==', res);
- }
- }
- },
- onTabChange(event: WechatMiniprogram.CustomEvent<{}, {}, { index: number }>) {
- const idx = event.currentTarget.dataset.index
- this.setData({
- idx,
- cid: this.data.tabs[idx].acid,
- })
- },
- })
|