master
王文杰 7 months ago
parent 81e782df73
commit d500942108

@ -45,8 +45,8 @@ const loginSuccess = (profile: LoginResult) => {
}
//
const isAgreePrivacy = ref(true)
const isAgreePrivacyShakeY = ref(true)
const isAgreePrivacy = ref(false)
const isAgreePrivacyShakeY = ref(false)
const checkedAgreePrivacy = async () => {
if (!isAgreePrivacy.value) {
uni.showToast({

@ -22,27 +22,28 @@ const form = ref({
//
const query = defineProps<{
id?: string
info?: Object
}>()
const isEdit = ref(false)
//
const getMemberAddressByIdData = async () => {
if (query.id) {
if (query.info) {
const addressInfo = JSON.parse(query.info)
isEdit.value = !!addressInfo.id
//
const res = await getMemberAddressByIdAPI(query.id)
// const res = await getMemberAddressByIdAPI(query.id)
//
Object.assign(form.value, res.result)
Object.assign(form.value, addressInfo)
//
uni.setNavigationBarTitle({ title: isEdit.value ? '修改地址' : '新建地址' })
}
}
//
onLoad(() => {
getMemberAddressByIdData()
})
//
uni.setNavigationBarTitle({ title: query.id ? '修改地址' : '新建地址' })
// //
// const onRegionChange: UniHelper.RegionPickerOnChange = (ev) => {
// // ()
@ -108,10 +109,9 @@ const onSubmit = async () => {
//
await formRef.value?.validate?.()
//
if (query.id) {
if (isEdit.value) {
//
const params = {
id: query.id,
...form.value,
location: {
...location,
@ -129,7 +129,7 @@ const onSubmit = async () => {
await postMemberAddressAPI(params)
}
//
uni.showToast({ icon: 'success', title: query.id ? '修改成功' : '添加成功' })
uni.showToast({ icon: 'success', title: isEdit.value ? '修改成功' : '添加成功' })
//
setTimeout(() => {
uni.navigateBack()

@ -1,15 +1,23 @@
<script setup lang="ts">
import { deleteMemberAddressByIdAPI, getMemberAddressAPI } from '@/services/address'
import { deleteMemberAddressAPI, getMemberAddressAPI } from '@/services/address'
import { useAddressStore } from '@/stores/modules/address'
import type { AddressItem } from '@/types/address'
import { onShow } from '@dcloudio/uni-app'
import { useMemberStore } from '@/stores'
import { ref } from 'vue'
//
const addressList = ref<AddressItem[]>([])
const memberStore = useMemberStore()
const storage_staffId = uni.getStorageSync('storage_userInfo').id
const staffId = memberStore.profile?.id || storage_staffId
const getMemberAddressData = async () => {
const res = await getMemberAddressAPI()
addressList.value = res.result
const params = {
clientId: staffId,
}
const res = await getMemberAddressAPI(params)
addressList.value = res.data
}
// ()
@ -26,7 +34,10 @@ const onDeleteAddress = (id: string) => {
success: async (res) => {
if (res.confirm) {
// id
await deleteMemberAddressByIdAPI(id)
const params = {
addressId: id,
}
await deleteMemberAddressAPI(params)
//
getMemberAddressData()
}
@ -54,16 +65,15 @@ const onChangeAddress = (item: AddressItem) => {
<uni-swipe-action-item class="item" v-for="item in addressList" :key="item.id">
<view class="item-content" @tap="onChangeAddress(item)">
<view class="user">
{{ item.receiver }}
<text class="contact">{{ item.contact }}</text>
{{ item.receiveUserName }}
<text class="contact">{{ item.receiveMobilePhone }}</text>
<text v-if="item.isDefault" class="badge"></text>
</view>
<view class="locate">{{ item.fullLocation }} {{ item.address }}</view>
<!-- H5 端需添加 .prevent 阻止链接的默认行为 -->
<view class="locate">{{ item.receiveStreet }}</view>
<navigator
class="edit"
hover-class="none"
:url="`/pagesMember/address-form/address-form?id=${item.id}`"
:url="`/pagesMember/address-form/address-form?info=${JSON.stringify(item)}`"
@tap.stop="() => {}"
@tap.prevent="() => {}"
>
@ -191,4 +201,5 @@ page {
font-size: 30rpx;
background-color: #3775F6;
}
</style>
</style>import type { stringify } from 'querystring'

@ -1,8 +1,14 @@
<script setup lang="ts">
import { useMemberStore } from '@/stores'
import { getLogoutWxMinAPI } from '@/services/login'
import { computed } from 'vue'
const memberStore = useMemberStore()
const isLogin = computed(() => {
const token = memberStore.profile?.token
const storage_token = uni.getStorageSync('storage_userInfo')?.token
return !!token || !!storage_token
})
// 退
const onLogout = () => {
//
@ -25,7 +31,7 @@ const onLogout = () => {
<template>
<view class="viewport">
<!-- 列表1 -->
<view class="list" v-if="memberStore.profile">
<view class="list" v-if="isLogin">
<navigator url="/pagesMember/address/address" hover-class="none" class="item arrow">
我的收货地址
</navigator>
@ -36,7 +42,7 @@ const onLogout = () => {
<button hover-class="none" class="item arrow" open-type="contact">联系我们</button>
</view>
<!-- 操作按钮 -->
<view class="action" v-if="memberStore.profile">
<view class="action" v-if="isLogin">
<view @tap="onLogout" class="button">退出登录</view>
</view>
</view>

@ -2,7 +2,7 @@
* @Author:
* @Date: 2024-01-04 12:54:56
* @LastEditors:
* @LastEditTime: 2024-03-15 11:12:20
* @LastEditTime: 2024-03-15 14:16:56
* @FilePath: /app-nx-personal/src/services/address.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
@ -59,9 +59,10 @@ export const postMemberAddressUpdateAPI = (data: any) => {
*
* @param id id()
*/
export const deleteMemberAddressByIdAPI = (id: string) => {
export const deleteMemberAddressAPI = (data: any) => {
return http({
method: 'DELETE',
url: `/client-address/remove/${id}`,
method: 'GET',
url: `/client-address/remove`,
data,
})
}

@ -11,8 +11,8 @@
* 4. token
*/
import { useMemberStore } from '@/stores'
// const baseURL = 'http://192.168.0.166:8808/api'
const baseURL = 'http://222.71.165.188:8808/api'
const baseURL = 'http://192.168.0.166:8808/api'
// const baseURL = 'http://222.71.165.188:8808/api'
// 添加拦截器
const httpInterceptor = {
// 拦截前触发

Loading…
Cancel
Save