person.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <page-meta :page-style="'overflow:'+(show?'hidden':'visible')"></page-meta>
  3. <view class="content">
  4. <view class="one">
  5. <view class="list" v-for="(item, index) in sortList" :key="index" @tap="toSort(item)">
  6. <view class="name">{{item.name}}</view>
  7. <view class="icon">
  8. <uni-icons style="height: 2vw;" custom-prefix="iconfont" type="icon-shangjiantou" size="10"
  9. :color="item.color1"></uni-icons>
  10. <uni-icons style="height: 2vw;" custom-prefix="iconfont" type="icon-xiajiantou" size="10"
  11. :color="item.color2"></uni-icons>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="two">
  16. <view class="two_1">
  17. <button size="mini" open-type="share" style="margin: 0;">
  18. <uni-icons custom-prefix="iconfont" type="icon-yaoqinghuida" size="20" color="#121212"></uni-icons>
  19. <text>邀请好友加入球队</text>
  20. </button>
  21. </view>
  22. <view class="two_2">
  23. <view class="list" v-for="(item, index) in list" :key="index" @tap="toInfo(item)">
  24. <view class="type">{{item.type||''}}</view>
  25. <image class="image" mode="aspectFill" :src="item.icon||config.logoUrl">
  26. </image>
  27. <view class="name">{{item.name||item.phone}}</view>
  28. <uni-icons custom-prefix="iconfont" type="icon-31dianhua" size="25" color="#20B2AA"></uni-icons>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="thr">
  33. <view class="thr_1">临时球员</view>
  34. <view class="thr_2" @tap="toCreate">
  35. <uni-icons custom-prefix="iconfont" type="icon-yaoqinghuida" size="25" color="#121212"></uni-icons>
  36. <text>创建临时成员</text>
  37. </view>
  38. </view>
  39. <!-- 添加临时成员 -->
  40. <uni-popup ref="popup" background-color="rgba(0,0,0,0)" type="center" @change="change">
  41. <view class="popup">
  42. <view class="popup_1">
  43. <view class="name">临时创建球员</view>
  44. <uni-icons @tap="toClose" type="closeempty" size="18" color="#999999"></uni-icons>
  45. </view>
  46. <view class="info">
  47. <form @submit="toAdd">
  48. <view class="value">
  49. <view class="title">手机号码</view>
  50. <view class="label">
  51. <input name="phone" class="input" :value="form.phone" placeholder="请输入手机号码" />
  52. </view>
  53. </view>
  54. <view class="value">
  55. <view class="title">球员姓名</view>
  56. <view class="label">
  57. <input name="name" class="input" :value="form.name" placeholder="请输入球员姓名" />
  58. </view>
  59. </view>
  60. <view class="value">
  61. <view class="title">球衣号码</view>
  62. <view class="label">
  63. <input name="num" class="input" :value="form.num" placeholder="请输入球衣号码" />
  64. </view>
  65. </view>
  66. <view class="button">
  67. <button type="warn" form-type="submit">添加球员</button>
  68. </view>
  69. </form>
  70. </view>
  71. </view>
  72. </uni-popup>
  73. </view>
  74. </template>
  75. <script setup lang="ts">
  76. import { getCurrentInstance, ref } from 'vue';
  77. //该依赖已内置不需要单独安装
  78. import { onLoad } from "@dcloudio/uni-app";
  79. // 请求接口
  80. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  81. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  82. interface PropsItem {
  83. id ?: number,
  84. name ?: string,
  85. icon ?: string,
  86. phone ?: string,
  87. type ?: string,
  88. };
  89. // 基本信息
  90. const config = ref({ logoUrl: '' });
  91. // 基本信息
  92. const show = ref(false);
  93. // 详情信息id
  94. const id = ref('');
  95. // 排序列表
  96. const sortList = ref([
  97. { name: 'A-Z', type: '0', sort: -1, color1: '#121212', color2: '#999999' },
  98. { name: '位置', type: '1', sort: 1, color1: '#121212', color2: '#121212' },
  99. { name: '职位', type: '2', sort: 1, color1: '#121212', color2: '#121212' },
  100. { name: '号码', type: '3', sort: 1, color1: '#121212', color2: '#121212' },
  101. ]);
  102. // 列表
  103. const list = ref<PropsItem[]>([{ id: 1, phone: '1234567890' }, { id: 1, name: '肝帝集团队' }]);
  104. // 分页
  105. const skip = ref(0);
  106. const limit = ref(6);
  107. const page = ref(0);
  108. const total = ref(0);
  109. // 弹框
  110. const popup = ref(null);
  111. // 临时成员
  112. const form = ref({});
  113. // 用户信息
  114. const user = ref({});
  115. // 球队信息
  116. const teamInfo = ref({});
  117. onLoad(async (options) => {
  118. id.value = options && options.id
  119. await searchUser();
  120. await searchConfig();
  121. await search();
  122. await searchShare();
  123. })
  124. // 用户信息
  125. const searchUser = async () => {
  126. user.value = uni.getStorageSync('user');
  127. };
  128. // config信息
  129. const searchConfig = async () => {
  130. config.value = uni.getStorageSync('config');
  131. };
  132. // 查询
  133. const search = async () => {
  134. if (id.value) {
  135. uni.setNavigationBarTitle({
  136. title: `球队阵容(${total.value})`
  137. });
  138. const res = await $api(`team/${id.value}`, 'GET', {});
  139. if (res.code === 200) {
  140. if (res.data) teamInfo.value = res.data
  141. } else {
  142. uni.showToast({
  143. title: res.msg || '',
  144. icon: 'error',
  145. });
  146. }
  147. }
  148. };
  149. // 用户详细信息
  150. const toInfo = async (item : any) => {
  151. // uni.navigateTo({
  152. // url: `/pagesHome/person/index?id=${item._id || item.id}`,
  153. // })
  154. uni.navigateTo({
  155. url: `/pagesHome/share/index?id=${id.value}`,
  156. })
  157. };
  158. // 去排序
  159. const toSort = async (item : any) => {
  160. let list;
  161. if (item.sort === -1) {
  162. list = sortList.value.map(i => {
  163. if (i.type === item.type) {
  164. i.sort = 1
  165. i.color1 = '#999999'
  166. i.color2 = '#121212'
  167. } else {
  168. i.color1 = '#121212'
  169. i.color2 = '#121212'
  170. }
  171. return i;
  172. })
  173. } else {
  174. list = sortList.value.map(i => {
  175. if (i.type === item.type) {
  176. i.sort = -1
  177. i.color1 = '#121212'
  178. i.color2 = '#999999'
  179. } else {
  180. i.color1 = '#121212'
  181. i.color2 = '#121212'
  182. }
  183. return i;
  184. })
  185. }
  186. sortList.value = list
  187. };
  188. // 邀请分享配置
  189. const searchShare = () => {
  190. $config.share = {
  191. title: `${user.value.name || '暂无名称'}邀请你加入${teamInfo.value.name || '暂无团队'}`,
  192. path: `/pagesHome/share/index?id=${id.value}` //后面是路径上要传递的参数
  193. }
  194. }
  195. // 创建临时成员
  196. const toCreate = () => {
  197. popup.value.open();
  198. };
  199. // 关闭弹框
  200. const toClose = () => {
  201. popup.value.close();
  202. };
  203. // 添加临时成员
  204. const toAdd = (e) => {
  205. console.log(e.deatil.value);
  206. };
  207. const change = (e) => {
  208. show.value = e.show
  209. };
  210. </script>
  211. <style lang="scss" scoped>
  212. .content {
  213. display: flex;
  214. flex-direction: column;
  215. width: 100vw;
  216. height: 100vh;
  217. .one {
  218. padding: 2vw;
  219. display: flex;
  220. justify-content: space-between;
  221. background-color: var(--f9Color);
  222. .list {
  223. display: flex;
  224. padding: 2vw;
  225. .icon {
  226. display: flex;
  227. flex-direction: column;
  228. position: relative;
  229. top: -5px;
  230. left: 2px;
  231. }
  232. }
  233. }
  234. .two {
  235. padding: 0 2vw;
  236. .two_1 {
  237. display: flex;
  238. padding: 4vw 2vw;
  239. border-bottom: 1px solid var(--footColor);
  240. text {
  241. padding: 0 1vw;
  242. font-size: var(--font18Size);
  243. }
  244. }
  245. .two_2 {
  246. .list {
  247. display: flex;
  248. align-items: center;
  249. padding: 2vw 0;
  250. border-bottom: 1px solid var(--footColor);
  251. .type {
  252. width: 10vw;
  253. padding: 0 0 0 1vw;
  254. color: var(--f85Color);
  255. font-size: var(--font12Size);
  256. }
  257. .image {
  258. width: 12vw;
  259. height: 12vw;
  260. border-radius: 12vw;
  261. }
  262. .name {
  263. width: 60vw;
  264. font-size: var(--font16Size);
  265. padding: 0 2vw;
  266. }
  267. }
  268. }
  269. }
  270. .thr {
  271. .thr_1 {
  272. padding: 3vw;
  273. background-color: var(--f9Color);
  274. font-size: var(--font14Size);
  275. color: var(--f85Color);
  276. }
  277. .thr_2 {
  278. display: flex;
  279. padding: 4vw 2vw;
  280. border-bottom: 1px solid var(--footColor);
  281. text {
  282. padding: 0 1vw;
  283. font-size: var(--font18Size);
  284. }
  285. }
  286. }
  287. .popup {
  288. display: flex;
  289. flex-direction: column;
  290. background: var(--mainColor);
  291. width: 90vw;
  292. height: 45vh;
  293. padding: 2vw;
  294. border-radius: 15px;
  295. .popup_1 {
  296. display: flex;
  297. justify-content: space-between;
  298. padding: 2vw;
  299. font-size: var(--font18Size);
  300. }
  301. .info {
  302. margin: 4vw 0;
  303. .value {
  304. display: flex;
  305. justify-content: space-between;
  306. align-items: center;
  307. padding: 3vw 2vw;
  308. border-bottom: 1px solid var(--footColor);
  309. font-size: var(--font16Size);
  310. .label {
  311. .input {
  312. text-align: right;
  313. }
  314. }
  315. }
  316. .button {
  317. margin: 8vw 0 0 0;
  318. text-align: center;
  319. button {
  320. width: 80vw;
  321. font-size: var(--font16Size);
  322. }
  323. }
  324. }
  325. }
  326. }
  327. </style>