sadjv3/anmo-shop/my/gird/browse.vue

220 lines
6.2 KiB
Vue
Raw Permalink Normal View History

2024-06-04 10:03:14 +08:00
<template>
<view class="margin-lr-sm">
<view v-if="dataList.length != 0" class="flex margin-top-sm bg padding-sm radius" @click="goOrder(item)"
@longpress="delData(item)" v-for="(item,index) in dataList" :key="index">
<!-- <image :src="item.orderTaking.headImg?item.orderTaking.headImg: '../../static/logo.png'"
style="width: 220rpx;height: 200rpx;border-radius: 10rpx;"></image> -->
<view style="width: 300upx;height: 260upx;border-radius: 10rpx;">
<image :src="item.headImg?item.headImg: '../../static/logo.png'"
style="width: 300upx;height: 260upx;border-radius: 4upx;"
mode="aspectFit"></image>
</view>
<view class=" margin-left-sm text-white flex-direction" style="width: 50%;">
<view class="flex justify-between">
<view class="flex">
<image src="../../static/images/geren.png"
style="width: 35rpx;height: 35rpx;margin-left: 10rpx;"></image>
<view class="margin-right-xs u-line-1"
style="margin-top: -2px;display: inline-block;width: 320rpx; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
{{item.orderTaking.myLevel}}
</view>
</view>
</view>
<view style="color: #999999;font-size: 24rpx;line-height: 40rpx;"
v-if="item.orderTaking.authentication == 1">
<text v-if="item.sex == 1"></text>
<text v-if="item.sex == 0"></text>
/<text>{{item.age}}</text>
/<text>{{item.orderTaking.orderLevel}}</text>
/<text>{{item.orderTaking.region}}</text>
</view>
<view style="color: #999999;" v-if="item.authentication == 2">
<text>{{item.orderTakingUserName}}</text> /<text>{{item.orderTaking.region}}</text>
</view>
<view class="flex radius" style="line-height: 45rpx;">
<view style="width: 100%;overflow: hidden;display: flex;flex-wrap: wrap;">
<text v-for="(item,index) in item.orderTaking.gameId" :key="index" class="box">{{item}}</text>
</view>
</view>
<view
style="width: 100%;display: flex;justify-content: space-between;align-items: center;margin-top: 20rpx;">
<view style="color:#FF1200;font-size: 31rpx;">
{{item.orderTaking.oldMoney}}/
</view>
<!-- <view>{{item.updateTime}}</view> -->
</view>
</view>
</view>
<empty v-if="dataList.length == 0"></empty>
</view>
</template>
<script>
import empty from '../../components/empty.vue'
export default {
components: {
empty
},
data() {
return {
dataList: [],
page: 1,
limit: 10,
myId: '',
isVip: false,
age: 0,
birthDate: ''
}
},
onLoad(e) {
this.$queue.showLoading("加载中...");
this.myId = uni.getStorageSync('userId')
this.isVip = uni.getStorageSync('isVIP') ? uni.getStorageSync('isVIP') : false
this.getBrowseList()
},
methods: {
//换算年龄
getAge(e) {
console.log('出生日期:' + e)
this.birthDate = e
//创建系统日期
var today = new Date();
//把出生日期转换成日期
this.birthDate = new Date(this.birthDate);
//分别获取到年份后相减
let age = today.getFullYear() - this.birthDate.getFullYear();
return age;
// console.log(this.age+'当前年龄')
},
// 足迹
getBrowseList() {
let data = {
page: this.page,
limit: this.limit
}
this.$Request.get("/app/userBrowse/myBrowse", data).then(res => {
uni.hideLoading();
if (res.code == 0) {
if (this.page == 1) {
this.dataList = res.data.list
for (let i = 0; i < this.dataList.length; i++) {
this.dataList[i].orderTaking.gameId = this.dataList[i].orderTaking.gameId.split(
",");
// this.dataList[i].orderTaking.region = this.dataList[i].orderTaking.region.split(
// ",");
if (this.dataList[i].orderTaking.region) {
let region = this.dataList[i].orderTaking.region.split(",");
this.dataList[i].orderTaking.region = region[1]
} else {
this.dataList[i].orderTaking.region = '不限地区'
}
this.dataList[i].age = this.getAge(this.dataList[i].birthdate)
}
} else {
this.dataList = [...this.dataList, ...res.data.list]
for (let i = 0; i < this.dataList.length; i++) {
this.dataList[i].orderTaking.gameId = this.dataList[i].orderTaking.gameId.split(
",");
// this.dataList[i].orderTaking.region = this.dataList[i].orderTaking.region.split(
// ",");
if (this.dataList[i].orderTaking.region) {
let region = this.dataList[i].orderTaking.region.split(",");
this.dataList[i].orderTaking.region = region[1]
} else {
this.dataList[i].orderTaking.region = '不限地区'
}
this.dataList[i].age = this.getAge(this.dataList[i].birthdate)
}
}
} else {
console.log(res.msg)
}
uni.stopPullDownRefresh();
})
},
// 跳转订单
goOrder(e) {
uni.navigateTo({
url: '/pages/index/order/order?id=' + e.orderTaking.id
});
},
// 删除
delData(e) {
let that = this
uni.showModal({
title: '提示',
content: '确定删除吗?',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
let data = {
id: e.id
}
that.$Request.post("/app/userBrowse/deleteMyBrowse", data).then(res => {
if (res.code == 0) {
uni.showToast({
title: '删除成功!',
icon: 'none'
})
that.getBrowseList()
}
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
}
},
onReachBottom: function() {
this.page = this.page + 1;
this.getBrowseList()
},
onPullDownRefresh: function() {
this.page = 1;
this.getBrowseList()
},
}
</script>
<style>
page {
background-color: #f7f7f7;
}
.bg {
background: #ffffff;
}
.line_s {
display: inline-flex;
width: 10rpx;
height: 10rpx;
background: #1AD566;
border-radius: 50%;
margin-right: 10rpx;
}
.line_x {
display: inline-flex;
width: 10rpx;
height: 10rpx;
background: #000000;
border-radius: 50%;
margin-right: 10rpx;
}
.box {
border: 1px solid #005dff;
border-radius: 4rpx;
color: #005dff;
padding: 0rpx 8rpx;
font-size: 22rpx;
margin-top: 10rpx;
margin-right: 5rpx;
}
</style>