import { getStoreOverView, getStoreInfo, depositStore } from "../../../api/ztb" const math = require('../../../utils/math') const util = require('../../../utils/util') const tdsdk = require('../../../libs/tdweapp') const app = getApp() Page({ data: { iconList: [ { index: 0, icon: 'pick', color: 'gray', badge: 0, name: '我要卖货' }, { index: 1, icon: 'edit', color: 'gray', badge: 0, name: '发布竞价' }, { index: 5, icon: 'shop', color: 'gray', badge: 0, name: '编辑店铺' }, { index: 7, icon: 'form', color: 'gray', badge: 0, name: '发布采购' } ], form: { margin: 0, todayMargin: 0, todayMarginNum: 0 }, detail: null, hasStore: 0, status: null, imageHeight: 0, imgList: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog') this.setData({ hasStore: app.globalData.userInfo.hasStore }) }, onShow: function () { wx.showLoading({ title: '加载中', mask: true }) // get/store-overview getStoreOverView().then(result => { //成功回调 app.globalData.userInfo.hasStore = result.data.hasStore this.setData({ form: result.data, hasStore: result.data.hasStore, status: result.data.status }) this.data.status = result.data.status if (this.data.hasStore && result.data.status != 2) { this.showDialog() } if(this.data.form.storeId){ getStoreInfo(this.data.form.storeId).then(res => { this.setData({ detail: res.data, imgList: res.data.coverImgUrlList, imageHeight: math.divide(math.times(750, 9), 16)}) wx.hideLoading() }).catch(err => { wx.hideLoading() }) } else { wx.hideLoading() } }).catch(err => { //异常回调 wx.hideLoading() }) }, showDialog: function(){ this.wuxDialog.open({ resetOnClose: true, maskClosable: false, title: '温馨提示', content: '您还没有完善店铺信息,现在去善店铺信息?', buttons: [{ text: '取消' }, { text: '确定', type: 'primary', onTap(e) { wx.navigateTo({ url: '/pages/shop/create/index' }) } }] }) }, onClose: function(){ this.setData({visible: false}) }, onImageClick: function(){ this.setData({visible: false}) wx.navigateTo({ url: '/pages/ztbvip/index' }) }, apllyShop: function(){ if(!app.globalData.userInfo.isAuth){ this.wuxDialog.open({ resetOnClose: true, title: '温馨提示', content: '您还没有进行个人信息认证,无法开店,现在去进行个人信息认证?', buttons: [{ text: '确定', type: 'primary', onTap(e) { wx.navigateTo({ url: '/pages/home/idcard/index' }) } }] }) return } if(!app.globalData.userInfo.isVIP){ this.setData({visible: true}) return } if (!app.globalData.userInfo.hasStore) { if(this.data.form.status == 1){ wx.navigateTo({ url: '/pages/shop/create/index' }) } else { wx.showLoading({ title: '加载中', mask: true }) depositStore().then(result => { //成功回调 app.globalData.userInfo.hasStore = 1 this.data.form.status == 1 wx.hideLoading() wx.navigateTo({ url: '/pages/shop/create/index' }) }).catch(err => { wx.hideLoading() util.showToast(err) }) } } else if(this.data.form.storeId){ if(this.data.form.status == 2){ wx.navigateTo({ url: '/pages/shop/detail/index?storeId=' + this.data.form.storeId }) } else { wx.navigateTo({ url: '/pages/shop/create/index' }) } } }, onGridTap: function (e) { if (!app.globalData.userInfo.hasStore) { this.wuxDialog.open({ resetOnClose: true, maskClosable: false, title: '温馨提示', content: '您还没有开店,请先申请开店吧!', buttons: [ { text: '确定', type: 'primary' }] }) return } if (this.data.form.status != 2) { this.showDialog() return } var index = e.currentTarget.dataset.index if (index === 0) { wx.navigateTo({ url: '/pages/goods/create/index?type=1' }) } else if (index === 1) { wx.navigateTo({ url: '/pages/goods/create/index?type=2' }) } else if (index === 2) { wx.navigateTo({ url: '/pages/shop/bidding/index' }) } else if (index === 3) { wx.navigateTo({ url: '/pages/goods/index/index' }) } else if (index === 4) { wx.navigateTo({ url: '/pages/shop/order/index?storeId=' + this.data.form.storeId }) } else if (index === 5) { wx.navigateTo({ url: '/pages/shop/create/index?storeId=' + this.data.form.storeId }) } else if (index === 6) { wx.navigateTo({ url: '/pages/shop/bill/index' }) } else if (index === 7) { wx.navigateTo({ url: '/submodel/pages/purchase/create/index' }) } else if (index === 8) { wx.navigateTo({ url: '/submodel/pages/purchase/index/index?storeId=' + this.data.form.storeId }) } }, viewImage: function(e){ wx.previewImage({ urls: this.data.imgList, current: e.currentTarget.dataset.url }); }, onShow: function () { tdsdk.Page.onShow() }, onHide: function(){ tdsdk.Page.onHide() }, onUnload: function () { tdsdk.Page.onUnload() } })