猎豆优选小程序

commissionRank.vue 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view
  3. class="page-wrap"
  4. :style="{
  5. background: `${newNavbarBackground.background}`,
  6. 'background-size': `${newNavbarBackground.backgroundSize}`,
  7. }"
  8. >
  9. <!-- 头部栏 -->
  10. <u-navbar
  11. class="navbar-wrap"
  12. title="分佣榜"
  13. title-color="#181818"
  14. back-icon-color="#181818"
  15. :background="newNavbarBackground"
  16. />
  17. <!-- 内容 -->
  18. <view class="content-wrap">
  19. <view class="date-wrap">
  20. <view v-for="(date, idx) in dateOptions" :key="idx" :class="['date-item', crtDateType === date.value ? 'on' : '']" @click="onClickDateType(date)">
  21. <text>{{ date.lable }}</text>
  22. <text v-if="idx + 1 < dateOptions.length" class="line">|</text>
  23. </view>
  24. </view>
  25. <view class="top-wrap">
  26. <image class="top-bg" src="/static/imgs/top-bg.png" />
  27. <!-- 2 -->
  28. <view v-if="top3List[1] && top3List[1].user_id" class="top-item">
  29. <image class="top-head" src="/static/imgs/top-2.png" />
  30. <view class="avatar-wrap user-2">
  31. <image class="avatar-img" :src="top3List[1].img || '/static/imgs/avatar-login.png'" />
  32. </view>
  33. <view class="name-wrap">
  34. <image class="icon-hg" src="/static/imgs/icon-hg.png" />
  35. <view class="username">{{ top3List[1].name }}</view>
  36. </view>
  37. <view class="price">{{ top3List[1].sum_rebate }}元</view>
  38. </view>
  39. <!-- 1 -->
  40. <view v-if="top3List[0] && top3List[0].user_id" class="top-item top-item-1">
  41. <image class="top-head" src="/static/imgs/top-1.png" />
  42. <view class="avatar-wrap user-1">
  43. <image class="avatar-img" :src="top3List[0].img || '/static/imgs/avatar-login.png'" />
  44. </view>
  45. <view class="name-wrap">
  46. <image class="icon-hg" src="/static/imgs/icon-hg.png" />
  47. <view class="username">{{ top3List[0].name }}</view>
  48. </view>
  49. <view class="price">{{ top3List[0].sum_rebate }}元</view>
  50. </view>
  51. <!-- 3 -->
  52. <view v-if="top3List[2] && top3List[2].user_id" class="top-item">
  53. <image class="top-head" src="/static/imgs/top-3.png" />
  54. <view class="avatar-wrap user-3">
  55. <image class="avatar-img" :src="top3List[2].img || '/static/imgs/avatar-login.png'" />
  56. </view>
  57. <view class="name-wrap">
  58. <image class="icon-hg" src="/static/imgs/icon-hg.png" />
  59. <view class="username">{{ top3List[2].name }}</view>
  60. </view>
  61. <view class="price">{{ top3List[2].sum_rebate }}元</view>
  62. </view>
  63. </view>
  64. <view class="list-wrap">
  65. <view v-for="(item, idx) in otherList" :key="idx" class="item-wrap">
  66. <view>
  67. <text class="idx">{{ idx + 4 }}</text>
  68. <text>{{ item.name }}</text>
  69. </view>
  70. <view>{{ item.sum_rebate }}元</view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. const app = getApp();
  78. export default {
  79. data() {
  80. return {
  81. newNavbarBackground: {
  82. background: `url(https://ld.726p.com/tbk/upload/c579f015a49a3f9e066f0ab00ab56f7.png) #ffffff no-repeat`,
  83. backgroundSize: "100% 370rpx",
  84. },
  85. background: {
  86. backgroundImage: "transparent",
  87. },
  88. statusBarHeight: app.globalData.statusBarHeight,
  89. navigationBarHeight: app.globalData.navigationBarHeight,
  90. dateOptions: [
  91. { lable: '今日', value: 'today' },
  92. { lable: '昨日', value: 'yesterday' },
  93. { lable: '七日', value: '7days' },
  94. { lable: '本月', value: 'crtMonth' },
  95. { lable: '上月', value: 'lastMonth' },
  96. ],
  97. crtDateType: 'lastMonth',
  98. top3List: [],
  99. otherList: [],
  100. };
  101. },
  102. onLoad() {
  103. this.onClickDateType()
  104. },
  105. methods: {
  106. onClickDateType(date) {
  107. let start_date = ''
  108. let end_date = ''
  109. this.crtDateType = date ? date.value : 'lastMonth'
  110. if (this.crtDateType === 'today') { // 今日
  111. start_date = this.$moment().format('YYYY-MM-DD');
  112. end_date = this.$moment().format('YYYY-MM-DD');
  113. } else if (this.crtDateType === 'yesterday') { // 昨日
  114. start_date = this.$moment().subtract(1, 'days').format('YYYY-MM-DD');
  115. end_date = this.$moment().subtract(1, 'days').format('YYYY-MM-DD');
  116. } else if (this.crtDateType === '7days') { // 七日
  117. start_date = this.$moment().subtract(6, 'days').format('YYYY-MM-DD');
  118. end_date = this.$moment().subtract(0, 'days').format('YYYY-MM-DD');
  119. } else if (this.crtDateType === 'crtMonth') { // 本月
  120. start_date = this.$moment().startOf('month').format('YYYY-MM-DD')
  121. end_date = this.$moment().endOf('month').format('YYYY-MM-DD')
  122. } else if (this.crtDateType === 'lastMonth') { // 上月
  123. start_date = this.$moment().subtract(1, 'month').startOf('month').format('YYYY-MM-DD');
  124. end_date = this.$moment().subtract(1, 'month').endOf('month').format('YYYY-MM-DD');
  125. }
  126. this.handleGetData({ start_date, end_date })
  127. },
  128. async handleGetData(options = {}) {
  129. const { start_date, end_date } = options
  130. try {
  131. const url = this.$api.commissionRank_list;
  132. const params = { start_date, end_date };
  133. uni.showLoading({ title: "加载中...", mask: true });
  134. const { data: res } = await this.$get(url, params);
  135. if (res && res.errno == 0 && res.rst.length) {
  136. this.top3List = [
  137. res.rst[0] || {},
  138. res.rst[1] || {},
  139. res.rst[2] || {},
  140. ]
  141. if (res.rst.length && res.rst.length > 3) {
  142. const list = JSON.parse(JSON.stringify(res.rst))
  143. list.splice(0, 3)
  144. this.otherList = [...list]
  145. }
  146. } else {
  147. uni.showToast({ title: res.err || "操作失败", icon: "none" });
  148. }
  149. } catch (error) {
  150. uni.showToast({ title: "服务器错误", icon: "none" });
  151. } finally {
  152. uni.hideLoading();
  153. }
  154. },
  155. },
  156. };
  157. </script>
  158. <style lang="scss" scoped>
  159. .page-wrap {
  160. position: relative;
  161. background-attachment: fixed;
  162. background-color: #f0f0f0;
  163. padding: 20rpx;
  164. min-height: 100vh;
  165. display: flex;
  166. flex-direction: column;
  167. .navbar-wrap {
  168. z-index: 9999;
  169. .navbar_name {
  170. color: #181818;
  171. font-size: 36rpx;
  172. padding-left: 40%;
  173. display: flex;
  174. align-items: center;
  175. }
  176. }
  177. .content-wrap {
  178. flex: 1;
  179. background: linear-gradient(#ff5656 0%, #ffffff 100%);
  180. background-size: 100% 569rpx;
  181. background-repeat: no-repeat;
  182. border-radius: 25rpx;
  183. .date-wrap {
  184. display: flex;
  185. align-items: center;
  186. justify-content: flex-end;
  187. margin: 21rpx 40rpx 0 0;
  188. font-weight: 400;
  189. font-size: 25rpx;
  190. color: rgba(0, 0, 0, 0.4);
  191. line-height: 35rpx;
  192. font-style: normal;
  193. .date-item {
  194. &.on {
  195. color: #fff;
  196. }
  197. .line {
  198. opacity: 0.32;
  199. color: #fff;
  200. margin: 0 17rpx;
  201. }
  202. }
  203. }
  204. .top-wrap {
  205. position: relative;
  206. margin-top: 60rpx;
  207. background-color: #fff;
  208. display: flex;
  209. justify-content: space-between;
  210. margin: 140rpx 25rpx 0;
  211. border-radius: 17rpx 17rpx 0 0;
  212. height: 430rpx;
  213. .top-bg {
  214. position: absolute;
  215. top: 0;
  216. left: 50%;
  217. transform: translateX(-50%);
  218. width: 256rpx;
  219. height: 194rpx;
  220. z-index: 99;
  221. }
  222. .top-item {
  223. position: relative;
  224. flex-shrink: 0;
  225. width: 33%;
  226. display: flex;
  227. flex-direction: column;
  228. align-items: center;
  229. background-color: #fff;
  230. border-radius: 17rpx 17rpx 0 0;
  231. box-sizing: border-box;
  232. &.top-item-1 {
  233. margin-top: -65rpx;
  234. z-index: 999;
  235. }
  236. .top-head {
  237. position: relative;
  238. z-index: 9;
  239. margin-top: 56rpx;
  240. width: 80rpx;
  241. height: 80rpx;
  242. }
  243. .avatar-wrap {
  244. margin-top: -36rpx;
  245. width: 121rpx;
  246. height: 121rpx;
  247. border: 4rpx solid #BFBFBF;
  248. overflow: hidden;
  249. border-radius: 50%;
  250. &.user-1 {
  251. border-color: #F9A603;
  252. }
  253. &.user-2 {
  254. border-color: #BFBFBF;
  255. }
  256. &.user-3 {
  257. border-color: #D1B685;
  258. }
  259. .avatar-img {
  260. width: 100%;
  261. height: 100%;
  262. border-radius: 50%;
  263. }
  264. }
  265. .name-wrap {
  266. margin-top: -14rpx;
  267. display: flex;
  268. align-items: center;
  269. min-width: 50%;
  270. max-width: 80%;
  271. background-color: #FFE9E9;
  272. padding: 4rpx 10rpx;
  273. border-radius: 13rpx;
  274. .icon-hg {
  275. width: 18rpx;
  276. height: 18rpx;
  277. }
  278. .username {
  279. margin-left: 4rpx;
  280. flex: 1;
  281. font-size: 21rpx;
  282. color: #333;
  283. word-break: break-all;
  284. overflow: hidden;
  285. -webkit-line-clamp: 1;
  286. text-overflow: ellipsis;
  287. display: -webkit-box;
  288. -webkit-box-orient: vertical;
  289. }
  290. }
  291. .price {
  292. margin-top: 12rpx;
  293. font-weight: 600;
  294. font-size: 33rpx;
  295. color: #FF5555;
  296. line-height: 46rpx;
  297. }
  298. }
  299. }
  300. .list-wrap {
  301. padding: 0 48rpx 60rpx;
  302. .item-wrap {
  303. margin-bottom: 54rpx;
  304. display: flex;
  305. justify-content: space-between;
  306. font-weight: 400;
  307. font-size: 31rpx;
  308. color: #333333;
  309. line-height: 44rpx;
  310. .idx {
  311. font-weight: 600;
  312. margin-right: 17rpx;
  313. }
  314. }
  315. }
  316. }
  317. }
  318. </style>