小程序打印小票,复制功能,自定义导航栏

发布时间 2023-04-19 09:51:31作者: shuihanxiao
// 复制联系地址
  fnCopyAddress() {
    wx.setClipboardData({
        data: this.data.detailInfo.address,
        success: res => {
          Util.errorShow('复制联系地址成功')
        }
    })
  },

  // 打印小票
  fnPrintTicket() {
    let _this = this;
    wx.showModal({
      title: '确认打印',
      content: '打印小票请确保打印机已正常开启',
      confirmText: '确认',
      confirmColor: "#E6AB51",
      success (res) {
        if (res.confirm) {
          // console.log('用户点击确定')
          _this.printNote()
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },

  /**
   * 打印接口
   * @param  outerSn 售后单号
   * @param  type  订单类型 
   */
  async printNote() {
    try {
      let params = {
        orderNo: this.data.orderNo,
        type: 2
      }
      let result = await Util.request(params, '/app/print/note')
      console.log(result)
      if (!Util.isEmpty(result)) {
        this.onShow()
        wx.showModal({
          title: '提示',
          content: result.result,
          showCancel: false
        })
        // Util.errorShow(result.result)
      }
    } catch (err) {

    }
  },

自定义导航栏 .json 文件

{
  "usingComponents": {},
  "navigationStyle": "custom"
}