Closed chenfeiyu0128 closed 5 years ago
刚提交了,拉取最新代码。不必须,组件自身data的也可以放在自身,不用放在store
组件的私有 data 也可以放在自身的 data 上,不用挂在 store.data 上,但是不能通过 this.update 更新,只能通过 setData
拉取了,但是还是在子页面的data上挂了数据 会被全部清空,相当去小程序现在appdata里面只有store.js的数据 而没有 store.
要把store里对应的key去掉
拉取最新,已经修复。组件和page可以有私有数据,需要setData来更新私有数据
页面声明了data但是没有用,一定要在storejs 声明data吗`//index.js //获取应用实例 import store from '../../store' import create from '../../utils/create' var app = getApp() const http = require('wehttp') create(store,{ data: { islogin: false, offline: false, remind: '加载中',
}, //分享 onShareAppMessage: function () { return { title: 'We重邮', desc: '碎片化、一站式、一体化校园移动门户', path: '/pages/index/index' }; }, //下拉更新 onPullDownRefresh: function () { if (app._user.is_bind) { this.getCardData(); } else { wx.stopPullDownRefresh(); } }, checkbind(userID) {
}, onShow: function () { //this.update() //var that = this //this.store.data.cores = {} var _this = this; var that = this; // console.log("onshow") var res = app.islogin() if (res != false) { that.setData({ islogin: true, })
}, onLoad: function () { this.login(); if (this.data.user = {}) { console.log("没登录") } }, userInfoHandler(data) { var that = this wx.BaaS.handleUserInfo(data).then(res => { // res 包含用户完整信息,详见下方描述 that.setData({ islogin: true, }) app.globalData.userinfo = res console.log(res) that.getCardData(); }, res => { // res 有两种情况:用户拒绝授权,res 包含基本用户信息:id、openid、unionid;其他类型的错误,如网络断开、请求超时等,将返回 Error 对象(详情见下方注解) }) }, login: function () { var _this = this; console.log(app.islogin()) //如果有缓存,则提前加载缓存 // 微信用户登录小程序
}, response: function (status) { var _this = this; if (status) { if (status != '离线缓存模式') { //错误 _this.setData({ 'remind': status }); return; } else { //离线缓存模式 _this.setData({ offline: true }); } } _this.setData({ user: app._user }); //判断绑定状态 if (!app._user.is_bind) { _this.setData({ 'remind': '未绑定' }); } else { _this.setData({ 'remind': '加载中' }); _this.getCardData(); } }, disabled_item: function () { var _this = this; if (!_this.data.disabledItemTap) { _this.setData({ disabledItemTap: true }); setTimeout(function () { _this.setData({ disabledItemTap: false }); }, 2000); } }, //课表渲染 kbRender(info) { if (info) { var classlist = info } else { var classlist = wx.getStorageInfoSync('kb_today') }
}, //获取当前时间 getCurrentWeekday() { var myDate = new Date(); return myDate.getDay(); }, getCardData: function () { var _this = this; var student_ID = _this.data.student_ID var student_Password = _this.data.student_Password //判断并读取缓存
} });`