Commit bca62d59787b925f1ca6ca091757acc18c0944de

Authored by 后端研发-倪永富
1 parent 935c5880

秒杀页增加分享小程序分享到朋友圈,商品详情页折扣数值处理

pages/activity/seckill_list/seckill_list.js
... ... @@ -177,6 +177,12 @@ Page({
177 177 _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
178 178 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
179 179 }
180   - }
  180 + },
  181 +
  182 + onShareTimeline() {
  183 + return {
  184 + title: '秒杀活动-' + getApp().globalData.config.store_name,
  185 + }
  186 + },
181 187  
182 188 });
... ...
pages/goods/goodsInfo/g_filter.wxs
... ... @@ -80,8 +80,38 @@ var g_filters = {
80 80 if(min_name.length>4) min_name=min_name.substring(0, 8);
81 81 return min_name;
82 82 },
  83 +
  84 + toFix: function (val, count,set) {
  85 + if(val===undefined) return 0;
  86 + if(val===null) return 0;
  87 + if(val==='') return 0;
  88 + val = parseFloat(val);
  89 + if(set==1 && val==0) return val;
  90 + return val.toFixed(count)
  91 + },
  92 +
  93 + //折扣数值处理,小数位数为1时,只显示1位;小数位数为2时,才显示2位;
  94 + num: function(value) {
  95 + if(value != 0) {
  96 + var val = value.toFixed(2).toString();
  97 + if(val.indexOf('.') != -1) {
  98 + var arrval = val.split('.');
  99 + if(arrval[1].length == 1 && arrval[1][0] == 0) {
  100 + val = val.slice(0,-2);
  101 + };
  102 +
  103 + if(arrval[1].length == 2 && arrval[1][1] == 0) {
  104 + val = val.slice(0,-1);
  105 + };
  106 + };
  107 + return val;
  108 + } else {
  109 + return value.toFixed(0);
  110 + };
  111 + },
83 112 }
84 113 module.exports = {
85 114 is_has_rank:g_filters.is_has_rank,
86   - get_card_price:g_filters.get_card_price,
  115 + get_card_price:g_filters.get_card_price,
  116 + num:g_filters.num,
87 117 }
88 118 \ No newline at end of file
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -700,7 +700,25 @@ Page({
700 700 ee.check_is_youhui(ee.data.gid);
701 701  
702 702 t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss');
703   - var txt = (t.data.data.shop_price / t.data.data.market_price * 10).toFixed(2);
  703 + var txt = (t.data.data.shop_price / t.data.data.market_price * 10).toFixed(2).toString();
  704 +
  705 +
  706 + if(txt != 0) {
  707 + if(txt.indexOf('.') != -1) {
  708 + var arrtxt = txt.split('.');
  709 + if(arrtxt[1].length == 1 && arrtxt[1][0] == 0) {
  710 + txt = txt.slice(0,-2);
  711 + };
  712 +
  713 + if(arrtxt[1].length == 2 && arrtxt[1][1] == 0) {
  714 + txt = txt.slice(0,-1);
  715 + };
  716 + };
  717 + } else {
  718 + txt = 0;
  719 + }
  720 +
  721 +
704 722 t.data.data['disc'] = txt;
705 723  
706 724 if (t.data.data.original_img.indexOf(o.imghost) == -1)
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -257,7 +257,8 @@
257 257  
258 258 <view class="goods-num">
259 259 <view class="sales">销量:{{prom_act.buy_num}}件</view>
260   - <view class="stock">折扣:{{filters.pInt((prom_price?prom_price:0)*100/data.shop_price)}}折</view>
  260 + <!-- <view class="stock">折扣:{{data.disc}}折</view> -->
  261 + <view class="stock">折扣:{{g_filters.num((prom_price?prom_price:0)*100/data.shop_price)}}折</view>
261 262 <view class="stock">{{categories3[0].num}}人评价</view>
262 263 </view>
263 264 </view>
... ... @@ -364,6 +365,7 @@
364 365 <view class="goods-num" wx:if="{{prom_type!=1}}">
365 366 <view class="sales">销量:{{data.sales_sum}}件</view>
366 367 <view class="stock">折扣:{{data.disc}}折</view>
  368 + <!-- <view class="stock">折扣:{{filters.pInt((prom_price?prom_price:0)*100/data.shop_price)}}折</view> -->
367 369 <view class="stock">{{categories3[0].num}}人评价</view>
368 370 </view>
369 371 <view wx:if="{{prom_type==1}}">
... ...