top.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <app-layout>
  3. <view class='top'>
  4. <image v-if="_num==1" :src='setting.ranking_pic.length > 0?setting.ranking_pic:stepImg.app_image.daily'></image>
  5. <image v-if="_num==2" :src='setting.ranking_pic.length > 0?setting.ranking_pic:stepImg.app_image.top_bg'></image>
  6. </view>
  7. <view class='rank'>
  8. <view @click="change(1)" class="rank-item">今日步数排行</view>
  9. <view @click="change(2)" class="rank-item">总财富排行</view>
  10. </view>
  11. <view v-if="_num==1" class="triangle-left"></view>
  12. <view v-if="_num==2" class="triangle-right"></view>
  13. <view class='my'>
  14. <view class='avatar'>
  15. <image :src='user.avatar'></image>
  16. </view>
  17. <view class='my-info'>
  18. <view class='my-name'>{{user.nickname}}</view>
  19. <view v-if="user.raking > 0">第{{user.raking}}名</view>
  20. <view v-if="user.raking == 0">暂未上榜</view>
  21. </view>
  22. <view class='moeny'>
  23. <view v-if="_num==1" class='number'>{{user.total_num ? user.total_num : 0}}</view>
  24. <view v-if="_num==2" class='number'>{{user.step_currency ? user.step_currency : 0}}</view>
  25. <view v-if="_num==1">步数</view>
  26. <view v-if="_num==2">{{setting.currency_name ? setting.currency_name : '活力币'}}数</view>
  27. </view>
  28. </view>
  29. <view class='list' :style="{'margin-bottom': `${adHeight}px`}">
  30. <view class='list-item' v-for="info in list" :key="info.id">
  31. <view class='noun'>
  32. <view class='noun-text' v-if='info.raking > 3'>{{info.raking}}</view>
  33. <image :src='info.img' v-if='info.raking < 4'></image>
  34. </view>
  35. <view class='avatar'>
  36. <image :src='info.avatar'></image>
  37. </view>
  38. <view class='info'>
  39. <view class='name'>{{info.nickname}}</view>
  40. </view>
  41. <view class='moeny'>
  42. <view v-if="_num==1" class='number'>{{info.total_num ? info.total_num : 0}}</view>
  43. <view v-if="_num==2" class='number'>{{info.step_currency ? info.step_currency : 0}}</view>
  44. <view v-if="_num==1">步数</view>
  45. <view v-if="_num==2">{{setting.currency_name ? setting.currency_name : '活力币'}}数</view>
  46. </view>
  47. </view>
  48. </view>
  49. <view id='ad'>
  50. <app-ad v-if="ad_data.unit_id"
  51. :unit-id="ad_data.unit_id"
  52. :type="ad_data.type"
  53. :video-url="ad_data.video_url"
  54. :pic-url="ad_data.pic_url"
  55. :coupon-url="coupon_url"
  56. :coupon-params="ad_data | getObje(ad_data)"
  57. />
  58. </view>
  59. </app-layout>
  60. </template>
  61. <script>
  62. import appAd from "../../../components/page-component/app-ad/app-ad"
  63. import {mapState} from "vuex";
  64. export default {
  65. data() {
  66. return {
  67. list: [],
  68. over: false,
  69. ad_data: {},
  70. user: {},
  71. loading: false,
  72. more: false,
  73. _num: 1,
  74. setting: null,
  75. adHeight: 0,
  76. coupon_url: this.$api.step.receive,
  77. }
  78. },
  79. components: {
  80. appAd
  81. },
  82. computed: {
  83. ...mapState({
  84. stepImg: state => state.mallConfig.plugin.step,
  85. })
  86. },
  87. filters: {
  88. getObje(data, temp) {
  89. return {
  90. id: data.id
  91. }
  92. }
  93. },
  94. methods: {
  95. getHeight() {
  96. const self = this;
  97. setTimeout(() => {
  98. const query = uni.createSelectorQuery().in(this);
  99. query.select('#ad').boundingClientRect(res => {
  100. self.adHeight = res.height;
  101. }).exec();
  102. })
  103. },
  104. change(num) {
  105. let that = this;
  106. uni.showLoading({
  107. mask: true,
  108. text: '加载中...'
  109. });
  110. that.list = [];
  111. that.user = {};
  112. that._num = num;
  113. let url;
  114. if (num == 1) {
  115. url = that.$api.step.step_convert
  116. } else if (num == 2) {
  117. url = that.$api.step.ranking
  118. }
  119. that.getList(url);
  120. },
  121. getSetting() {
  122. let that = this;
  123. that.$request({
  124. url: that.$api.step.setting,
  125. }).then(response=>{
  126. that.$hideLoading();
  127. if(response.code == 0) {
  128. that.setting = response.data;
  129. }else {
  130. uni.showToast({
  131. title: response.msg,
  132. icon: 'none',
  133. duration: 1000
  134. });
  135. }
  136. }).catch(response => {
  137. that.$hideLoading();
  138. });
  139. },
  140. getList(url) {
  141. let that = this;
  142. that.$request({
  143. url: url,
  144. data: {
  145. status: that._num
  146. }
  147. }).then(response=>{
  148. that.$hideLoading();
  149. uni.hideLoading();
  150. if(response.code == 0) {
  151. that.list = response.data.list;
  152. that.user = response.data.user;
  153. that.ad_data = response.data.ad_data;
  154. if (that.list.length > 0) {
  155. for (let i = 0; i < that.list.length; i++) {
  156. that.list[i].raking = i + 1;
  157. }
  158. that.list[0].img = '/static/image/step/top1.png';
  159. if (that.list.length > 1) {
  160. that.list[1].img = '/static/image/step/top2.png';
  161. }
  162. if (that.list.length > 2) {
  163. that.list[2].img = '/static/image/step/top3.png';
  164. }
  165. }
  166. that.getHeight();
  167. }else {
  168. uni.showToast({
  169. title: response.msg,
  170. icon: 'none',
  171. duration: 1000
  172. });
  173. }
  174. }).catch(response => {
  175. that.$hideLoading();
  176. uni.hideLoading();
  177. });
  178. },
  179. },
  180. onLoad() { this.$commonLoad.onload();
  181. let that = this;
  182. let url = that.$api.step.step_convert;
  183. that._num = 1;
  184. that.$showLoading({
  185. type: 'global',
  186. text: '加载中...'
  187. });
  188. that.getSetting();
  189. that.getList(url);
  190. }
  191. }
  192. </script>
  193. <style scoped lang="scss">
  194. .top {
  195. width: 100%;
  196. height: #{400rpx};
  197. }
  198. .top image {
  199. width: 100%;
  200. height: #{400rpx};
  201. z-index: 2;
  202. }
  203. .triangle-left {
  204. width: 0;
  205. height: 0;
  206. border-left: #{14rpx} solid transparent;
  207. border-right: #{14rpx} solid transparent;
  208. border-bottom: #{18rpx} solid white;
  209. position: absolute;
  210. left: 22.5%;
  211. top: #{384rpx};
  212. z-index: 10;
  213. }
  214. .triangle-right {
  215. width: 0;
  216. height: 0;
  217. border-left: #{14rpx} solid transparent;
  218. border-right: #{14rpx} solid transparent;
  219. border-bottom: #{18rpx} solid white;
  220. position: absolute;
  221. right: 22.5%;
  222. top: #{384rpx};
  223. z-index: 10;
  224. }
  225. .rank {
  226. width: 100%;
  227. position: absolute;
  228. top: #{300rpx};
  229. background-color: rgba(0, 0, 0, 0.1);
  230. color: white;
  231. font-size: #{32rpx};
  232. z-index: 5;
  233. }
  234. .rank .rank-item {
  235. display: inline-block;
  236. width: 50%;
  237. height: 100%;
  238. line-height: #{100rpx};
  239. text-align: center;
  240. }
  241. .my {
  242. height: #{136rpx};
  243. width: 100%;
  244. background-color: white;
  245. margin-bottom: #{20rpx};
  246. }
  247. .avatar {
  248. padding: #{24rpx};
  249. float: left;
  250. }
  251. .avatar image {
  252. height: #{80rpx};
  253. width: #{80rpx};
  254. border: #{4rpx} #f09b48 solid;
  255. border-radius: #{40rpx};
  256. }
  257. .my-info {
  258. color: #999;
  259. font-size: #{24rpx};
  260. padding: #{32rpx} 0;
  261. height: 100%;
  262. float: left;
  263. }
  264. .my-name {
  265. color: #353535;
  266. font-size: #{30rpx};
  267. margin-bottom: #{8rpx};
  268. }
  269. .moeny {
  270. float: right;
  271. color: #999;
  272. font-size: #{24rpx};
  273. padding: #{32rpx} #{24rpx};
  274. height: 100%;
  275. text-align: right;
  276. }
  277. .number {
  278. font-size: #{34rpx};
  279. font-family: 'DIN';
  280. color: #353535;
  281. margin-bottom: #{10rpx};
  282. }
  283. .temp {
  284. visibility: hidden;
  285. }
  286. .list-item {
  287. height: #{135rpx};
  288. width: 100%;
  289. background-color: white;
  290. border-bottom: #{1rpx} solid #e2e2e2;
  291. overflow: hidden;
  292. }
  293. .noun {
  294. width: #{100rpx};
  295. height: #{135rpx};
  296. float: left;
  297. text-align: center;
  298. padding: #{43rpx} #{25rpx};
  299. }
  300. .noun image {
  301. width: #{50rpx};
  302. height: #{50rpx};
  303. }
  304. .noun-text {
  305. font-size: #{30rpx};
  306. color: #353535;
  307. }
  308. .list .avatar {
  309. padding-left: 0;
  310. }
  311. .info {
  312. float: left;
  313. color: #353535;
  314. font-size: #{30rpx};
  315. line-height: #{136rpx};
  316. width: 45%;
  317. overflow: hidden;
  318. }
  319. .name {
  320. overflow: hidden;
  321. white-space: nowrap;
  322. text-overflow: ellipsis;
  323. }
  324. .loading {
  325. font-size: #{24rpx};
  326. color: #353535;
  327. text-align: center;
  328. height: #{80rpx};
  329. line-height: #{80rpx};
  330. background-color: white;
  331. }
  332. #ad {
  333. width: 100%;
  334. position: fixed;
  335. bottom: 0;
  336. }
  337. </style>