diff --git a/fair_online/fair_online_service/fairDir/empty/project/empty_project/assets/fair/lib_page_hotel_listview_hotel_listview_template.fair.js b/fair_online/fair_online_service/fairDir/empty/project/empty_project/assets/fair/lib_page_hotel_listview_hotel_listview_template.fair.js index 3c6e7d02..3805c152 100644 --- a/fair_online/fair_online_service/fairDir/empty/project/empty_project/assets/fair/lib_page_hotel_listview_hotel_listview_template.fair.js +++ b/fair_online/fair_online_service/fairDir/empty/project/empty_project/assets/fair/lib_page_hotel_listview_hotel_listview_template.fair.js @@ -1 +1,121 @@ -GLOBAL['#FairKey#']=(function(__initProps__){const __global__=this;defineModule(1,function(__mod__){with(__mod__.imports){}},[]);return runCallback(function(__mod__){with(__mod__.imports){function HotelModel(){const inner=HotelModel.__inner__;if(this==__global__){return new HotelModel({__args__:arguments});}else{const args=arguments.length>0?arguments[0].__args__||arguments:[];inner.apply(this,args);HotelModel.prototype.ctor.apply(this,args);return this;}}HotelModel.__inner__=function inner(){this.imagePath='';this.titleTxt='';this.subTxt='';this.dist='';this.reviews='';this.perNight='';};HotelModel.prototype={};HotelModel.prototype.ctor=function(){};function _HotelListViewState(){const inner=_HotelListViewState.__inner__;if(this==__global__){return new _HotelListViewState({__args__:arguments});}else{const args=arguments.length>0?arguments[0].__args__||arguments:[];inner.apply(this,args);_HotelListViewState.prototype.ctor.apply(this,args);return this;}}_HotelListViewState.__inner__=function inner(){this._listData=[];this._page=0;};_HotelListViewState.prototype={initState:function initState(){const __thiz__=this;with(__thiz__){onLoad();}},onLoad:function onLoad(){const __thiz__=this;with(__thiz__){requestData();}},onUnload:function onUnload(){const __thiz__=this;with(__thiz__){}},requestData:function requestData(){const __thiz__=this;with(__thiz__){_page++;FairNet().requestData(convertObjectLiteralToSetOrMap({['pageName']:'#FairKey#',['method']:'GET',['url']:'https://wos2.58cdn.com.cn/DeFazYxWvDti/frsupload/3be6c61070d3b48c8165af5d18464c0e_hotel_list_data.json',['data']:convertObjectLiteralToSetOrMap({['page']:_page,}),['success']:function dummy(resp){if(resp==null){return null;}let data=resp.__op_idx__('data');data.forEach(function dummy(item){let dataItem=HotelModel();try{dataItem.imagePath=item.imagePath;dataItem.titleTxt=item.titleTxt;dataItem.subTxt=item.subTxt;dataItem.dist=item.dist+' km';dataItem.reviews=item.reviews+' reviews';dataItem.perNight=item.perNight+'';}catch(e){dataItem.imagePath=item.__op_idx__('imagePath');dataItem.titleTxt=item.__op_idx__('titleTxt');dataItem.subTxt=item.__op_idx__('subTxt');dataItem.dist=`${item['dist']} km`;dataItem.reviews=`${item['reviews']} reviews`;dataItem.perNight=`${item['perNight']}`;}_listData.add(dataItem);});setState('#FairKey#',function dummy(){});},}));}},isDataEmpty:function isDataEmpty(){const __thiz__=this;with(__thiz__){return _listData.isEmpty;}},};_HotelListViewState.prototype.ctor=function(){};;return _HotelListViewState();}},[1]);})(convertObjectLiteralToSetOrMap(JSON.parse('#FairProps#'))); \ No newline at end of file +GLOBAL['#FairKey#'] = (function(__initProps__) { + const __global__ = this; + return runCallback(function(__mod__) { + with(__mod__.imports) { + function HotelModel() { + const inner = HotelModel.__inner__; + if (this == __global__) { + return new HotelModel({ + __args__: arguments + }); + } else { + const args = arguments.length > 0 ? arguments[0].__args__ || arguments: []; + inner.apply(this, args); + HotelModel.prototype.ctor.apply(this, args); + return this; + } + } + HotelModel.__inner__ = function inner() { + this.imagePath = ''; + this.titleTxt = ''; + this.subTxt = ''; + this.dist = ''; + this.reviews = ''; + this.perNight = ''; + }; + HotelModel.prototype = {}; + HotelModel.prototype.ctor = function() {}; + function _HotelListViewState() { + const inner = _HotelListViewState.__inner__; + if (this == __global__) { + return new _HotelListViewState({ + __args__: arguments + }); + } else { + const args = arguments.length > 0 ? arguments[0].__args__ || arguments: []; + inner.apply(this, args); + _HotelListViewState.prototype.ctor.apply(this, args); + return this; + } + } + _HotelListViewState.__inner__ = function inner() { + this._listData = []; + this._page = 0; + }; + _HotelListViewState.prototype = { + initState: function initState() { + const __thiz__ = this; + with(__thiz__) { + onLoad(); + } + }, + onLoad: function onLoad() { + const __thiz__ = this; + with(__thiz__) { + requestData(); + } + }, + onUnload: function onUnload() { + const __thiz__ = this; + with(__thiz__) {} + }, + requestData: function requestData() { + const __thiz__ = this; + with(__thiz__) { + _page++; + FairNet().requestData(convertObjectLiteralToSetOrMap({ ['pageName'] : '#FairKey#', + ['method'] : 'GET', + ['url'] : 'https://wos2.58cdn.com.cn/DeFazYxWvDti/frsupload/3be6c61070d3b48c8165af5d18464c0e_hotel_list_data.json', + ['data'] : convertObjectLiteralToSetOrMap({ ['page'] : _page, + }), + ['success'] : function dummy(resp) { + if (resp == null) { + return null; + } + let data = resp.__op_idx__('data'); + data.forEach(function dummy(item) { + let dataItem = HotelModel(); + try { + dataItem.imagePath = item.imagePath; + dataItem.titleTxt = item.titleTxt; + dataItem.subTxt = item.subTxt; + dataItem.dist = item.dist + ' km'; + dataItem.reviews = item.reviews + ' reviews'; + dataItem.perNight = item.perNight + ''; + } catch(e) { + dataItem.imagePath = item.__op_idx__('imagePath'); + dataItem.titleTxt = item.__op_idx__('titleTxt'); + dataItem.subTxt = item.__op_idx__('subTxt'); + dataItem.dist = `$ { + item['dist'] + } + km`; + dataItem.reviews = `$ { + item['reviews'] + } + reviews`; + dataItem.perNight = `$ { + item['perNight'] + }`; + } + _listData.add(dataItem); + }); + setState('#FairKey#', + function dummy() {}); + }, + })); + } + }, + isDataEmpty: function isDataEmpty() { + const __thiz__ = this; + with(__thiz__) { + return _listData.isEmpty; + } + }, + }; + _HotelListViewState.prototype.ctor = function() {};; + return _HotelListViewState(); + } + }, + []); +})(convertObjectLiteralToSetOrMap(JSON.parse('#FairProps#'))); \ No newline at end of file diff --git a/fair_online/fair_online_service/fairDir/empty/project/empty_project/web/plugin/fair_net_plugin.js b/fair_online/fair_online_service/fairDir/empty/project/empty_project/web/plugin/fair_net_plugin.js index 06186fac..9b76fed9 100644 --- a/fair_online/fair_online_service/fairDir/empty/project/empty_project/web/plugin/fair_net_plugin.js +++ b/fair_online/fair_online_service/fairDir/empty/project/empty_project/web/plugin/fair_net_plugin.js @@ -5,12 +5,12 @@ let callBackId = 0; let FairNet = function () { return { - request: function (resp) { + requestData: function (resp) { let respMap = {}; respMap = mapOrSetToObject(resp); let id = 'FairNet$' + (++callBackId); let requestParameter = {}; - requestParameter['className'] = "FairNet#request"; + requestParameter['className'] = "FairNet#requestData"; callBack[id] = [respMap['complete'], respMap['error'], respMap['success']]; respMap['callId'] = id; requestParameter['funcName'] = 'invokePlugin'; diff --git a/fair_online/fair_online_service/fairDir/template/project/fair_samples/web/plugin/fair_net_plugin.js b/fair_online/fair_online_service/fairDir/template/project/fair_samples/web/plugin/fair_net_plugin.js index 06186fac..9b76fed9 100644 --- a/fair_online/fair_online_service/fairDir/template/project/fair_samples/web/plugin/fair_net_plugin.js +++ b/fair_online/fair_online_service/fairDir/template/project/fair_samples/web/plugin/fair_net_plugin.js @@ -5,12 +5,12 @@ let callBackId = 0; let FairNet = function () { return { - request: function (resp) { + requestData: function (resp) { let respMap = {}; respMap = mapOrSetToObject(resp); let id = 'FairNet$' + (++callBackId); let requestParameter = {}; - requestParameter['className'] = "FairNet#request"; + requestParameter['className'] = "FairNet#requestData"; callBack[id] = [respMap['complete'], respMap['error'], respMap['success']]; respMap['callId'] = id; requestParameter['funcName'] = 'invokePlugin';