(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pagesActivity/index/apply"],{1425:function(e,t,i){},2300:function(e,t,i){"use strict";i.r(t);var n=i("f1f3"),a=i.n(n);for(var o in n)["default"].indexOf(o)<0&&function(e){i.d(t,e,(function(){return n[e]}))}(o);t["default"]=a.a},"3d02":function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return a})),i.d(t,"a",(function(){}));var n=function(){var e=this.$createElement;this._self._c},a=[]},"51bd":function(e,t,i){"use strict";var n=i("1425"),a=i.n(n);a.a},"69b3":function(e,t,i){"use strict";(function(e,t){var n=i("47a9");i("aa6c");n(i("3240"));var a=n(i("90a9"));e.__webpack_require_UNI_MP_PLUGIN__=i,t(a.default)}).call(this,i("3223")["default"],i("df3c")["createPage"])},"90a9":function(e,t,i){"use strict";i.r(t);var n=i("3d02"),a=i("2300");for(var o in a)["default"].indexOf(o)<0&&function(e){i.d(t,e,(function(){return a[e]}))}(o);i("51bd");var u=i("828b"),l=Object(u["a"])(a["default"],n["b"],n["c"],!1,null,null,null,!1,n["a"],void 0);t["default"]=l.exports},f1f3:function(e,t,i){"use strict";(function(e){var n=i("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=n(i("7ca3")),o=i("8f59");function u(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}var l={components:{activityApply:function(){i.e("pages/component/activity/apply").then(function(){return resolve(i("6d5f"))}.bind(null,i)).catch(i.oe)}},data:function(){return{pageShow:!1,loadEnd:!1,activityId:null,applyField:[],userMobile:""}},computed:function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?u(Object(i),!0).forEach((function(t){(0,a.default)(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):u(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},(0,o.mapState)({themeColor:function(e){return e.app.themeColor}})),onLoad:function(t){var i=this;this.activityId=t.id,e.showLoading({title:"加载中"}),this.getUserMobile(),this.getApplyField((function(){i.loadEnd=!0,e.hideLoading()}))},methods:{pageChange:function(e){this.pageShow=e},getUserMobile:function(){var t=this;this.$util.request("login.getMobile").then((function(i){if(1==i.code){t.userMobile=i.data.mobile||"";var n=t.applyField.findIndex((function(e){if("number"==e.type&&"mobile"==e.field)return!0}));n>-1&&!t.applyField[n].value&&(t.applyField[n].value=t.userMobile)}else e.showToast({title:i.msg,icon:"none"})})).catch((function(e){console.error("获取用户手机号 ",e)}))},getApplyField:function(t){var i=this;this.$util.request("activity.field",{id:this.activityId}).then((function(n){if(t&&t(),1==n.code){var a=n.data;a.forEach((function(e){"checkbox"==e.type||"image"==e.type?e.value=[]:"map"==e.type?e.value={latitude:"",longitude:"",name:"",address:""}:"number"==e.type&&"mobile"==e.field?e.value=i.userMobile||"":e.value=""})),i.applyField=a}else e.showToast({title:n.msg,icon:"none"})})).catch((function(e){t&&t(),console.error("获取报名字段 ",e)}))},heandleSubmit:function(){var t=this;e.showLoading({title:"加载中",mask:!0}),this.$refs.activityApply.getApplyField((function(i){var n=[];for(var a in i){if(1==i[a].required){var o=!1;if("checkbox"==i[a].type||"image"==i[a].type?i[a].value.length||(o=!0):"map"==i[a].type?i[a].value.address||(o=!0):i[a].value||0===i[a].value||(o=!0),o)return e.hideLoading(),void e.showToast({icon:"none",title:i[a].label+"不能为空"})}if("number"==i[a].type&&"mobile"==i[a].field&&!t.$util.validation("phone",i[a].value))return e.hideLoading(),void e.showToast({icon:"none",title:"请输入正确的手机号"});if("number"==i[a].type)i[a].value=i[a].value||0===i[a].value?Number(i[a].value):i[a].value;else if("checkbox"==i[a].type)i[a].value=i[a].value.join();else if("image"==i[a].type)for(var u in i[a].value)n.push({index:a,number:u,value:i[a].value[u]});else"video"==i[a].type&&i[a].value&&n.push({index:a,value:i[a].value})}n.length?t.uploadFiles(n,(function(e){for(var a in n)"image"==i[n[a].index].type?i[n[a].index].value[n[a].number]=e[a]:"video"==i[n[a].index].type&&(i[n[a].index].value=e[a]);t.submitEvent(i)})):t.submitEvent(i)}))},uploadFiles:function(e,t){this.$util.uploadFileMultiple(e.map((function(e){return e.value}))).then((function(e){t(e)})).catch((function(e){console.error("上传文件 ",e)}))},submitEvent:function(e){for(var t in e)"image"==e[t].type&&(e[t].value=e[t].value.join());this.$store.commit("app/setActivityField",JSON.stringify(e)),this.$util.toPage({mode:1,path:"/pagesActivity/index/order?id="+this.activityId})}}};t.default=l}).call(this,i("df3c")["default"])}},[["69b3","common/runtime","common/vendor"]]]);