payOrder

parent

<script>
  export default class Parents extends wepy.page {
    
    data = {
        tabdata:{}, //下面要用这里必须要写上
    }
    
    async onLoad() {
        
       let data =  await getData(,"public/data",{session_key:"1234456"});
       this.tabdata= data.tab;
       this.$apply();//必须
    }
  }
</script>
<template lang="wxml">
   <view class="title" slot="title"></view>
   <view class="title" slot="content">
     <Tab :tab.sync="tabdata" ></Tab>
   </view>
</template>
child

<template lang="wxml">
    <view class="title" slot="title">{{tab}}</view>
</template>
export default class Tab extends wepy.component {
      props = {
        tab:{
          type:Object,
          default:null,
          twoWay:true
        }
}
payOrder(e) {
      let _this = this
      payOrder(e.currentTarget.id).then(res => {
        if (res && res.data) {
          if (res.data.code) {
            _this.$invoke('toast', 'showToast', {
              title: res.data.message,
              time: 1000
            })
            _this.isClick = false
            return
          }
        }
        wx.requestPayment({
          timeStamp: res.timeStamp,
          nonceStr: res.nonceStr,
          package: res.package,
          signType: 'MD5',
          paySign: res.sign,
          success: function(_res) {
            console.log('orderItem=>payOrder=>支付成功', _res)
            wx.navigateTo({
              url: `/pages/pay-success-page?orderNo=${res.orderNo}`
            })
            _this.toDoWhatUShouldDo(e, 2)
          },
          fail: function(err) {
            console.log('orderItem=>payOrder=>支付失败', err)
          }
        })
      })
    },
this.couponList[e.currentTarget.id].type

chooseCoupon(e) {
      // 是否用默认优惠券
      this.useDefaultCoupon = 0

      // 判断选择优惠券类型 不同型要取消重选
      if (!this.couponList[e.currentTarget.id].chosen) {
        let isChangeType = this.judgeChosen(
          this.couponList[e.currentTarget.id].type
        )
        if (isChangeType === 0) {
          this.$invoke('toast', 'showToast', {
            title: '如需更换优惠券,请先取消当前优惠券',
            time: 500
          })
          return
        }
      }
_getOrderList(status, fn, refresh) {
    let _status = ''
    if (parseInt(status)) {
      _status = status
    }
    if (this.over) {
      return
    }
    getOrderList(_status, this.page++)
      .then(res => {
        if (res.length === 0) {
          this.over = true
        } else {
          //  初始化列表 添加唯一标识index 倒计时初始值
          res &&
            res.map((el, index) => {
              // 订单商品奇偶背景色
              el.detailList.map(e => {
                e.odd = this.pNum % 2
                this.pNum++
              })
              el.index = index + (this.page - 2) * 10
              el.createTime = format(el.createTime, 8)
              el.currentPage = _status
              console.log('order-page==>expireTime', el.expireTime)
              let minutes = parseInt((el.expireTime / 1000 / 60) % 60, 10)
              let seconds = parseInt((el.expireTime / 1000) % 60, 10)
              el.overTime = `${minutes >= 10 ? minutes : '0' + minutes}:${
                seconds >= 10 ? seconds : '0' + seconds
              }`
              console.log('order-page==>el.overTime', el.overTime)
            })
          if (refresh) {
            this.orderList = []
          }
          this.orderList = this.orderList.concat(res)
          this.delay = false
          fn && fn()
        }
        this.showEmpty = true
        this.$apply()
        console.log('order-page=>getOrderList=>订单列表', this.orderList)
      })
      .catch(err => {
        this.delay = false
        console.log('order-page=>getOrderList=>订单列表错了err', err)
      })
  }
posted @ 2019-05-28 01:35  达达前端  阅读(698)  评论(0编辑  收藏  举报