require('./common/vendor.js');(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages_course/webview"],{934:function(e,t,n){"use strict";(function(e,t){var i=n(4);n(26);i(n(25));var o=i(n(935));e.__webpack_require_UNI_MP_PLUGIN__=n,t(o.default)}).call(this,n(1)["default"],n(2)["createPage"])},935:function(e,t,n){"use strict";n.r(t);var i=n(936),o=n(938);for(var r in o)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return o[e]}))}(r);n(940);var c,a=n(34),s=Object(a["default"])(o["default"],i["render"],i["staticRenderFns"],!1,null,"7380d86e",null,!1,i["components"],c);s.options.__file="pages_course/webview.vue",t["default"]=s.exports},936:function(e,t,n){"use strict";n.r(t);var i=n(937);n.d(t,"render",(function(){return i["render"]})),n.d(t,"staticRenderFns",(function(){return i["staticRenderFns"]})),n.d(t,"recyclableRender",(function(){return i["recyclableRender"]})),n.d(t,"components",(function(){return i["components"]}))},937:function(e,t,n){"use strict";var i;n.r(t),n.d(t,"render",(function(){return o})),n.d(t,"staticRenderFns",(function(){return c})),n.d(t,"recyclableRender",(function(){return r})),n.d(t,"components",(function(){return i}));var o=function(){var e=this,t=e.$createElement;e._self._c},r=!1,c=[];o._withStripped=!0},938:function(e,t,n){"use strict";n.r(t);var i=n(939),o=n.n(i);for(var r in i)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(r);t["default"]=o.a},939:function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=n(913),o={data:function(){return{loading:!1,userinfos:{nickname:"",avatar:""},usercode:{},h5Appid:"",redirect_uri:"",appid:"",webviewUrl:""}},onLoad:function(t){this.appid=getApp().globalData.appId,this.webviewUrl=e.getStorageSync("weixinOauth"),t.code&&this.loginweixin(t.code),console.log(this.webviewUrl)},methods:{getUrlParam:function(){var e=this.webviewUrl,t=new Object;if(-1!=e.indexOf("?"))for(var n=e.substr(1),i=n.split("&"),o=0;o<i.length;o++)t[i[o].split("=")[0]]=i[o].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};(0,i.H5logoinApp)(r).then((function(i){e.hideLoading(),200==i.code?(n.$store.commit("setCoureLogin",1),e.setStorageSync("web_userInfo",i.user),e.setStorageSync("TOKEN_WEXIN",i.token),n.usercode.code=t,n.usercode.userId=i.user.userId,e.$emit("usercode",n.usercode),e.navigateBack({delta:1})):(e.showToast({title:i.msg||"获取用户信息失败",icon:"none"}),setTimeout((function(){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=o}).call(this,n(2)["default"])},940:function(e,t,n){"use strict";n.r(t);var i=n(941),o=n.n(i);for(var r in i)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(r);t["default"]=o.a},941:function(e,t,n){}},[[934,"common/runtime","common/vendor"]]]);
//# sourceMappingURL=../../.sourcemap/mp-weixin/pages_course/webview.js.map