|
@@ -0,0 +1,155 @@
|
|
|
+
|
|
|
+
|
|
|
+var dever =
|
|
|
+{
|
|
|
+
|
|
|
+ init : function()
|
|
|
+ {
|
|
|
+ if (!this.config) {
|
|
|
+ this.config = require('config.js').config;
|
|
|
+ this.setting = {};
|
|
|
+ this.log('init config', this.config);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,title : function(title)
|
|
|
+ {
|
|
|
+ wx.setNavigationBarTitle({
|
|
|
+ title: title
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,getData : function(event)
|
|
|
+ {
|
|
|
+ return event.currentTarget.dataset;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,save : function(key, value)
|
|
|
+ {
|
|
|
+ wx.setStorageSync(key, value);
|
|
|
+ this.log('save ' + key, value);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,getSave: function (key) {
|
|
|
+ wx.getStorageSync(key)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,setSetting : function(value)
|
|
|
+ {
|
|
|
+ this.setting = value;
|
|
|
+ this.log('init server setting', this.setting);
|
|
|
+ if (value.title) {
|
|
|
+ this.title(value.title);
|
|
|
+ } else if(value.name) {
|
|
|
+ this.title(value.name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,set : function(self, key, value)
|
|
|
+ {
|
|
|
+ var data = {};
|
|
|
+ data[key] = value;
|
|
|
+ this.sets(self, data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,setList: function (self, value) {
|
|
|
+ this.set(self, 'list', value);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ , setView: function (self, value) {
|
|
|
+ this.set(self, 'view', value);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,sets: function (self, data) {
|
|
|
+ this.log('data', data);
|
|
|
+ self.setData(data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,package : function(name)
|
|
|
+ {
|
|
|
+ return require('package/' + name + '.js');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,html : function()
|
|
|
+ {
|
|
|
+ var wxParse = this.package('wxParse');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,request : function(url, param, callback, method)
|
|
|
+ {
|
|
|
+ if (!method) {
|
|
|
+ method = 'get';
|
|
|
+ }
|
|
|
+ return this.package('network').request(this, url, param, callback, method);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,alert : function(msg, title)
|
|
|
+ {
|
|
|
+ wx.showToast({
|
|
|
+ title: msg,
|
|
|
+ icon: 'success',
|
|
|
+ duration: 3000
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,location : function(url)
|
|
|
+ {
|
|
|
+ this.log('location', url);
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../../template/' + url,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,goBack: function(delta){
|
|
|
+ if(typeof delta == 'undefined') delta = 1;
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: delta
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,log : function(title, msg)
|
|
|
+ {
|
|
|
+ if (this.config.debug) {
|
|
|
+ console.log('dever debug -- ' + title, msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,startPullDown : function(self)
|
|
|
+ {
|
|
|
+ wx.showNavigationBarLoading();
|
|
|
+ self.onLoad();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,stopPullDown: function () {
|
|
|
+ wx.hideNavigationBarLoading();
|
|
|
+ wx.stopPullDownRefresh();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ,carts: function(self, save, path)
|
|
|
+ {
|
|
|
+ this.package('carts').load(self, save, path);
|
|
|
+ }
|
|
|
+}
|
|
|
+dever.init();
|
|
|
+module.exports = {
|
|
|
+ load: dever
|
|
|
+}
|