2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-5bb6b064"],{"25c7":function(e,t,r){"use strict";r("54bf")},4400:function(e,t,r){"use strict";r.r(t);var n=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"app-container"},[r("sticky",{attrs:{"z-index":10,"class-name":"sub-navbar"}},[r("el-button-group",[r("el-button",{attrs:{icon:"el-icon-close"},on:{click:e.onCancel}},[e._v("取消")]),r("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),r("el-row",[1===e.userLevel?r("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 r("el-option",{key:e._id,attrs:{label:e.name,value:e._id}})})),1):e._e()],1),e._l(e.list,(function(t){return r("div",{key:t._id,staticClass:"one-block"},[r("el-row",[r("el-switch",{attrs:{"active-text":t.name,disabled:e.noShop,"inactive-text":""},on:{change:function(r){return e.gameSelectedChange(t._id)}},model:{value:t.selected,callback:function(r){e.$set(t,"selected",r)},expression:"game.selected"}})],1),r("el-divider",{attrs:{"content-position":"left"}}),r("el-row",{staticStyle:{display:"flex","flex-wrap":"wrap"}},e._l(t.versions,(function(n,i){return r("el-col",{key:n._id,staticStyle:{"margin-bottom":"20px"},attrs:{span:4,offset:i%4===0?0:2}},[r("el-card",{attrs:{"body-style":{padding:"0px"}}},[r("img",{staticClass:"image",attrs:{src:n.image,alt:n.name}}),r("div",{staticStyle:{padding:"14px"}},[r("div",{staticClass:"sub-bottom"},[r("span",[e._v(e._s(n.name))]),r("span",[e.noShop?e._e():r("router-link",{staticClass:"link-type",attrs:{to:"/shop/theme_edit/"+e.shop+"/"+t._id+"/"+n._id}},[e._v(" 自定义 ")])],1)]),r("div",{staticClass:"bottom"},[e.noShop?e._e():r("el-image",{staticStyle:{width:"40px",height:"40px"},attrs:{src:1===n.type?"img/icons/wqr.png":"img/icons/preview.png"},on:{click:function(r){return e.showPreview(n,t._id,n.image)}}}),1!==n.type||e.noShop?e._e():r("span",{on:{click:function(r){return e.showPreview(n,t._id,n.image)}}},[e._v(" 查看小程序码 ")]),0!==n.type||e.noShop?e._e():r("span",[r("a",{attrs:{href:n.url,target:"_blank"}},[e._v("预览游戏 ")])]),r("el-switch",{attrs:{"active-text":"",disabled:e.noShop,"inactive-text":""},on:{change:function(r){return e.versionSelectedChange(t._id,n._id)}},model:{value:n.selected,callback:function(t){e.$set(n,"selected",t)},expression:"vdata.selected"}})],1)])])],1)})),1)],1)})),r("el-dialog",{staticStyle:{"z-index":"1999"},attrs:{visible:e.dialogVisible,"modal-append-to-body":!1,title:"自定义小程序码"},on:{"update:visible":function(t){e.dialogVisible=t}}},[r("el-row",{staticStyle:{display:"flex","flex-wrap":"wrap"}},[r("el-col",{staticStyle:{width:"430px"},attrs:{span:12}},[r("el-image",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],staticStyle:{width:"100%"},attrs:{src:e.qrUrl}}),r("canvas",{attrs:{id:"qr_canvas",width:"430",height:"430"}})],1),r("el-col",{attrs:{span:10}},[r("el-form",{ref:"modalForm",attrs:{"label-position":"left"}},[r("el-form-item",{attrs:{label:"参数"}},[r("el-input",{attrs:{placeholder:"参数",maxlength:19},model:{value:e.qrParam,callback:function(t){e.qrParam=t},expression:"qrParam"}})],1),r("el-form-item",[r("el-button",{attrs:{type:"primary",loading:e.refreshing},on:{click:e.refreshImg}},[e._v(" 生成 ")]),r("el-button",{attrs:{type:"success",loading:e.refreshing},on:{click:e.exportCanvasAsPNG}},[e._v(" 下载 ")])],1)],1),r("label",{staticClass:"history_list"},[e._v("历史记录")]),r("ul",{staticClass:"infinite-list",staticStyle:{overflow:"auto"},attrs:{id:"history_list"}},e._l(e.historys,(function(t){return r("li",{key:t,staticClass:"infinite-list-item"},[r("el-button",{staticClass:"history_content",attrs:{size:"mini",type:"text",loading:e.refreshing,round:""},on:{click:function(r){return e.historyClicked(t)}}},[e._v(e._s(t))]),r("el-button",{attrs:{size:"mini",type:"primary",icon:"el-icon-delete"},on:{click:function(r){return e.deleteHistory(t)}}})],1)})),0)],1)],1)],1),e.showViewer?r("el-image-viewer",{staticStyle:{"z-index":"2500"},attrs:{"on-close":e.closeViewer,"url-list":[e.qrUrl]}}):e._e()],2)},i=[],a=r("b85c"),s=r("1da1"),o=r("d4ec"),c=r("bee2"),u=r("262e"),l=r("2caf"),h=(r("7db0"),r("99af"),r("4795"),r("0d03"),r("cb29"),r("a15b"),r("96cf"),r("9ab4")),d=r("1b40"),p=r("c1a2"),f=r("b804"),m=r("08a9"),v=r("db85"),g=r("9dba"),b=r("4c9b"),y=r("d257"),w=r("b7c7"),k=function(e){Object(u["a"])(r,e);var t=Object(l["a"])(r);function r(){var e;return Object(o["a"])(this,r),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.listQuery={page:1,limit:20,key:"",hasVersion:1},e}return Object(c["a"])(r,[{key:"userLevel",get:function(){return g["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!==g["a"].level){e.next=9;break}return e.next=5,this.getRemoteDeptList("");case 5:b["i"].$on(b["h"],(function(){t.getRemoteDeptList()})),this.$local.get(w["a"])&&(this.shop=this.$local.get(w["a"]).id),e.next=10;break;case 9:this.shop=g["a"].department;case 10:this.shop&&this.getShopInfo(this.shop),b["i"].$on(b["d"],(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===g["a"].level&&b["i"].$off(b["h"]),b["i"].$off(b["d"])}},{key:"onShopChange",value:function(){this.shop&&(this.getShopGameSetting(this.shop),this.$local.set(w["a"],{id:this.shop}),this.getShopInfo(this.shop))}},{key:"getList",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t,r;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,r=t.data,this.listLoading=!1,this.list=r.records,this.total=r.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 r,n,i,s,o,c,u;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(v["f"])({shopid:t});case 2:r=e.sent,n=r.data,console.log(n),this.gameid=n.gameid,this.versionid=n.versionid,this.updateGameSelected(),i=0;case 9:if(!(i<this.list.length)){e.next=34;break}s=this.list[i],o=Object(a["a"])(s.versions),e.prev=12,o.s();case 14:if((c=o.n()).done){e.next=22;break}if(u=c.value,1!==u.type){e.next=20;break}return e.next=19,this.getGameQr(this.shop,s._id,u._id);case 19:u.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,i,s);case 31:i++,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,r,n,i){var a,s,o;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return a={shop:t,gameId:r,version:n,params:i},e.next=3,Object(v["g"])(a);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,r,n,i){return e.apply(this,arguments)}return t}()},{key:"updateGameSelected",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var t,r,n,i,s,o,c,u,l=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(a["a"])(this.list),e.prev=4,t.s();case 6:if((r=t.n()).done){e.next=13;break}if(n=r.value,n._id!==this.gameid){e.next=11;break}return n.versions.find((function(e){return e._id===l.versionid}))||(this.versionid=n.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(i=0;i<this.list.length;i++){s=this.list[i],s.selected=s._id===this.gameid,o=Object(a["a"])(s.versions);try{for(o.s();!(c=o.n()).done;)u=c.value,u.selected=u._id===this.versionid}catch(h){o.e(h)}finally{o.f()}d["c"].set(this.list,i,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 r,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(!(g["a"].level>1)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,Object(v["k"])({key:t});case 4:if(r=e.sent,n=r.data,n.records){e.next=8;break}return e.abrupt("return");case 8:this.allDepts=n.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(v["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,r){var n=this;if(this.preGameId=t,this.preVersionId=e._id,1===e.type&&e.qr){this.qrUrl=e.qr,this.dialogVisible=!0;var i="".concat(this.preGameId,"|").concat(this.preVersionId),a=this.$local.get(i);this.historys.length=0,a&&(this.historys=a),setTimeout((function(){n.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,r,n;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),r="".concat(this.preGameId,"|").concat(this.preVersionId),this.$local.set(r,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 n=e.sent,e.next=20,Object(y["b"])(1);case 20:this.qrUrl=n,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 r="".concat(this.preGameId,"|").concat(this.preVersionId);this.$local.set(r,this.historys)}}},{key:"getShopInfo",value:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Object(v["e"])(t,{});case 3:r=e.sent,n=r.data,this.shopLogo=n.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:"doDraw",value:function(){var e=this,t=document.getElementById("qr_canvas");if(!t)return!1;var r=t.getContext("2d");r.clearRect(0,0,430,430);var n=new Image;n.src=this.qrUrl+"?t="+(new Date).getDate(),n.setAttribute("crossOrigin","Anonymous"),n.onload=function(){n.complete&&(r.drawImage(n,0,0,n.width,n.height),e.shopLogo&&e.drawLogo(r))}}},{key:"drawLogo",value:function(e){var t=new Image;t.src=this.shopLogo,t.setAttribute("crossOrigin","Anonymous"),t.onload=function(){if(t.complete){var r=document.createElement("canvas"),n=r.getContext("2d");r.width=430,r.height=430,n.fillStyle="#fff",n.fillRect(0,0,430,430),n.drawImage(t,0,0,t.width,t.height,120,120,190,190);var i=e.createPattern(r,"no-repeat");e.roundRect(120,120,190,190,95),e.fillStyle=i,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 r="image/png",n=t.toDataURL(r),i=document.createElement("a");i.download=e,i.href=n,i.dataset.downloadurl=[r,i.download,i.href].join(":"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}}]),r}(d["c"]);Object(h["a"])([Object(d["d"])("shop")],k.prototype,"onShopChange",null),k=Object(h["a"])([Object(d["a"])({name:"GameSetting",components:{Sticky:f["a"],ElImageViewer:m["a"]},filters:{parseGameType:function(e){return 1===e?"微信小游戏":"网页版"}}})],k);var x=k,_=x,S=(r("eda93"),r("25c7"),r("0c7c")),O=Object(S["a"])(_,n,i,!1,null,"0c3bb980",null);t["default"]=O.exports},"4c9b":function(e,t,r){"use strict";r.d(t,"i",(function(){return i})),r.d(t,"g",(function(){return a})),r.d(t,"a",(function(){return s})),r.d(t,"c",(function(){return o})),r.d(t,"d",(function(){return c})),r.d(t,"b",(function(){return u})),r.d(t,"e",(function(){return l})),r.d(t,"h",(function(){return h})),r.d(t,"f",(function(){return d}));var n=r("2b0e"),i=new n["default"],a="event_shop_puzzles_update",s="event_activity_update",o="event_exam_update",c="event_game_update",u="event_coupon_update",l="event_puzzle_update",h="event_shop_update",d="event_role_update"},"54bf":function(e,t,r){},"7db0":function(e,t,r){"use strict";var n=r("23e7"),i=r("b727").find,a=r("44d2"),s="find",o=!0;s in[]&&Array(1)[s]((function(){o=!1})),n({target:"Array",proto:!0,forced:o},{find:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}}),a(s)},"81d5":function(e,t,r){"use strict";var n=r("7b0b"),i=r("23cb"),a=r("50c4");e.exports=function(e){var t=n(this),r=a(t.length),s=arguments.length,o=i(s>1?arguments[1]:void 0,r),c=s>2?arguments[2]:void 0,u=void 0===c?r:i(c,r);while(u>o)t[o++]=e;return t}},c1a2:function(e,t,r){"use strict";r.d(t,"b",(function(){return i})),r.d(t,"a",(function(){return a})),r.d(t,"e",(function(){return s})),r.d(t,"d",(function(){return o})),r.d(t,"f",(function(){return c})),r.d(t,"c",(function(){return u}));var n=r("b32d"),i={type:0,name:""},a={versions:[i],name:""},s=function(e){return Object(n["a"])({url:"/api/games",method:"post",params:e})},o=function(e,t){return Object(n["a"])({url:"/api/game/".concat(e),method:"get",params:t})},c=function(e){return Object(n["a"])({url:"/api/game/save",method:"post",data:e})},u=function(e){return Object(n["a"])({url:"/api/game/".concat(e,"/delete"),method:"post"})}},cb29:function(e,t,r){var n=r("23e7"),i=r("81d5"),a=r("44d2");n({target:"Array",proto:!0},{fill:i}),a("fill")},dd49:function(e,t,r){e.exports={menuBg:"#304156",menuText:"#bfcbd9",menuActiveText:"#409eff"}},eda93:function(e,t,r){"use strict";r("dd49")}}]);
|
|
//# sourceMappingURL=chunk-5bb6b064.9cf003da.js.map
|