123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- // pages/store/index.js
- /**
- * 店铺管理
- */
- import * as API_Shop from '../../api/shop.js'
- import * as Common from '../../utils/common.js'
- import * as API_Passport from '../../api/passport.js'
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- shopLogo: '',
- changeShopShow: false,
- changeShopValue: '',
- shops: [],
- todayOrderNum: 0,
- todayOrderTotal: 0,
- loaded:false,
- shopAdminMemberId: null,
- userId: null
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- const that=this
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- attached:function(){
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- console.log('onshow')
- let that = this
- that.getCurrentShopData()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- },
- gridClick(e) {
- const {
- name
- } = e.currentTarget.dataset
- switch (name) {
- case 'product':
- {
- wx.switchTab({
- url: '/pages/goods/goods-list',
- })
- break
- }
- case 'business':
- {
- wx.navigateTo({
- url: '/pages/store/businessSetting',
- })
- break
- }
- case 'orderquery':
- {
- wx.switchTab({
- url: '/pages/order/index',
- })
- break
- }
- case 'shopsetting':
- {
- wx.navigateTo({
- url: '/pages/shop/shop-edit',
- })
- break
- }
- case 'aftersale':{
- wx.navigateTo({
- url: '/pages/aftersale/index',
- })
- break
- }
- case 'withdrawApply':{
- wx.navigateTo({
- url: '/pages/fund/withdrawApply',
- })
- break
- }
- case 'withdrawAccount':{
- wx.navigateTo({
- url: '/pages/fund/withdrawAccount',
- })
- break
- }
- case 'bill':{
- wx.navigateTo({
- url: '/pages/bill/index',
- })
- }
- case 'statistic':{
- wx.navigateTo({
- url: '/pages/statistic/statisticNav',
- })
- }
- }
- },
- getO2OShops() {
- API_Shop.getO2OShops({
- contains_current: 1
- }).then(res => {
- this.setData({
- shops: [...res],
- changeShopShow: true
- })
- })
- },
- changeShopShowClose(e) {
- this.setData({
- changeShopShow: false
- })
- },
- onChangeShop(e) {
- const {
- value
- } = e.detail
- this.setData({
- changeShopValue: value
- })
- const that = this
- API_Shop.changeLoginShop(value).then(res => {
- const {
- access_token,
- refresh_token,
- access_token_timeout,
- refresh_token_timeout
- } = res
- const authorInfo=app.globalData.authorInfo
- const now=Date.parse(new Date())/1000
- app.globalData.authorInfo={...authorInfo,
- 'access_token':access_token,
- 'refresh_token':refresh_token,'refresh_token_timeout':now+refresh_token_timeout-1000,'access_token_timeout':now+access_token_timeout-1000}
- wx.setStorageSync('authorInfo', app.globalData.authorInfo)
- that.getCurrentShopData()
- that.setData({
- changeShopShow: false
- })
- })
- },
- /** 加载店铺信息 **/
- getCurrentShopData(){
- const that=this
- Common.getCurrentShopData().then(res => {
- console.log('res',res)
- that.setData({
- shopLogo: app.globalData.sellerShop.shop_logo,
- shopName: app.globalData.sellerShop.shop_name,
- startTime: app.globalData.sellerShop.start_time,
- endTime: app.globalData.sellerShop.end_time,
- shop_state: app.globalData.sellerShop.shop_state,
- bool_o2o: app.globalData.authorInfo.bool_o2o,
- shopAdminMemberId: app.globalData.sellerShop.member_id,
- userId: app.globalData.authorInfo.uid
- })
- console.log('begininit')
- that.getTabBar().init()
- //数据加载完成后1秒展现
- setTimeout(function() {that.setData({
- loaded:true,
- todayOrderNum: app.globalData.todayOrderNum,
- todayOrderTotal: app.globalData.todayOrderTotal,
- })
- let i = 0;
- if(app.globalData.todayOrderNum>0||app.globalData.todayOrderTotal>0){
- numDH()
- }
- function numDH() {
- clearTimeout()
- if (i < 20) {
- setTimeout(function () {
- that.setData({
- todayOrderNum: i,
- todayOrderTotal: i,
- })
- i++
- numDH();
- }, 20)
- } else {
- that.setData({
- todayOrderNum: app.globalData.todayOrderNum,
- todayOrderTotal: app.globalData.todayOrderTotal,
- })
- }
- }
- }, 1000);
- }).catch(err=>{
- wx.showToast({
- title:err.message,
- icon:'none'
- })
- })
- }
- })
|