2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-1dbb5124"],{4400:function(e,t,n){"use strict";n.r(t);var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"app-container"},[n("sticky",{attrs:{"z-index":10,"class-name":"sub-navbar"}},[n("el-button-group",[n("el-button",{attrs:{icon:"el-icon-close"},on:{click:e.onCancel}},[e._v("取消")]),n("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["shop:game_setting"],expression:"['shop:game_setting']"}],attrs:{type:"success",icon:"el-icon-check"},on:{click:e.saveVal}},[e._v("保存")])],1)],1),n("el-row",[1===e.userLevel?n("el-select",{staticClass:"w100",attrs:{placeholder:"选择"+e.$t("main.shop"),name:"shop",required:""},model:{value:e.shop,callback:function(t){e.shop=t},expression:"shop"}},e._l(e.allDepts,(function(e){return n("el-option",{key:e._id,attrs:{label:e.name,value:e._id}})})),1):e._e()],1),e._l(e.list,(function(t){return n("div",{key:t._id,staticClass:"one-block"},[n("el-row",[n("el-switch",{attrs:{"active-text":t.name,disabled:e.noShop,"inactive-text":""},on:{change:function(n){return e.gameSelectedChange(t._id)}},model:{value:t.selected,callback:function(n){e.$set(t,"selected",n)},expression:"game.selected"}})],1),n("el-divider",{attrs:{"content-position":"left"}}),n("el-row",{staticStyle:{display:"flex","flex-wrap":"wrap"}},e._l(t.versions,(function(r,a){return n("el-col",{key:r._id,staticStyle:{"margin-bottom":"20px"},attrs:{span:4,offset:a%4===0?0:2}},[n("el-card",{attrs:{"body-style":{padding:"0px"}}},[n("img",{staticClass:"image",attrs:{src:r.image,alt:r.name}}),n("div",{staticStyle:{padding:"14px"}},[n("div",{staticClass:"sub-bottom"},[n("span",[e._v(e._s(r.name))]),n("span",[e.noShop?e._e():n("router-link",{staticClass:"link-type",attrs:{to:"/shop/theme_edit/"+e.shop+"/"+t._id+"/"+r._id}},[e._v(" 自定义 ")])],1)]),n("div",{staticClass:"bottom"},[e.noShop?e._e():n("el-image",{staticStyle:{width:"40px",height:"40px"},attrs:{src:1===r.type?"img/icons/wqr.png":"img/icons/preview.png"},on:{click:function(n){return e.showPreview(r,t._id,r.image)}}}),1!==r.type||e.noShop?e._e():n("span",{on:{click:function(n){return e.showPreview(r,t._id,r.image)}}},[e._v(" 查看小程序码 ")]),0!==r.type||e.noShop?e._e():n("span",[n("a",{attrs:{href:r.url,target:"_blank"}},[e._v("预览游戏 ")])]),n("el-switch",{attrs:{"active-text":"",disabled:e.noShop,"inactive-text":""},on:{change:function(n){return e.versionSelectedChange(t._id,r._id)}},model:{value:r.selected,callback:function(t){e.$set(r,"selected",t)},expression:"vdata.selected"}})],1)])])],1)})),1)],1)})),n("el-dialog",{staticStyle:{"z-index":"1999"},attrs:{visible:e.dialogVisible,"modal-append-to-body":!1,title:"自定义小程序码"},on:{"update:visible":function(t){e.dialogVisible=t}}},[n("el-row",{staticStyle:{display:"flex","flex-wrap":"wrap"}},[n("el-col",{staticStyle:{width:"430px"},attrs:{span:12}},[n("el-image",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],staticStyle:{width:"100%"},attrs:{src:e.qrUrl}}),n("canvas",{attrs:{id:"qr_canvas",width:"430",height:"430"}})],1),n("el-col",{attrs:{span:10}},[n("el-form",{ref:"modalForm",attrs:{"label-position":"top"}},[n("el-form-item",{attrs:{label:"参数"}},[n("el-input",{attrs:{placeholder:"参数",maxlength:19},model:{value:e.qrParam,callback:function(t){e.qrParam=t},expression:"qrParam"}})],1),n("el-form-item",{attrs:{label:"logo大小"}},[n("el-slider",{attrs:{min:.5,max:1,step:.01},on:{change:e.logoScaleChange},model:{value:e.logoScale,callback:function(t){e.logoScale=t},expression:"logoScale"}})],1),n("el-form-item",{attrs:{label:"logo背景色"}},[n("el-color-picker",{on:{change:e.logoBgChange},model:{value:e.logoBg,callback:function(t){e.logoBg=t},expression:"logoBg"}})],1),n("el-form-item",[n("el-button",{attrs:{type:"primary",loading:e.refreshing},on:{click:e.refreshImg}},[e._v(" 生成 ")]),n("el-button",{attrs:{type:"success",loading:e.refreshing},on:{click:e.exportCanvasAsPNG}},[e._v(" 下载 ")])],1)],1),n("label",{staticClass:"history_list"},[e._v("历史记录")]),n("ul",{staticClass:"infinite-list",staticStyle:{overflow:"auto"},attrs:{id:"history_list"}},e._l(e.historys,(function(t){return n("li",{key:t,staticClass:"infinite-list-item"},[n("el-button",{staticClass:"history_content",attrs:{size:"mini",type:"text",loading:e.refreshing,round:""},on:{click:function(n){return e.historyClicked(t)}}},[e._v(e._s(t))]),n("el-button",{attrs:{size:"mini",type:"primary",icon:"el-icon-delete"},on:{click:function(n){return e.deleteHistory(t)}}})],1)})),0)],1)],1)],1),e.showViewer?n("el-image-viewer",{staticStyle:{"z-index":"2500"},attrs:{"on-close":e.closeViewer,"url-list":[e.qrUrl]}}):e._e()],2)},a=[],i=n("b85c"),s=n("1da1"),o=n("d4ec"),c=n("bee2"),l=n("262e"),u=n("2caf"),h=(n("7db0"),n("99af"),n("4795"),n("0d03"),n("cb29"),n("a15b"),n("96cf"),n("9ab4")),d=n("1b40"),p=n("c1a2"),f=n("b804"),g=n("08a9"),m=n("db85"),v=n("9dba"),b=n("4c9b"),y=n("d257"),k=n("b7c7"),w=430,x=190,_=function(e){Object(l["a"])(n,e);var t=Object(u["a"])(n);function n(){var e;return Object(o["a"])(this,n),e=t.apply(this,arguments),e.total=0,e.list=[],e.listLoading=!0,e.shop="",e.allDepts=[],e.gameid="",e.versionid="",e.qrUrl="",e.shopLogo="",e.showViewer=!1,e.dialogVisible=!1,e.qrParam="",e.refreshing=!1,e.preGameId="",e.preVersionId="",e.historys=[],e.logoScale=1,e.logoBg="#ffffff",e.listQuery={page:1,limit:20,key:"",hasVersion:1},e}return Object(c["a"])(n,[{key:"userLevel",get:function(){return v["a"].level}},{key:"noShop",get:function(){return!this.shop}},{key:"created",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,this.getList();case 2:if(1!==v["a"].level){e.next=9;break}return e.next=5,this.getRemoteDeptList("");case 5:b["k"].$on(b["j"],(function(){t.getRemoteDeptList()})),this.$local.get(k["a"])&&(this.shop=this.$local.get(k["a"]).id),e.next=10;break;case 9:this.shop=v["a"].department;case 10:this.shop&&this.getShopInfo(this.shop),b["k"].$on(b["e"],(function(){t.getList()}));case 12:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"beforeDestory",value:function(){1===v["a"].level&&b["k"].$off(b["j"]),b["k"].$off(b["e"])}},{key:"onShopChange",value:function(){this.shop&&(this.getShopGameSetting(this.shop),this.$local.set(k["a"],{id:this.shop}),this.getShopInfo(this.shop))}},{key:"getList",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return this.listLoading=!0,e.next=3,Object(p["e"])(this.listQuery);case 3:t=e.sent,n=t.data,this.listLoading=!1,this.list=n.records,this.total=n.total;case 8:case"end":return e.stop()}}),e,this)})));function t(){return e.apply(this,arguments)}return t}()},{key:"getShopGameSetting",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(t){var n,r,a,s,o,c,l;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(m["f"])({shopid:t});case 2:n=e.sent,r=n.data,console.log(r),this.gameid=r.gameid,this.versionid=r.versionid,this.updateGameSelected(),a=0;case 9:if(!(a<this.list.length)){e.next=34;break}s=this.list[a],o=Object(i["a"])(s.versions),e.prev=12,o.s();case 14:if((c=o.n()).done){e.next=22;break}if(l=c.value,1!==l.type){e.next=20;break}return e.next=19,this.getGameQr(this.shop,s._id,l._id);case 19:l.qr=e.sent;case 20:e.next=14;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e["catch"](12),o.e(e.t0);case 27:return e.prev=27,o.f(),e.finish(27);case 30:d["c"].set(this.list,a,s);case 31:a++,e.next=9;break;case 34:case"end":return e.stop()}}),e,this,[[12,24,27,30]])})));function t(t){return e.apply(this,arguments)}return t}()},{key:"getGameQr",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(t,n,r,a){var i,s,o;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return i={shop:t,gameId:n,version:r,params:a},e.next=3,Object(m["g"])(i);case 3:return s=e.sent,o=s.data,e.abrupt("return",o.url);case 6:case"end":return e.stop()}}),e)})));function t(t,n,r,a){return e.apply(this,arguments)}return t}()},{key:"updateGameSelected",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t,n,r,a,s,o,c,l,u=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(0!==this.list.length){e.next=2;break}return e.abrupt("return");case 2:this.gameid||(this.gameid=this.list[0]._id),t=Object(i["a"])(this.list),e.prev=4,t.s();case 6:if((n=t.n()).done){e.next=13;break}if(r=n.value,r._id!==this.gameid){e.next=11;break}return r.versions.find((function(e){return e._id===u.versionid}))||(this.versionid=r.versions[0]._id),e.abrupt("break",13);case 11:e.next=6;break;case 13:e.next=18;break;case 15:e.prev=15,e.t0=e["catch"](4),t.e(e.t0);case 18:return e.prev=18,t.f(),e.finish(18);case 21:for(a=0;a<this.list.length;a++){s=this.list[a],s.selected=s._id===this.gameid,o=Object(i["a"])(s.versions);try{for(o.s();!(c=o.n()).done;)l=c.value,l.selected=l._id===this.versionid}catch(h){o.e(h)}finally{o.f()}d["c"].set(this.list,a,s)}case 22:case"end":return e.stop()}}),e,this,[[4,15,18,21]])})));function t(){return e.apply(this,arguments)}return t}()},{key:"getRemoteDeptList",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!(v["a"].level>1)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,Object(m["k"])({key:t});case 4:if(n=e.sent,r=n.data,r.records){e.next=8;break}return e.abrupt("return");case 8:this.allDepts=r.records;case 9:case"end":return e.stop()}}),e,this)})));function t(t){return e.apply(this,arguments)}return t}()},{key:"gameSelectedChange",value:function(e){console.log(e),this.gameid=e,this.updateGameSelected()}},{key:"versionSelectedChange",value:function(e,t){console.log(e,t),this.gameid=e,this.versionid=t,this.updateGameSelected()}},{key:"onCancel",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.$confirm("确认不保存当前信息?","Warning",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"});case 3:this.$store.dispatch("delView",this.$route),this.$router.go(-1),e.next=9;break;case 7:e.prev=7,e.t0=e["catch"](0);case 9:case"end":return e.stop()}}),e,this,[[0,7]])})));function t(){return e.apply(this,arguments)}return t}()},{key:"saveVal",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(this.shop&&this.gameid&&this.versionid){e.next=3;break}return this.$message({message:"请先选择一个游戏",type:"warning"}),e.abrupt("return");case 3:return e.prev=3,t={shopid:this.shop,gameid:this.gameid,versionid:this.versionid},e.next=7,Object(m["n"])(t);case 7:this.$notify({title:"Success",message:"更新游戏配置成功",type:"success",duration:2e3}),e.next=13;break;case 10:e.prev=10,e.t0=e["catch"](3),console.log("save shop gamesetting error");case 13:case"end":return e.stop()}}),e,this,[[3,10]])})));function t(){return e.apply(this,arguments)}return t}()},{key:"showPreview",value:function(e,t,n){var r=this;if(this.preGameId=t,this.preVersionId=e._id,1===e.type&&e.qr){this.qrUrl=e.qr,this.dialogVisible=!0;var a="".concat(this.preGameId,"|").concat(this.preVersionId),i=this.$local.get(a);this.historys.length=0,i&&(this.historys=i),setTimeout((function(){r.doDraw()}),500)}else e.url&&window.open(e.url,"_blank")}},{key:"closeViewer",value:function(){this.qrUrl="",this.showViewer=!1}},{key:"refreshImg",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(console.log("refresh qr with gameid: ".concat(this.preGameId,", versionid: ").concat(this.preVersionId,", param: ").concat(this.qrParam)),t=[],!this.qrParam){e.next=13;break}if(!(this.qrParam.length>19)){e.next=6;break}return this.$message({message:"参数的长度不能超过19个字符",type:"error"}),e.abrupt("return",!1);case 6:if(/^[a-zA-Z0-9]+$/.test(this.qrParam)){e.next=9;break}return this.$message({message:"参数只能是数字或大小写字母",type:"error"}),e.abrupt("return",!1);case 9:t.push(this.qrParam),this.historys.pushOnce(this.qrParam),n="".concat(this.preGameId,"|").concat(this.preVersionId),this.$local.set(n,this.historys);case 13:return this.refreshing=!0,e.prev=14,e.next=17,this.getGameQr(this.shop,this.preGameId,this.preVersionId,t);case 17:return r=e.sent,e.next=20,Object(y["b"])(1);case 20:this.qrUrl=r,this.doDraw(),e.next=27;break;case 24:e.prev=24,e.t0=e["catch"](14),this.$message({message:"生成二维码出错",type:"error"});case 27:this.refreshing=!1;case 28:case"end":return e.stop()}}),e,this,[[14,24]])})));function t(){return e.apply(this,arguments)}return t}()},{key:"historyClicked",value:function(e){this.qrParam=e,this.refreshImg()}},{key:"deleteHistory",value:function(e){var t=this.historys.zremove(e);if(t){var n="".concat(this.preGameId,"|").concat(this.preVersionId);this.$local.set(n,this.historys)}}},{key:"getShopInfo",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Object(m["e"])(t,{});case 3:n=e.sent,r=n.data,this.shopLogo=r.logo,e.next=11;break;case 8:e.prev=8,e.t0=e["catch"](0),console.log("err get shop info",e.t0);case 11:case"end":return e.stop()}}),e,this,[[0,8]])})));function t(t){return e.apply(this,arguments)}return t}()},{key:"logoScaleChange",value:function(e){console.log("logo scale change",e),this.doDraw()}},{key:"logoBgChange",value:function(e){this.doDraw()}},{key:"doDraw",value:function(){var e=this,t=document.getElementById("qr_canvas");if(!t)return!1;var n=t.getContext("2d");n.clearRect(0,0,w,w);var r=new Image;r.src=this.qrUrl+"?t="+(new Date).getDate(),r.setAttribute("crossOrigin","Anonymous"),r.onload=function(){r.complete&&(n.drawImage(r,0,0,w,w),e.shopLogo&&e.drawLogo(n))}}},{key:"drawLogo",value:function(e){var t=this,n=new Image;n.src=this.shopLogo,n.setAttribute("crossOrigin","Anonymous"),n.onload=function(){if(n.complete){var r=document.createElement("canvas"),a=r.getContext("2d");r.width=430,r.height=430,a.fillStyle=t.logoBg,a.fillRect(0,0,w,w);var i=x*t.logoScale,s=(w-i)/2;a.drawImage(n,0,0,n.width,n.height,s,s,i,i);var o=e.createPattern(r,"no-repeat"),c=(w-x)/2;e.roundRect(c,c,x,x,x/2),e.fillStyle=o,e.fill()}}}},{key:"exportCanvasAsPNG",value:function(){var e="".concat(this.shop,".png");this.qrParam&&(e="".concat(this.shop,"_").concat(this.qrParam,".png"));var t=document.getElementById("qr_canvas");if(!t)return!1;var n="image/png",r=t.toDataURL(n),a=document.createElement("a");a.download=e,a.href=r,a.dataset.downloadurl=[n,a.download,a.href].join(":"),document.body.appendChild(a),a.click(),document.body.removeChild(a)}}]),n}(d["c"]);Object(h["a"])([Object(d["d"])("shop")],_.prototype,"onShopChange",null),_=Object(h["a"])([Object(d["a"])({name:"GameSetting",components:{Sticky:f["a"],ElImageViewer:g["a"]},filters:{parseGameType:function(e){return 1===e?"微信小游戏":"网页版"}}})],_);var S=_,j=S,O=(n("eda93"),n("c9a1"),n("0c7c")),C=Object(O["a"])(j,r,a,!1,null,"cb98f782",null);t["default"]=C.exports},"4c9b":function(e,t,n){"use strict";n.d(t,"k",(function(){return a})),n.d(t,"i",(function(){return i})),n.d(t,"a",(function(){return s})),n.d(t,"d",(function(){return o})),n.d(t,"e",(function(){return c})),n.d(t,"c",(function(){return l})),n.d(t,"g",(function(){return u})),n.d(t,"j",(function(){return h})),n.d(t,"h",(function(){return d})),n.d(t,"f",(function(){return p})),n.d(t,"b",(function(){return f}));var r=n("2b0e"),a=new r["default"],i="event_shop_puzzles_update",s="event_activity_update",o="event_exam_update",c="event_game_update",l="event_coupon_update",u="event_puzzle_update",h="event_shop_update",d="event_role_update",p="event_mail_update",f="event_announce_update"},"7db0":function(e,t,n){"use strict";var r=n("23e7"),a=n("b727").find,i=n("44d2"),s="find",o=!0;s in[]&&Array(1)[s]((function(){o=!1})),r({target:"Array",proto:!0,forced:o},{find:function(e){return a(this,e,arguments.length>1?arguments[1]:void 0)}}),i(s)},"81d5":function(e,t,n){"use strict";var r=n("7b0b"),a=n("23cb"),i=n("50c4");e.exports=function(e){var t=r(this),n=i(t.length),s=arguments.length,o=a(s>1?arguments[1]:void 0,n),c=s>2?arguments[2]:void 0,l=void 0===c?n:a(c,n);while(l>o)t[o++]=e;return t}},c1a2:function(e,t,n){"use strict";n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return i})),n.d(t,"e",(function(){return s})),n.d(t,"d",(function(){return o})),n.d(t,"f",(function(){return c})),n.d(t,"c",(function(){return l}));var r=n("b32d"),a={type:0,name:""},i={versions:[a],name:""},s=function(e){return Object(r["a"])({url:"/api/games",method:"post",params:e})},o=function(e,t){return Object(r["a"])({url:"/api/game/".concat(e),method:"get",params:t})},c=function(e){return Object(r["a"])({url:"/api/game/save",method:"post",data:e})},l=function(e){return Object(r["a"])({url:"/api/game/".concat(e,"/delete"),method:"post"})}},c9a1:function(e,t,n){"use strict";n("f4f0")},cb29:function(e,t,n){var r=n("23e7"),a=n("81d5"),i=n("44d2");r({target:"Array",proto:!0},{fill:a}),i("fill")},dd49:function(e,t,n){e.exports={menuBg:"#304156",menuText:"#bfcbd9",menuActiveText:"#409eff"}},eda93:function(e,t,n){"use strict";n("dd49")},f4f0:function(e,t,n){}}]);
|
|
//# sourceMappingURL=chunk-1dbb5124.1d950491.js.map
|