"use strict";const e=require("../../../common/vendor.js"),t=require("../../../request/api.js"),s=require("../../../common/assets.js"),i={data:()=>({avatarTop:"",contentTop:"",avatar:"",avatarUrl:"",investPreferenceList:["长期投资","中短期投资","风险控制型"],selectInvestIndex:-1,stockYearList:["新手入门","1年以内","1-3年","3-5年","5-10年","10年以上"],selectYearIndex:-1,riskPreferenceList:["保守型","稳健型","积极型"],selectRiskIndex:-1,investmentScaleList:["50万以下","50-100万","100万以上"],selectScaleIndex:-1,preferredMarketList:[{title:"A股"},{title:"港股"},{title:"美股"},{title:"期货"},{title:"虚拟货币"},{title:"新兴市场"}]}),onLoad(){this.avatarTop=e.inject("navHeight")+.08*e.inject("windowWidth"),this.contentTop=this.avatarTop+.1*e.inject("windowWidth"),this.getUserInfoData()},methods:{chooseAvatar(e){this.avatar=e.detail.avatarUrl},clickInvestItem(e){this.selectInvestIndex!=e&&(this.selectInvestIndex=e)},clickYearItem(e){this.selectYearIndex!=e&&(this.selectYearIndex=e)},clickRiskItem(e){this.selectRiskIndex!=e&&(this.selectRiskIndex=e)},clickScaleItem(e){this.selectScaleIndex!=e&&(this.selectScaleIndex=e)},clickMarketItem(e){this.preferredMarketList[e].select=!this.preferredMarketList[e].select},clickPre(){e.index.navigateBack()},clickFinish(){if(this.selectInvestIndex<0)return void e.index.showToast({title:"请选择投资偏好",icon:"none"});if(this.selectYearIndex<0)return void e.index.showToast({title:"请选择炒股年限",icon:"none"});if(this.selectRiskIndex<0)return void e.index.showToast({title:"请选择风险偏好",icon:"none"});if(this.selectScaleIndex<0)return void e.index.showToast({title:"请选择投资规模",icon:"none"});let t=[];for(let e of this.preferredMarketList)e.select&&t.push(e.title);if(0!=t.length)if(this.avatar){let e={avatar:this.avatar,isFile:1};updateBasicInfo(e).then((e=>{this.uploadInvestPreferenceData()})).catch((e=>{}))}else this.uploadInvestPreferenceData();else e.index.showToast({title:"请选择偏好市场",icon:"none"})},uploadInvestPreferenceData(){let s=[];for(let e of this.preferredMarketList)e.select&&s.push(e.title);let i={trading_experience:this.selectYearIndex,investment_style:this.investPreferenceList[this.selectInvestIndex],risk_preference:this.riskPreferenceList[this.selectRiskIndex],investment_amount:this.investmentScaleList[this.selectScaleIndex],preferred_markets:s};t.updateInvestPreference(i).then((t=>{e.index.navigateBack({delta:2})})).catch((e=>{}))},getUserInfoData(){t.userInfo().then((t=>{if(200==t.code){this.avatarUrl=t.data.basic_info.avatar_url;let e=t.data.investment_preferences;for(var s=0;s<this.investPreferenceList.length;s++){if(this.investPreferenceList[s]==e.investment_style){this.selectInvestIndex=s;break}}this.selectYearIndex=e.trading_experience;for(s=0;s<this.riskPreferenceList.length;s++){if(this.riskPreferenceList[s]==e.risk_preference){this.selectRiskIndex=s;break}}for(s=0;s<this.investmentScaleList.length;s++){if(this.investmentScaleList[s]==e.investment_amount){this.selectScaleIndex=s;break}}for(let t of this.preferredMarketList){JSON.parse(e.preferred_markets)[0].split(",").indexOf(t.title)>-1?t.select=!0:t.select=!1}}else e.wx$1.showToast({title:t.message})})).catch((e=>{}))}}};if(!Array){e.resolveComponent("navBar")()}Math;const n=e._export_sfc(i,[["render",function(t,i,n,r,a,c){return{a:e.p({leftText:"信息完善"}),b:s._imports_0,c:a.avatar?a.avatar:a.avatarUrl,d:s._imports_1$5,e:e.o(((...e)=>c.chooseAvatar&&c.chooseAvatar(...e))),f:e.s("top:"+a.avatarTop+"px;"),g:e.f(a.investPreferenceList,((t,s,i)=>({a:e.t(t),b:e.n("item "+(a.selectInvestIndex==s?"select":"")),c:s,d:e.o((e=>c.clickInvestItem(s)),s)}))),h:e.f(a.stockYearList,((t,s,i)=>({a:e.t(t),b:e.n("item "+(a.selectYearIndex==s?"select":"")),c:s,d:e.o((e=>c.clickYearItem(s)),s)}))),i:e.f(a.riskPreferenceList,((t,s,i)=>({a:e.t(t),b:e.n("item "+(a.selectRiskIndex==s?"select":"")),c:s,d:e.o((e=>c.clickRiskItem(s)),s)}))),j:e.f(a.investmentScaleList,((t,s,i)=>({a:e.t(t),b:e.n("item "+(a.selectScaleIndex==s?"select":"")),c:s,d:e.o((e=>c.clickScaleItem(s)),s)}))),k:e.f(a.preferredMarketList,((t,s,i)=>({a:e.t(t.title),b:e.n("item "+(t.select?"select":"")),c:s,d:e.o((e=>c.clickMarketItem(s)),s)}))),l:e.s("top:"+a.contentTop+"px;"),m:e.o((e=>c.clickPre())),n:e.o((e=>c.clickFinish()))}}]]);wx.createPage(n);
