This commit is contained in:
2025-06-16 10:09:19 +08:00
commit 7a066b3026
428 changed files with 50385 additions and 0 deletions

63
pages/user/address.vue Normal file
View File

@ -0,0 +1,63 @@
<template>
<view class="px-2">
<i-loading v-if="loading"></i-loading>
<i-address-list :resdata="list" @click="toShow" @delete="doDelete" />
<button @click="addAddress" class="fixed-bottom">添加地址</button>
</view>
</template>
<script>
import { TaAjax } from '../../common/ajax'
export default {
data() {
return {
order_no: '',
loading: false,
list:[]
}
},
onLoad(e) {
this.order_no = e.order_no
},
onShow() {
this.loadData()
},
methods: {
loadData() {
this.loading = true
TaAjax.get('/points_mall/api.auth.address/list').then((resp) => {
const data = resp.data;
this.list = data
}).finally(() => {
this.loading = false
})
},
addAddress(e) {
uni.navigateTo({
url:'/pages/user/address_edit'
})
},
toShow(item){
if (this.order_no) {
uni.redirectTo({
url: '/pages/points-mall/buy?order_no=' + this.order_no + '&address_id=' + item.id
})
} else {
uni.navigateBack()
}
},
doDelete(item) {
TaAjax.post('/points_mall/api.auth.address/delete', {
id: item.id,
}).then((resp) => {
this.loadData()
})
},
}
}
</script>
<style>
</style>

141
pages/user/address_edit.vue Normal file
View File

@ -0,0 +1,141 @@
<template>
<view class="mx-2">
<view class="bg-white rounded-lg p-3 mt-3">
<view class="flex align-center justify-between border-bottom border-light py-3">
<view class="flex-1">
<input class="font28" focus placeholder="姓名" v-model="userName" />
</view>
<view class="flex-1">
<input class="font28" type="number" placeholder="联系方式" v-model="tel" />
</view>
</view>
<pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
<view class=" border-bottom border-light py-3 flex align-center justify-between">
<view class=" font28 flex align-center flex-1" v-if="province">{{province}}{{city}}{{district}}
</view>
<view class=" font28 text-light-black flex-1" v-else>省市区</view>
<uni-icons type="right" color="#cccccc" size="20"></uni-icons>
</view>
</pick-regions>
<view class=" border-bottom border-light py-3 flex align-center justify-between">
<textarea v-model="address" autoHeight class="flex-1 font28" placeholder="详细地址(例如**街**号**)" />
</view>
<view class="flex align-center justify-between">
<view class="flex align-center justify-between mt-2" @click="clear">
<uni-icons type="trash-filled" size="16" color="#cccccc"></uni-icons>
<text class="font24 ml-1 text-muted">清空当前信息</text>
</view>
</view>
</view>
<view class="fixed-bottom border-top bg-white py-2 px-3">
<view class="bg-danger py-3 font30 text-center text-white shadow rounded-circle" @click="toList">立即保存
</view>
</view>
<uni-popup ref="message" type="message">
<uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
</uni-popup>
</view>
</template>
<script>
import {
TaAjax
} from '../../common/ajax'
export default {
data() {
return {
id: "",
province: null,
city: null,
district: null,
address: null,
userName: null,
tel: null,
// 弹出验证信息
message: null,
msgType: null,
messageText: null,
region: [],
defaultRegionCode: '110101'
}
},
onLoad(options) {
this.id = options.id || ""
},
methods: {
// 获取选择的地区
handleGetRegion(region) {
this.region = region
this.province = region[0].name
this.city = region[1].name
this.district = region[2].name
},
toList() {
if (this.userName == null || this.userName == '') {
this.msgType = "error"
this.messageText = `请输入联系人姓名`
this.$refs.message.open()
return
}
if (this.tel == null || this.tel == '') {
this.msgType = "error"
this.messageText = `请输入联系人手机号`
this.$refs.message.open()
return
}
if (!/^1[3456789]\d{9}$/.test(this.tel)) {
this.msgType = "error"
this.messageText = `请输入正确手机号`
this.$refs.message.open()
return
}
if (this.province == null || this.province == '') {
this.msgType = "error"
this.messageText = `请选择地址`
this.$refs.message.open()
return
}
const item = {
id: this.id,
user_name: this.userName,
user_phone: this.tel,
region_prov: this.province,
region_city: this.city,
region_area: this.district,
region_addr: this.address,
}
TaAjax.post("/points_mall/api.auth.address/save", item).then((res) => {
if (res.code == 1) {
this.msgType = "success"
this.messageText = `保存成功`
this.$refs.message.open()
setTimeout(() => {
uni.navigateBack()
}, 1000)
} else {
this.msgType = "error"
this.messageText = `保存失败`
this.$refs.message.open()
}
})
},
clear() {
this.address = '',
this.companyName = '',
this.userName = '',
this.tel = '',
this.province = '',
this.city = '',
this.district = ''
},
}
}
</script>
<style>
</style>

150
pages/user/bind/bind.vue Normal file
View File

@ -0,0 +1,150 @@
<template>
<view class="flex flex-column">
<view class="center-list">
<view class="center-list-item">
<text class="list-text">绑定手机</text>
<input class="list-input" v-model="form.phone">
</view>
</view>
<view class="center-list">
<view class="center-list-item">
<text class="list-text">手机验证码</text>
<view class="flex">
<input type="nickname" class="list-input" v-model="form.verify">
<button class="list-btn" :disabled="waiting" @click="getVerify">{{waiting ? `重新获取${waitingTime}s` : '获取验证码'}}</button>
</view>
</view>
</view>
<view style="margin-top:80rpx;" class="flex-center">
<button type="success" size="large" @click="doBind" customStyle="width:600rpx;height:100rpx">绑定</button>
</view>
</view>
</template>
<script>
import { TaAjax, TaPost } from '../../../common/ajax';
import { TaCache } from '../../../common/cache';
export default {
data() {
return {
form: {
phone: '',
verify: ''
},
waiting: false,
waitingTime: 60
}
},
methods: {
getVerify() {
TaAjax.post('/cms/api.auth.Bind/send', {
phone: this.form.phone
}).then(res => {
uni.showToast({
title: res.info,
icon: 'success',
})
this.form.verify = "123456"
this.waiting = true;
this.waitingTime = 60;
this.timer = setInterval(() => {
this.waitingTime--;
if (this.waitingTime <= 0) {
this.waiting = false;
clearInterval(this.timer);
}
}, 1000)
}).catch(err => {
uni.showToast({
title: "网络异常",
icon: 'none',
})
})
},
doBind() {
TaPost("/plugin-account/api.auth.center/bind", this.form).then((ret) => {
if (ret.code === 1) {
TaCache.set('auth.user', ret.data)
uni.showToast({
title: '绑定成功',
icon: 'success',
})
uni.navigateBack()
} else {
uni.showToast({
title: ret.info,
icon: 'none',
})
}
}).catch(err => {
console.log(err)
uni.showToast({
title: "网络异常",
icon: 'none',
})
})
},
}
}
</script>
<style>
page {
background-color: #f8f8f8;
}
.go-login-navigat-arrow {
font-size: 38upx;
color: #FFFFFF;
}
.login-title {
height: 150upx;
flex-direction: column;
align-items: center;
justify-content: center;
margin-left: 20upx;
}
.center-list {
flex-direction: column;
background-color: #FFFFFF;
margin-top: 20upx;
width: 690upx;
margin-left: 30upx;
margin-right: 30upx;
}
.center-list-item {
height: 90upx;
width: 690upx;
display: flex;
flex-direction: row;
padding: 0upx 20upx;
border-radius: 10upx;
box-shadow: #55555555 1rpx 0rpx 2rpx 0rpx;
justify-content: space-between;
}
.list-text {
flex-shrink: 0;
}
.list-text,.list-input {
height: 90upx;
line-height: 90upx;
font-size: 34upx;
color: #555;
}
.list-input {
text-align: right;
}
.list-btn {
font-size: 24rpx;
flex-shrink: 0;
height: 90upx;
line-height: 90upx;
}
</style>

203
pages/user/index.vue Normal file
View File

@ -0,0 +1,203 @@
<template>
<view class="flex flex-column">
<view class="logo" @click="goLogin" :hover-class="!isLogin ? 'logo-hover' : ''">
<image class="logo-img" :src="isLogin ? userInfo.extra.avatarUrl : avatarUrl"></image>
<view class="logo-title">
<text class="user-name">Hi{{userInfo.nickname || userInfo.extra.nickName}}</text>
</view>
</view>
<view class="center-list" @click="goUserInfo">
<view class="center-list-item">
<text class="list-text">账号管理</text>
</view>
</view>
<view class="center-list" @click="goUserUserShare">
<view class="center-list-item">
<text class="list-text">我的随手拍</text>
</view>
</view>
<view class="center-list" @click="goUserPoint">
<view class="center-list-item">
<text class="list-text">用户积分</text>
</view>
</view>
<view class="center-list" @click="goUserOrder">
<view class="center-list-item">
<text class="list-text">我的订单</text>
</view>
</view>
<view class="center-list" @click="goMessage">
<view class="center-list-item">
<text class="list-text">我的消息</text>
</view>
</view>
<view class="center-list" @click="goMorePage">
<view class="center-list-item">
<text class="list-text">更多设置</text>
</view>
</view>
</view>
</template>
<script>
import { TaCache } from '@/common/cache'
export default {
data() {
return {
avatarUrl: '/static/images/user-no-avatar.png',
isLogin: false,
userInfo: {
extra: {
avatarUrl: '/static/images/user-no-avatar.png',
nickname: '未登录',
},
},
}
},
onShow() {
const userInfo = TaCache.get('auth.user');
if (userInfo) {
this.userInfo = userInfo;
this.isLogin = true;
}
},
methods: {
goLogin() {
if (!this.isLogin) {
uni.navigateTo({
url: "/pages/user/login"
})
}
},
goUserInfo() {
if (!this.isLogin) {
uni.navigateTo({
url: "/pages/user/login"
})
} else {
uni.navigateTo({
url: "/pages/user/info",
})
}
},
goUserPoint() {
if (!this.isLogin) {
uni.navigateTo({
url: "/pages/user/login"
})
} else {
uni.navigateTo({
url: "/pages/user/point"
})
}
},
goUserUserShare() {
if (!this.isLogin) {
uni.navigateTo({
url: "/pages/user/login"
})
} else {
uni.navigateTo({
url: "/pages/user/user_share"
})
}
},
goMessage() {
uni.navigateTo({
url: "/pages/message/message",
})
},
goUserOrder() {
uni.navigateTo({
url: "/pages/user/order",
})
},
goMorePage() {
uni.navigateTo({
url: "/pages/const/more"
})
},
}
}
</script>
<style>
page {
background-color: #f8f8f8;
}
.logo {
width: 750upx;
height: 240upx;
padding: 20upx;
background-color: #2F85FC;
flex-direction: row;
align-items: center;
}
.logo-hover {
opacity: 0.8;
}
.logo-img {
width: 150upx;
height: 150upx;
border-radius: 150upx;
}
.logo-title {
height: 150upx;
flex: 1;
align-items: center;
justify-content: space-between;
flex-direction: row;
margin-left: 20upx;
}
.user-name {
height: 60upx;
line-height: 60upx;
font-size: 38upx;
color: #FFFFFF;
}
.go-login-navigat-arrow {
font-size: 38upx;
color: #FFFFFF;
}
.login-title {
height: 150upx;
flex-direction: column;
align-items: center;
justify-content: center;
margin-left: 20upx;
}
.center-list {
flex-direction: column;
background-color: #FFFFFF;
margin-top: 20upx;
width: 690upx;
margin-left: 30upx;
margin-right: 30upx;
}
.center-list-item {
height: 90upx;
width: 690upx;
flex-direction: row;
padding: 0upx 20upx;
border-radius: 10upx;
box-shadow: #55555555 1rpx 0rpx 2rpx 0rpx;
}
.list-text {
height: 90upx;
line-height: 90upx;
font-size: 34upx;
color: #555;
flex: 1;
}
</style>

157
pages/user/info.vue Normal file
View File

@ -0,0 +1,157 @@
<template>
<view class="flex flex-column">
<view class="center-list">
<view class="center-list-item">
<text class="list-text">账号昵称</text>
<input type="nickname" class="list-input" v-model="form.nickname" @nicknamereview="changeName" @confirm="changeName">
</view>
</view>
<view class="center-list">
<view class="center-list-item" @click="setAvatar">
<text class="list-text">修改头像</text>
</view>
</view>
</view>
</template>
<script>
import { TaAjax, TaPost, baseUrl } from '../../common/ajax';
import { TaCache } from '../../common/cache';
import { TaImageToBase64 } from '../../common/image';
export default {
data() {
return {
userInfo: {},
form: {
nickname: "",
}
}
},
onShow() {
const userInfo = TaCache.get('auth.user');
if (userInfo) {
this.userInfo = userInfo;
if (!this.userInfo.phone) {
uni.navigateTo({
url: '/pages/user/bind'
})
}
this.form.nickname = this.userInfo.nickname || this.userInfo.extra.nickName
} else {
uni.navigateTo({
url: '/pages/user/login'
})
}
},
methods: {
changeName() {
uni.showLoading({
title: "修改中..."
})
TaAjax.post('/plugin-account/api.auth.center/set', {
nickname: this.form.nickname,
extra: {
nickName: this.form.nickname
}
}, {
header: {
'Content-Type': 'application/json'
}
}).then(res => {
uni.hideLoading();
if (res.code == 1) {
uni.showToast({
title: "修改成功",
icon: "success"
})
TaCache.set('auth.user', res.data);
} else {
uni.showToast({
title: res.msg,
icon: "none"
})
}
}).finally()
},
setAvatar() {
uni.chooseImage({
count: 1,
sourceType: ['album'],
success: (res) => {
uni.showLoading({
title: "上传中..."
})
uni.uploadFile({
url: baseUrl + '/custom/api.Upload/file',
filePath: res.tempFilePaths[0],
name: 'file',
success(res) {
const responseStr = res.data;
const response = JSON.parse(res.data);
const data = response.data;
const url = data.url;
TaPost('/plugin-account/api.auth.center/set', {
headimg: url
}).then().finally(() => uni.hideLoading())
},
complete() {
uni.hideLoading()
},
})
}
})
},
}
}
</script>
<style>
page {
background-color: #f8f8f8;
}
.go-login-navigat-arrow {
font-size: 38upx;
color: #FFFFFF;
}
.login-title {
height: 150upx;
flex-direction: column;
align-items: center;
justify-content: center;
margin-left: 20upx;
}
.center-list {
flex-direction: column;
background-color: #FFFFFF;
margin-top: 20upx;
width: 690upx;
margin-left: 30upx;
margin-right: 30upx;
}
.center-list-item {
height: 90upx;
width: 690upx;
display: flex;
flex-direction: row;
padding: 0upx 20upx;
border-radius: 10upx;
box-shadow: #55555555 1rpx 0rpx 2rpx 0rpx;
justify-content: space-between;
}
.list-text,.list-input {
height: 90upx;
line-height: 90upx;
font-size: 34upx;
color: #555;
}
.list-input {
text-align: right;
}
</style>

101
pages/user/login.vue Normal file
View File

@ -0,0 +1,101 @@
<template>
<view class="login">
<view class="login-head flex-y">
<text class="login-head-h1">登录</text>
</view>
<view class="login-body flex-y">
<view class="flex-center">
<text class="login-body-name">微信授权</text>
</view>
<view style="margin-top:80rpx;" class="flex-center">
<button type="success" size="large" @click="doLogin" customStyle="width:600rpx;height:100rpx">
</button>
</view>
</view>
<!--
<view class="login-foot">
<view class='login-foot-agent flex-center'>
<checkbox label="1" v-model="agent.value">同意协议</checkbox>
<text @click="agent.show = true">用户隐私协议</text>
</view>
</view> -->
</view>
</template>
<script>
import { TaAjax } from '@/common/ajax';
import { TaCache } from '@/common/cache';
import { TaToast } from '@/common/toast';
export default {
data() {
return {
// 用户协议
agent: {
show: false,
value: true,
},
}
},
created() {
const userInfo = TaCache.get('auth.user')
if (userInfo) {
uni.navigateBack()
}
},
methods: {
// 执行注册登录
doLogin() {
TaToast.loading("登录中")
this.login().then((data) => {
TaCache.set('auth.user', data)
}).finally(() => {
TaToast.loadhide()
})
},
login() {
return new Promise((resolve, reject) => uni.login({
provider: 'weixin',
success(loginRes) {
// 换取会话密钥
let data = {
code: loginRes.code,
iv: '',
encrypted: ''
}
TaAjax.post('/plugin-account/api.wxapp/session', data).then((ret) => {
console.log('SessionDone: ', ret)
TaCache.set('auth.token', ret.data.token)
// 获取用户信息
uni.getUserInfo({
provider: 'weixin',
success: (infoRes) => {
console.log('UserInfo: ', infoRes)
data.iv = infoRes.iv, data.encrypted = infoRes
.encryptedData
TaAjax.post('/plugin-account/api.wxapp/decode', data)
.then((ret) => {
console.log('UserDone: ', ret.data)
resolve(ret.data)
}).catch((ret) => {
console.log('UserFail: ', ret.data)
reject(ret)
})
}
})
}).catch((ret) => {
console.log('SessionFail: ', ret)
reject(ret);
})
}
}))
}
},
}
</script>

167
pages/user/order.vue Normal file
View File

@ -0,0 +1,167 @@
<template>
<view class="flex flex-column overflow-hidden" style="height: 100vh;">
<!-- <view class="flex align-center justify-between pt-3 bg-white flex-shrink">
<view v-for="(item,index) in tabBar" :key="index" class="flex-1 text-center " @click="changeTab(index)">
<text :class="tabIndex==index?'text-danger font-weight-bold':'text-muted'">{{item}}</text>
<view :class="tabIndex==index?'bg-danger':''" style="width: 30rpx;height: 10rpx;" class="rounded-lg d-block mx-auto mt-2 "></view>
</view>
</view> -->
<view class="flex-1" style="overflow-y: auto;">
<scroll-view class="flex-1 list overflow-hidden" :scroll-y="true" :refresher-enabled="true"
:refresher-triggered="refresh" @refresherrefresh="refreshData()" @scrolltolower="loadData()">
<i-order-list :resdata="orderList" @cancel="cancelOrder" @confirm="confirmOrder"></i-order-list>
<uni-load-more :status="more_status" @clickLoadMore="loadData"></uni-load-more>
</scroll-view>
</view>
<!-- <swiper class="flex-1" :current="tabIndex" @change="swiperChange" > -->
<!-- <swiper-item class="flex" v-for="(item,index) in tabBar" :key="index"> -->
<!-- </swiper-item> -->
<!-- </swiper> -->
</view>
</template>
<script>
import { TaAjax } from '../../common/ajax'
import { friendlyDate } from '../../common/util';
export default {
data() {
return {
tabIndex:0,
tabBar:['全部','待发货','待收货','已收货'],
loading: false,
refresh: true,
finish: true,
curPage: 1,
orderList: [],
}
},
computed: {
more_status() {
if (this.finish) {
return 'no-more';
} else if (this.loading) {
return 'loading';
} else {
return 'more';
}
},
},
methods: {
refreshData() {
this.refresh = true;
this.curPage = 1;
this.loadData();
},
loadData() {
if (this.refresh) {
this.orderList.length = 0;
this.finish = false;
}
if (this.finish) {
return;
}
this.loading = true;
TaAjax.get('/points_mall/api.auth.order/get', {
page: this.curPage
}).then((response) => {
const data = response.data;
const data_list = data.list.map((item) => {
item.create_at = friendlyDate(new Date(item.create_time.replace(/\-/g, '/'))
.getTime())
return item;
})
if (this.refresh) {
this.orderList.length = 0
}
this.orderList = this.orderList.concat(data_list)
this.finish = data.page.total <= this.orderList.length;
this.curPage++;
}).catch((e) => {
console.warn(e)
if (this.orderList.length == 0) {
this.finish = true;
}
}).finally(() => {
this.refresh = false;
this.loading = false;
});
},
changeTab(index){
this.tabIndex = index
this.refreshData()
},
swiperChange(e){
this.tabIndex = e.detail.current
this.refreshData()
},
cancelOrder(orderNo) {
uni.showLoading({
title: '取消中'
})
TaAjax.post('/points_mall/api.auth.order/cancel', {
order_no: orderNo,
}).then((response) => {
if (response.code == 1) {
uni.hideLoading()
uni.showToast({
title: '取消成功',
icon: 'success',
})
} else {
uni.hideLoading()
uni.showToast({
title: response.info,
icon: 'none',
})
}
}).catch((e) => {
console.warn(e)
uni.hideLoading()
uni.showToast({
title: '取消失败',
icon: 'none',
})
}).finally(() => {
this.refreshData()
})
},
confirmOrder(orderNo) {
uni.showLoading({
title: '确认中',
})
TaAjax.post('/points_mall/api.auth.order/confirm', {
order_no: orderNo,
}).then((response) => {
if (response.code == 1) {
uni.hideLoading()
uni.showToast({
title: '确认成功',
icon: 'success',
})
} else {
uni.hideLoading()
uni.showToast({
title: response.info,
icon: 'none',
})
}
}).catch((e) => {
console.warn(e)
uni.hideLoading()
uni.showToast({
title: '确认失败',
icon: 'none',
})
}).finally(() => {
this.refreshData()
})
},
}
}
</script>
<style scoped>
</style>

143
pages/user/point.vue Normal file
View File

@ -0,0 +1,143 @@
<template>
<view class="flex flex-column flex-1" style="height: 100vh;">
<view class="flex logo">
<view class="flex flex-1 flex-column center logo-title">
<text class="text-center title title-huge">{{point}}</text>
<text class="text-center title">当前积分</text>
</view>
</view>
<scroll-view class="flex-1 list" :scroll-y="true" :refresher-enabled="true"
:refresher-triggered="refresh" @refresherrefresh="refreshLog" @scrolltolower="getLog">
<uni-list class="flex flex-column flex-1">
<uni-list-item v-for="(item, index) in logList" :key="index">
<template v-slot:body>
<view class="flex flex-1 flex-column">
<text style="font-size: 36rpx;">{{item.reason}}</text>
<text style="font-size: 24rpx; color: gray;">{{item.create_at}}</text>
</view>
</template>
<template v-slot:footer>
<view class="flex align-center justify-center">
<text>{{item.point>0?'+':''}}{{item.point}}</text>
</view>
</template>
</uni-list-item>
</uni-list>
<uni-load-more :status="more_status" @clickLoadMore="getLog"></uni-load-more>
</scroll-view>
</view>
</template>
<script>
import {
TaAjax
} from '@/common/ajax';
import {
friendlyDate
} from '@/common/util';
export default {
computed: {
more_status() {
if (this.finish) {
return 'no-more';
} else if (this.loading) {
return 'loading';
} else {
return 'more';
}
},
},
data() {
return {
point: 0,
logList: [],
loading: false,
refresh: false,
finish: false,
curPage: 1,
}
},
onLoad() {
this.getPoint();
this.getLog();
},
methods: {
getPoint() {
TaAjax.get('/points_mall/api.auth.UserPoint/myPoint').then((response) => {
const data = response.data;
this.point = data.point
})
},
refreshLog() {
this.refresh = true;
this.curPage = 1;
this.getPoint()
this.getLog();
},
getLog() {
if (this.refresh) {
this.logList.length = 0
this.finish = false;
}
if (this.finish) {
return;
}
TaAjax.get('/points_mall/api.auth.UserPoint/myPointLog', {
page: this.curPage
}).then((response) => {
const data = response.data;
const data_list = data.data.map((item) => {
item.create_at = friendlyDate(new Date(item.create_at.replace(/\-/g, '/'))
.getTime())
return item;
})
if (this.refresh) {
this.logList.length = 0
}
this.logList = this.logList.concat(data_list)
this.finish = data.page.total <= this.logList.length;
this.curPage++;
}).catch((e) => {
console.warn(e)
if (this.logList.length == 0) {
this.finish = true;
}
}).finally(() => {
this.refresh = false;
this.loading = false;
});
},
}
}
</script>
<style lang="scss">
.logo {
width: 750upx;
height: 240upx;
padding: 20upx;
background-color: $uni-color-primary;
flex-direction: row;
align-items: center;
}
.logo-title {
height: 150upx;
align-items: center;
justify-content: space-around;
}
.title {
color: white;
font-size: 40rpx;
}
.title-huge {
font-size: 72rpx;
font-weight: bold;
}
.list {
height: calc(100vh - 240rpx);
}
</style>

91
pages/user/user_share.vue Normal file
View File

@ -0,0 +1,91 @@
<template>
<view class="flex flex-column flex-1" style="height: 100vh;">
<i-loading v-if="loading" />
<view class="flex flex-column flex-1" style="height: 100%;">
<scroll-view class="flex-1 overflow-hidden" style="height: 100%;" scroll-y :refresher-enabled="true"
:refresher-triggered="refresh" @refresherrefresh="refreshData" @scrolltolower="loadData">
<view class="px-2 overflow-scroll">
<i-user-share-list :resdata="shareList" />
</view>
<uni-load-more :status="more_status" @clickLoadMore="loadData"></uni-load-more>
</scroll-view>
</view>
</view>
</template>
<script>
import {
TaAjax
} from '@/common/ajax';
import {
friendlyDate
} from '@/common/util';
export default {
computed: {
more_status() {
if (this.finish) {
return 'no-more';
} else if (this.loading) {
return 'loading';
} else {
return 'more';
}
},
},
data() {
return {
shareList: [],
curPage: 1,
loading: true,
refresh: true,
finish: false
}
},
methods: {
loadData() {
if (this.refresh) {
this.shareList.length = 0;
this.finish = false;
}
if (this.finish) {
return;
}
TaAjax.get('/ticket/api.auth.UserShare/index', {
page: this.curPage
}).then((result) => {
const data = result.data;
const data_list = data.data.map((share) => {
share.create_at = friendlyDate(new Date(share.create_at.replace(/\-/g, '/'))
.getTime());
share.imgs = share.imgs_arr;
return share;
});
if (this.refresh) {
this.shareList.length = 0;
}
this.shareList = this.shareList.concat(data_list);
this.finish = data.total <= this.shareList.length;
this.curPage++;
}).catch((e) => {
console.warn(e)
if (this.shareList.length == 0) {
this.finish = true;
}
}).finally(() => {
this.refresh = false;
this.loading = false;
});
},
refreshData() {
this.finish = false;
this.refresh = true;
this.curPage = 1;
this.loadData();
},
}
}
</script>
<style>
</style>