Compare commits

...

2 Commits

Author SHA1 Message Date
448f281570 Merge remote-tracking branch 'origin/master' 2025-10-17 17:21:56 +08:00
a5a5534c36 2025-10-17
收货地址添加修改
2025-10-17 17:21:11 +08:00
8 changed files with 217 additions and 40 deletions

16
api/address.js Normal file
View File

@@ -0,0 +1,16 @@
import {
http
} from "../util/api"
// const baseURL = "http://192.168.0.12:3005/term"
const baseURL = "http://192.168.0.26:3000/api"
// 项目相关API
export const addressAPI = {
// 列表
getList: (params) => http.get(baseURL + '/addresses', params),
}
export default {
addressAPI
}

View File

@@ -1,7 +1,9 @@
import { http } from "../util/api"; import { http } from "../util/api";
const baseURL = "http://192.168.0.26:3000/api"
export const commonAPI = { export const commonAPI = {
getRegion: () => http.get('/common/provinces'), getRegion: () => http.get(baseURL + '/regions/provinces'),
} }
export default { export default {

View File

@@ -1,5 +1,5 @@
{ {
"name" : "jurong_circle_front_app", "name" : "炬融圈",
"appid" : "__UNI__11908F8", "appid" : "__UNI__11908F8",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
@@ -18,9 +18,7 @@
}, },
/* */ /* */
"modules" : { "modules" : {
"Payment" : {}, "Payment" : {}
"Record" : {},
"Camera" : {}
}, },
/* */ /* */
"distribute" : { "distribute" : {

View File

@@ -4,7 +4,8 @@
"path": "pages/home/index", "path": "pages/home/index",
"style": { "style": {
"navigationBarTitleText": "主页", "navigationBarTitleText": "主页",
"navigationStyle": "custom" "navigationStyle": "custom",
"enablePullDownRefresh": true
} }
}, },
{ {

View File

@@ -1,6 +1,8 @@
<template> <template>
<view class="message-container"> <view class="message-container">
<scroll-view scroll-y="true" style="height: 100%;"> <scroll-view scroll-y="true" :style="'height:'+height+'px'" @scrolltolower="loadMallData"
:refresher-threshold="50" :refresher-triggered="isRefresher" refresher-background="transparent"
refresher-enabled="true" @refresherrefresh="reflash">
<view class="header-search"> <view class="header-search">
<u-search :action-style="searchBtn" shape="square" bg-color="#CADBFF" placeholder="输入商品名称或商品种类" <u-search :action-style="searchBtn" shape="square" bg-color="#CADBFF" placeholder="输入商品名称或商品种类"
v-model="keyword"></u-search> v-model="keyword"></u-search>
@@ -133,22 +135,32 @@
</view> </view>
</template> </template>
</u-waterfall> </u-waterfall>
<u-loadmore margin-top="20" :status="loadStatus"></u-loadmore>
</view> </view>
<u-loadmore margin-top="20" :status="loadStatus" color="#fff"></u-loadmore>
<view class="box-div"></view> <view class="box-div"></view>
</scroll-view> </scroll-view>
</view> </view>
<Tabbar id="tabbarId"></Tabbar> <Tabbar id="tabbarId"></Tabbar>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { import {
ref, onMounted ref, onMounted, getCurrentInstance
} from 'vue'; } from 'vue';
import { mallAPI } from '../../api/mall'; import { mallAPI } from '../../api/mall';
import { getImageUrl } from '../../util/common'; import { getImageUrl } from '../../util/common';
const instance = getCurrentInstance();
const height = ref(0)
const loadHeight = () => {
uni.getSystemInfo({
success(res) {
let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#tabbarId").boundingClientRect((data : any) => {
height.value = screenHeight - data.height
}).exec()
}
})
}
const keyword = ref('') const keyword = ref('')
const searchBtn = { const searchBtn = {
@@ -167,11 +179,10 @@
}) })
} }
const params = ref({ const params = ref({
keyword: '', keyword: '',
page: 1, page: 1,
limit: 5, limit: 10,
category: '' category: ''
}) })
const mallList = ref([]) const mallList = ref([])
@@ -192,17 +203,28 @@
// 加载数据 // 加载数据
const loadMallData = () => { const loadMallData = () => {
console.log(111);
if (loadStatus.value == 'nomore') return if (loadStatus.value == 'nomore') return
mallAPI.getMallList(params.value).then((res) => { mallAPI.getMallList(params.value).then((res) => {
console.log(res.data);
mallList.value = mallList.value.concat(res.data.products) mallList.value = mallList.value.concat(res.data.products)
maxPage.value = res.data.pagination.pages maxPage.value = res.data.pagination.pages
params.value.page++ params.value.page++
if (maxPage.value < params.value.page) { if (maxPage.value < params.value.page) {
loadStatus.value = 'nomore' loadStatus.value = 'nomore'
} }
}).finally(() => {
isRefresher.value = false
}) })
} }
const isRefresher = ref(false)
const reflash = () => {
isRefresher.value = true
params.value.page = 1
params.value.category = ''
params.value.keyword = ''
loadStatus.value = 'loadmore'
loadMallData()
}
const handleCheck = (item : any) => { const handleCheck = (item : any) => {
uni.navigateTo({ uni.navigateTo({
@@ -211,6 +233,7 @@
} }
onMounted(() => { onMounted(() => {
loadHeight()
loadMallData() loadMallData()
}) })
</script> </script>
@@ -333,7 +356,7 @@
.box-div { .box-div {
padding: 30rpx 0rpx; padding: 60rpx 0rpx;
} }
} }
</style> </style>

View File

@@ -155,7 +155,6 @@
onMounted(() => { onMounted(() => {
user.value = uni.getStorageSync("user") user.value = uni.getStorageSync("user")
console.log(user.value);
}) })
const loginOut = () => { const loginOut = () => {

View File

@@ -10,18 +10,18 @@
<view v-if="isManage" class="u-m-l-10 del-text" @click="showDelModel"> <view v-if="isManage" class="u-m-l-10 del-text" @click="showDelModel">
删除 删除
</view> </view>
<view class="u-m-l-10 add-text"> <view class="u-m-l-10 add-text" @click="handleAdd">
新增地址 新增地址
</view> </view>
</view> </view>
</template> </template>
</u-navbar> </u-navbar>
<scroll-view scroll-y="true" :style="'height:'+scrollHeight+'px'" @scrolltolower="loadData"> <scroll-view scroll-y="true" :style="'height:'+scrollHeight+'px'">
<view class="data-list"> <view class="data-list">
<view class="data-item" v-for="item in dataList" @click="handleClick(item)"> <view class="data-item" v-for="item in dataList" @click="handleClick(item)">
<view class="item-text"> <view class="item-text">
<view class="address u-m-b-18"> <view class="address u-m-b-18">
{{item.province + item.city + item.district}} {{item.province_name + " " + item.city_name + " " + item.district_name}}
</view> </view>
<view class="specific-address u-m-b-18"> <view class="specific-address u-m-b-18">
{{item.detailed_address}} {{item.detailed_address}}
@@ -44,18 +44,83 @@
</template> </template>
</view> </view>
</view> </view>
<u-loadmore :status="status" />
</view> </view>
</scroll-view> </scroll-view>
<!-- 新增/修改 -->
<u-popup v-model="showForm" mode="bottom" length="60%" class="form-popup" @close="form={}">
<view class="form">
<view class="form-item u-m-b-30">
<view class="item-title">
<image class="must-icon" src="/static/my/must.png" mode=""></image>
<u-input v-model="form.regionLabel" type="select" placeholder="请选择省市区" @click="openProvince" />
</view>
</view>
<view class="form-item">
<view class="item-title">
<image class="must-icon" src="/static/my/must.png" mode=""></image>详细地址与门牌号
</view>
<view class="item-value">
<u-input v-model="form.detailed_address" placeholder="请输入详细地址与门牌号" type="text" />
</view>
</view>
<view class="form-item">
<view class="item-title">
<image class="must-icon" src="/static/my/must.png" mode=""></image>收货人名字
</view>
<view class="item-value">
<u-input v-model="form.receiver_name" placeholder="请输入收货人名字" type="text" />
</view>
</view>
<view class="form-item">
<view class="item-title">
<image class="must-icon" src="/static/my/must.png" mode=""></image>手机号
</view>
<view class="item-value">
<u-input v-model="form.receiver_phone" placeholder="请输入收货人名字" type="text" />
</view>
</view>
<view class="form-item">
<view class="item-title">
标签
</view>
<view class="item-tag u-m-t-10">
<span class="active"></span>
<span>公司</span>
<span>学校</span>
</view>
</view>
<view class="form-item">
<view class="item-title">
<span class="u-m-r-10">是否设置为默认</span><u-checkbox v-model="form.is_default"
:disabled="false"></u-checkbox>
</view>
</view>
</view>
<u-button class="submit" hover-class="none" @click="handleSubmit">确定</u-button>
</u-popup>
<!-- 省市区 -->
<u-select v-model="showRegitionPicker" :list="regionOptions" mode="mutil-column-auto" label-name="label"
value-name="code" child-name="children" @confirm="handleRegion"></u-select>
<!-- 确认是否删除 --> <!-- 确认是否删除 -->
<u-modal v-model="showDel" content="是否删除选中的地址" :show-cancel-button="true" @confirm="handleDel"></u-modal> <u-modal v-model="showDel" content="是否删除选中的地址" :show-cancel-button="true" @confirm="handleDel"></u-modal>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup>
import { computed, getCurrentInstance, onMounted, ref } from 'vue' import {
import { addressAPI } from '../../api/address' computed,
getCurrentInstance,
onMounted,
ref
} from 'vue'
import {
addressAPI
} from '../../api/address'
import {
commonAPI
} from '../../api/common'
const navBarTitle = { const navBarTitle = {
fontWeight: '510', fontWeight: '510',
@@ -66,7 +131,13 @@ import { addressAPI } from '../../api/address'
const isManage = ref(false) const isManage = ref(false)
const showDel = ref(false) const showDel = ref(false)
const showForm = ref(false)
const showRegitionPicker = ref(false)
const form = ref({})
const handleAdd = () => {
showForm.value = true
}
const handleManage = () => { const handleManage = () => {
if (isManage.value) { if (isManage.value) {
ids.value = [] ids.value = []
@@ -79,6 +150,22 @@ import { addressAPI } from '../../api/address'
const handleDel = () => { const handleDel = () => {
// TODO 删除 // TODO 删除
} }
// 打开省市区选择
const openProvince = () => {
showRegitionPicker.value = true
}
// 选择省市区
const handleRegion = (e) => {
form.value.regionLabel = e[0].label + "/" + e[1].label + "/" + e[2].label
form.value.province = e[0].value
form.value.city = e[1].value
form.value.district = e[2].value
form.value.district_id = e[2].value
}
// 确认提交
const handleSubmit = () => {
}
const scrollHeight = ref(0) const scrollHeight = ref(0)
const instance = getCurrentInstance(); const instance = getCurrentInstance();
@@ -86,39 +173,33 @@ import { addressAPI } from '../../api/address'
uni.getSystemInfo({ uni.getSystemInfo({
success(res) { success(res) {
let screenHeight = res.screenHeight let screenHeight = res.screenHeight
uni.createSelectorQuery().in(instance.proxy).select("#uNavbarId").boundingClientRect((data : any) => { uni.createSelectorQuery().in(instance.proxy).select("#uNavbarId").boundingClientRect((
data) => {
scrollHeight.value = screenHeight - data.height scrollHeight.value = screenHeight - data.height
}).exec() }).exec()
} }
}) })
} }
const defaultSize = 10
const params = ref({
page: 1,
size: defaultSize,
keyword: ''
})
const status = ref('loadmore')
const maxPage = ref()
const dataList = ref([]) const dataList = ref([])
const regionOptions = ref([])
const loadData = () => { const loadData = () => {
if (status.value == 'nomore') return addressAPI.getList().then((res) => {
addressAPI.getList(params.value).then(res => { dataList.value = res.data
console.log(res); })
}).finally(() => { commonAPI.getRegion().then(res => {
uni.stopPullDownRefresh() regionOptions.value = res.data
}) })
} }
const ids = ref([]) const ids = ref([])
const handleClick = (item : any) => { const handleClick = (item) => {
if (isManage.value) { // 开始管理 if (isManage.value) { // 开始管理
ids.value.push(item.id) ids.value.push(item.id)
} }
} }
const isIncludeId = (id : any) => { const isIncludeId = (id) => {
return ids.value.includes(id); return ids.value.includes(id);
} }
@@ -199,5 +280,62 @@ import { addressAPI } from '../../api/address'
} }
} }
} }
.form-popup {
.form {
padding: 30rpx 28rpx;
.form-item {
margin-bottom: 20rpx;
line-height: 100%;
.item-title {
display: flex;
align-items: center;
font-weight: 400;
font-size: 24rpx;
.must-icon {
width: 24rpx;
height: 24rpx;
}
}
.item-value {}
.item-tag {
font-weight: 400;
font-size: 26rpx;
line-height: 100%;
letter-spacing: -2%;
span {
padding: 0 20rpx;
background: #D9D9D9;
border-radius: 12rpx;
margin-left: 16rpx;
}
.active {
background: #BFCEFF;
color: #305DEF;
}
}
}
}
.submit {
position: absolute;
bottom: 10rpx;
width: 248rpx;
left: 0;
right: 0;
text-align: center;
background: #7B99FF;
border: none;
border-radius: 24rpx;
color: #fff;
}
}
} }
</style> </style>

BIN
static/my/must.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B