top.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. text: '加载中...'
  108. });
  109. that.list = [];
  110. that.user = {};
  111. that._num = num;
  112. let url;
  113. if (num == 1) {
  114. url = that.$api.step.step_convert
  115. } else if (num == 2) {
  116. url = that.$api.step.ranking
  117. }
  118. that.getList(url);
  119. },
  120. getSetting() {
  121. let that = this;
  122. that.$request({
  123. url: that.$api.step.setting,
  124. }).then(response=>{
  125. that.$hideLoading();
  126. if(response.code == 0) {
  127. that.setting = response.data;
  128. }else {
  129. uni.showToast({
  130. title: response.msg,
  131. icon: 'none',
  132. duration: 1000
  133. });
  134. }
  135. }).catch(response => {
  136. that.$hideLoading();
  137. });
  138. },
  139. getList(url) {
  140. let that = this;
  141. that.$request({
  142. url: url,
  143. data: {
  144. status: that._num
  145. }
  146. }).then(response=>{
  147. that.$hideLoading();
  148. uni.hideLoading();
  149. if(response.code == 0) {
  150. that.list = response.data.list;
  151. that.user = response.data.user;
  152. that.ad_data = response.data.ad_data;
  153. if (that.list.length > 0) {
  154. for (let i = 0; i < that.list.length; i++) {
  155. that.list[i].raking = i + 1;
  156. }
  157. that.list[0].img = './../image/top1.png';
  158. if (that.list.length > 1) {
  159. that.list[1].img = './../image/top2.png';
  160. }
  161. if (that.list.length > 2) {
  162. that.list[2].img = './../image/top3.png';
  163. }
  164. }
  165. that.getHeight();
  166. }else {
  167. uni.showToast({
  168. title: response.msg,
  169. icon: 'none',
  170. duration: 1000
  171. });
  172. }
  173. }).catch(response => {
  174. that.$hideLoading();
  175. uni.hideLoading();
  176. });
  177. },
  178. },
  179. onLoad() {
  180. let that = this;
  181. let url = that.$api.step.step_convert;
  182. that._num = 1;
  183. that.$showLoading({
  184. type: 'global',
  185. text: '加载中...'
  186. });
  187. that.getSetting();
  188. that.getList(url);
  189. }
  190. }
  191. </script>
  192. <style scoped lang="scss">
  193. .top {
  194. width: 100%;
  195. height: #{400rpx};
  196. }
  197. .top image {
  198. width: 100%;
  199. height: #{400rpx};
  200. z-index: 2;
  201. }
  202. .triangle-left {
  203. width: 0;
  204. height: 0;
  205. border-left: #{14rpx} solid transparent;
  206. border-right: #{14rpx} solid transparent;
  207. border-bottom: #{18rpx} solid white;
  208. position: absolute;
  209. left: 22.5%;
  210. top: #{384rpx};
  211. z-index: 10;
  212. }
  213. .triangle-right {
  214. width: 0;
  215. height: 0;
  216. border-left: #{14rpx} solid transparent;
  217. border-right: #{14rpx} solid transparent;
  218. border-bottom: #{18rpx} solid white;
  219. position: absolute;
  220. right: 22.5%;
  221. top: #{384rpx};
  222. z-index: 10;
  223. }
  224. .rank {
  225. width: 100%;
  226. position: absolute;
  227. top: #{300rpx};
  228. background-color: rgba(0, 0, 0, 0.1);
  229. color: white;
  230. font-size: #{32rpx};
  231. z-index: 5;
  232. }
  233. .rank .rank-item {
  234. display: inline-block;
  235. width: 50%;
  236. height: 100%;
  237. line-height: #{100rpx};
  238. text-align: center;
  239. }
  240. .my {
  241. height: #{136rpx};
  242. width: 100%;
  243. background-color: white;
  244. margin-bottom: #{20rpx};
  245. }
  246. .avatar {
  247. padding: #{24rpx};
  248. float: left;
  249. }
  250. .avatar image {
  251. height: #{80rpx};
  252. width: #{80rpx};
  253. border: #{4rpx} #f09b48 solid;
  254. border-radius: #{40rpx};
  255. }
  256. .my-info {
  257. color: #999;
  258. font-size: #{24rpx};
  259. padding: #{32rpx} 0;
  260. height: 100%;
  261. float: left;
  262. }
  263. .my-name {
  264. color: #353535;
  265. font-size: #{30rpx};
  266. margin-bottom: #{8rpx};
  267. }
  268. .moeny {
  269. float: right;
  270. color: #999;
  271. font-size: #{24rpx};
  272. padding: #{32rpx} #{24rpx};
  273. height: 100%;
  274. text-align: right;
  275. }
  276. .number {
  277. font-size: #{34rpx};
  278. font-family: 'DIN';
  279. color: #353535;
  280. margin-bottom: #{10rpx};
  281. }
  282. .temp {
  283. visibility: hidden;
  284. }
  285. .list-item {
  286. height: #{135rpx};
  287. width: 100%;
  288. background-color: white;
  289. border-bottom: #{1rpx} solid #e2e2e2;
  290. overflow: hidden;
  291. }
  292. .noun {
  293. width: #{100rpx};
  294. height: #{135rpx};
  295. float: left;
  296. text-align: center;
  297. padding: #{43rpx} #{25rpx};
  298. }
  299. .noun image {
  300. width: #{50rpx};
  301. height: #{50rpx};
  302. }
  303. .noun-text {
  304. font-size: #{30rpx};
  305. color: #353535;
  306. }
  307. .list .avatar {
  308. padding-left: 0;
  309. }
  310. .info {
  311. float: left;
  312. color: #353535;
  313. font-size: #{30rpx};
  314. line-height: #{136rpx};
  315. width: 45%;
  316. overflow: hidden;
  317. }
  318. .name {
  319. overflow: hidden;
  320. white-space: nowrap;
  321. text-overflow: ellipsis;
  322. }
  323. .loading {
  324. font-size: #{24rpx};
  325. color: #353535;
  326. text-align: center;
  327. height: #{80rpx};
  328. line-height: #{80rpx};
  329. background-color: white;
  330. }
  331. #ad {
  332. width: 100%;
  333. position: fixed;
  334. bottom: 0;
  335. }
  336. </style>