index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <page-meta :page-style="'overflow:'+(show?'hidden':'visible')"></page-meta>
  3. <view class="content">
  4. <view class="one">
  5. <view class="one_1" @tap="toBasic">
  6. <image class="image" mode="aspectFill" :src="user.icon||config.logoUrl"></image>
  7. <text class="name">{{user.nickname||'体验账号'}}</text>
  8. <uni-icons style="padding: 4px 0 0 0;" type="forward" size="20" color="#ffffff"></uni-icons>
  9. </view>
  10. <view class="one_2">
  11. <view class="list" v-for="(item, index) in menuList" :key="index">
  12. <uni-icons custom-prefix="iconfont" :type="item.icon" size="18" :color="item.color"></uni-icons>
  13. <view class="name">{{item.name}}</view>
  14. <view class="num">{{item.num}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="two">
  19. <uni-segmented-control :current="current" :values="list" @clickItem="onClickItem" styleType="text"
  20. activeColor="#dd524d"></uni-segmented-control>
  21. <view class="two_1">
  22. <view v-show="current === 0">
  23. <team :config="config"></team>
  24. </view>
  25. <view v-show="current === 1">
  26. <activity :config="config"></activity>
  27. </view>
  28. <view v-show="current === 2">
  29. <game :config="config"></game>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 普通弹窗 -->
  34. <uni-popup ref="popup" background-color="rgba(0,0,0,0)" type="bottom" @change="change">
  35. <view class="popup">
  36. <view class="top">
  37. <uni-icons @tap="toClose" type="closeempty" size="18" color="#999999"></uni-icons>
  38. </view>
  39. <view class="center">
  40. <text>以上为未登录体验数据 立即登录 开启俱乐部管理</text>
  41. </view>
  42. <view class="bottom">
  43. <button type="primary" size="mini" class="button" @click="toLogin">立即授权</button>
  44. </view>
  45. </view>
  46. </uni-popup>
  47. <!-- 悬浮按钮 -->
  48. <uni-fab :pattern="pattern" :content="content" horizontal="right" direction="vertical" @trigger="trigger" />
  49. </view>
  50. </template>
  51. <script setup lang="ts">
  52. import { getCurrentInstance, computed, ref } from 'vue';
  53. //该依赖已内置不需要单独安装
  54. import { onPullDownRefresh, onShow } from "@dcloudio/uni-app";
  55. import activity from './components/activity.vue';
  56. import game from './components/game.vue';
  57. import team from './components/team.vue';
  58. // 请求接口
  59. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  60. // openid
  61. const openid = computed(() => {
  62. return uni.getStorageSync('openid');
  63. })
  64. // 基本信息
  65. const config = ref({});
  66. // 用户信息
  67. const user = ref({});
  68. // 禁止滚动穿透
  69. const show = ref(false);
  70. // 标签列表
  71. const menuList = ref([]);
  72. const list = ref(['球队', '活动', '赛事']);
  73. const current = ref(0);
  74. // 悬浮按钮
  75. const pattern = ref({
  76. color: '#3c3e49',
  77. backgroundColor: '#fff',
  78. selectedColor: '#fff',
  79. buttonColor: '#fff',
  80. iconColor: '#3c3e49'
  81. });
  82. const content = ref([{
  83. iconPath: '/static/qiudui.png',
  84. text: '建球队',
  85. route: '/pagesHome/team/index',
  86. },
  87. {
  88. iconPath: '/static/saishi.png',
  89. text: '建赛事',
  90. route: '/pagesHome/match/index',
  91. }
  92. ]);
  93. // 弹框
  94. const popup = ref(null);
  95. onShow(async () => {
  96. uni.hideHomeButton();
  97. await searchConfig();
  98. await search();
  99. })
  100. // 下拉刷新
  101. onPullDownRefresh(() => {
  102. uni.stopPullDownRefresh()
  103. })
  104. // config信息
  105. const searchConfig = async () => {
  106. config.value = uni.getStorageSync('config');
  107. };
  108. // 用户信息
  109. const search = async () => {
  110. const res = await $api(`matchUser/find`, 'GET', {
  111. openid: openid.value
  112. });
  113. if (res.code === 200) {
  114. if (res.data) {
  115. user.value = res.data
  116. uni.setStorageSync('user', res.data);
  117. // 球队统计
  118. const arr = await $api(`matchUser/statistics/${res.data.id}`, 'GET', {});
  119. if (arr.code === 200) {
  120. menuList.value = arr.data
  121. } else {
  122. uni.showToast({
  123. title: arr.msg || '',
  124. icon: 'error',
  125. });
  126. }
  127. }
  128. else popup.value.open();
  129. } else {
  130. uni.showToast({
  131. title: res.msg || '',
  132. icon: 'error',
  133. });
  134. }
  135. };
  136. const change = (e) => {
  137. show.value = e.show
  138. };
  139. // 个人信息
  140. const toBasic = () => {
  141. uni.navigateTo({
  142. url: `/pagesMy/basic/index`,
  143. })
  144. };
  145. // 微信信任登录
  146. const toLogin = () => {
  147. uni.navigateTo({
  148. url: `/pages/login/index`,
  149. })
  150. };
  151. // 点击分页器
  152. const onClickItem = (e) => {
  153. if (current.value !== e.currentIndex) current.value = e.currentIndex
  154. };
  155. // 点击悬浮按钮
  156. const trigger = (e) => {
  157. uni.navigateTo({
  158. url: e.item.route,
  159. })
  160. };
  161. // 关闭弹框
  162. const toClose = () => {
  163. popup.value.close();
  164. };
  165. </script>
  166. <style lang="scss" scoped>
  167. .content {
  168. display: flex;
  169. flex-direction: column;
  170. .one {
  171. height: 45vw;
  172. background-color: var(--f12Color);
  173. .one_1 {
  174. display: flex;
  175. align-items: center;
  176. padding: 4vw;
  177. color: var(--mainColor);
  178. .image {
  179. width: 15vw;
  180. height: 15vw;
  181. border-radius: 20vw;
  182. background: var(--mainColor);
  183. }
  184. .name {
  185. padding: 0 1vw 0 2vw;
  186. font-size: var(--font18Size);
  187. }
  188. }
  189. .one_2 {
  190. display: flex;
  191. justify-content: space-around;
  192. color: var(--mainColor);
  193. font-size: var(--font16Size);
  194. padding: 4vw;
  195. margin: 2vw 0 0 0;
  196. .list {
  197. display: flex;
  198. align-items: center;
  199. .name {
  200. padding: 0 1vw;
  201. color: var(--f85Color);
  202. }
  203. }
  204. }
  205. }
  206. .popup {
  207. height: 30vw;
  208. background: var(--mainColor);
  209. padding: 2vw 2vw 0 2vw;
  210. border-top-left-radius: 25px;
  211. border-top-right-radius: 25px;
  212. .top {
  213. text-align: right;
  214. padding: 1vw;
  215. }
  216. .center {
  217. padding: 1vw 0 0 0;
  218. text-align: center;
  219. font-size: var(--font12Size);
  220. color: var(--f99Color);
  221. }
  222. .bottom {
  223. padding: 4vw 0 0 0;
  224. text-align: center;
  225. .button {
  226. font-size: var(--font14Size);
  227. border-radius: 2vw;
  228. background: linear-gradient(to right, #00BFFF, #3F94F1, #7B68EE);
  229. }
  230. }
  231. }
  232. }
  233. </style>