Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
tbkjx: fix bug and upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
zimocode committed Oct 13, 2019
1 parent cff79a3 commit ade7d77
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 20 deletions.
20 changes: 17 additions & 3 deletions css/inject/tbkjx.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_sortbtncur{
background: rgb(86, 119, 252);
}
smartup.su_apps#su_apps_tbkjx .su_tbkjx_extent{
padding: 4px 0;
/*padding: 4px 0;*/
padding: 0;
margin-bottom: 4px;
}
smartup.su_apps#su_apps_tbkjx .su_tbkjx_extenttext{
width: 35px;
Expand All @@ -104,6 +106,7 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_img{
height: 360px;
width: 360px;
display: block;
cursor: pointer;
}
smartup.su_apps#su_apps_tbkjx .su_tbkjx_name{
width: 360px;
Expand Down Expand Up @@ -143,7 +146,7 @@ smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing{
padding-top: 86px;

padding-top: 0;
margin-top: 86px;
margin-top: 106px;
position: initial;
}
smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing ul{
Expand All @@ -155,7 +158,7 @@ height: 288px;
overflow-y: auto;
overflow-x: hidden;
height: 328px;
height: 298px;
height: 278px;
padding: 2px 0;
}
smartup.su_apps#su_apps_tbkjx .su_tbkjx_listjing li{
Expand Down Expand Up @@ -247,4 +250,15 @@ smartup.su_apps#su_apps_tbkjx .su_options_help li{
font-size: 12px;
display: block;
float: unset;
}
smartup.su_apps#su_apps_tbkjx .su_tbkjx_qr{
position: absolute;
left: 16px;
bottom: 76px;
}
smartup.su_apps#su_apps_tbkjx .su_tbkjx_qr img{
width: 0px;
height: 0px;
opacity: 0;
cursor: pointer;
}
5 changes: 3 additions & 2 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3583,7 +3583,8 @@ var sub={
}else if(message.apptype=="qr"){
chrome.tabs.executeScript({file:"js/qrcode.js",runAt:"document_start"},function(){})
}else if(message.apptype=="tbkjx"){
chrome.tabs.executeScript({file:"js/purify.js",runAt:"document_start"},function(){})
chrome.tabs.executeScript({file:"js/purify.js",runAt:"document_start"},function(){});
chrome.tabs.executeScript({file:"js/qrcode.js",runAt:"document_start"},function(){});
}

chrome.tabs.insertCSS({file:"css/inject/"+message.apptype+".css",runAt:"document_start"},function(){});
Expand Down Expand Up @@ -4262,7 +4263,7 @@ var sub={
fetch(_configURL)
.then(response=>response.json())
.then(json=>{
if(!localStorage.getItem("tbkjx_dataversion")||Number(json.version)>sub.date.get()){
if(!localStorage.getItem("tbkjx_dataversion")||Number(json.version)>=sub.date.get()){
_url=_url+"?"+sub.date.get().toString();
localStorage.setItem("tbkjx_dataversion",json.version);
}else{
Expand Down
74 changes: 60 additions & 14 deletions js/inject/tbkjx.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ sue.apps.tbkjx={
let headSort=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_sort"]});
let _sortReset=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortreset"]},null,null,null,"默认排序"),
_sortUp=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortup"]},null,"margin:0 5px;",null,"价格由低到高"),
_sortDn=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortdn"]},null,null,null,"价格由高到低");
_sortDn=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortdn"]},null,null,null,"价格由高到低"),
_sortCup=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortcup"]},null,null,null,"优惠券额由低到高"),
_sortCdn=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_sortbtn su_tbkjx_sortcdn"]},null,"margin:4px;",null,"优惠券额由高到低");
headSort.appendChild(_sortReset);
headSort.appendChild(_sortUp);
headSort.appendChild(_sortDn);
headSort.appendChild(_sortCup);
headSort.appendChild(_sortCdn);

let headExtent=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_extent"]});
let _extentSpan=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_extentspan"]},null,null,null,"价格范围:"),
Expand Down Expand Up @@ -80,8 +84,9 @@ sue.apps.tbkjx={
_info=sue.apps.domCreate("ul");
_info.appendChild(sue.apps.domCreate("li",null,null,null,null,"1、每日更新上万款优惠券商品,购物前可以从这里搜索是否有和心意的。"));
_info.appendChild(sue.apps.domCreate("li",null,null,null,null,"2、由于商家调价等因素,部分商品价格可能有变动。"));
_info.appendChild(sue.apps.domCreate("li",null,null,null,null,"3、理性购物,多多比较,购买需要的物品。"));
let _li=sue.apps.domCreate("li",null,null,null,null,"4、此迷你应用也有相应的网页版本:");
_info.appendChild(sue.apps.domCreate("li",null,null,null,null,"3、点击商品图片显示领券地址的二维码。可以通过手机淘宝扫码在手机上领券购买!"));
_info.appendChild(sue.apps.domCreate("li",null,null,null,null,"4、理性购物,多多比较,购买需要的物品。"));
let _li=sue.apps.domCreate("li",null,null,null,null,"5、此迷你应用也有相应的网页版本:");
let _a=sue.apps.domCreate("a",{setName:["href","target"],setValue:["https://quan.zimoapps.com","_blank"]},null,null,null,"quan.zimoapps.com");
_li.appendChild(_a);
_info.appendChild(_li);
Expand All @@ -93,16 +98,19 @@ sue.apps.tbkjx={
dom.querySelector(".su_head").style.cssText+="background-color:#2b2b34;";
dom.addEventListener("click",this.handleEvent,false);
dom.addEventListener("keypress",this.handleEvent,false);
dom.addEventListener("mouseover",this.handleEvent,false);
},
itemInit:function(data){
let _dom=sue.apps.tbkjx.dom.querySelector(".su_main .su_tbkjx_boxcontent");
_dom.textContent="";
let _img=sue.apps.domCreate("img",{setName:["className","src"],setValue:["su_tbkjx_img",data[1]]}),
// let _img=sue.apps.domCreate("img",{setName:["className","src"],setValue:["su_tbkjx_img",data[1]]}),
let _img=sue.apps.domCreate("div",{setName:["className","title"],setValue:["su_tbkjx_img","点击图片显示领券地址的二维码。\n通过手机淘宝扫码在手机上领券购买!"]},null,"background-image:url("+data[1]+");background-size:contain"),

_name=sue.apps.domCreate("div",{setName:["className","title"],setValue:["su_tbkjx_name",DOMPurify.sanitize(data[0])]},null,null,null,DOMPurify.sanitize(data[0])),

_spanPrice=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_spanprice su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]},"券后价"),
_price=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_price su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]},"¥"+DOMPurify.sanitize(data[2])),
_buy=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_buy su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]},"前往领券"),
_buy=sue.apps.domCreate("span",{setName:["className"],setValue:["su_tbkjx_buy su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]},"前往领券(¥"+DOMPurify.sanitize(data[4])+")"),

_btnBox=sue.apps.domCreate("button",{setName:["className"],setValue:["su_tbkjx_btnbox su_tbkjx_open"]},null,null,{setName:["link"],setValue:[DOMPurify.sanitize(data[3])]});

Expand All @@ -113,6 +121,13 @@ sue.apps.tbkjx={
_dom.appendChild(_img);
_dom.appendChild(_name);
_dom.appendChild(_btnBox);

let _domQr=sue.apps.domCreate("div",{setName:["className"],setValue:["su_tbkjx_qr"]},null,"display:none;");
new QRCode(_domQr,data[3]);
_img.appendChild(_domQr);
window.setTimeout(function(){
_domQr.style.cssText+="display:block;";
},500)
},
initList:function(data,page){
// sue.apps.tbkjx.cons.curData=data;
Expand Down Expand Up @@ -175,6 +190,10 @@ sue.apps.tbkjx={
sortType="up";
}else if(e.target.classList.contains("su_tbkjx_sortdn")){
sortType="dn";
}else if(e.target.classList.contains("su_tbkjx_sortcup")){
sortType="cup";
}else if(e.target.classList.contains("su_tbkjx_sortcdn")){
sortType="cdn";
}else{
sortType="reset";
}
Expand All @@ -186,6 +205,9 @@ sue.apps.tbkjx={
if(e.target.classList.contains("menu_item_help")){
sue.apps.tbkjx.showHelp(e);
}
if(e.target.classList.contains("su_tbkjx_img")||(e.target.parentNode&&e.target.parentNode.classList.contains("su_tbkjx_qr"))){
sue.apps.tbkjx.showQR();
}
break;
case"keypress":
if(e.keyCode==13&&e.target.id=="su_tbkjx_searchkey"){
Expand All @@ -196,6 +218,17 @@ sue.apps.tbkjx={
break;
}
},
showQR:function(){
var _qrImg=sue.apps.tbkjx.dom.querySelector(".su_tbkjx_qr img");
console.log(_qrImg)
var _qrState=window.getComputedStyle(_qrImg).width=="0px"?true:false;
console.log(_qrState)
if(_qrState){
_qrImg.style.cssText+="width:345px;height:345px;opacity:1;";
}else{
_qrImg.style.cssText+="width:0px;height:0px;opacity:0;";
}
},
itemSearch:function(){
let _dom=sue.apps.tbkjx.dom;
_dom.querySelector("#su_tbkjx_extentfrom").value="";
Expand All @@ -207,6 +240,7 @@ sue.apps.tbkjx={
let arrayDiff=function(arr) {
let result = [];
let obj = {};
if(!arr){return result;}
for(var i=0;i<arr.length;i++){
if(!obj[arr[i]]){
result.push(arr[i]);
Expand All @@ -219,7 +253,7 @@ sue.apps.tbkjx={
var _num=-1;
for(var ii=0;ii<_keys.length;ii++){
if(_keys[ii]==" "){_keys.splice(ii,1);continue;}
if(data[i][0].indexOf(_keys[ii])!=-1){
if(data[i][0].toLowerCase().indexOf(_keys[ii].toLowerCase())!=-1){
_num++;
}
}
Expand Down Expand Up @@ -253,14 +287,26 @@ sue.apps.tbkjx={
},
itemSort:function(sortType){
let compare=function(type){
return function(m,n){
var a = m[2];
var b = n[2];
if(type=="up"){
return a - b;
}else{
return b - a;
}
if(type=="up"||type=="dn"){
return function(m,n){
var a = m[2];
var b = n[2];
if(type=="up"){
return a - b;
}else{
return b - a;
}
}
}else{
return function(m,n){
var a = m[4];
var b = n[4];
if(type=="cup"){
return a - b;
}else{
return b - a;
}
}
}
}
if(sortType!="reset"){
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"minimum_chrome_version": "22",
"name": "smartUp Gestures(Beta)",
"short_name":"smartUp",
"version": "6.5.1341.1024",
"version": "6.5.1341.1025",
"description": "__MSG_ext_des__",
"default_locale": "en",
"author":"zimo",
Expand Down

0 comments on commit ade7d77

Please sign in to comment.