require('./common/vendor.js');(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages_course/webview"],{401:function(e,t,n){"use strict";(function(e,t){var o=n(4);n(26);o(n(25));var i=o(n(402));e.__webpack_require_UNI_MP_PLUGIN__=n,t(i.default)}).call(this,n(1)["default"],n(2)["createPage"])},402:function(e,t,n){"use strict";n.r(t);var o=n(403),i=n(405);for(var r in i)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(r);n(407);var s,c=n(34),a=Object(c["default"])(i["default"],o["render"],o["staticRenderFns"],!1,null,"7380d86e",null,!1,o["components"],s);a.options.__file="pages_course/webview.vue",t["default"]=a.exports},403:function(e,t,n){"use strict";n.r(t);var o=n(404);n.d(t,"render",(function(){return o["render"]})),n.d(t,"staticRenderFns",(function(){return o["staticRenderFns"]})),n.d(t,"recyclableRender",(function(){return o["recyclableRender"]})),n.d(t,"components",(function(){return o["components"]}))},404:function(e,t,n){"use strict";var o;n.r(t),n.d(t,"render",(function(){return i})),n.d(t,"staticRenderFns",(function(){return s})),n.d(t,"recyclableRender",(function(){return r})),n.d(t,"components",(function(){return o}));var i=function(){var e=this,t=e.$createElement;e._self._c},r=!1,s=[];i._withStripped=!0},405:function(e,t,n){"use strict";n.r(t);var o=n(406),i=n.n(o);for(var r in o)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(r);t["default"]=i.a},406:function(e,t,n){"use strict";(function(e){var o=n(4);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;o(n(84));var i=n(390),r=(n(162),{data:function(){return{loading:!1,userinfos:{nickname:"",avatar:""},usercode:{},h5Appid:"",redirect_uri:""}},onLoad:function(e){e.code&&this.loginweixin(e.code),console.log(this.webviewUrl)},computed:{appid:function(){return this.$store.state.appid},isSpare:function(){return this.$store.state.isSpare},webviewUrl:function(){return this.$store.state.webviewUrl}},methods:{getUrlParam:function(){var e=this.webviewUrl,t=new Object;if(-1!=e.indexOf("?"))for(var n=e.substr(1),o=n.split("&"),i=0;i<o.length;i++)t[o[i].split("=")[0]]=o[i].split("=")[1];return t},loginweixin:function(t){var n=this,o=e.getStorageSync("H5course"),r={code:t,appId:this.appid,companyId:o.companyId,companyUserId:o.companyUserId,projectId:o.projectId},s=1==this.isSpare&&1==o.type?1:0;(0,i.H5logoinApp)(r,s).then((function(o){n.res=o,e.hideLoading(),200==o.code?(n.$store.commit("setCoureLogin",1),console.log(o),e.hideLoading(),e.showToast({icon:"none",title:"成功获取用户信息"}),n.userinfos.nickname=o.user.nickname,n.userinfos.avatar=o.user.avatar,e.setStorageSync("userinfos",n.userinfos),e.setStorageSync("userInfo",o.user),e.setStorageSync("TOKEN_WEXIN",o.token),n.usercode.code=t,n.usercode.userId=o.user.userId,e.$emit("usercode",n.usercode),e.navigateBack({delta:1})):(e.hideLoading(),e.showToast({title:o.msg||"获取用户信息失败",icon:"none"}),setTimeout((function(){e.$emit("vipMsg",o.msg),e.navigateBack({delta:1})}),2e3))}),(function(e){})).catch((function(t){e.hideLoading(),e.showToast({icon:"none",title:"获取用户信息失败"})}))},generateAuthUrl:function(){var t=e.getLaunchOptionsSync().scene;this.h5Appid=this.getUrlParam().appid,this.redirect_uri=this.webviewUrl;var n={scene:t,appid:this.h5Appid,redirect_uri:encodeURIComponent(this.redirect_uri),scope:"snsapi_userinfo",state:"wechat_redirect"};return"https://open.weixin.qq.com/connect/oauth2/authorize?appid=".concat(n.appid,"&redirect_uri=").concat(n.redirect_uri,"&response_type=code&scope=").concat(n.scope,"&state=").concat(n.state,"#wechat_redirect")},handleMessage:function(t){console.log("收到web-view消息:",t.detail),console.log("收到web-view消息:",t),t.detail&&"user_info"===t.detail.type&&(this.userInfo=t.detail.data,this.token=t.detail.token,e.setStorageSync("userInfo",this.userInfo),e.setStorageSync("TOKEN_WEXIN",this.userInfo),e.showToast({title:"登录成功",icon:"success"}),setTimeout((function(){e.navigateBack()}),1500))},onLoads:function(){this.loading=!1,console.log("web-view加载完成")},onError:function(t){this.loading=!1,console.error("web-view加载失败:",t),e.showToast({title:"页面加载失败",icon:"none"})}}});t.default=r}).call(this,n(2)["default"])},407:function(e,t,n){"use strict";n.r(t);var o=n(408),i=n.n(o);for(var r in o)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(r);t["default"]=i.a},408:function(e,t,n){}},[[401,"common/runtime","common/vendor","pages_course/common/vendor"]]]);
//# sourceMappingURL=../../.sourcemap/mp-weixin/pages_course/webview.js.map