helpers.js 755 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import {networkImage} from '../utility/lang';
  2. import {jump} from '../utility/api';
  3. function toast(message, icon = 'none') {
  4. if (message && message.message) {
  5. message = message.message;
  6. }
  7. if (!message) {
  8. return;
  9. }
  10. if (typeof message !== 'string') {
  11. message = JSON.stringify(message);
  12. }
  13. //console.log('[toast] ' + message);
  14. return new Promise((resolve,reject)=>{
  15. uni.showToast({
  16. title: message,
  17. icon,
  18. duration: 1500
  19. });
  20. setTimeout(()=>{
  21. resolve();
  22. },1500);
  23. });
  24. }
  25. export default function install(Vue) {
  26. Object.defineProperties(Vue.prototype, {
  27. $toast: {get: () => toast},
  28. $img: {get: () => networkImage},
  29. $jump: {get: () => jump},
  30. });
  31. }