Commit 7d6ab3d6e22da39a7e4c7d7381afae7dc6f062eb

Authored by F5VT98DI7XY4X12\Administrator
1 parent 46ab4175

点赞避免重复点击

pages/goods/goodsInfo/goodsInfo.js
... ... @@ -201,6 +201,9 @@ Page({
201 201 is_show_pp:0, //是否品牌
202 202 is_show_gb:0, //是否国别
203 203 is_closecoupon:0,
  204 +
  205 + //是否点赞中
  206 + iszaning: 0,
204 207 },
205 208  
206 209 //------初始化加载----------
... ... @@ -2070,6 +2073,9 @@ Page({
2070 2073 }
2071 2074  
2072 2075 var iszan=th.data.comments[item_id].userZanNum;
  2076 + if(this.data.iszaning) return false;
  2077 + this.data.iszaning=1;
  2078 +
2073 2079  
2074 2080 app.request.post("/api/weshop/commentZan/save",{
2075 2081 data:{store_id:o.stoid,user_id:app.globalData.user_id,goods_id:th.data.gid,comment_id:com_id},
... ... @@ -2077,11 +2083,11 @@ Page({
2077 2083  
2078 2084 if (ee.data.code == "-1") {
2079 2085 app.my_warnning("不能给自己点赞", 0, th);
  2086 + th.data.iszaning=0;
2080 2087 return;
2081 2088 }
2082 2089  
2083 2090 if(ee.data.code==0 && iszan!=1){
2084   -
2085 2091 var num=th.data.comments[item_id].zan_num; num++;
2086 2092 var text="comments["+item_id+"].zan_num";
2087 2093 var text1="comments["+item_id+"].userZanNum";
... ... @@ -2089,6 +2095,7 @@ Page({
2089 2095 _errObj[text]=num;
2090 2096 _errObj[text1]=1;
2091 2097 th.setData(_errObj);
  2098 +
2092 2099 }else{
2093 2100 var num=th.data.comments[item_id].zan_num; num--;
2094 2101 var text="comments["+item_id+"].zan_num";
... ... @@ -2098,6 +2105,11 @@ Page({
2098 2105 _errObj[text1]=0;
2099 2106 th.setData(_errObj);
2100 2107 }
  2108 +
  2109 + setTimeout(function(){
  2110 + th.data.iszaning = 0;
  2111 + },500)
  2112 +
2101 2113 }
2102 2114 })
2103 2115 },
... ...