小程序功能模块

1、拉起微信支付

let data = res.Data.m_values;
  wx.requestPayment({
	'timeStamp': data.timeStamp,
    'nonceStr': data.nonceStr,
    'package': data.package,
    'signType': data.signType,
    'paySign': data.paySign,
    'success': function (res) {
       if (res.errMsg == 'requestPayment:ok') {
           wx.setNavigationBarTitle({
           title: ''
       })
       that.setData({
          showSuccess: true
       })
     }
   },
   'fail': function (err) {
       wx.redirectTo({
       url: '/pages/myOrderDetail/myOrderDetail?orderid=' + that.data.orderid,
       })
    }
})

2、picker日期选择

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
const formatTime = () => {
  let date = new Date;
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  return [year, month].map(formatNumber).join('-') 
}

data: {
	date: formatTime()
}
//切换日期
bindDateChange(e) {
    this.setData({
      date: e.detail.value
    });
},

3、 tab栏滑动切换

 bindChange(e) {
    this.setData({
      currentTab: e.detail.current,
    });
 }

4、组件间通信
具体参数详情见文档组件间通信

在对组件进行封装时 
在当前页面想要获取组件中的某一状态
需要使用到this.triggerEvent(' ',{},{})

3、手机拨打电话(涉及组件间通信)

//json
 "usingComponents": {
    "i-modal": "/components/iview/modal/index"
 }

<view bindtap="callTel"></view>  
//拨打电话模态框
<i-modal visible="{{ showTel }}" ok-text="拨打" bind:ok="makeCall" bind:cancel="downphone">
	<view>{{callPhone}}</view>
</i-modal>
  
callTel() {
    wx.showActionSheet({
      //电话列表数据
      itemList: this.data.phoneList,
      success: res => {
        let phoneNums = this.data.phoneNums;
        let callPhone = phoneNums[res.tapIndex]; 
        this.setData({
          callPhone  
        })
        this.downphone();
      },
      fail: err => {
        // console.log(err.errMsg)
      }
    })
}

//modal子组件
Component({
    externalClasses: ['i-class', 'i-class-mask'],

    properties: {
        visible: {
            type: Boolean,
            value: false
        },
        title: {
            type: String,
            value: ''
        },
        showOk: {
            type: Boolean,
            value: true
        },
        showCancel: {
            type: Boolean,
            value: true
        },
        okText: {
            type: String,
            value: '确定'
        },
        cancelText: {
            type: String,
            value: '取消'
        },
        // 按钮组,有此值时,不显示 ok 和 cancel 按钮
        actions: {
            type: Array,
            value: []
        },
        // horizontal || vertical
        actionMode: {
            type: String,
            value: 'horizontal'
        }
    },

    methods: {
        handleClickItem ({ currentTarget = {} }) {
            const dataset = currentTarget.dataset || {};
            const { index } = dataset;
            this.triggerEvent('click', { index });
        },
        handleClickOk () {
            this.triggerEvent('ok');
        },
        handleClickCancel () {
        
            this.triggerEvent('cancel');
        }
    }
});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值