index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. { 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(async () => {
  102. uni.hideHomeButton();
  103. await searchConfig();
  104. await search();
  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) {
  117. user.value = res.data
  118. uni.setStorageSync('user', res.data);
  119. }
  120. else popup.value.open();
  121. } else {
  122. uni.showToast({
  123. title: res.msg || '',
  124. icon: 'error',
  125. });
  126. }
  127. };
  128. // config信息
  129. const searchConfig = async () => {
  130. config.value = uni.getStorageSync('config');
  131. };
  132. const change = (e) => {
  133. show.value = e.show
  134. };
  135. // 个人信息
  136. const toBasic = () => {
  137. uni.navigateTo({
  138. url: `/pagesMy/basic/index`,
  139. })
  140. };
  141. // 微信信任登录
  142. const toLogin = () => {
  143. uni.navigateTo({
  144. url: `/pages/login/index`,
  145. })
  146. };
  147. // 点击分页器
  148. const onClickItem = (e) => {
  149. if (current.value !== e.currentIndex) current.value = e.currentIndex
  150. };
  151. // 点击悬浮按钮
  152. const trigger = (e) => {
  153. uni.navigateTo({
  154. url: e.item.route,
  155. })
  156. };
  157. // 关闭弹框
  158. const toClose = () => {
  159. popup.value.close();
  160. };
  161. </script>
  162. <style lang="scss" scoped>
  163. .content {
  164. display: flex;
  165. flex-direction: column;
  166. .one {
  167. height: 45vw;
  168. background-color: var(--f12Color);
  169. .one_1 {
  170. display: flex;
  171. align-items: center;
  172. padding: 4vw;
  173. color: var(--mainColor);
  174. .image {
  175. width: 15vw;
  176. height: 15vw;
  177. border-radius: 20vw;
  178. background: var(--mainColor);
  179. }
  180. .name {
  181. padding: 0 1vw 0 2vw;
  182. font-size: var(--font18Size);
  183. }
  184. }
  185. .one_2 {
  186. display: flex;
  187. justify-content: space-around;
  188. color: var(--mainColor);
  189. font-size: var(--font16Size);
  190. padding: 4vw;
  191. margin: 2vw 0 0 0;
  192. .list {
  193. display: flex;
  194. align-items: center;
  195. .name {
  196. padding: 0 1vw;
  197. color: var(--f85Color);
  198. }
  199. }
  200. }
  201. }
  202. .popup {
  203. height: 30vw;
  204. background: var(--mainColor);
  205. padding: 2vw 2vw 0 2vw;
  206. border-top-left-radius: 25px;
  207. border-top-right-radius: 25px;
  208. .top {
  209. text-align: right;
  210. padding: 1vw;
  211. }
  212. .center {
  213. padding: 1vw 0 0 0;
  214. text-align: center;
  215. font-size: var(--font12Size);
  216. color: var(--f99Color);
  217. }
  218. .bottom {
  219. padding: 4vw 0 0 0;
  220. text-align: center;
  221. .button {
  222. font-size: var(--font14Size);
  223. border-radius: 2vw;
  224. background: linear-gradient(to right, #00BFFF, #3F94F1, #7B68EE);
  225. }
  226. }
  227. }
  228. }
  229. </style>