kitchendDevice/unpackage/dist/build/mp-weixin/pageTwo/count/search.js

1 line
8.2 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pageTwo/count/search"],{"2e8a":function(t,e,i){"use strict";i.d(e,"b",(function(){return o})),i.d(e,"c",(function(){return a})),i.d(e,"a",(function(){return n}));var n={uniIcons:function(){return Promise.all([i.e("common/vendor"),i.e("uni_modules/uni-icons/components/uni-icons/uni-icons")]).then(i.bind(null,"5de9"))}},o=function(){var t=this,e=t.$createElement,i=(t._self._c,t.search_list.length),n=i?null:t.history_food.length,o=!i&&n?t.history_food.length:null,a=i||!n||t.showAll?null:t.history_food.slice(0,10),c=t.search_list.length,s=t.ActiveList.length,r=s?t.ActiveList.length:null,h=s&&r?t.ActiveList.length:null,u=t.isShop?t.ActiveList.length:null,l=t.isShop?t.ActiveList.length:null,f=t.IsWeight?t.__map(t.activeType.nutrients_four,(function(e,i){var n=t.__get_orig(e),o=t.unitConversion(e.unit),a=Number(t.activeType.weight/100*e.value).toFixed(1);return{$orig:n,m0:o,g10:a}})):null,d=t.IsWeight?t.__map(t.activeType.nutrients_list,(function(e,i){var n=t.__get_orig(e),o=Number(e.value*t.activeType.weight/100).toFixed(2);return{$orig:n,g11:o}})):null;t._isMounted||(t.e0=function(e){t.showAll=!t.showAll},t.e1=function(e,i){var n=arguments[arguments.length-1].currentTarget.dataset,o=n.eventParams||n["event-params"];i=o.item;return t.handleSearchHistory(i.keyword)},t.e2=function(e){t.showAutoSearchDlg=!1},t.e3=function(e){t.isShop=!t.isShop},t.e4=function(e){t.isShop=!1},t.e5=function(e){t.IsWeight=!1},t.e6=function(e){t.IsWeight=!1}),t.$mp.data=Object.assign({},{$root:{g0:i,g1:n,g2:o,g3:a,g4:c,g5:s,g6:r,g7:h,g8:u,g9:l,l0:f,l1:d}})},a=[]},"2f87":function(t,e,i){"use strict";i.r(e);var n=i("b239"),o=i.n(n);for(var a in n)["default"].indexOf(a)<0&&function(t){i.d(e,t,(function(){return n[t]}))}(a);e["default"]=o.a},"5b92":function(t,e,i){"use strict";(function(t,e){var n=i("47a9");i("6c4c");n(i("3240"));var o=n(i("f123"));t.__webpack_require_UNI_MP_PLUGIN__=i,e(o.default)}).call(this,i("3223")["default"],i("df3c")["createPage"])},"86ac":function(t,e,i){},b239:function(t,e,i){"use strict";(function(t){var n=i("47a9");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=n(i("7ca3")),a=i("8f59");function c(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function s(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?c(Object(i),!0).forEach((function(e){(0,o.default)(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):c(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}var r=requirePlugin("WechatSI"),h={data:function(){return{opts:{dataLabel:!1,color:["#5180D8","#ED7886","#FFB169"],background:"transparent",canvas:{background:"transparent"},legend:{show:!1},title:{name:"",fontSize:20,offsetY:-3,color:"#333333"},subtitle:{name:"千卡",fontSize:14,offsetY:12,color:"#888888"},extra:{ring:{ringWidth:10,labelWidth:0,border:!1}}},index:0,page:1,typename:"",showAll:!1,IsWeight:!1,search_list:[],isShop:!1,lastPage:"",isBle:!0,weightKcal:"",search_value:"",ActiveList:[],activeType:{},mic_touch:!1,voiceManager:null,autoSearchContent:"",showAutoSearchDlg:!1}},computed:s(s({},(0,a.mapState)(["configInfo","user"])),{},{popular_food:function(){return this.configInfo.search_guess.food_data},history_food:function(){return this.configInfo.search_history.food}}),components:{search:function(){i.e("components/search").then(function(){return resolve(i("f1d3"))}.bind(null,i)).catch(i.oe)},blueTooth:function(){Promise.all([i.e("common/vendor"),i.e("components/bluetooth_food")]).then(function(){return resolve(i("d025"))}.bind(null,i)).catch(i.oe)},qiunDataCharts:function(){Promise.all([i.e("common/vendor"),i.e("uni_modules/qiun-data-charts/components/qiun-data-charts")]).then(function(){return resolve(i("bd05"))}.bind(null,i)).catch(i.oe)}},onLoad:function(t){this.typename=t.name},watch:{activeType:{handler:function(t,e){console.log(t)},deep:!0}},mounted:function(){var t=this;t.voiceManager=r.getRecordRecognitionManager(),t.voiceManager.onStop=function(e){t.autoSearchContent=e.result.replace("。","")},t.voiceManager.onError=function(t){console.error("error msg",t.retcode)},t.voiceManager.stop()},onReachBottom:function(){!this.lastPage||this.page>=this.lastPage?t.showToast({title:"没有更多数据!",icon:"none"}):(this.page++,this.handleSerach())},methods:{handleBle:function(t,e,i){this.isBle=!1,this.activeType.weight=t,this.activeType.unit=e,this.activeType.kcal=i,this.Next(),console.log("返回",this.activeType,t,e,i)},handleToggleBle:function(){this.isBle=!this.isBle,this.isBle||(this.activeType.weight=0!=this.activeType.weight?this.activeType.weight:"")},replaceInput:function(t){var e=t.target.value;this.activeType=Object.assign({},this.activeType,{weight:e})},realTimeWeight:function(t,e){this.activeType=Object.assign({},this.activeType,{weight:this.convertToGrams(t,e)})},unitConversion:function(t){return"kcal"==t?"千卡":"g"==t?"克":t},convertToGrams:function(t,e){var i={lb:453.59237,oz:28.349523125,kg:1e3,g:1};return i.hasOwnProperty(e)?t*i[e]:""},handleDetail:function(t){this.isBle=!0,this.isShop=!1,this.IsWeight=!0,this.activeType=t,this.activeType.weight=0,this.weightKcal=this.activeType.kcal;var e=[];this.opts.color=[];for(var i=1;i<t.nutrients_four.length;++i)this.opts.color.push(t.nutrients_four[i].color),e.push({name:t.nutrients_four[i].name,value:Number(t.nutrients_four[i].proportion)});this.chartData=JSON.parse(JSON.stringify({series:[{data:e}]}))},Next:function(){var t=this.activeType;if(this.activeType.weight<=0)this.$tools.msg("请输入重量");else{if(this.IsWeight=!1,-1==this.ActiveList.indexOf(t))this.ActiveList.push(t);else{var e=this.ActiveList.indexOf(t);this.ActiveList[e].weight=this.activeType.weight,this.ActiveList[e].unit=this.activeType.unit}console.log("保存",this.ActiveList)}},handleSerach:function(){var e=this;e.search_list=[],e.$model.getFoodSearch({page:e.page,search_data:e.search_value}).then((function(i){0==i.code?e.search_list=e.search_list.concat(i.data.content_list):t.showToast({title:i.msg,icon:"error"})}))},handlecolse:function(){this.search_value="",this.search_list=[]},handleSearchHistory:function(t){this.search_value=t,this.showAutoSearchDlg=!1,this.autoSearchContent="",this.handleSerach()},retrySearch:function(){this.autoSearchContent="",2==this.autoSearchType&&(this.showAutoSearchDlg=!1,this.selectPhoto())},onVoiceTouchStart:function(){this.mic_touch=!0,this.voiceManager.start({duration:6e4,lang:"zh_CN"})},onVoiceTouchEnd:function(){this.mic_touch=!1,this.voiceManager.stop()},onShowSearchType:function(t){this.autoSearchType=t,1==t?this.showAutoSearchDlg=!0:2==t&&this.selectPhoto()},selectPhoto:function(){var e=this;t.chooseMedia({count:1,mediaType:["image"],sourceType:["album","camera"],sizeType:["compressed"],camera:"back",success:function(i){var n=i.tempFiles[0].tempFilePath;t.getFileSystemManager().readFile({filePath:n,encoding:"base64",success:function(i){var n="data:image/jpeg;base64,"+i.data;t.showLoading({title:"图片识别中...",mask:!0}),e.$model.getPhotoSearch({img_str:n}).then((function(i){t.hideLoading(),0==i.code&&(e.autoSearchContent=i.data.name,e.showAutoSearchDlg=!0)}))},fail:function(t){console.error("读取文件失败:",t)}})},fail:function(t){console.error("拍照失败:",t)}})},handlesubbtn:function(){var e=this;e.ActiveList.length<=0||e.$model.getAddIntakeFood({aud_id:e.user.aud_id,meals_type:e.typename,food_list:e.ActiveList}).then((function(i){0==i.code&&(e.$store.dispatch("getCountFoodInfo",{aud_id:e.user.aud_id,time:e.$tools.getDate("start")}),setTimeout((function(){t.navigateBack({delta:1})}),200))}))},handledelactive:function(t){this.ActiveList.splice(this.ActiveList.indexOf(t),1)}}};e.default=h}).call(this,i("df3c")["default"])},dbaf:function(t,e,i){"use strict";var n=i("86ac"),o=i.n(n);o.a},f123:function(t,e,i){"use strict";i.r(e);var n=i("2e8a"),o=i("2f87");for(var a in o)["default"].indexOf(a)<0&&function(t){i.d(e,t,(function(){return o[t]}))}(a);i("dbaf");var c=i("828b"),s=Object(c["a"])(o["default"],n["b"],n["c"],!1,null,"3dd489c8",null,!1,n["a"],void 0);e["default"]=s.exports}},[["5b92","common/runtime","common/vendor"]]]);