小程序中加載數據,請求數據,阿賈克斯,時間戳

 

wxml代碼:javascript

<wxs module="t" src="../../../utils/time.wxs">
</wxs>
<block wx:for="{{coin.list}}">
 <view class="detail" data="{{item}}">
   <view class="row">
     <view class="col-7">
       <view class="remark">{{item.remark}}</view>
       <view class="coin-box">
         <view>變更積分</view>
         <view wx:if="{{item.type == '1'}}">+</view>
         <view wx:if="{{item.type == '2'}}">-</view>
         <view>{{item.coin}}</view>
       </view>
     </view>
     <view class="col-5">
       <view class="time">{{t.timestampToTime(item.create_time)}}</view>
     </view>
   </view>
 </view>
</block>

wxss代碼:css

.detail {
 width: 100%;
 box-sizing: border-box;
 padding: 20rpx 30rpx;
 height: 190rpx;
 margin-top: 10rpx;
 background: #fff;
}
.detail .remark {
 height: 75rpx;
 line-height: 75rpx;
 font-size: 28rpx;
}
.detail  .coin-box {
 height: 75rpx;
 line-height: 75rpx;
 font-size: 28rpx;
 display: flex;
}
.detail .time {
 height: 150rpx;
 line-height: 150rpx;
 text-align: right;
 font-size: 28rpx;
}

wxjs代碼:html

var app = getApp();
Page({
 /**
  * 頁面的初始數據
  */
 data: {
   coin: {
     total: 0,
     list: [],
   }, //積分
   page_num: 1
 },
 /**
  * 生命週期函數--監聽頁面加載
  */
 onLoad: function(options) {
   this.loadCoinList();
 },
 /**
  * 生命週期函數--監聽頁面初次渲染完成
  */
 onReady: function() {
 },
 /**
  * 生命週期函數--監聽頁面顯示
  */
 onShow: function() {
 },
 /**
  * 生命週期函數--監聽頁面隱藏
  */
 onHide: function() {
 },
 /**
  * 生命週期函數--監聽頁面卸載
  */
 onUnload: function() {
 },
 /**
  * 頁面相關事件處理函數--監聽用戶下拉動做
  */
 onPullDownRefresh: function() {
 },
 /**
  * 頁面上拉觸底事件的處理函數
  */
 onReachBottom: function() {
 },
 /**
  * 用戶點擊右上角分享
  */
 onShareAppMessage: function() {
 },
 loadCoinList() {
   var data = {
     page_num: this.data.page_num
   }
   app.httpPost('/coin/trans/list', data, (res) => {
     this.setData({
       coin: res.data
     })
   })
 }
})

以上是一個請求積分變更列表的代碼。java

相關文章
相關標籤/搜索