index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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" @tap="toInfo(item)">
  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></team>
  24. </view>
  25. <view v-show="current === 1">
  26. <activity></activity>
  27. </view>
  28. <view v-show="current === 2">
  29. <game></game>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 普通弹窗 -->
  34. <uni-popup ref="popup" background-color="#fff" 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. { name: '球队', num: '5', icon: 'icon-qi', color: '#1E90FF' },
  73. { name: '|' },
  74. { name: '出勤', num: '16%', icon: 'icon-kaoqinchuqin', color: '#FF4500' },
  75. { name: '|' },
  76. { name: '进球', num: '1', icon: 'icon-zuqiu', color: '#FFFFFF' },
  77. ]);
  78. const list = ref(['球队', '活动', '赛事']);
  79. const current = ref(0);
  80. // 悬浮按钮
  81. const pattern = ref({
  82. color: '#3c3e49',
  83. backgroundColor: '#fff',
  84. selectedColor: '#fff',
  85. buttonColor: '#fff',
  86. iconColor: '#3c3e49'
  87. });
  88. const content = ref([{
  89. iconPath: '/static/qiudui.png',
  90. text: '建球队',
  91. route: '/pagesHome/team/index',
  92. },
  93. {
  94. iconPath: '/static/saishi.png',
  95. text: '建赛事',
  96. route: '/pagesHome/match/index',
  97. }
  98. ]);
  99. // 弹框
  100. const popup = ref(null);
  101. onShow(() => {
  102. uni.hideHomeButton();
  103. search();
  104. searchConfig();
  105. })
  106. // 下拉刷新
  107. onPullDownRefresh(() => {
  108. uni.stopPullDownRefresh()
  109. })
  110. // 用户信息
  111. const search = async () => {
  112. const res = await $api(`matchUser/find`, 'GET', {
  113. openid: openid.value
  114. });
  115. if (res.code === 200) {
  116. if (res.data) console.log(res.data);
  117. else popup.value.open();
  118. } else {
  119. uni.showToast({
  120. title: res.msg || '',
  121. icon: 'error',
  122. });
  123. }
  124. };
  125. // config信息
  126. const searchConfig = async () => {
  127. config.value = uni.getStorageSync('config');
  128. };
  129. const change = (e) => {
  130. show.value = e.show
  131. };
  132. // 个人信息
  133. const toBasic = () => {
  134. uni.navigateTo({
  135. url: `/pagesMy/basic/index`,
  136. })
  137. };
  138. // 微信信任登录
  139. const toLogin = () => {
  140. uni.navigateTo({
  141. url: `/pages/login/index`,
  142. })
  143. };
  144. // 点击分页器
  145. const onClickItem = (e) => {
  146. if (current.value !== e.currentIndex) current.value = e.currentIndex
  147. };
  148. // 点击悬浮按钮
  149. const trigger = (e) => {
  150. uni.navigateTo({
  151. url: e.item.route,
  152. })
  153. };
  154. // 关闭弹框
  155. const toClose = () => {
  156. popup.value.close();
  157. };
  158. </script>
  159. <style lang="scss" scoped>
  160. .content {
  161. display: flex;
  162. flex-direction: column;
  163. .one {
  164. height: 45vw;
  165. background-color: var(--f12Color);
  166. .one_1 {
  167. display: flex;
  168. align-items: center;
  169. padding: 4vw;
  170. color: var(--mainColor);
  171. .image {
  172. width: 15vw;
  173. height: 15vw;
  174. border-radius: 20vw;
  175. }
  176. .name {
  177. padding: 0 1vw 0 2vw;
  178. font-size: var(--font18Size);
  179. }
  180. }
  181. .one_2 {
  182. display: flex;
  183. justify-content: space-around;
  184. color: var(--mainColor);
  185. font-size: var(--font16Size);
  186. padding: 4vw;
  187. margin: 2vw 0 0 0;
  188. .list {
  189. display: flex;
  190. align-items: center;
  191. .name {
  192. padding: 0 1vw;
  193. color: var(--f85Color);
  194. }
  195. }
  196. }
  197. }
  198. .two {
  199. .two_1 {
  200. padding: 2vw;
  201. }
  202. }
  203. .popup {
  204. height: 25vw;
  205. padding: 2vw 2vw 0 2vw;
  206. .top {
  207. text-align: right;
  208. }
  209. .center {
  210. padding: 1vw 0 0 0;
  211. text-align: center;
  212. font-size: var(--font12Size);
  213. color: var(--f99Color);
  214. }
  215. .bottom {
  216. padding: 2vw;
  217. text-align: center;
  218. .button {
  219. font-size: var(--font14Size);
  220. border-radius: 2vw;
  221. background: linear-gradient(to right, #00BFFF, #3F94F1, #7B68EE);
  222. }
  223. }
  224. }
  225. }
  226. </style>