refactor: 重构多个组件以支持 Vue 3 语法和功能

- 将多个组件转换为 `<script setup>` 语法,提升可读性和性能
- 优化状态管理和事件处理逻辑,简化代码结构
- 更新样式和布局以适应新组件结构
- 添加新功能和修复已知问题,提升用户体验
This commit is contained in:
Yer11214
2026-07-08 18:37:11 +08:00
parent 4d0b0fb5e4
commit 349ffa4f34
189 changed files with 18278 additions and 20758 deletions

View File

@@ -15,58 +15,53 @@
</div>
</template>
<script>
import { getBargainList } from "@/api/promotions";
<script setup lang="ts">
import { ref } from 'vue'
import { onShow, onReachBottom } from '@dcloudio/uni-app'
import { getBargainList } from '@/api/promotions'
import goodsTemplate from '@/components/m-goods-list/promotion'
export default {
components:{goodsTemplate},
data() {
return {
background: {
backgroundColor: "transparent",
},
params: {
promotionStatus: "START", //开始/上架
pageNumber: 1,
pageSize: 20,
},
bargainList: [], //砍价活动列表
};
},
onShow() {
this.params.pageNumber = 1;
this.bargainList = [];
this.init();
},
onReachBottom() {
this.params.pageNumber++;
this.init();
},
methods: {
// 返回上一级
back() {
uni.switchTab({
url: "/pages/tabbar/home/index",
});
},
/**
* 初始化砍价列表
*/
async init() {
let res = await getBargainList(this.params); //砍价列表
if (res.data.success) {
this.bargainList.push(...res.data.result.records);
}
},
// 跳转到砍价详情
navigateToBargainDetail(val) {
uni.navigateTo({
url: `/pages/promotion/bargain/detail?id=${val.id}`,
});
},
},
};
const background = ref({
backgroundColor: 'transparent',
})
const params = ref({
promotionStatus: 'START',
pageNumber: 1,
pageSize: 20,
})
const bargainList = ref<any[]>([])
onShow(() => {
params.value.pageNumber = 1
bargainList.value = []
init()
})
onReachBottom(() => {
params.value.pageNumber++
init()
})
function back() {
uni.switchTab({
url: '/pages/tabbar/home/index',
})
}
async function init() {
const res = await getBargainList(params.value)
if (res.data.success) {
bargainList.value.push(...res.data.result.records)
}
}
function navigateToBargainDetail(val: any) {
uni.navigateTo({
url: `/pages/promotion/bargain/detail?id=${val.id}`,
})
}
</script>
<style lang="scss">
page {
@@ -129,4 +124,4 @@ page {
.empty {
height: 400rpx;
}
</style>
</style>