index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Created by JianJia.Zhou<jianjia.zhou> on 2022/5/26.
  3. */
  4. export function copyText(text, tips) {
  5. uni.setClipboardData({
  6. data: text,
  7. success: function() {
  8. uni.hideLoading()
  9. uni.showToast({
  10. title: tips || '复制成功',
  11. icon: 'none'
  12. })
  13. }
  14. })
  15. }
  16. export function checkOS() {
  17. if (uni.getSystemInfoSync().platform === 'ios') {
  18. uni.showModal({
  19. title: '提示',
  20. content: '由于相关规范,iOS功能暂不可用',
  21. showCancel: false,
  22. success: function(res) {
  23. // res.confirm res.cancel
  24. }
  25. })
  26. return false
  27. }
  28. return true
  29. }
  30. const shareMessage = user => {
  31. // #ifdef MP-KUAISHOU
  32. const title ="四海剧场"
  33. // #endif
  34. // #ifdef MP-TOUTIAO | MP-WEIXIN
  35. const title ="张四爷剧场"
  36. // #endif
  37. console.log('-->data', user)
  38. return {
  39. path: `/pages/index/index?user_id=${user.id}`,
  40. title: title,
  41. desc: title
  42. // imageUrl: ''
  43. }
  44. }
  45. const tranNumber = (num, point = 2) => {
  46. let numStr = parseFloat(num).toString()
  47. // 万以内直接返回
  48. if (numStr.length < 5) {
  49. return numStr;
  50. }
  51. //大于6位数是百万
  52. else if (numStr.length > 6) {
  53. let decimal = numStr.substring(numStr.length - 5, numStr.length - 5 + point);
  54. return parseFloat(parseInt(num / 100000) + '.' + decimal) + 'M';
  55. }
  56. //大于5位数是万 (以1W分割 1W以下全部显示)
  57. else if (numStr.length > 4) {
  58. let decimal = numStr.substring(numStr.length - 4, numStr.length - 4 + point)
  59. return parseFloat(parseInt(num / 1000) + '.' + decimal) + 'K';
  60. }
  61. }
  62. export default {
  63. copyText,
  64. checkOS,
  65. shareMessage,
  66. tranNumber
  67. }