123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- const { getShopInfo } = require('./api/index')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- nav: [
- {
- icon: 'goods_release.png',
- name: '产品发布',
- path: 'businessGoodsEdit'
- },
- {
- icon: 'goods_manage.png',
- name: '产品管理',
- path: 'businessGoodsManage'
- }
- ],
- shopInfo: {},
- products: [],
- isFetchLock: false, // 接口调用加锁
- isRefresh: false, // 是否下拉刷新
- finished: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.fetchShopInfo()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- onPullDownRefresh() {
- if (this.data.isRefresh) {
- return
- }
- this.setData({
- isRefresh: true,
- finished: false
- })
- this.fetchShopInfo()
- },
- bindCallBack() {
- this.fetchShopInfo()
- },
- jump(e) {
- const { path, tabvalue = '' } = e.currentTarget.dataset
- wx.navigateTo({
- url: `/pages/${path}/${path}?tabvalue=${tabvalue}`
- })
- },
- handleNav(e) {
- const { item } = e.currentTarget.dataset
- const path = item.path
- wx.navigateTo({
- url: `/pages/${path}/${path}`
- })
- },
- async fetchShopInfo() {
- const that = this
- const isRefresh = that.data.isRefresh
- if (that.data.isFetchLock) {
- return
- }
- that.setData({
- isFetchLock: true
- })
- try {
- const { status, data, msg } = await getShopInfo()
- if (status) {
- this.setData({
- shopInfo: data,
- products: data.products
- })
- } else {
- wx.showToast({
- title: msg,
- icon: 'none'
- })
- }
- } catch (err) {}
- this.setData({
- isFetchLock: false,
- isRefresh: false,
- finished: true
- })
- if (isRefresh) {
- wx.stopPullDownRefresh()
- }
- },
- jumpBusinessInfo() {
- wx.navigateTo({
- url: '/pages/businessInfo/businessInfo'
- })
- }
- })
|