微信小程序常用代码

微信的通知服务

var access_token = await wepy.request({
  url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=小程序的appid&secret=小程序的secret`,
  method: 'GET',
  header: { 'content-type': 'application/json' }
})

var sendMsg = await wepy.request({
  url: `https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=${access_token
    .data.access_token}`,
  method: 'POST',
  header: { 'content-type': 'application/json' },   //必须是json , 如果是urlencode会报错
  data: {
    touser: openid,
    template_id: '模板id在控制台获取',
    page: 'pages/setting/manage-address-page',
    form_id: prepay_id,   //支付的prepay_id
    data: {
      keyword1: '123',  
      keyword2: 'LION '
    }
  }
})

微信的客服服务

<contact-button 
  type="default-light" 
  size="20"
  session-from="weapp"
>
</contact-button>
微信管理平台设置后台客服的微信, 消息会自动推送到指定的微信

微信自带弹框

wx.showModal({
  title: '确认收货?',
  confirmText: '确认',
  confirmColor: '#ffde00',
  success: function(res) {
    if (res.confirm) {
      changeOrderStatus(e.currentTarget.id, 4).then(res => {
        this.toDoWhatUShouldDo(e, 4)
      })
    } else if (res.cancel) {
      console.log('用户点击取消收货')
    }
  },
  fail: function() {}
})
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值