📖 code review:砍价界面

pull/34/head
YunaiV 2023-12-27 19:50:11 +08:00
parent ccb5796468
commit 90751ac3c3
2 changed files with 19 additions and 28 deletions

View File

@ -1,4 +1,8 @@
<!-- 砍价详情 -->
<template>
<!-- TODO @科举按照项目的代码风格调整下这个界面 -->
<!-- TODO @科举挪到 bargain/detail.vue -->
<!-- TODO @科举尽量都迁移完依赖数据的部分通过直接在 state 写死状态不用后端返回跑通整个界面不追求 100% 但是至少自己观感是 ok -->
<s-layout title='砍价详情'>
<view class='bargain'>
<!-- :class="startBargainUid !== userInfo.uid ? 'on' : ''" -->

View File

@ -1,5 +1,7 @@
<!-- 砍价列表 TODO @科举新建一个 bargain 然后这个页面挪进去改成 list.vue写的时候要思考怎么更好的融入到当前项目 -->
<template>
<s-layout title='砍价列表'>
<!-- TODO @科举参考 groupon/list.vue seckill/list.vue 界面调整下头部就是从 5 11 行的 -->
<s-layout navbar="inner" title='砍价列表'>
<view style='background-color: red;height:100vh;'>
<view class='bargain-list'>
<!-- #ifdef H5 -->
@ -12,7 +14,7 @@
<view class='header'>
<view class="pic">
<view class='swipers'>
<swiper :indicator-dots="state.indicatorDots" :autoplay="state.autoplay" interval="2500"
<swiper indicator-dots="true" autoplay="true" interval="2500"
duration="500" vertical="true" circular="true">
<block v-for="(item,index) in state.bargainSuccessList" :key='index'>
<swiper-item>
@ -69,25 +71,11 @@
</template>
<script setup>
import {
computed,
reactive
} from 'vue';
import { reactive } from 'vue';
import sheep from '@/sheep';
import _ from 'lodash';
import {
onLoad,
onReachBottom
} from '@dcloudio/uni-app';
import {
useDurationTime
} from '@/sheep/hooks/useGoods';
import {
showShareModal
} from '@/sheep/hooks/useModal';
import {
isEmpty
} from 'lodash';
import { onLoad, onReachBottom } from '@dcloudio/uni-app';
import { fen2yuan } from '@/sheep/hooks/useGoods';
const state = reactive({
navH: '',
@ -96,8 +84,6 @@
// ========== ==========
bargainTotal: 0,
bargainSuccessList: [],
autoplay: true,
indicatorDots: false,
// ========== ==========
bargainList: [],
@ -116,6 +102,7 @@
});
function getBargainHeader() {
// TODO @ BargainApi.getBargainRecordSummary使 await
sheep.$api.activity.getBargainRecordSummary().then(res => {
state.bargainTotal = res.data.successUserCount;
state.bargainSuccessList = res.data.successList;
@ -127,12 +114,14 @@
}
function getBargainList() {
if (state.loadend || state.loading) {
// TODO @loading loadTitle 使 uni-load-more
if (state.loadend || state.loading) {
return;
}
state.loading = true;
state.loadTitle = '';
sheep.$api.activity.getBargainActivityPage({
// TODO @ BargainApi.getBargainRecordSummary使 await
sheep.$api.activity.getBargainActivityPage({
pageNo: state.page,
pageSize: state.limit
}).then(res => {
@ -154,6 +143,8 @@
function openSubscribe(e) {
console.log(e)
// TODO @ pages/pay/result.vue subscribeMessage
// TODO @navigateTo sheep.$router.go
uni.navigateTo({
url: page,
});
@ -176,6 +167,7 @@
});
// #endif
}
onLoad(function() {
getBargainHeader();
getBargainList();
@ -184,11 +176,6 @@
onReachBottom(() => {
getBargainList();
});
//
function fen2yuan(price) {
return (price / 100.0).toFixed(2)
}
</script>
<style lang='scss' scoped>