uniapp 时间戳转换

pull/9/head
Jruome 2023-06-01 11:24:27 +08:00
parent ad21968346
commit d6ea232b81
5 changed files with 39 additions and 22 deletions

View File

@ -28,14 +28,14 @@
<view class="up" @tap="goEquity"> <view class="up" @tap="goEquity">
<image style="width: ;" src="@/static/images/shop/vip_oneStar.png" mode=""></image> <image style="width: ;" src="@/static/images/shop/vip_oneStar.png" mode=""></image>
</view> </view>
<text>会员等级1级</text> <text>会员等级{{vipData.findIndex((item) => item == vip.grade) +1}}</text>
<view class="button" @tap="goEquity"></view> <view class="button" @tap="goEquity"></view>
</view> </view>
<view class="right" v-else> <view class="right" v-else>
<view class="up" @tap="goEquity"> <view class="up" @tap="goEquity">
<image style="width: ;" src="@/static/images/shop/vip_oneStar.png" mode=""></image> <image style="width: ;" src="@/static/images/shop/vip_oneStar.png" mode=""></image>
</view> </view>
<text>会员等级0</text> <text>会员等级{{vipData.findIndex((item) => item == vip.grade) +1}}</text>
<view class="button" @tap="goEquity"></view> <view class="button" @tap="goEquity"></view>
</view> </view>
</view> </view>
@ -223,7 +223,7 @@
bastInfo: '', bastInfo: '',
fastInfo: '', fastInfo: '',
fastList: [], fastList: [],
text: '尊敬的业主:接环卫所通知,近期将对小区进行大扫除,请大家做好准备', text: '暂无公告',
firstInfo: '', firstInfo: '',
salesInfo: '', salesInfo: '',
indicatorDots: false, indicatorDots: false,
@ -286,7 +286,7 @@
lineColor: 'red', lineColor: 'red',
lineStyle: {}, // 线-- lineStyle: {}, // 线--
listActive: 0, // listActive: 0, //
vipData:['普通会员','中级会员','高级会员'],
duration: 0.2 // 线 duration: 0.2 // 线
} }
}, },

View File

@ -14,7 +14,7 @@
</view> </view>
<view class="item-text"> <view class="item-text">
<text>充值档次{{item.grade}}</text> <text>充值档次{{item.grade}}</text>
<text>日期{{item.stringCreateTime}}</text> <text>日期{{$util.timestampToTime(item.stringCreateTime)}}</text>
</view> </view>
</view> </view>
<u-empty v-show="!memberData.length" text="暂无数据" mode="list"></u-empty> <u-empty v-show="!memberData.length" text="暂无数据" mode="list"></u-empty>

View File

@ -15,6 +15,9 @@ import {
setVisit, setVisit,
getUserInfo getUserInfo
} from '@/api/user.js' } from '@/api/user.js'
import {
mapGetters
} from "vuex";
export default { export default {
data(){ data(){
return { return {
@ -23,11 +26,11 @@ export default {
userInfo: {} userInfo: {}
} }
}, },
computed: mapGetters(['tenantId']),
mounted(){ mounted(){
getUserInfo().then(res => { getUserInfo().then(res => {
this.userInfo = res.data this.userInfo = res.data
console.log(res.data) getTenant(this.tenantId).then(res => {
getTenant(153).then(res => {
this.tenant = res.data this.tenant = res.data
this.text = res.data.notice this.text = res.data.notice
}) })

View File

@ -67,7 +67,7 @@
<text>{{item.nickname}}</text> <text>{{item.nickname}}</text>
</view> </view>
<text class="extra"> <text class="extra">
{{ timestampToTime(item.payTime) }} {{ $util.timestampToTime(item.payTime) }}
<view>{{ item.grade }}</view> <view>{{ item.grade }}</view>
</text> </text>
</view> </view>
@ -152,20 +152,20 @@
} }
}, },
methods: { methods: {
timestampToTime(timestamp) { // timestampToTime(timestamp) {
// 10*1000131000 // // 10*1000131000
var date = new Date(timestamp); // var date = new Date(timestamp);
var Y = date.getFullYear() + "-"; // var Y = date.getFullYear() + "-";
var M = // var M =
(date.getMonth() + 1 < 10 // (date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1) // ? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-"; // : date.getMonth() + 1) + "-";
var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " "; // var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":"; // var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":"; // var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
var s = (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds()); // var s = (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds());
return Y + M + D + h + m + s; // return Y + M + D + h + m + s;
}, // },
selectClick(value) { selectClick(value) {
console.log(value) console.log(value)
this.active = value.id this.active = value.id

View File

@ -8,6 +8,20 @@ import {
pathToBase64 pathToBase64
} from '@/plugin/image-tools/index.js'; } from '@/plugin/image-tools/index.js';
export default { export default {
timestampToTime(timestamp) {
// 时间戳为10位需*1000时间戳为13位不需乘1000
var date = new Date(timestamp);
var Y = date.getFullYear() + "-";
var M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
var s = (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds());
return Y + M + D + h + m + s;
},
/** /**
* opt object | string * opt object | string
* to_url object | string * to_url object | string