微信小程序显示进度条showLoading,关闭进度条hideLoading,消息提示showToast,弹出窗showModal

时间:2024-12-16 19:49:56

弹出进度条

      wx.showLoading({
        title: '正在加载',
      })

关闭提示

wx.hideLoading()

消息提示

          wx.showToast({
            title: '不能分享文件夹,请选择单个文件进行分享!',
          })

弹出框

          wx.showModal({
            title: '提示',
            content: '不能分享文件夹,请选择单个文件进行分享!',
            success (res) {
              if (res.confirm) {
                console.log('用户点击确定')
              } else if (res.cancel) {
                console.log('用户点击取消')
              }
            }
          })

应用代码

share(record) {
      console.log("record====", record)
      if (record.type == 1) {
          wx.showToast({
            title: '不能分享文件夹,请选择单个文件进行分享!',
          })
          return false;
      }      
      let data = {
          "docId": record.id, 
          "fileId": record.fileId,
          "code": getShareToken(12), 
          "userId": wx.getStorageSync('userId'),
          "openShare":1,
          "wantPassword":0,
          "pwCode": getShareToken(6), 
          "openDays":0,
          "days":1,
          "openTimes":0,
          "times": 1,
          "canComment": 1
      }
      wx.showLoading({
        title: '正在加载',
      })
      let url = config.apiUrl + "/business/lzShare/add";
      util.httpPost(url, data).then((res) => {
        wx.hideLoading()
        this.setData({
          showShare: true
        })
 
      })
 
    },