浏览代码

Merge branch 'feature_业主工会' of http://192.168.4.246:3000/elab-damai-h5/h5-elab-open-ownerUnion into feature_业主工会

王晓晨 3 年之前
父节点
当前提交
ae9d98b81b
共有 6 个文件被更改,包括 793 次插入343 次删除
  1. 2 0
      main.js
  2. 17 0
      pages.json
  3. 426 336
      pages/homePage/homePage.vue
  4. 243 0
      pages/revenueRankingPage/revenueRankingPage.vue
  5. 101 0
      static/cache.js
  6. 4 7
      util/api.js

+ 2 - 0
main.js

@@ -2,11 +2,13 @@ import Vue from 'vue'
 import App from './App'
 import { myRequest } from 'util/api.js'
 Vue.config.productionTip = false
+import MinCache from './static/cache.js'
 //引入vuex
 import store from './store'
 //把vuex定义成全局组件
 Vue.prototype.$store = store
 
+Vue.use(MinCache,{timeout:1800}) //缓存时间30分钟
 
 App.mpType = 'app'
 Vue.prototype.$myRequest = myRequest

+ 17 - 0
pages.json

@@ -32,6 +32,23 @@
 				}
 			}
 		}
+        ,{
+            "path" : "pages/revenueRankingPage/revenueRankingPage",
+            "style": {
+            	"navigationBarTitleText": "收益排行榜",
+            	"enablePullDownRefresh": true,
+            	"onReachBottomDistance": 50,
+            	"scrollIndicator": "none",
+            	"app-plus": {
+            		"pullToRefresh": {
+            			"support": true,
+            			"color": "#ff3333",
+            			"style": "circle"
+            		}
+            	}
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",

文件差异内容过多而无法显示
+ 426 - 336
pages/homePage/homePage.vue


+ 243 - 0
pages/revenueRankingPage/revenueRankingPage.vue

@@ -0,0 +1,243 @@
+<template>
+	<view class="ranking_body">
+		<view class="title">
+			收益排行 TOP10
+		</view>
+		<view class="rank_tab">
+			<view class="tab_item" @click="tab(1)" :class="{active1:currentTab==1}" :style="{background:currentTab==1?color1:''}">
+				总量
+			</view>
+			<view class="tab_line"></view>
+			<view class="tab_item" @click="tab(2)"  :class="{active2:currentTab==2}" :style="{background:currentTab==2?color1:''}">
+				本月
+			</view>
+			<view class="tab_line"></view>
+			<view class="tab_item" @click="tab(3)"  :class="{active3:currentTab==3}" :style="{background:currentTab==3?color1:''}">
+				本日
+			</view>
+		</view>
+		<view class="rank_list">
+			<view class="rank_title">
+				<view class="rank_title_name" style="width: 20%;">
+					排名
+				</view>
+				<view class="rank_title_name" style="width: 30%;">
+					用户名
+				</view>
+				<view class="rank_title_name" style="width: 20%;">
+					用户等级
+				</view>
+				<view class="rank_title_name" style="width: 30%;">
+					累计收益(元)
+				</view>
+			</view>
+			
+			<view class="rank_item" v-for="(item,index) in rankingList" :key='index'>
+				<view class="rank_item_name" style="width: 20%;">
+					<image class="icon" v-if="index==0" src="https://dm.static.elab-plus.com/yezhu/icon_first.png" mode=""></image>
+					<image class="icon" v-if="index==1"  src="https://dm.static.elab-plus.com/yezhu/icon_twice.png" mode=""></image>
+					<image class="icon" v-if="index==2"  src="https://dm.static.elab-plus.com/yezhu/icon_thrid.png" mode=""></image>
+				    <text  v-if="index!=0&&index!=1&&index!=2" >{{index+1}}</text>
+				</view>
+				<view class="rank_item_name" style="width: 30%;" :style="{color:(index==0||index==1||index==2)?color1:'auto'}">
+					淘房**神
+				</view>
+				<view class="rank_item_name" style="width: 20%;">
+					LV10
+				</view>
+				<view class="rank_item_name" style="width: 30%;" :style="{color:(index==0||index==1||index==2)?color1:'auto'}">
+					8273.00
+				</view>
+				<view class="item_line">
+					
+				</view>
+			</view>
+			
+			<view class="back_home" :style="{background:color2}" @click="backHome">
+				<image class="back_home_icon" src="https://dm.static.elab-plus.com/yezhu/icon_home.png" mode=""></image>
+				<text>返回\n任务大厅</text>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	let app = getApp();
+	export default {
+		data() {
+			return {
+				rankingList:[
+					{
+						
+					},
+					{
+						
+					},
+					{
+						
+					},{
+						
+					},
+					{
+						
+					},{
+						
+					},{
+						
+					},{
+						
+					},{
+						
+					},{
+						
+					}
+				],
+			    color1:"",
+				color2:"",
+				currentTab:1,
+			};
+		},
+		mounted() {
+			this.color1 = app.globalData.color1;
+			this.color2 = app.globalData.color2;
+		},
+		methods:{
+			tab(index){
+				this.currentTab = index;
+			},
+			backHome(){
+				uni.navigateBack({
+					delta:1,
+				})
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+.ranking_body{
+	margin-left: 20rpx;
+	margin-right: 20rpx;
+	background: #ffffff;
+	border-radius: 16rpx;
+	padding-top: 20rpx;
+	margin-top: 20rpx;
+	.title{
+		text-align: center;
+		font-size: 32rpx;
+		font-family: Verdana, Verdana-Bold;
+		font-weight: 700;
+		text-align: center;
+		color: #262626;
+	}
+	
+	.rank_tab{
+		display: flex;
+		margin: 0 auto;
+		margin-top: 40rpx;
+		width: 450rpx;
+		height: 60rpx;
+		background: #ffffff;
+		border: 2rpx solid #ededed;
+		border-radius: 8rpx;
+		.tab_item{
+			height: 100%;
+			text-align: center;
+			flex: auto;
+			line-height: 60rpx;
+			font-size: 24rpx;
+			font-family: Verdana, Verdana-Regular;
+			font-weight: 400;
+			color: #b1b1b1;
+		}
+		.tab_line{
+			width: 2rpx;
+			height: 60rpx;
+			background: #ededed;
+		}
+		.active1{
+			border-radius: 8rpx 0 0 8rpx;
+			color: #FFFFFF;
+		}
+		.active2{
+			border-radius: 0;
+			color: #FFFFFF;
+		}
+		.active3{
+			border-radius: 0 8rpx 8rpx 0 ;
+			color: #FFFFFF;
+		}
+	}
+	
+	.rank_list{
+		width: 100%;
+		.rank_title{
+			display: flex;
+			width: 100%;
+			margin: 0 auto;
+			margin-top: 40rpx;
+			.rank_title_name{
+				font-size: 28rpx;
+				flex: auto;
+				font-family: Verdana, Verdana-Bold;
+				font-weight: 700;
+				text-align: center;
+				color: #b1b1b1;
+			}
+		}
+		.rank_item{
+			display: flex;
+			align-items: center;
+			width: 100%;
+			height: 104rpx;
+			margin: 0 auto;
+			position: relative;
+			.rank_item_name{
+				font-size: 28rpx;
+				flex: auto;
+				font-family: Verdana, Verdana-Bold;
+				font-weight: 400;
+				text-align: center;
+				color: #666666;
+				.icon{
+					width: 36rpx;
+					height: 40rpx;
+				}
+			}
+			.item_line{
+				position: absolute;
+				bottom: 0;
+				left: 50%;
+				transform: translateX(-50%);
+				width: 630rpx;
+				height: 2rpx;
+				background-color: rgba(0,0,0,0.05);
+			}
+		}
+	}
+	
+	.back_home{
+		position: fixed;
+		bottom: 180rpx;
+		right: 0;
+		width: 100rpx;
+		height: 120rpx;
+		border-radius: 20rpx 0rpx 0rpx 20rpx;
+		box-shadow: 0rpx 10rpx 20rpx 0rpx rgba(119,55,12,0.20); 
+		display: flex;
+		flex-direction: column;
+		justify-content: center;
+		align-items: center;
+		.back_home_icon{
+			width: 30rpx;
+			height: 28rpx;
+			margin-bottom: 9rpx;
+		}
+		font-size: 20rpx;
+		font-family: PingFang SC, PingFang SC-Semibold;
+		font-weight: 600;
+		text-align: center;
+		color: #ffffff;
+	}
+}
+</style>

+ 101 - 0
static/cache.js

@@ -0,0 +1,101 @@
+let cacheMap =  new Map()
+let timeoutDefault = 1200
+
+function isTimeout (name) {
+  const data = cacheMap.get(name)
+  if (!data) return true
+  if (data.timeout === 0) return false 
+  const currentTime = Date.now()
+  const overTime = (currentTime - data.createTime) / 1000
+  if (overTime > data.timeout) {
+    cacheMap.delete(name)
+    if (name.startsWith('_')) {
+      try {
+        uni.removeStorageSync(name)
+      } catch (e) {
+        console.log(e)
+      }
+    }
+    return true
+  }
+  return false
+}
+
+class CacheCell {
+  constructor (data, timeout) {
+    this.data = data
+    this.timeout = timeout
+    this.createTime = Date.now()
+  }
+}
+
+class MinCache {
+  constructor (timeout) {
+    try {
+      const res = uni.getStorageInfoSync()
+      res.keys.forEach(name => {
+        try {
+          const value = uni.getStorageSync(name)
+          cacheMap.set(name, value)
+        } catch (e) {
+          console.log(e)
+        }
+      })
+    } catch (e) {
+      console.log(e)
+    }
+    timeoutDefault = timeout
+  }
+  set (name, data, timeout = timeoutDefault) {
+    const cachecell = new CacheCell(data, timeout)
+    let cache = null
+    if (name.startsWith('_')) {
+      try {
+        uni.setStorageSync(name, cachecell)
+        cache = cacheMap.set(name, cachecell)
+      } catch (e) {
+        console.log(e)
+      }
+    } else {
+      cache = cacheMap.set(name, cachecell)
+    }
+    return cache
+  }
+  get (name) {
+    return isTimeout(name) ? null : cacheMap.get(name).data
+  }
+  delete (name) {
+    let value = false
+    if (name.startsWith('_')) {
+      try {
+        uni.removeStorageSync(name)
+        value = cacheMap.delete(name)
+      } catch (e) {
+        console.log(e)
+      }
+    } else {
+      value = cacheMap.delete(name)
+    }
+    return value
+  }
+  has (name) {
+    return !isTimeout(name)
+  }
+  clear () {
+    let value = false
+    try {
+      uni.clearStorageSync()
+      cacheMap.clear()
+      value = true
+    } catch (e) {
+      console.log(e)
+    }
+    return value
+  }
+}
+
+MinCache.install = function (Vue, {timeout = 1200} = {}) {
+  Vue.prototype.$cache = new MinCache(timeout)
+}
+
+export default MinCache

+ 4 - 7
util/api.js

@@ -15,7 +15,7 @@ export const myRequest = (options) => {
 			})
 		}
 	}
-	let token = getApp().globalData.token;
+	let token = getApp().globalData.token
 	if (token) {
 		options.token = token
 	} else {
@@ -27,12 +27,9 @@ export const myRequest = (options) => {
 			url: BASE_URL + options.url,
 			method: options.method || "POST",
 			data: options.data || {},
-			// header: {
-			// 	'token': options.token || null,
-			// 	'elabprojectname': elabprojectname,
-			// 	'elabsystem': elabsystem,
-			// 	'elabEnvironment': elabEnvironment
-			// },
+			header: {
+				'token': options.token || null,
+			},
 			success: res => {
 				uni.hideLoading()
 				uni.hideNavigationBarLoading();