index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * 功能:全局混入函数
  3. * 作者:小莫唐尼
  4. * 邮箱:studio@925i.cn
  5. * 时间:2022年07月21日 17:39:32
  6. * 版本:v0.1.0
  7. * 修改记录:
  8. * 修改内容:
  9. * 修改人员:
  10. * 修改时间:
  11. */
  12. import HaloConfig from '@/config/halo.config.js';
  13. import HaloAdConfig from '@/config/ad.config.js';
  14. export default {
  15. install(Vue) {
  16. Vue.mixin({
  17. data() {
  18. return {
  19. author: HaloConfig.author,
  20. _isWechat: true,
  21. haloAdConfig: HaloAdConfig
  22. };
  23. },
  24. computed: {
  25. // 获取全局应用设置
  26. globalAppSettings() {
  27. return uni.$tm.vx.getters().getSettings;
  28. }
  29. },
  30. created() {
  31. // #ifdef MP-WEIXIN
  32. this._isWechat = true;
  33. uni.$tm.vx.commit('setWxShare', HaloConfig.wxShareConfig);
  34. // #endif
  35. // #ifndef MP-WEIXIN
  36. this._isWechat = false;
  37. // #endif
  38. },
  39. methods: {
  40. /**
  41. * 设置页面标题
  42. * @param {Object} title 标题
  43. */
  44. fnSetPageTitle(title) {
  45. uni.setNavigationBarTitle({
  46. title: title || HaloConfig.title
  47. })
  48. },
  49. /**
  50. * 页面返回顶部
  51. */
  52. fnToTopPage(duration = 500) {
  53. duration = isNaN(duration) ? 500 : duration
  54. uni.pageScrollTo({
  55. scrollTop: 0,
  56. duration: duration,
  57. fail: (err) => {
  58. console.log('err:', err);
  59. },
  60. });
  61. }
  62. },
  63. });
  64. },
  65. };