util.js 523 B

1234567891011121314151617181920212223242526
  1. const promisic = function (func) {
  2. return function (params = {}) {
  3. return new Promise((resolve, reject) => {
  4. const args = Object.assign(params, {
  5. success: (res) => {
  6. resolve(res);
  7. },
  8. fail: (error) => {
  9. reject(error);
  10. }
  11. });
  12. func(args);
  13. });
  14. };
  15. };
  16. const px2rpx = function (pxNumber) {
  17. const { screenWidth } = wx.getSystemInfoSync();
  18. const rpxNumber = (750 / screenWidth) * pxNumber;
  19. return rpxNumber;
  20. };
  21. export {
  22. promisic,
  23. px2rpx
  24. };