myteam.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="money-box">
  5. <!-- <view class="text">当前总积分</view>
  6. <view class="money">{{ userInfo.integral | getMoneyStyle }}</view> -->
  7. <image :src="userInfo.avatar" class="andr-mt-avatar andr-mt-avatarBd"></image>
  8. <view class="text">{{ userInfo.nickname }}</view>
  9. <!--<view class="text">试用赠予次数:5(暂时固定值,需要动态修改)</view>-->
  10. </view>
  11. <!-- <view class="moneyTx" @click="navto('/pages/wallet/recharge')">充值</view> -->
  12. <!-- <view class="flex buttom-box">
  13. <view class="buttom" @click="navto('/pages/wallet/recharge')">
  14. <view class="icon"><image class="icon-img" src="/static/icon/i5.png" mode="aspectFit"></image></view>
  15. <text>充值</text>
  16. </view>
  17. <view class="interval"></view>
  18. <view class="buttom" @click="navto('/pages/award/award')">
  19. <view class="icon"><image class="icon-img" src="/static/icon/i1.png" mode="aspectFit"></image></view>
  20. <text>我的奖励</text>
  21. </view>
  22. </view> -->
  23. </view>
  24. <view class="navbar">
  25. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">
  26. <text>{{ item.text }}</text>
  27. <text>{{ item.num || '' }}</text>
  28. </view>
  29. </view>
  30. <swiper :current="tabCurrentIndex" :style="{ height: maxheight + 'rpx' }" class="swiper-box" duration="300" @change="changeTab">
  31. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  32. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  33. <!-- 空白页 -->
  34. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  35. <!-- 订单列表 -->
  36. <view v-for="(item, index) in tabItem.orderList" :key="item.uid" class="andr-mt-flex andr-mt-lBox">
  37. <!-- 订单列表 -->
  38. <image :src="item.avatar" class="andr-mt-avatar andr-mt-marR20"></image>
  39. <view class="andr-mt-flex andr-mt-fdC">
  40. <text class="andr-mt-lname">{{ item.nickname }}</text>
  41. <text class="andr-mt-ltime">{{ item.time }}</text>
  42. </view>
  43. </view>
  44. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  45. </scroll-view>
  46. </swiper-item>
  47. </swiper>
  48. </view>
  49. </template>
  50. <script>
  51. import { spreadPeople } from '@/api/myteam.js';
  52. import { userinfo } from '@/api/user.js';
  53. import { mapState, mapMutations } from 'vuex';
  54. import { getMoneyStyle } from '@/utils/rocessor.js';
  55. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  56. import empty from '@/components/empty';
  57. export default {
  58. filters: {
  59. getMoneyStyle
  60. },
  61. components: {
  62. empty,
  63. uniLoadMore
  64. },
  65. onReady() {
  66. // 初始化获取页面宽度
  67. uni.createSelectorQuery()
  68. .select('.content')
  69. .fields(
  70. {
  71. size: true
  72. },
  73. data => {
  74. // 保存头部高度
  75. // this.maxheight = data.height - Math.floor((data.width / 750) * 570);
  76. this.maxheight = 940;
  77. }
  78. )
  79. .exec();
  80. },
  81. data() {
  82. return {
  83. userInfo: {},
  84. // 头部图高度
  85. maxheight: '',
  86. tabCurrentIndex: 0,
  87. navList: [
  88. {
  89. state: 0,
  90. text: '一级团队',
  91. loadingType: 'more',
  92. num: 0, //人数
  93. orderList: [],
  94. page: 1, //当前页数
  95. limit: 10 //每次信息条数
  96. },
  97. {
  98. state: 1,
  99. text: '二级团队',
  100. num: 0, //团队人数
  101. loadingType: 'more',
  102. orderList: [],
  103. page: 1, //当前页数
  104. limit: 10 //每次信息条数
  105. }
  106. ],
  107. money: ''
  108. };
  109. },
  110. onLoad(options) {},
  111. onShow() {
  112. this.loadData();
  113. // 获取用户积分
  114. let obj = this;
  115. userinfo({})
  116. .then(({ data }) => {
  117. console.log(data);
  118. obj.userInfo = data;
  119. })
  120. .catch(e => {});
  121. },
  122. methods: {
  123. // 页面跳转
  124. navto(e) {
  125. uni.navigateTo({
  126. url: e
  127. });
  128. },
  129. //获取收入支出信息
  130. async loadData(source) {
  131. let obj = this;
  132. //这里是将订单挂载到tab列表下
  133. let index = obj.tabCurrentIndex;
  134. let navItem = obj.navList[index];
  135. let state = navItem.state;
  136. if (source === 'tabChange' && navItem.loaded === true) {
  137. //tab切换只有第一次需要加载数据
  138. return;
  139. }
  140. if (navItem.loadingType === 'loading') {
  141. //防止重复加载
  142. return;
  143. }
  144. // 修改当前对象状态为加载中
  145. navItem.loadingType = 'loading';
  146. spreadPeople({
  147. page: navItem.page,
  148. limit: navItem.limit,
  149. grade: state,
  150. keyword: '',
  151. sort: ''
  152. })
  153. .then(({ data }) => {
  154. obj.navList[0].num = data.total;
  155. obj.navList[1].num = data.totalLevel;
  156. if (data.list.length > 0) {
  157. navItem.orderList = navItem.orderList.concat(data.list);
  158. console.log(navItem.orderList);
  159. navItem.page++;
  160. }
  161. if (navItem.limit == data.list.length) {
  162. //判断是否还有数据, 有改为 more, 没有改为noMore
  163. navItem.loadingType = 'more';
  164. return;
  165. } else {
  166. //判断是否还有数据, 有改为 more, 没有改为noMore
  167. navItem.loadingType = 'noMore';
  168. }
  169. uni.hideLoading();
  170. obj.$set(navItem, 'loaded', true);
  171. })
  172. .catch(e => {
  173. console.log(e);
  174. });
  175. },
  176. //swiper 切换
  177. changeTab(e) {
  178. this.tabCurrentIndex = e.target.current;
  179. this.loadData('tabChange');
  180. },
  181. //顶部tab点击
  182. tabClick(index) {
  183. this.tabCurrentIndex = index;
  184. }
  185. }
  186. };
  187. </script>
  188. <style lang="scss">
  189. page {
  190. background: #ffffff;
  191. height: 100%;
  192. }
  193. .content-money {
  194. padding-bottom: 30rpx;
  195. background: $page-color-base;
  196. // border: 2px solid #ffffff;
  197. .moneyTx {
  198. position: absolute;
  199. top: 150rpx;
  200. right: 0rpx;
  201. width: 150rpx;
  202. padding: 10rpx 30rpx;
  203. border: 2px solid #ffffff;
  204. border-top-left-radius: 99rpx;
  205. border-bottom-left-radius: 99rpx;
  206. color: #ffffff;
  207. line-height: 1;
  208. font-size: $font-base;
  209. }
  210. .buttom-box {
  211. background-color: #ffffff;
  212. text-align: center;
  213. margin: 0 30rpx;
  214. padding: 20rpx 0;
  215. border-radius: $border-radius-sm;
  216. margin-top: -60rpx;
  217. .buttom {
  218. font-size: $font-lg;
  219. flex-grow: 1;
  220. }
  221. .interval {
  222. width: 2px;
  223. height: 60rpx;
  224. background-color: #eeeeee;
  225. }
  226. .icon {
  227. height: 50rpx;
  228. width: 48rpx;
  229. margin: 0 auto;
  230. .icon-img {
  231. width: 100%;
  232. height: 100%;
  233. }
  234. }
  235. }
  236. }
  237. .money-box {
  238. background-color: $base-color;
  239. padding-top: var(--status-bar-height);
  240. // height: 368rpx;
  241. height: 180rpx;
  242. display: flex;
  243. flex-direction: column;
  244. align-items: center;
  245. justify-content: center;
  246. color: #ffffff;
  247. // text-align: center;
  248. .text {
  249. // padding-top: 147rpx;
  250. font-size: $font-sm;
  251. }
  252. .money {
  253. font-size: 56rpx;
  254. }
  255. }
  256. .navbar {
  257. display: flex;
  258. height: 40px;
  259. padding: 0 5px;
  260. background: #fff;
  261. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  262. position: relative;
  263. z-index: 10;
  264. .nav-item {
  265. flex: 1;
  266. display: flex;
  267. justify-content: center;
  268. align-items: center;
  269. height: 100%;
  270. font-size: 15px;
  271. color: $font-color-dark;
  272. position: relative;
  273. &.current {
  274. color: $base-color;
  275. &:after {
  276. content: '';
  277. position: absolute;
  278. left: 50%;
  279. bottom: 0;
  280. transform: translateX(-50%);
  281. width: 44px;
  282. height: 0;
  283. border-bottom: 2px solid $base-color;
  284. }
  285. }
  286. }
  287. }
  288. // 列表
  289. .swiper-box {
  290. padding-top: 10rpx;
  291. .order-item {
  292. padding: 20rpx 30rpx;
  293. line-height: 1.5;
  294. .title-box {
  295. .title {
  296. font-size: $font-lg;
  297. color: $font-color-base;
  298. }
  299. .time {
  300. font-size: $font-base;
  301. color: $font-color-light;
  302. }
  303. }
  304. .money {
  305. color: #fd5b23;
  306. font-size: $font-lg;
  307. }
  308. }
  309. }
  310. .list-scroll-content {
  311. height: 100%;
  312. }
  313. .content {
  314. height: 100%;
  315. .empty-content {
  316. background-color: #ffffff;
  317. }
  318. }
  319. .andr-mt-avatar {
  320. width: 78rpx;
  321. height: 78rpx;
  322. border-radius: 50rpx;
  323. }
  324. .andr-mt-avatarBd {
  325. border: 2px solid #ffffff;
  326. }
  327. .andr-mt-cname {
  328. font-size: 28rpx;
  329. color: #ffffff;
  330. }
  331. .andr-mt-flex {
  332. display: flex;
  333. }
  334. .andr-mt-lBox {
  335. background-color: #ffffff;
  336. height: 130rpx;
  337. padding: 20rpx 20rpx;
  338. border-bottom: 1px solid #f0f0f0;
  339. }
  340. .andr-mt-marR20 {
  341. margin-right: 20rpx;
  342. }
  343. .andr-mt-fdC {
  344. flex-direction: column;
  345. }
  346. .andr-mt-lname {
  347. font-size: 30rpx;
  348. color: #3f454b;
  349. }
  350. .andr-mt-ltime {
  351. font-size: 22rpx;
  352. color: #999999;
  353. }
  354. </style>