index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="fui-wrap">
  3. <view class="user-info-bg">
  4. </view>
  5. <view class="ctl-container">
  6. <view class="user-info-content">
  7. <view class="user-info-img" @click="handClick">
  8. <u-avatar :src=" userInfo && userInfo.avatarUrl || ''" shape="circle" :size="60"></u-avatar>
  9. </view>
  10. <view class="user-info" @click="$u.throttle(onHeadClick,500)">
  11. <view>
  12. {{ userInfo.usrName || '点击登录' }}
  13. </view>
  14. <view>
  15. {{ userInfo.tel || '' }}
  16. </view>
  17. </view>
  18. </view>
  19. <view class="ctl-panel">
  20. <u-grid
  21. :border="false"
  22. :col="3"
  23. >
  24. <u-grid-item
  25. v-for="(baseListItem,baseListIndex) in baseList"
  26. :key="baseListIndex"
  27. @click="$u.throttle(()=>onItemClick(baseListItem), 500)"
  28. >
  29. <view class="grid-item-icon" :style="[baseListItem.style]">
  30. <image :src="baseListItem.icon"></image>
  31. </view>
  32. <text class="grid-text">{{ baseListItem.title }}</text>
  33. </u-grid-item>
  34. </u-grid>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import { fetchViewCfgList } from '@/common/api';
  41. import { COMP_CODE } from '@/common/EnumConst';
  42. import AuthWrap from '@/components/AuthComp/index.vue';
  43. import { authLogin, exit, getImageUrl, getUrlParams, getUserInfo, setStorageObj } from '@/util';
  44. export default {
  45. components: { AuthWrap },
  46. data() {
  47. return {
  48. userInfo: {},
  49. baseList: [],
  50. src: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
  51. };
  52. },
  53. onLoad() {
  54. },
  55. onShow() {
  56. this.userInfo = getUserInfo();
  57. this.viewCfg();
  58. },
  59. methods: {
  60. onHeadClick() {
  61. if (this.userInfo) {
  62. return;
  63. }
  64. authLogin(() => {
  65. this.userInfo = getUserInfo();
  66. });
  67. },
  68. // 单击或双击
  69. handClick(index) {
  70. let _this = this;
  71. let curTime = new Date().getTime();
  72. let lastTime = _this.lastTapDiffTime;
  73. _this.lastTapDiffTime = curTime;
  74. //两次点击间隔小于300ms, 认为是双击
  75. let diff = curTime - lastTime;
  76. if (diff < 300) {
  77. console.log('双击');
  78. //_this.handleVideo('screen',index)自定义事件
  79. clearTimeout(_this.lastTapTimeoutFunc); // 成功触发双击事件时,取消单击事件的执行
  80. exit();
  81. authLogin();
  82. } else {
  83. // 单击事件延时300毫秒执行
  84. _this.lastTapTimeoutFunc = setTimeout(function () {
  85. console.log('单击');
  86. //_this.handleVideo('playOrStop',index)自定义事件
  87. }, 300);
  88. }
  89. },
  90. onItemClick(item) {
  91. if (item.url) {
  92. const reqs = getUrlParams(item.url);
  93. if (reqs && reqs.storage) {
  94. setStorageObj(reqs.storage, reqs);
  95. }
  96. uni.navigateTo({
  97. url: item.url,
  98. });
  99. }
  100. },
  101. async viewCfg() {
  102. const res = await fetchViewCfgList({
  103. pageNum: 1,
  104. pageSize: 99,
  105. compCode: COMP_CODE.my,
  106. });
  107. if (res.rows.length > 0) {
  108. this.baseList = res.rows.map(item => {
  109. return {
  110. icon: getImageUrl(item.iconUri),
  111. style: JSON.parse(item.style),
  112. title: item.labelTxt,
  113. url: item.url,
  114. };
  115. });
  116. }
  117. },
  118. },
  119. onShareAppMessage() {
  120. return {
  121. title: '',
  122. };
  123. },
  124. };
  125. </script>
  126. <style lang="scss" src="./index.scss">
  127. </style>