欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

微信小程序如何實現(xiàn)購物時限購商品的數(shù)量

這篇文章主要介紹微信小程序如何實現(xiàn)購物時限購商品的數(shù)量,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

沙坪壩網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)建站,沙坪壩網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為沙坪壩1000+提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請找那個售后服務(wù)好的沙坪壩做網(wǎng)站的公司定做!

展示效果如下:

微信小程序如何實現(xiàn)購物時限購商品的數(shù)量

兩個底部用的是一個彈框,利用submit_type的類型不一樣來進行區(qū)分哪個是單獨購買哪個是包郵開團

wxml代碼如下:

 <view class="num-box">
      <view class="weui-media-box__bd">
          <view class="promotion-sku clear">
             <view class="Spinner">
                <a wx:if="{{goods_count==1}}" class="DisDe">
                     <i bindtap="minusCount" data-index="{{index}}" class="DisDe">-</i>
                </a>
                <a wx:if="{{goods_count>1}}" class="Decrease">
                     <i bindtap="minusCount" data-index="{{index}}" class="DisDe">-</i>
                </a>
             <view>
              <input class="Amount" bindinput="changeCount" type='number' value="{{goods_count}}" autocomplete="off" maxlength="3"  data-submit_type="{{submit_type}}" />
           </view>
                <a class="Increase">
                   <i bindtap="addCount" data-index="{{index}}" data-submit_type="{{submit_type}}">+</i>
                </a>                   
          </view>
         </view>
      </view>
 </view>

data-submit_type="{{submit_type}}"中的submit_type就是判斷是單獨還是開團購買

js代碼如下:

// 增加數(shù)量
  addCount(e) {
    // 購買類型,單獨購買或拼團購買
    let submit_type = e.target.dataset.submit_type;
    var goods_count = this.data.goods_count;
    goods_count = parseInt(goods_count) + 1;
    //debugger
    if (submit_type == 2) {  // 拼團購買
      var limited_num = this.data.collage.limited_num;
      if (goods_count > limited_num) {
        this.showTip('超出限購');
        return;
      }
    }
    this.setData({
      goods_count: goods_count
    });
  },
// 改變數(shù)量(input內(nèi)的值)
  changeCount(e) {
    var goods_count = e.detail.value;

    let submit_type = e.target.dataset.submit_type;
    if (submit_type == 1) {
      var sys_num = this.data.goods_num;
      if (goods_count > sys_num) {  // 單獨購買
        this.showTip('庫存不足');
        return;
      }
    } else if (submit_type == 2) {  // 拼團購買
      var limited_num = this.data.collage.limited_num;
      if (goods_count > limited_num) {
        this.showTip('超出限購');
        return;
      }
    }

    if (!(/^[\d]+\.?\d*$/.test(goods_count))) {
      goods_count = goods_count.replace(/\D/g, '');
      return goods_count ? goods_count : 1;
    }
    if (goods_count < 1) {
      return 1;
    }
    this.setData({
      goods_count: goods_count
    });
  },

以上是“微信小程序如何實現(xiàn)購物時限購商品的數(shù)量”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

文章標題:微信小程序如何實現(xiàn)購物時限購商品的數(shù)量
當前網(wǎng)址:http://chinadenli.net/article42/gddshc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT關(guān)鍵詞優(yōu)化、移動網(wǎng)站建設(shè)、標簽優(yōu)化網(wǎng)站收錄、自適應(yīng)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護公司