我需要从我的服务器获取数据并将模型与我的本地存储同步
这是我的代码
模型.js
Ext.define('bluebutton.model.BlueButton.Loyalty', {
extend: 'Ext.data.Model',
config: {
idProperty: 'loyaltyModel',
fields: [
{ name: 'fullName' },
{ name: 'age' },
{ name: 'lastvisited' },
{ name: 'consumer_bbID' },
{ name: 'merchant_bbID' },
{ name: 'sessionId' },
{ name: 'deviceId' },
{ name: 'updatedPoint' },
{ name: 'currentPoint' },
{ name: 'action' },
{ name: 'result' },
{ name: 'loyaltyMembership_Id'}
],
proxy: {
type: 'rest',
url: 'http://192.168.251.131:8080/WebCommon/rest/BBWebService/updateLoyaltyCardPoint',
reader: 'json',
actionMethods: {
create: 'POST',
read: 'POST',
update: 'PUT',
destroy: 'DELETE'
},
noCache: false, // get rid of the '_dc' url parameter
// extraParams: {
// userid: "test",
// // add as many as you need
// },
// timeout:300,
// listeners: {
// exception: function(proxy, response, operation) {
// alert("Connection Problem");
//
// }
// },
reader: {
type: 'json',
},
writer: {
type: 'json',
},
}
}
});
Store.js
Ext.define('bluebutton.store.BlueButton.LoginLS', {
extend: "Ext.data.Store",
requires: ['bluebutton.model.BlueButton.Login'],
config: {
model :'bluebutton.model.BlueButton.Login',
proxy: {
type: 'localstorage',
id: 'loginLS'
}
}
});
查看.js
Ext.define('bluebutton.view.Login', {
extend: 'Ext.form.Panel',
xtype: 'loginview',
id: 'loginview',
requires: [
'bluebutton.view.Main',
'Ext.field.Password',
'bluebutton.store.BlueButton.LoginLS'
],
config: {
labelWidth: 80,
frame: true,
title: 'Please Login',
items: [
{
xtype: 'textfield',
id: 'bbID',
label: 'User ID',
},
{
xtype: 'passwordfield',
id: 'bbPassword',
label: 'Password',
},
{
xtype: 'button',
text: 'Login',
id:'btnLogin',
// handler: function () {
// }
},
当我按下登录按钮时,如何将我的模型与本地存储同步?请指导我解决方案