123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <view class="widthBox">
- <view v-for="item in data" :key="item.id" @click.stop="jumpDetails(item)">
- <image :src="item.url"
- style="width: 100%;height: 350rpx;border-radius: 10rpx;" mode="scaleToFill">
- </image>
- </view>
- <u-empty v-if="data.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
- <u-loadmore v-if="page.total !== 0 && data.length != 0" :status="status" />
- </view>
- </template>
- <script>
- import {
- activityList
- } from '@/api/tabBar/activity.js'
- import {
- shoppingCartList
- } from '@/api/tabBar/shoppingCart.js'
- export default {
- data() {
- return {
- page: {
- current: 1,
- size: 10,
- total: 0,
- },
- data: [],
- status: 'loadmore',
- }
- },
- onLoad() {
- // this.activityListfun()
- },
- onShow() {
- this.getUpdate()
- shoppingCartList({ whetherIntegral: '0'}).then(res => {
- let num=0
- res.data.forEach(e=>{
- console.log(e.list)
- num=num+e.list.length
- })
- uni.setTabBarBadge({
- index: 3, // tabIndex,tabBar的哪一项,从0开始
- text: num.toString()// 显示的文本,超过 99 显示成 “…”
- })
- })
- this.data = [];
- this.page.current = 1;
- size: this.page.size = 10;
- this.activityListfun()
- },
- onReachBottom() {
- this.status = 'loading'
- if (this.data.length < this.page.total) {
- this.page.current++
- this.activityListfun()
- } else {
- this.status = 'nomore'
- }
- },
- methods: {
- getUpdate() {
- const updateManager = uni.getUpdateManager();
- updateManager.onCheckForUpdate(function(res) {
- // 请求完新版本信息的回调
- if (res.hasUpdate) {
- updateManager.onUpdateReady(function() {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success: function(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- }
- });
- });
- updateManager.onUpdateFailed(function() {
- // 新的版本下载失败
- uni.showModal({
- title: '已经有新版本了哟~',
- content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
- });
- });
- }
- });
- },
- // 跳转详情
- jumpDetails(row) {
- uni.navigateTo({
- url: '/pages/tabBar/activity/details?id=' + row.id
- })
- },
- // 获取列表数据
- activityListfun() {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- activityList({
- current: this.page.current,
- size: this.page.size,
- status: 1
- }).then(res => {
- this.data = this.data.concat(res.data.records)
- this.page.total = res.data.total
- if (this.data.length == res.data.total) {
- this.status = 'nomore'
- }
- uni.setTabBarBadge({
- index: 1, // tabIndex,tabBar的哪一项,从0开始
- text: res.data.total.toString() // 显示的文本,超过 99 显示成 “…”
- })
- uni.hideLoading();
- }).catch(err => {
- uni.hideLoading();
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .widthBox {
- background-color: #fff;
- padding: 32rpx;
- height: 100vh;
- }
- </style>
|