小程序模板網(wǎng)

怎么實(shí)現(xiàn)兩個(gè)view動(dòng)態(tài)排序?

發(fā)布時(shí)間:2018-10-26 08:49 所屬欄目:小程序開發(fā)教程
wxml:
<view class='LBall' >
<!-- 1:樓盤商品介紹 -->
<block  wx:for='{{loupanbt}}'  data-loupanID="{{loupanbt.loupanbtID}}" wx:for-item="loupanbt"   wx:key="{{loupanbt.id}}">
<view class='anjia-loupanjieshao'>
<view class='maidian-thought-1'>\r\t{{loupanbt.loupanbiaoti}}\t\r</view>
<view class='anjia-wenzi'>{{loupanbt.loupanwenben}}</view>
<view class='anjia-image'><image src='{{loupanbt.images}}'></image></view>
</view>

<!-- 2:預(yù)約撥打電話 -->
<view class='tantou' wx:for='{{tantou}}' data-tantouID="{{tantou.tantouID}}"  wx:for-item="tantou"   wx:key="{{unique}}">
<view class='tantou-xinxi'>
<button class='tantou-lejie'><navigator url="">{{tantou.lejie}}
</navigator></button>
<button class='tantou-bodas' catchtap='phone'>{{tantou.bodas}}</button>
</view>
<view class='tantou-xinxi'>
<form bindsubmit="yuyueSubmit">
<input type="number"  class="yuyuephone" name="yuyuephone" placeholder="輸入您電話"id="yuyuephone"  maxlength="11" bindinput='blurPhone'/>
<button form-type='submit' class='yuyuebtn'>{{tantou.queding}}</button>
</form>
</view>
</view>
</block>
</view>







js:請(qǐng)求代碼
//成功后的回調(diào)
      success: function (res) {
        console.log(res)
        var status=that.data.loupanID;
        var status=that.data.tantouID;
        if (status == 1) { //假設(shè)這json有l(wèi)oupanbt.loupanbtID參數(shù)
          that.setData({
            loupanbt: res.data,//生成div  
          })
        } else if (status == 2) { //假設(shè)這json有tantou.tantouID參數(shù)
          const length = this.data.tantou.length;
          this.data.tantou = [{ lejie: length, bodas: length, queding: length, unique:'unique_' + length }].concat(this.data.tantou)//小程序端自動(dòng)增加一個(gè)靜態(tài)div
           this.setData({
             tantou:boda//生成div
           })


        }

json模擬:
[  {          "loupanbtID":"1",     "loupanbiaoti": "靠近地鐵,臨近商圈1",    
 "loupanwenben":"穗莞深軌道規(guī)劃接駁,東莞地鐵時(shí)代來臨卓越中寰踞R2線天寶站B出口,
真地鐵口物業(yè)直達(dá)CBD,縱貫穗-莞-深-港同時(shí)20多條公交線路,交通便捷",     "images": "http://192.168.1.103/img/ceshi.jpg"  }, 
 {           "loupanbtID":"1",     "loupanbiaoti": "靠近地鐵,臨近商圈2",    
 "loupanwenben":"穗莞深軌道規(guī)劃接駁,東莞地鐵時(shí)代來臨卓越中寰踞R2線天寶站B出口,
真地鐵口物業(yè)直達(dá)CBD,縱貫穗-莞-深-港同時(shí)20多條公交線路,交通便捷",    
 "images": "http://192.168.1.103/img/ceshi.jpg"  },  {          "tantouID":"2"  }, 
 {          "loupanbtID":"1",     "loupanbiaoti": "靠近地鐵,臨近商圈3",    
 "loupanwenben":"穗莞深軌道規(guī)劃接駁,東莞地鐵時(shí)代來臨卓越中寰踞R2線天寶站B出口,
真地鐵口物業(yè)直達(dá)CBD,縱貫穗-莞-深-港同時(shí)20多條公交線路,交通便捷",    
 "images": "http://192.168.1.103/img/ceshi.jpg"  },  {           "loupanbtID":"1",    
 "loupanbiaoti": "靠近地鐵,臨近商圈4",     "loupanwenben":"穗莞深軌道規(guī)劃接駁,東莞地鐵時(shí)代來臨卓越中寰踞R2線天寶站B出口,
真地鐵口物業(yè)直達(dá)CBD,縱貫穗-莞-深-港同時(shí)20多條公交線路,交通便捷",     "images": "http://192.168.1.103/img/ceshi.jpg"  },        ]


我想根據(jù)后端排序來實(shí)現(xiàn):商品列表view和撥打電話view,動(dòng)態(tài)隨意排序(我后端有個(gè)編輯器可以把商品列表和撥打電話view隨意打亂順序),我前端請(qǐng)求時(shí)候該怎么判斷是商品列表還是撥打電話view?
目前我上面代碼:我的思路是:根據(jù)定義id(data-tantouID="{{tantou.tantouID}}" )來判斷順序,數(shù)據(jù)我拿到了,可是組裝不成功,,有大佬指教下問題所在嗎?

 
本主題由 Rolan 于 4 天前 審核通過
 

SF)MN8PF`Q39LFV$@V(OGZI.png (91.32 KB, 下載次數(shù): 1)

 

SF)MN8PF`Q39LFV$@V(OGZI.png


易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://22321a.com/wxmini/doc/course/24909.html 復(fù)制鏈接 如需定制請(qǐng)聯(lián)系易優(yōu)客服咨詢:800182392 點(diǎn)擊咨詢
QQ在線咨詢