index.js 3.1 KB

1
  1. "use strict";const e=require("../../common/vendor.js"),l=require("../../api/home.js"),r=require("../../common/assets.js"),d=()=>String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i))==="micromessenger",u={data(){return{isLogin:!1,code:"",livedata:{},path:"http://live.ylrzcloud.com/prod-api",iskefu:!1,isLongPress:!1,timeout:null,liveId:2}},onLoad(i){this.a()},onShow(){e.index.getStorageSync("AppToken")&&this.getliving()},methods:{a(){e.index.login({provider:"weixin",success:async i=>{let o=i.code;console.log("that.code",o)}})},open(){},close(){this.iskefu=!this.iskefu},longPress(){this.timeout=setTimeout(()=>{this.isLongPress=!0,e.index.saveImageToPhotosAlbum({filePath:this.livedata.qwQrCode,success:()=>{e.index.showToast({title:"保存成功"})},fail:()=>{e.index.showToast({title:"保存失败",icon:"none"})}})},500)},cancelLongPress(){clearTimeout(this.timeout),this.isLongPress=!1},getliving(){const i={id:this.liveId};l.getlive(i).then(o=>{o.code==200?this.livedata=o.data:e.index.showToast({title:o.msg,icon:"none",duration:2e3})})},getWechatCode(){if(d){let i="wx93ce67750e3cfba3",o=this.getUrlCode().code,s=window.location.href.split("#")[0];o==null||o===""?window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+i+"&redirect_uri="+encodeURIComponent(s)+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect":(this.code=o,this.loginByMp())}},loginByMp(){if(this.code!=null){e.index.showLoading({title:"处理中..."});var i={code:this.code};l.loginByMp(i).then(o=>{if(e.index.hideLoading(),o.code==200){console.log(o),e.index.setStorageSync("AppToken",o.token),e.index.setStorageSync("userInfo",JSON.stringify(o.user));let s=e.index.getStorageSync("beforLoginPage");e.index.reLaunch({url:s}),e.index.showToast({title:"登录成功",icon:"none"}),this.getliving()}else e.index.showToast({title:o.msg,icon:"none"})},o=>{})}},getUrlCode(){var i=location.search,o=new Object;if(i.indexOf("?")!=-1)for(var s=i.substr(1),c=s.split("&"),n=0;n<c.length;n++)o[c[n].split("=")[0]]=c[n].split("=")[1];return o},comelive(){e.index.setStorageSync("AppToken",null),e.index.getStorageSync("AppToken")?e.index.navigateTo({url:"/pages/home/living"}):(e.index.showToast({title:"请登录授权!",icon:"none"}),e.index.navigateTo({url:"/pages/auth/login"}))}}};if(!Array){const i=e.resolveComponent("u-icon"),o=e.resolveComponent("u-popup");(i+o)()}const g=()=>"../../uni_modules/uview-plus/components/u-icon/u-icon.js",p=()=>"../../uni_modules/uview-plus/components/u-popup/u-popup.js";Math||(g+p)();function h(i,o,s,c,n,t){return{a:r._imports_0,b:n.livedata.liveImgUrl,c:e.t(n.livedata.liveName),d:e.t(n.livedata.startTime),e:e.t(n.livedata.finishTime),f:n.livedata.liveDesc,g:e.o((...a)=>t.comelive&&t.comelive(...a)),h:e.o(a=>i.showadd=!i.showadd),i:e.p({name:"close",size:"18"}),j:i.codeimg,k:e.o((...a)=>t.longPress&&t.longPress(...a)),l:e.o((...a)=>t.cancelLongPress&&t.cancelLongPress(...a)),m:e.o(t.close),n:e.o(t.open),o:e.p({show:n.iskefu,round:"20rpx",bgColor:"#fffee1"})}}const m=e._export_sfc(u,[["render",h],["__scopeId","data-v-4978fed5"]]);wx.createPage(m);