getTickImg.js 634 B

12345678910111213141516171819202122232425262728293031
  1. class GetTickImg {
  2. constructor(imgPath, len) {
  3. this.imgPath = imgPath
  4. this.len = len
  5. this.imgList = []
  6. this.loadState = false
  7. this.initDraw = false
  8. this.getDrawImgUrl()
  9. }
  10. async getDrawImgUrl() {
  11. for (let i = 1; i < this.len + 1; i++) {
  12. let imgHostUrl = await this.getImgInfo(i)
  13. this.imgList.push(imgHostUrl)
  14. }
  15. this.loadState = true
  16. }
  17. getImgInfo(index) {
  18. return new Promise((resolev, reject) => {
  19. uni.downloadFile({
  20. url: `${this.imgPath} (${index}).png`,
  21. success: (res) => {
  22. resolev(res.tempFilePath)
  23. },
  24. fail(err) {
  25. reject(err)
  26. }
  27. })
  28. })
  29. }
  30. }
  31. export default GetTickImg