image.js 884 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Page({
  2. chooseImage() {
  3. my.chooseImage({
  4. sourceType: ['camera','album'],
  5. count: 2,
  6. success: (res) => {
  7. my.alert({
  8. content: JSON.stringify(res),
  9. });
  10. },
  11. fail:()=>{
  12. my.showToast({
  13. content: 'fail', // 文字内容
  14. });
  15. }
  16. })
  17. },
  18. previewImage() {
  19. my.previewImage({
  20. current: 2,
  21. urls: [
  22. 'https://img.alicdn.com/tps/TB1sXGYIFXXXXc5XpXXXXXXXXXX.jpg',
  23. 'https://img.alicdn.com/tps/TB1pfG4IFXXXXc6XXXXXXXXXXXX.jpg',
  24. 'https://img.alicdn.com/tps/TB1h9xxIFXXXXbKXXXXXXXXXXXX.jpg'
  25. ],
  26. });
  27. },
  28. saveImage() {
  29. my.saveImage({
  30. url: 'https://img.alicdn.com/tps/TB1sXGYIFXXXXc5XpXXXXXXXXXX.jpg',
  31. showActionSheet: true,
  32. success: () => {
  33. my.alert({
  34. title: '保存成功',
  35. });
  36. },
  37. });
  38. }
  39. });