fix: 优化提交订单页面js警告,充值订单跳转bug以及其他bug。refactor: 重构地址选择
This commit is contained in:
@ -17,7 +17,7 @@ export function getAddressAddAndEdit(data) {
|
|||||||
|
|
||||||
// 用户地址列表
|
// 用户地址列表
|
||||||
export function getAddressList(data) {
|
export function getAddressList(data) {
|
||||||
return requestUtil.get(`/address/list`, data, {login: true})
|
return requestUtil.get(`/address/list`, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 城市列表
|
// 城市列表
|
||||||
|
@ -162,3 +162,5 @@ export const wechatPay = (data) => requestUtil.post(`/pay/payment`, data)
|
|||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
export const checkPay = (data) => requestUtil.post(`/order/pay/orderQuery`, data)
|
export const checkPay = (data) => requestUtil.post(`/order/pay/orderQuery`, data)
|
||||||
|
|
||||||
|
export const checkRecharge = (data) => requestUtil.get(`/recharge-order/isPay`, data)
|
||||||
|
@ -60,7 +60,7 @@ async function handleSubmit() {
|
|||||||
close()
|
close()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
push({url: '/pages/payStatus/index'}, {data: {type: 2}})
|
push({url: '/pages/payStatus/index'}, {data: {type: 1}})
|
||||||
toast({title: '支付失败了'})
|
toast({title: '支付失败了'})
|
||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
export const VUE_APP_API_URL = 'https://b2c-pro-api-dev.zkthink.com/app-api'
|
export const VUE_APP_API_URL = 'https://b2c-pro-api.zkthink.com/app-api'
|
||||||
// export const VUE_APP_API_URL = 'https://843308749k.wocp.fun/app-api'
|
// export const VUE_APP_API_URL = 'https://843308749k.wocp.fun/app-api'
|
||||||
|
|
||||||
export const VUE_APP_UPLOAD_URL = VUE_APP_API_URL + '/infra/file/upload'
|
export const VUE_APP_UPLOAD_URL = VUE_APP_API_URL + '/infra/file/upload'
|
||||||
export const VUE_APP_STATIC_URL = "https://b2c-pro-static-dev.zkthink.com/" // 静态资源路径
|
export const VUE_APP_STATIC_URL = "https://b2c-pro-static-dev.zkthink.com/" // 静态资源路径
|
||||||
export const VUE_SHARE_TITLE = '邀请您使用YShop~'
|
export const VUE_SHARE_TITLE = '邀请您使用YShop~'
|
||||||
// export const VUE_H5_DOMAIN_NAME = "http://localhost:10086/#"
|
// export const VUE_H5_DOMAIN_NAME = "http://localhost:10086/#"
|
||||||
export const VUE_H5_DOMAIN_NAME = "https://b2c-pro-ui-h5-dev.zkthink.com/#"
|
export const VUE_H5_DOMAIN_NAME = "https://b2c-pro-ui-h5.zkthink.com/#"
|
||||||
|
|
||||||
const orderListStatus = {}
|
const orderListStatus = {}
|
||||||
|
|
||||||
|
@ -8,22 +8,36 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 封装uni app界面相关接口,利于维护
|
* 封装uni app界面相关接口,利于维护
|
||||||
* @returns { * }
|
* @returns {
|
||||||
|
* {
|
||||||
|
* toast:Function,
|
||||||
|
* loading:Function,
|
||||||
|
* hideLoading:Function,
|
||||||
|
* setNavTitle:Function,
|
||||||
|
* setNavBgColor:Function,
|
||||||
|
* scrollTo:Function,
|
||||||
|
* pageResize:Function,
|
||||||
|
* unPageResize:Function,
|
||||||
|
* startPullDownRefresh:Function,
|
||||||
|
* stopPullDownRefresh:Function,
|
||||||
|
* createSelectorQuery:Function,
|
||||||
|
* createObserver:Function,
|
||||||
|
* createMediaObserver:Function,
|
||||||
|
* createAnimation:Function,
|
||||||
|
* getMenuButtonInfo:Function
|
||||||
|
* }
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
export const useInterface = () => {
|
export const useInterface = () => {
|
||||||
/**
|
/**
|
||||||
* 使用uni的toast
|
* 使用uni的toast
|
||||||
* @param options
|
* @param options
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
function toast(options) {
|
function toast(options) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none', mask: false, ...options, success: () => resolve(true), fail: (error) => reject(error)
|
||||||
mask: false,
|
|
||||||
...options,
|
|
||||||
success: () => resolve(true),
|
|
||||||
fail: (error) => reject(error)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -36,11 +50,7 @@ export const useInterface = () => {
|
|||||||
function loading(options = {}) {
|
function loading(options = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
icon: 'none',
|
icon: 'none', mask: true, ...options, success: () => resolve(true), fail: (error) => reject(error)
|
||||||
mask: true,
|
|
||||||
...options,
|
|
||||||
success: () => resolve(true),
|
|
||||||
fail: (error) => reject(error)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -57,9 +67,7 @@ export const useInterface = () => {
|
|||||||
function setNavTitle(title) {
|
function setNavTitle(title) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
title,
|
title, success: () => resolve(true), fail: (error) => reject(error)
|
||||||
success: () => resolve(true),
|
|
||||||
fail: (error) => reject(error)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -73,18 +81,14 @@ export const useInterface = () => {
|
|||||||
function setNavBgColor(options, timeout = 500) {
|
function setNavBgColor(options, timeout = 500) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const setNavigationBarColor = () => uni.setNavigationBarColor({
|
const setNavigationBarColor = () => uni.setNavigationBarColor({
|
||||||
...options,
|
...options, success: () => resolve(true), fail: (error) => reject(error)
|
||||||
success: () => resolve(true),
|
|
||||||
fail: (error) => reject(error)
|
|
||||||
})
|
})
|
||||||
if (timeout === 0) {
|
if (timeout === 0) {
|
||||||
setNavigationBarColor()
|
setNavigationBarColor()
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.setNavigationBarColor({
|
uni.setNavigationBarColor({
|
||||||
...options,
|
...options, success: () => resolve(true), fail: (error) => reject(error)
|
||||||
success: () => resolve(true),
|
|
||||||
fail: (error) => reject(error)
|
|
||||||
})
|
})
|
||||||
}, timeout)
|
}, timeout)
|
||||||
}
|
}
|
||||||
@ -100,9 +104,7 @@ export const useInterface = () => {
|
|||||||
function scrollTo(options) {
|
function scrollTo(options) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
...options,
|
...options, success: () => resolve(true), fail: (error) => reject(error)
|
||||||
success: () => resolve(true),
|
|
||||||
fail: (error) => reject(error)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -134,8 +136,7 @@ export const useInterface = () => {
|
|||||||
function startPullDownRefresh() {
|
function startPullDownRefresh() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.startPullDownRefresh({
|
uni.startPullDownRefresh({
|
||||||
success: () => resolve(true),
|
success: () => resolve(true), fail: (error) => reject(error)
|
||||||
fail: (error) => reject(error)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ export const useRouter = () => {
|
|||||||
* 注意:2.8.9+以后版本可以使用events参数传递一个方法对象和新打开的页面建立一个channel通讯,getOpenerEventChannel获取到这个channel
|
* 注意:2.8.9+以后版本可以使用events参数传递一个方法对象和新打开的页面建立一个channel通讯,getOpenerEventChannel获取到这个channel
|
||||||
* @docs: https://uniapp.dcloud.net.cn/api/router.html#navigateto
|
* @docs: https://uniapp.dcloud.net.cn/api/router.html#navigateto
|
||||||
* @param {object} options 原始参数
|
* @param {object} options 原始参数
|
||||||
* @param {object} config 配置参数
|
* @param {any} config 配置参数
|
||||||
* @param {'navigateTo'|'redirectTo'|'reLaunch'} config.type 跳转类型
|
* @param {'navigateTo'|'redirectTo'|'reLaunch'} config.type 跳转类型
|
||||||
* @param {object} config.data 跳转参数
|
* @param {object} config.data 跳转参数
|
||||||
* @param {number} config.timeout 延时时间
|
* @param {number} config.timeout 延时时间
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<!-- <meta-->
|
<meta
|
||||||
<!-- http-equiv="Content-Security-Policy"-->
|
http-equiv="Content-Security-Policy"
|
||||||
<!-- content="upgrade-insecure-requests">-->
|
content="upgrade-insecure-requests">
|
||||||
<script>
|
<script>
|
||||||
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
||||||
CSS.supports('top: constant(a)'))
|
CSS.supports('top: constant(a)'))
|
||||||
|
2
main.js
2
main.js
@ -10,7 +10,7 @@ import { createSSRApp } from 'vue'
|
|||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import util from '@/utils'
|
import util from '@/utils'
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
import VConsole from 'vconsole'
|
// import VConsole from 'vconsole'
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
@ -1,68 +1,31 @@
|
|||||||
<template>
|
<template>
|
||||||
<layout>
|
|
||||||
|
|
||||||
<Header :scroll-top="scrollTop">
|
<Header :scroll-top="scrollTop">
|
||||||
{{ title }}
|
{{ pageTitle }}
|
||||||
</Header>
|
</Header>
|
||||||
|
<view
|
||||||
<view class="addressList">
|
class="address-list"
|
||||||
<template v-if=" main.address.length>0">
|
v-if="list.length>0">
|
||||||
<uv-swipe-action>
|
<uv-swipe-action>
|
||||||
<uv-swipe-action-item
|
<uv-swipe-action-item
|
||||||
v-for="(item, index) in main.address"
|
v-for="(item, index) in list"
|
||||||
:key="index"
|
:key="item.id"
|
||||||
:options="options"
|
:options="options"
|
||||||
@click="showModal( item)"
|
@click="showModal( item)"
|
||||||
>
|
>
|
||||||
<view
|
<AddressItem
|
||||||
:class="{ address: true, noBorder: index == 0 }"
|
:address-item="item"
|
||||||
@tap="handleClick(item)"
|
:border="index!==list.length - 1"
|
||||||
>
|
@edit="goEditorAddress"
|
||||||
<view class="address-main">
|
@click="handleClick" />
|
||||||
<view class="address-header">
|
|
||||||
<view class="address-name">{{ item.realName }}</view>
|
|
||||||
<view class="address-phone">{{ item.phone }}</view>
|
|
||||||
</view>
|
|
||||||
<view class="address-content">
|
|
||||||
<view
|
|
||||||
class="address-default"
|
|
||||||
v-if="item.isDefault"
|
|
||||||
>
|
|
||||||
<uv-tags
|
|
||||||
text="默认"
|
|
||||||
plain
|
|
||||||
size="mini"
|
|
||||||
></uv-tags>
|
|
||||||
</view>
|
|
||||||
<view class="address-desc">{{ item.province }}-{{ item.city }}-{{ item.district }} {{
|
|
||||||
item.detail
|
|
||||||
}}
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
<view class="address-actions">
|
|
||||||
<view
|
|
||||||
class="address-actions-edit"
|
|
||||||
@tap.stop="goEditorAddress(item)"
|
|
||||||
>
|
|
||||||
<image
|
|
||||||
class="image"
|
|
||||||
:src="addressEditIcon"
|
|
||||||
alt=""
|
|
||||||
></image>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</uv-swipe-action-item>
|
</uv-swipe-action-item>
|
||||||
</uv-swipe-action>
|
</uv-swipe-action>
|
||||||
</template>
|
</view>
|
||||||
<Empty
|
<Empty
|
||||||
:iconSrc="emptyAddressIcon"
|
:iconSrc="emptyAddressIcon"
|
||||||
v-else
|
v-else
|
||||||
>
|
>
|
||||||
您还没有新增地址~
|
您还没有新增地址~
|
||||||
</Empty>
|
</Empty>
|
||||||
</view>
|
|
||||||
<view class="form-buttons">
|
<view class="form-buttons">
|
||||||
<view class="btn">
|
<view class="btn">
|
||||||
<uv-button
|
<uv-button
|
||||||
@ -77,102 +40,105 @@
|
|||||||
</view>
|
</view>
|
||||||
<ReturnTop :scroll-top="scrollTop" />
|
<ReturnTop :scroll-top="scrollTop" />
|
||||||
<Modal
|
<Modal
|
||||||
ref="modalRef"
|
ref="delModalRef"
|
||||||
content="确认要删除地址吗?"
|
content="确认要删除地址吗?"
|
||||||
@confirm="doDeleteRequest" />
|
@confirm="doDeleteRequest" />
|
||||||
</layout>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, unref } from 'vue'
|
import { ref, unref, computed } from 'vue'
|
||||||
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||||
import { useMainStore } from '@/store/modules/useMainStore'
|
|
||||||
import Empty from '@/components/Empty/index.vue'
|
import Empty from '@/components/Empty/index.vue'
|
||||||
import { addressEditIcon, emptyAddressIcon } from "@/utils/images";
|
import { emptyAddressIcon } from "@/utils/images";
|
||||||
import { getAddressDel, } from '@/api/address'
|
import { getAddressDel, getAddressList, } from '@/api/address'
|
||||||
import { useRouter } from "@/hooks/useRouter";
|
import { useRouter } from "@/hooks/useRouter";
|
||||||
import Header from "@/components/Header/index.vue"
|
import Header from "@/components/Header/index.vue"
|
||||||
import ReturnTop from "@/components/ReturnTop/index.vue";
|
import ReturnTop from "@/components/ReturnTop/index.vue";
|
||||||
import { useScroll } from "@/hooks/useScroll";
|
import { useScroll } from "@/hooks/useScroll";
|
||||||
import Modal from "@/components/Modal/index.vue";
|
import Modal from "@/components/Modal/index.vue";
|
||||||
|
import UvSwipeAction from "@/uni_modules/uv-swipe-action/components/uv-swipe-action/uv-swipe-action.vue";
|
||||||
|
import UvSwipeActionItem from "@/uni_modules/uv-swipe-action/components/uv-swipe-action-item/uv-swipe-action-item.vue";
|
||||||
|
import AddressItem from "@/pages/address/component/AddressItem.vue";
|
||||||
|
import UvButton from "@/uni_modules/uv-button/components/uv-button/uv-button.vue";
|
||||||
|
import { usePaging } from "@/hooks/usePaging";
|
||||||
|
import { emitter } from "@/utils/emitter";
|
||||||
|
|
||||||
const {push, goBack} = useRouter()
|
// ================================= hooks =============================================
|
||||||
|
const {push, goBack, getParams} = useRouter()
|
||||||
const {scrollTop} = useScroll()
|
const {scrollTop} = useScroll()
|
||||||
|
|
||||||
const title = ref('')
|
const actionType = ref(undefined) // 页面状态是选择还是管理 'select' | undefined
|
||||||
|
const pageTitle = computed(() => actionType.value === 'select' ? '选择地址' : '地址管理') // 页面title
|
||||||
const main = useMainStore()
|
// swipe配置
|
||||||
const moreLoding = ref(true)
|
|
||||||
const actionType = ref('')
|
|
||||||
const page = ref(1)
|
|
||||||
const selectCartId = ref(undefined)
|
|
||||||
const options = ref([{
|
const options = ref([{
|
||||||
text: '删除',
|
// text: '删 除',
|
||||||
|
icon: 'trash',
|
||||||
style: {
|
style: {
|
||||||
backgroundColor: '#EE6D46'
|
backgroundColor: '#EE6D46'
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
|
|
||||||
onReachBottom((e) => {
|
|
||||||
if (main.moreLoading) {
|
|
||||||
page.value = page.value + 1
|
|
||||||
main.getAddressList(page.value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const goCreateAddress = () => {
|
|
||||||
let addressData = {};
|
|
||||||
if (actionType.value === 'select') {
|
|
||||||
addressData.type = 'select';
|
|
||||||
}
|
|
||||||
push({url: '/pages/createAddress/createAddress'}, {data: addressData})
|
|
||||||
}
|
|
||||||
|
|
||||||
const goEditorAddress = (address) => {
|
|
||||||
let addressData = {
|
|
||||||
id: address.id
|
|
||||||
};
|
|
||||||
if (actionType.value === 'select') {
|
|
||||||
addressData.type = 'select';
|
|
||||||
}
|
|
||||||
push({url: '/pages/createAddress/createAddress'}, {data: addressData})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleClick = (item) => {
|
|
||||||
if (actionType.value === 'select') {
|
|
||||||
main.setSelectAddress(item.id)
|
|
||||||
goBack()
|
|
||||||
// push({url: '/pages/submitOrder/submitOrder'}, {
|
|
||||||
// data: {cartId: unref(selectCartId) || main.cartId},
|
|
||||||
// type: 'redirectTo'
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const {getParams} = useRouter()
|
|
||||||
onLoad((option) => {
|
onLoad((option) => {
|
||||||
main.restAddress()
|
const params = getParams?.(option)
|
||||||
const params = getParams(option)
|
actionType.value = params?.type
|
||||||
params.cartId ? main.cartId = params.cartId : void (0)
|
|
||||||
if (params.type) {
|
|
||||||
actionType.value = params.type
|
|
||||||
title.value = '选择地址'
|
|
||||||
selectCartId.value = params.cartId
|
|
||||||
} else {
|
|
||||||
title.value = '地址管理'
|
|
||||||
}
|
|
||||||
main.getAddressList(page.value)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const modalRef = ref()
|
onShow(() => {
|
||||||
const prepareData = ref({})
|
refreshPage?.()
|
||||||
|
})
|
||||||
|
// ============================== 用户地址列表相关 =================================
|
||||||
|
const {list, refreshPage} = usePaging({
|
||||||
|
request: getAddressList,
|
||||||
|
// load: true
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去创建地址
|
||||||
|
*/
|
||||||
|
function goCreateAddress() {
|
||||||
|
push?.({url: '/pages/createAddress/createAddress'}, {
|
||||||
|
data: {
|
||||||
|
type: actionType.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去修改地址
|
||||||
|
* @param address
|
||||||
|
*/
|
||||||
|
function goEditorAddress(address) {
|
||||||
|
push?.({url: '/pages/createAddress/createAddress'}, {
|
||||||
|
data: {
|
||||||
|
type: actionType.value,
|
||||||
|
address
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理选择状态下返回
|
||||||
|
* @param item
|
||||||
|
*/
|
||||||
|
function handleClick(item) {
|
||||||
|
if (actionType.value === 'select') {
|
||||||
|
emitter.emit('selectAddress', item)
|
||||||
|
goBack?.({delta: 1})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ============================ 删除相关 ============================
|
||||||
|
const delModalRef = ref()
|
||||||
|
const prepareData = ref(undefined)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开弹窗
|
* 打开弹窗
|
||||||
*/
|
*/
|
||||||
function showModal(data) {
|
function showModal(data) {
|
||||||
prepareData.value = data
|
prepareData.value = data
|
||||||
unref(modalRef).show()
|
unref(delModalRef).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,110 +146,20 @@ function showModal(data) {
|
|||||||
*/
|
*/
|
||||||
async function doDeleteRequest() {
|
async function doDeleteRequest() {
|
||||||
await getAddressDel(prepareData.value)
|
await getAddressDel(prepareData.value)
|
||||||
await main.restAddress()
|
await refreshPage?.()
|
||||||
await main.getAddressList(1)
|
|
||||||
if (main.selectAddress && prepareData.value.id === main.selectAddress.id) {
|
|
||||||
main.clearSelectAddress()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import "../../style/images";
|
@import "../../style/images";
|
||||||
|
|
||||||
.address {
|
.address-list {
|
||||||
padding: 25rpx 35rpx;
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
&-actions {
|
|
||||||
&-edit {
|
|
||||||
width: 33rpx;
|
|
||||||
height: 33rpx;
|
|
||||||
|
|
||||||
.image {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
&.noBorder {
|
|
||||||
&::after {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
left: 35rpx;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 1rpx;
|
|
||||||
background: #E6E6E6;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
background: #fff;
|
|
||||||
|
|
||||||
&-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-name {
|
|
||||||
line-height: 40rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #333333;
|
|
||||||
margin-right: 30rpx;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
&-phone {
|
|
||||||
line-height: 40rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #333333;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-content {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding-right: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-default {
|
|
||||||
width: 80rpx;
|
|
||||||
margin-right: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-desc {
|
|
||||||
flex: 1;
|
|
||||||
line-height: 33rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #999999;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-line-clamp: 3;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.addressList {
|
|
||||||
padding-bottom: 100rpx;
|
padding-bottom: 100rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-buttons {
|
.form-buttons {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: env(safe-area-inset-bottom);
|
bottom: calc(env(safe-area-inset-bottom) + 20rpx);
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -295,25 +171,4 @@ async function doDeleteRequest() {
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.address-default :deep(.uv-tags) {
|
|
||||||
justify-content: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.addressList :deep(.uv-swipe-action-item__right__button__wrapper) {
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
position: absolute;
|
|
||||||
content: '';
|
|
||||||
background: $addDelIcon no-repeat center center;
|
|
||||||
width: 50rpx;
|
|
||||||
height: 50rpx;
|
|
||||||
background-size: contain;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.addressList :deep(.uv-swipe-action-item__right__button__wrapper__text) {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
139
pages/address/component/AddressItem.vue
Normal file
139
pages/address/component/AddressItem.vue
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<!--
|
||||||
|
@name: addressItem
|
||||||
|
@author: kahu4
|
||||||
|
@date: 2024-03-04 15:58
|
||||||
|
@description:addressItem
|
||||||
|
@update: 2024-03-04 15:58
|
||||||
|
-->
|
||||||
|
<script setup>
|
||||||
|
|
||||||
|
import { addressEditIcon } from "@/utils/images";
|
||||||
|
import { toRefs } from "vue";
|
||||||
|
import UvTags from "@/uni_modules/uv-tags/components/uv-tags/uv-tags.vue";
|
||||||
|
|
||||||
|
const emits = defineEmits(['edit', 'click'])
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
addressItem: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
border: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const {addressItem, border} = toRefs(props)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view
|
||||||
|
class="address"
|
||||||
|
:class="{'no-border':!border}"
|
||||||
|
@tap="emits('click',addressItem)"
|
||||||
|
>
|
||||||
|
<view class="address-main">
|
||||||
|
<view class="address-header">
|
||||||
|
<view class="address-name">{{ addressItem.realName }}</view>
|
||||||
|
<view class="address-phone">{{ addressItem.phone }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="address-content">
|
||||||
|
<view
|
||||||
|
class="address-default"
|
||||||
|
v-if="addressItem.isDefault"
|
||||||
|
>
|
||||||
|
<uv-tags
|
||||||
|
text="默认"
|
||||||
|
plain
|
||||||
|
size="mini"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="address-desc">
|
||||||
|
{{ addressItem.province }}-{{ addressItem.city }}-{{ addressItem.district }} {{ addressItem.detail }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="address-actions">
|
||||||
|
<view
|
||||||
|
class="address-actions-edit"
|
||||||
|
@tap.stop="emits('edit',addressItem)"
|
||||||
|
>
|
||||||
|
<image
|
||||||
|
class="image"
|
||||||
|
:src="addressEditIcon"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style
|
||||||
|
scoped
|
||||||
|
lang="scss">
|
||||||
|
.address {
|
||||||
|
padding: 25rpx 35rpx;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
&-actions {
|
||||||
|
&-edit {
|
||||||
|
width: 33rpx;
|
||||||
|
height: 33rpx;
|
||||||
|
|
||||||
|
.image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
background: #fff;
|
||||||
|
|
||||||
|
&-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-name {
|
||||||
|
line-height: 40rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333333;
|
||||||
|
margin-right: 30rpx;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
&-phone {
|
||||||
|
line-height: 40rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-content {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding-right: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-default {
|
||||||
|
width: 80rpx;
|
||||||
|
margin-right: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-desc {
|
||||||
|
flex: 1;
|
||||||
|
line-height: 33rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #999999;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,13 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<layout>
|
<view>
|
||||||
<uv-navbar
|
<Header>{{ title }}</Header>
|
||||||
:fixed="false"
|
|
||||||
:title="title"
|
|
||||||
left-arrow
|
|
||||||
@leftClick="goBack"
|
|
||||||
/>
|
|
||||||
<view class="create-address">
|
<view class="create-address">
|
||||||
|
|
||||||
<view class="list noBorder">
|
<view class="list noBorder">
|
||||||
<view class="list-main">
|
<view class="list-main">
|
||||||
<view class="list-label w-158">
|
<view class="list-label w-158">
|
||||||
@ -15,15 +9,15 @@
|
|||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="list-content"
|
class="list-content"
|
||||||
@click="handleChooseAddress"
|
@click="openAddressSelect"
|
||||||
>
|
>
|
||||||
<template v-if="addressData.address.cityId">
|
<template v-if="form.address.cityId">
|
||||||
{{ addressData.address.province }} {{ addressData.address.city }} {{ addressData.address.district }}
|
{{ form.address.province }} {{ form.address.city }} {{ form.address.district }}
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span class="chooise">
|
<span class="choose">
|
||||||
点击选择
|
点击选择
|
||||||
<uv-icon name="arrow-right"></uv-icon>
|
<uv-icon name="arrow-right" />
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
@ -38,7 +32,7 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="请输入详细地址"
|
placeholder="请输入详细地址"
|
||||||
v-model="addressData.detail"
|
v-model="form.detail"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -52,7 +46,7 @@
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="请输入姓名"
|
placeholder="请输入姓名"
|
||||||
v-model="addressData.realName"
|
v-model="form.realName"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
@ -68,23 +62,21 @@
|
|||||||
type="tel"
|
type="tel"
|
||||||
placeholder="请输入电话"
|
placeholder="请输入电话"
|
||||||
maxlength="11"
|
maxlength="11"
|
||||||
v-model="addressData.phone"
|
v-model="form.phone"
|
||||||
@input="phoneInput"
|
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="form-checkbox">
|
<view class="form-checkbox">
|
||||||
<uv-checkbox-group v-model="isDefaultList">
|
<uv-checkbox-group v-model="defaultAddress">
|
||||||
<uv-checkbox
|
<uv-checkbox
|
||||||
shape="circle"
|
shape="circle"
|
||||||
label="设为默认地址"
|
label="设为默认地址"
|
||||||
name="isDefault"
|
name="isDefault"
|
||||||
labelColor="#999999"
|
labelColor="#999999"
|
||||||
activeColor="#EE6D46"
|
activeColor="#EE6D46"
|
||||||
@change="changeDefault"
|
/>
|
||||||
></uv-checkbox>
|
|
||||||
</uv-checkbox-group>
|
</uv-checkbox-group>
|
||||||
</view>
|
</view>
|
||||||
<view class="form-buttons">
|
<view class="form-buttons">
|
||||||
@ -92,38 +84,41 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
text="提交"
|
text="提交"
|
||||||
customStyle="margin-top: 10px"
|
customStyle="margin-top: 10px"
|
||||||
@click="onSave"
|
@click="submit"
|
||||||
></uv-button>
|
/>
|
||||||
|
</view>
|
||||||
|
<AddressSelect
|
||||||
|
ref="addressSelectRef"
|
||||||
|
@confirm="addressSelectConfirm" />
|
||||||
</view>
|
</view>
|
||||||
<uv-picker
|
|
||||||
ref="addressPickerRef"
|
|
||||||
:columns="columns"
|
|
||||||
keyName="name"
|
|
||||||
@change="handlePickerChange"
|
|
||||||
@confirm="handlePickerConfirm"
|
|
||||||
></uv-picker>
|
|
||||||
</layout>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, nextTick, onMounted, ref, unref, watch } from 'vue'
|
import { computed, onMounted, ref, unref, } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { useMainStore } from '@/store/modules/useMainStore'
|
import { getAddressAddAndEdit } from '@/api/address'
|
||||||
import { getAddressAddAndEdit, getAddressDel, } from '@/api/address'
|
|
||||||
import { useRouter } from "@/hooks/useRouter";
|
import { useRouter } from "@/hooks/useRouter";
|
||||||
import { storeToRefs } from "pinia";
|
import Header from "@/components/Header/index.vue";
|
||||||
import UvPicker from "@/uni_modules/uv-picker/components/uv-picker/uv-picker.vue";
|
import UvCheckboxGroup from "@/uni_modules/uv-checkbox/components/uv-checkbox-group/uv-checkbox-group.vue";
|
||||||
|
import UvCheckbox from "@/uni_modules/uv-checkbox/components/uv-checkbox/uv-checkbox.vue";
|
||||||
|
import UvButton from "@/uni_modules/uv-button/components/uv-button/uv-button.vue";
|
||||||
|
import UvIcon from "@/uni_modules/uv-icon/components/uv-icon/uv-icon.vue";
|
||||||
|
import AddressSelect from '@/components/AddressSelect/index.vue'
|
||||||
|
import { useInterface } from "@/hooks/useInterface";
|
||||||
|
import { checkPhone } from "@/utils/utils";
|
||||||
|
|
||||||
const main = useMainStore()
|
// ========================== hooks ================================================
|
||||||
|
const {toast} = useInterface();
|
||||||
const {getParams, push, goBack} = useRouter()
|
const {getParams, push, goBack} = useRouter()
|
||||||
|
|
||||||
const {areaList, address} = storeToRefs(main)
|
const title = computed(() => form.value.id ? '编辑地址' : '添加地址')
|
||||||
// const areaList = ref(main.areaList)
|
const defaultAddress = ref([]) // 是否为默认地址 ['isDefault']默认 []非默认
|
||||||
const title = ref('')
|
const actionType = ref(undefined) // 是否是选择地址
|
||||||
|
|
||||||
const editId = ref('')
|
// =========================== 表单相关 ==========================================
|
||||||
|
// 表单
|
||||||
const addressData = ref({
|
const form = ref({
|
||||||
|
id: undefined,
|
||||||
realName: undefined,
|
realName: undefined,
|
||||||
phone: undefined,
|
phone: undefined,
|
||||||
detail: undefined,
|
detail: undefined,
|
||||||
@ -136,209 +131,108 @@ const addressData = ref({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const isDefaultList = ref([])
|
/**
|
||||||
const changeDefault = (props) => {
|
* 校验表单
|
||||||
addressData.value.isDefault = props
|
* @param form
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
function checkForm(form) {
|
||||||
|
if (!form.address?.cityId) {
|
||||||
|
toast?.({title: "请选择收货地址"})
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
const actionType = ref('')
|
if (!form.detail) {
|
||||||
const onSave = async () => {
|
toast?.({title: "请输入详细地址"})
|
||||||
if (!addressData.value.address?.cityId) {
|
return false
|
||||||
uni.showToast({
|
|
||||||
title: "请选择收货地址",
|
|
||||||
icon: "none",
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!addressData.value.detail) {
|
if (!form.realName) {
|
||||||
uni.showToast({
|
toast?.({title: "请输入姓名"})
|
||||||
title: "请输入详细地址!",
|
return false
|
||||||
icon: "none",
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!addressData.value.realName) {
|
if (!checkPhone(form.phone)) {
|
||||||
uni.showToast({
|
toast?.({title: "请输入正确手机号"})
|
||||||
title: "请输入姓名!",
|
return false
|
||||||
icon: "none",
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!addressData.value.phone || !(/^1[34578]\d{9}$/.test(addressData.value.phone))) {
|
return true
|
||||||
uni.showToast({
|
|
||||||
title: "请输入正确手机号!",
|
|
||||||
icon: "none",
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
uni.showLoading({
|
|
||||||
title: '保存中',
|
const submitLoading = ref(false) // 是否正在提交
|
||||||
mask: true,
|
|
||||||
})
|
/**
|
||||||
|
* 提交表单
|
||||||
|
* @return {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function submit() {
|
||||||
|
if (!checkForm(form.value) || submitLoading.value) return
|
||||||
try {
|
try {
|
||||||
let res = await getAddressAddAndEdit({
|
submitLoading.value = true
|
||||||
id: editId.value,
|
await getAddressAddAndEdit({
|
||||||
realName: addressData.value.realName,
|
...form.value,
|
||||||
postCode: addressData.value.postCode,
|
postCode: undefined,
|
||||||
isDefault: addressData.value.isDefault ? 1 : 0,
|
isDefault: defaultAddress.value.length > 0 ? 1 : 0,
|
||||||
detail: addressData.value.detail,
|
|
||||||
phone: addressData.value.phone,
|
|
||||||
address: {
|
|
||||||
cityId: addressData.value.address.cityId,
|
|
||||||
city: addressData.value.address.city,
|
|
||||||
district: addressData.value.address.district,
|
|
||||||
province: addressData.value.address.province,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
toast?.({title: '保存成功'})
|
||||||
uni.showToast({
|
|
||||||
title: "保存成功",
|
|
||||||
icon: "none",
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
uni.hideLoading()
|
|
||||||
main.restAddress()
|
|
||||||
if (actionType.value == 'select') {
|
|
||||||
push({url: '/pages/address/address'}, {data: {type: 'select'}, type: 'redirectTo'})
|
|
||||||
} else {
|
|
||||||
main.getAddressList(1)
|
|
||||||
goBack()
|
goBack()
|
||||||
|
} finally {
|
||||||
|
submitLoading.value = false
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.log(error, 'err')
|
|
||||||
// closeToast()
|
|
||||||
if (error.msg) {
|
|
||||||
// showFailToast(error.msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const onDelete = async () => {
|
|
||||||
getAddressDel()
|
|
||||||
main.getAddressList(1)
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = (values) => {
|
|
||||||
addressData.value.address = {
|
|
||||||
province: values.province.name || '',
|
|
||||||
city: values.city.name || '',
|
|
||||||
district: values.district.name || '',
|
|
||||||
cityId: values.city.id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const addressPickerRef = ref()
|
|
||||||
const provinces = ref([])
|
|
||||||
const citys = ref([])
|
|
||||||
const areas = ref([])
|
|
||||||
const pickerValue = ref([0, 0, 0])
|
|
||||||
const defaultValue = ref([0, 0, 0])
|
|
||||||
|
|
||||||
const columns = computed(() => {
|
|
||||||
return [
|
|
||||||
provinces.value, citys.value, areas.value
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
function handleSetDefaultColumns() {
|
|
||||||
console.log(addressPickerRef.value)
|
|
||||||
pickerValue.value[0] = provinces.value.findIndex((item, index) => index === defaultValue.value[0])
|
|
||||||
citys.value = provinces.value[pickerValue.value[0]].children || []
|
|
||||||
pickerValue.value[1] = citys.value.findIndex((item, index) => index === defaultValue.value[1])
|
|
||||||
areas.value = citys.value[pickerValue.value[1]].children || []
|
|
||||||
pickerValue.value[2] = areas.value.findIndex((item, index) => index === defaultValue.value[2])
|
|
||||||
// 重置下位置
|
|
||||||
// addressPickerRef.value.setColumnValues(0,provinces.value)
|
|
||||||
// addressPickerRef.value.setColumnValues(1,citys.value)
|
|
||||||
// addressPickerRef.value.setColumnValues(2,areas.value)
|
|
||||||
nextTick(() => {
|
|
||||||
addressPickerRef.value.setIndexs([pickerValue.value[0], pickerValue.value[1], pickerValue.value[2]], true);
|
|
||||||
console.log('设置完毕')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePickerChange(e) {
|
|
||||||
const {columnIndex, index, indexs} = e
|
|
||||||
// 改变了省
|
|
||||||
if (columnIndex === 0) {
|
|
||||||
citys.value = provinces.value[index]?.children || []
|
|
||||||
areas.value = citys.value[0]?.children || []
|
|
||||||
addressPickerRef.value.setIndexs([index, 0, 0], true)
|
|
||||||
} else if (columnIndex === 1) {
|
|
||||||
areas.value = citys.value[index]?.children || []
|
|
||||||
addressPickerRef.value.setIndexs(indexs, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePickerConfirm(e) {
|
|
||||||
const {indexs, value} = e
|
|
||||||
defaultValue.value = indexs
|
|
||||||
addressData.value.address = {
|
|
||||||
province: value[0].name || '',
|
|
||||||
city: value[1].name || '',
|
|
||||||
district: value[2].name || '',
|
|
||||||
cityId: value[1].id,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleFindDefault(data) {
|
|
||||||
const provinceIndex = areaList.value.findIndex(item => item.name === data.province);
|
|
||||||
const cityIndex = areaList.value[provinceIndex].children.findIndex(item => item.name === data.city);
|
|
||||||
const areasIndex = areaList.value[provinceIndex].children[cityIndex].children.findIndex(item => item.name === data.district);
|
|
||||||
defaultValue.value = [provinceIndex, cityIndex, areasIndex]
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleChooseAddress() {
|
|
||||||
provinces.value = areaList.value
|
|
||||||
handleSetDefaultColumns()
|
|
||||||
unref(addressPickerRef).open()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手机号验证
|
* 设置编辑表单
|
||||||
|
* @param addressItem
|
||||||
*/
|
*/
|
||||||
function phoneInput(event) {
|
function setFormDefault(addressItem) {
|
||||||
const pattern = /[^\d]/g;
|
form.value.id = addressItem.id
|
||||||
nextTick(() => {
|
form.value = {
|
||||||
addressData.value.phone = event.detail.value.replace(pattern, '');
|
...form.value,
|
||||||
})
|
...addressItem,
|
||||||
|
address: {
|
||||||
|
cityId: addressItem.cityId,
|
||||||
|
city: addressItem.city,
|
||||||
|
district: addressItem.district,
|
||||||
|
province: addressItem.province,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 默认地址
|
||||||
|
if (addressItem.isDefault) {
|
||||||
|
defaultAddress.value = ['isDefault']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================================= 地址选择相关 ==================================
|
||||||
|
const addressSelectRef = ref()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开选择地址
|
||||||
|
*/
|
||||||
|
function openAddressSelect() {
|
||||||
|
const {address} = unref(form)
|
||||||
|
let defaultAddressStr = ''
|
||||||
|
if (address.province && address.city && address.district) {
|
||||||
|
defaultAddressStr = `${ address.province }-${ address.city }-${ address.district }`
|
||||||
|
}
|
||||||
|
unref(addressSelectRef).open(defaultAddressStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址选择confirm
|
||||||
|
* @param areaList 地区 [省, 市, 区]
|
||||||
|
*/
|
||||||
|
function addressSelectConfirm(areaList) {
|
||||||
|
if (areaList.length < 3) return
|
||||||
|
const {address} = unref(form)
|
||||||
|
address.province = areaList[0]?.name
|
||||||
|
address.city = areaList[1]?.name
|
||||||
|
address.cityId = areaList[2]?.id
|
||||||
|
address.district = areaList[2]?.name
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
const params = getParams(options)
|
const params = getParams?.(options)
|
||||||
let id = params.id
|
actionType.value = params?.type
|
||||||
actionType.value = params.type
|
if (params?.address) {
|
||||||
// main.restAddress()
|
setFormDefault(params?.address)
|
||||||
await main.getAddressCityList()
|
|
||||||
if (id) {
|
|
||||||
editId.value = id
|
|
||||||
title.value = '编辑地址'
|
|
||||||
let data = address.value.filter(item => item.id == id)[0]
|
|
||||||
if (!data) return
|
|
||||||
addressData.value = {
|
|
||||||
realName: data.realName,
|
|
||||||
phone: data.phone,
|
|
||||||
detail: data.detail,
|
|
||||||
isDefault: data.isDefault,
|
|
||||||
address: {
|
|
||||||
cityId: data.cityId,
|
|
||||||
city: data.city,
|
|
||||||
district: data.district,
|
|
||||||
province: data.province,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(addressData.value)
|
|
||||||
// 设置默认选择
|
|
||||||
handleFindDefault(data)
|
|
||||||
isDefaultList.value = data.isDefault ? ['isDefault'] : []
|
|
||||||
} else {
|
|
||||||
title.value = '新增地址'
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -358,8 +252,8 @@ onMounted(() => {
|
|||||||
flex: 0 0 158rpx;
|
flex: 0 0 158rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chooise {
|
.choose {
|
||||||
@include useFlex(space-between, center);
|
@include useFlex(space-between, center);
|
||||||
color: #999;
|
color: #808080;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import { useRouter } from "@/hooks/useRouter";
|
import { useRouter } from "@/hooks/useRouter";
|
||||||
import { computed, nextTick, ref, unref } from "vue";
|
import { computed, nextTick, ref, unref } from "vue";
|
||||||
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
|
import { onLoad, onReachBottom } from "@dcloudio/uni-app";
|
||||||
import {checkPay, orderInfo} from "@/api/order";
|
import { checkPay, checkRecharge, orderInfo } from "@/api/order";
|
||||||
import { CacheKey } from "@/utils/config";
|
import { CacheKey } from "@/utils/config";
|
||||||
import Header from '@/components/Header/index.vue'
|
import Header from '@/components/Header/index.vue'
|
||||||
import Recommend from '@/components/Recommend/index.vue'
|
import Recommend from '@/components/Recommend/index.vue'
|
||||||
@ -47,7 +47,7 @@ const retryTime = ref(3) // 重试次数
|
|||||||
* 查询服务端支付状态
|
* 查询服务端支付状态
|
||||||
*/
|
*/
|
||||||
async function queryOrderStatus() {
|
async function queryOrderStatus() {
|
||||||
loading({title: '查询中...'})
|
loading?.({title: '查询中...'})
|
||||||
// 异步去查,有可能接口比微信快
|
// 异步去查,有可能接口比微信快
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
@ -57,6 +57,8 @@ async function queryOrderStatus() {
|
|||||||
return orderType.value === 2 ? toMyBalance() : toOrderList(0)
|
return orderType.value === 2 ? toMyBalance() : toOrderList(0)
|
||||||
}
|
}
|
||||||
const parse = JSON.parse(payInfoStr);
|
const parse = JSON.parse(payInfoStr);
|
||||||
|
// 商品
|
||||||
|
if (orderType.value === 1) {
|
||||||
if (parse.options && parse.options.isGroup) {
|
if (parse.options && parse.options.isGroup) {
|
||||||
campaignType.value = 1
|
campaignType.value = 1
|
||||||
}
|
}
|
||||||
@ -74,19 +76,43 @@ async function queryOrderStatus() {
|
|||||||
uni.removeStorageSync(CacheKey.PAY_INFO)
|
uni.removeStorageSync(CacheKey.PAY_INFO)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
type.value = 1
|
||||||
|
uni.removeStorageSync(CacheKey.PAY_INFO)
|
||||||
}
|
}
|
||||||
// todo 查询订单详情
|
// 平团
|
||||||
if (parse.options && parse.options.isGroup) {
|
if (parse.options && parse.options.isGroup) {
|
||||||
const order = await orderInfo({key: parse.payData.orderId})
|
const order = await orderInfo({key: parse.payData.orderId})
|
||||||
if (order && order._status._type === '8') {
|
if (order && order._status._type === '8') {
|
||||||
campaignType.value = 4
|
campaignType.value = 4
|
||||||
}
|
}
|
||||||
console.log(campaignType.value)
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (orderType.value === 2) {
|
||||||
|
const res = await checkRecharge({
|
||||||
|
id: parse.payData.orderId
|
||||||
|
})
|
||||||
|
console.log(res)
|
||||||
|
if (Number(res) === 0) {
|
||||||
|
// 支付失败重新查询
|
||||||
|
if (retryTime.value > 0) {
|
||||||
|
retryTime.value--
|
||||||
|
await queryOrderStatus()
|
||||||
|
} else {
|
||||||
|
type.value = 2
|
||||||
|
uni.removeStorageSync(CacheKey.PAY_INFO)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
type.value = 1
|
type.value = 1
|
||||||
uni.removeStorageSync(CacheKey.PAY_INFO)
|
uni.removeStorageSync(CacheKey.PAY_INFO)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
retryTime.value = 0
|
||||||
|
type.value = 2
|
||||||
|
uni.removeStorageSync(CacheKey.PAY_INFO)
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading()
|
hideLoading?.()
|
||||||
}
|
}
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
@ -129,8 +155,12 @@ onReachBottom(() => {
|
|||||||
const orderType = ref(1) // 1商品 2充值
|
const orderType = ref(1) // 1商品 2充值
|
||||||
|
|
||||||
onLoad(async (options) => {
|
onLoad(async (options) => {
|
||||||
|
if (options.details) {
|
||||||
|
options = getParams?.(options)
|
||||||
|
}
|
||||||
|
console.log(options)
|
||||||
// type
|
// type
|
||||||
orderType.value = options.type
|
orderType.value = Number(options.type) || 1
|
||||||
// const params = getParams(options)
|
// const params = getParams(options)
|
||||||
// campaignType.value = params.campaignType
|
// campaignType.value = params.campaignType
|
||||||
// H5 和 APP 需要弹窗去确认
|
// H5 和 APP 需要弹窗去确认
|
||||||
@ -177,6 +207,7 @@ onLoad(async (options) => {
|
|||||||
text="查询中..." />
|
text="查询中..." />
|
||||||
</view>
|
</view>
|
||||||
<view class="button-group flex flex-ai__center flex-jc__center">
|
<view class="button-group flex flex-ai__center flex-jc__center">
|
||||||
|
<template v-if="orderType === 1">
|
||||||
<view
|
<view
|
||||||
class="animation-button button white-button"
|
class="animation-button button white-button"
|
||||||
v-if="Number(type)===1"
|
v-if="Number(type)===1"
|
||||||
@ -184,7 +215,6 @@ onLoad(async (options) => {
|
|||||||
>
|
>
|
||||||
继续逛逛
|
继续逛逛
|
||||||
</view>
|
</view>
|
||||||
<template v-if="orderType !== 1">
|
|
||||||
<view
|
<view
|
||||||
class="animation-button button"
|
class="animation-button button"
|
||||||
v-if="Number(type)===1"
|
v-if="Number(type)===1"
|
||||||
|
@ -25,7 +25,7 @@ onPageScroll(() => {
|
|||||||
const {getParams, push, goBack} = useRouter()
|
const {getParams, push, goBack} = useRouter()
|
||||||
const {toast, loading, hideLoading} = useInterface();
|
const {toast, loading, hideLoading} = useInterface();
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
const {selectAddress, defaultAddress, address, integralName} = storeToRefs(mainStore);
|
const {integralName} = storeToRefs(mainStore);
|
||||||
const campaignType = ref(0)
|
const campaignType = ref(0)
|
||||||
const zeroPrice = ref(false) // 本单支付金额是否为0
|
const zeroPrice = ref(false) // 本单支付金额是否为0
|
||||||
/**
|
/**
|
||||||
@ -34,20 +34,19 @@ const zeroPrice = ref(false) // 本单支付金额是否为0
|
|||||||
*/
|
*/
|
||||||
async function calculateOrder() {
|
async function calculateOrder() {
|
||||||
orderDetail.value = await orderConfirm({
|
orderDetail.value = await orderConfirm({
|
||||||
cartId: unref(routerParams).cartId,
|
cartId: unref(routerParams)?.cartId,
|
||||||
orderType: unref(routerParams).orderType,
|
orderType: unref(routerParams)?.orderType,
|
||||||
addressId: unref(selectAddress)?.id || undefined,
|
addressId: unref(selectAddress)?.id || undefined,
|
||||||
shippingType: addressTabSelect.value, // 默认快递 1快递 2门店
|
shippingType: addressTabSelect.value, // 默认快递 1快递 2门店
|
||||||
storeId: shopSelect.value?.id,
|
storeId: shopSelect.value?.id,
|
||||||
useIntegral: useIntegral.value.length > 0,
|
useIntegral: useIntegral.value.length > 0,
|
||||||
couponId: currentCouponId.value
|
couponId: currentCouponId.value
|
||||||
})
|
})
|
||||||
console.log(orderDetail.value)
|
|
||||||
// 余额为0 自动走余额支付
|
// 余额为0 自动走余额支付
|
||||||
if (orderDetail.value.priceGroup.totalPrice <= 0) {
|
if (orderDetail.value.priceGroup.totalPrice <= 0) {
|
||||||
payType.value = PayType["1"]
|
payType.value = PayType["1"]
|
||||||
zeroPrice.value = true
|
zeroPrice.value = true
|
||||||
toast({title: '支付金额为0.00,自动选择余额支付', icon: 'none', duration: 3000})
|
toast?.({title: '支付金额为0.00,自动选择余额支付', icon: 'none', duration: 3000})
|
||||||
} else {
|
} else {
|
||||||
zeroPrice.value = false
|
zeroPrice.value = false
|
||||||
}
|
}
|
||||||
@ -59,13 +58,13 @@ const currentCouponId = ref(undefined)
|
|||||||
const selectCouponFn = async (coupon) => {
|
const selectCouponFn = async (coupon) => {
|
||||||
currentCouponId.value = coupon.couponId
|
currentCouponId.value = coupon.couponId
|
||||||
await calculateOrder()
|
await calculateOrder()
|
||||||
selectCouponRef.value.close()
|
selectCouponRef.value?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const showCouponSelect = (index) => {
|
const showCouponSelect = (index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
selectCouponRef.value.open()
|
selectCouponRef.value?.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,29 +85,25 @@ function changeAddressTab(tab) {
|
|||||||
* 去选择地址
|
* 去选择地址
|
||||||
*/
|
*/
|
||||||
function gotoSelectAddress() {
|
function gotoSelectAddress() {
|
||||||
push({url: '/pages/address/address'}, {data: {type: 'select', cartId: unref(routerParams).cartId}})
|
push?.({url: '/pages/address/address'}, {
|
||||||
|
data: {
|
||||||
|
type: 'select', cartId: unref(routerParams)?.cartId
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取默认选择的地址
|
* 获取默认选择的地址
|
||||||
*/
|
*/
|
||||||
async function doGetSelectAddress() {
|
async function doGetSelectAddress() {
|
||||||
// store内部没有地址,就先去获取地址
|
if (!selectAddress.value && orderDetail.value?.addressInfo) {
|
||||||
if (unref(address).length <= 0) {
|
selectAddress.value = orderDetail.value?.addressInfo
|
||||||
await mainStore.getAddressList(1)
|
await doGetInitConfirmOrder()
|
||||||
}
|
|
||||||
// 获取完地址还是空
|
|
||||||
if (unref(address).length <= 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 没有默认地址设置默认地址
|
|
||||||
if (!selectAddress.value || !selectAddress.value?.id) {
|
|
||||||
defaultAddress.value && defaultAddress.value.id ? mainStore.setSelectAddress(defaultAddress.value.id) : mainStore.setSelectAddress(unref(address)[0].id)
|
|
||||||
doGetInitConfirmOrder()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const shopSelect = ref(null) // 当前选择的店铺
|
const shopSelect = ref(null) // 当前选择的店铺
|
||||||
|
const selectAddress = ref(null) // 当前选择的地址
|
||||||
|
|
||||||
// 注册事件监听
|
// 注册事件监听
|
||||||
emitter.on('selectShop', (res) => {
|
emitter.on('selectShop', (res) => {
|
||||||
@ -116,7 +111,9 @@ emitter.on('selectShop', (res) => {
|
|||||||
shopSelect.value = res
|
shopSelect.value = res
|
||||||
doGetInitConfirmOrder()
|
doGetInitConfirmOrder()
|
||||||
})
|
})
|
||||||
emitter.on('selectAddress', async () => {
|
emitter.on('selectAddress', async (item) => {
|
||||||
|
// item
|
||||||
|
selectAddress.value = item
|
||||||
// 处理门店选择逻辑
|
// 处理门店选择逻辑
|
||||||
await doGetSelectAddress()
|
await doGetSelectAddress()
|
||||||
await doGetInitConfirmOrder()
|
await doGetInitConfirmOrder()
|
||||||
@ -126,7 +123,7 @@ emitter.on('selectAddress', async () => {
|
|||||||
* 选择店铺
|
* 选择店铺
|
||||||
*/
|
*/
|
||||||
function selectShop() {
|
function selectShop() {
|
||||||
push({url: '/pages/submitOrder/shopSelect'}, {data: {shopSelect: shopSelect.value}})
|
push?.({url: '/pages/submitOrder/shopSelect'}, {data: {shopSelect: shopSelect.value}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================== 订单信息相关 ======================================================
|
// =============================== 订单信息相关 ======================================================
|
||||||
@ -155,8 +152,8 @@ const orderDetail = ref({
|
|||||||
*/
|
*/
|
||||||
async function doGetInitConfirmOrder() {
|
async function doGetInitConfirmOrder() {
|
||||||
await calculateOrder()
|
await calculateOrder()
|
||||||
cartIds.value = unref(routerParams).cartId
|
cartIds.value = unref(routerParams)?.cartId
|
||||||
currentCouponId.value = orderDetail.value.priceGroup.couponId
|
currentCouponId.value = orderDetail.value.priceGroup?.couponId
|
||||||
flag.value = true
|
flag.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,11 +174,11 @@ const subLoading = ref(false) // 加载中
|
|||||||
*/
|
*/
|
||||||
async function handleConfirm() {
|
async function handleConfirm() {
|
||||||
if (addressTabSelect.value === 1 && (!unref(selectAddress) || !unref(selectAddress).id)) {
|
if (addressTabSelect.value === 1 && (!unref(selectAddress) || !unref(selectAddress).id)) {
|
||||||
toast({title: '请先选择地址'})
|
toast?.({title: '请先选择地址'})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (addressTabSelect.value === 2 && !shopSelect.value) {
|
if (addressTabSelect.value === 2 && !shopSelect.value) {
|
||||||
toast({title: '请先选择门店'})
|
toast?.({title: '请先选择门店'})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
subLoading.value = true
|
subLoading.value = true
|
||||||
@ -190,18 +187,18 @@ async function handleConfirm() {
|
|||||||
// 去拉取支付
|
// 去拉取支付
|
||||||
await doPayment({type: payType.value, payInfo, isGroup: routerParams.value.campaignType === 1})
|
await doPayment({type: payType.value, payInfo, isGroup: routerParams.value.campaignType === 1})
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
push({url: '/pages/payStatus/index'}, {data: {campaignType: campaignType.value}, type: 'redirectTo'})
|
push?.({url: '/pages/payStatus/index'}, {data: {campaignType: campaignType.value}, type: 'redirectTo'})
|
||||||
// #endif
|
// #endif
|
||||||
// 处理微信内h5
|
// 处理微信内h5
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
if (h5InWeChat()) {
|
if (h5InWeChat()) {
|
||||||
push({url: '/pages/payStatus/index'}, {data: {campaignType: campaignType.value}, type: 'redirectTo'})
|
push?.({url: '/pages/payStatus/index'}, {data: {campaignType: campaignType.value}, type: 'redirectTo'})
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
toast({title: '支付失败'})
|
toast?.({title: '支付失败'})
|
||||||
push({url: '/pages/payStatus/index'}, {data: {campaignType: campaignType.value}, type: 'redirectTo'})
|
push?.({url: '/pages/payStatus/index'}, {data: {campaignType: campaignType.value}, type: 'redirectTo'})
|
||||||
} finally {
|
} finally {
|
||||||
subLoading.value = false
|
subLoading.value = false
|
||||||
mainStore.cartId = null
|
mainStore.cartId = null
|
||||||
@ -213,11 +210,11 @@ async function handleConfirm() {
|
|||||||
*/
|
*/
|
||||||
async function doCreateServiceOrder() {
|
async function doCreateServiceOrder() {
|
||||||
try {
|
try {
|
||||||
loading({title: '订单创建中...'})
|
loading?.({title: '订单创建中...'})
|
||||||
const data = {
|
const data = {
|
||||||
key: unref(orderDetail).orderKey,
|
key: unref(orderDetail)?.orderKey,
|
||||||
addressId: unref(selectAddress) && unref(selectAddress).id,
|
addressId: unref(selectAddress)?.id,
|
||||||
storeId: unref(shopSelect) && unref(shopSelect).id,
|
storeId: unref(shopSelect)?.id,
|
||||||
bargainId: 0,
|
bargainId: 0,
|
||||||
combinationId: 0,
|
combinationId: 0,
|
||||||
couponId: currentCouponId.value,
|
couponId: currentCouponId.value,
|
||||||
@ -235,7 +232,7 @@ async function doCreateServiceOrder() {
|
|||||||
const res = await orderCreate(data);
|
const res = await orderCreate(data);
|
||||||
return res.result
|
return res.result
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading()
|
hideLoading?.()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,15 +242,15 @@ async function doCreateServiceOrder() {
|
|||||||
*/
|
*/
|
||||||
function setActivityData(data) {
|
function setActivityData(data) {
|
||||||
// 处理活动数据 路由参数 orderType 1普通下单 2活动下单
|
// 处理活动数据 路由参数 orderType 1普通下单 2活动下单
|
||||||
if (routerParams.value.orderType !== 2) return
|
if (routerParams.value?.orderType !== 2) return
|
||||||
// 活动商品
|
// 活动商品
|
||||||
data.campaignType = routerParams.value.campaignType // 1拼团 2秒杀 3砍价
|
data.campaignType = routerParams.value?.campaignType // 1拼团 2秒杀 3砍价
|
||||||
campaignType.value = routerParams.value.campaignType
|
campaignType.value = routerParams.value?.campaignType
|
||||||
data.campaignDetailId = routerParams.value.campaignDetailId // 活动营销ID
|
data.campaignDetailId = routerParams.value?.campaignDetailId // 活动营销ID
|
||||||
// 拼团 路由参数 campaignType 1拼团活动
|
// 拼团 路由参数 campaignType 1拼团活动
|
||||||
if (routerParams.value.campaignType !== 1) return;
|
if (routerParams.value?.campaignType !== 1) return;
|
||||||
data.teamworkType = routerParams.value.teamworkType // 1发起拼团 2加入
|
data.teamworkType = routerParams.value?.teamworkType // 1发起拼团 2加入
|
||||||
data.teamworkType === 2 ? data.teamworkId = routerParams.value.teamworkId : void (0) // 加入拼团的id
|
data.teamworkType === 2 ? data.teamworkId = routerParams.value?.teamworkId : void (0) // 加入拼团的id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -267,7 +264,7 @@ const cartIds = ref('')
|
|||||||
*/
|
*/
|
||||||
function checkRouterParam(params) {
|
function checkRouterParam(params) {
|
||||||
if (!params.cartId) {
|
if (!params.cartId) {
|
||||||
toast({title: '路由参数错误'})
|
toast?.({title: '路由参数错误'})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
routerParams.value = params
|
routerParams.value = params
|
||||||
@ -276,7 +273,7 @@ function checkRouterParam(params) {
|
|||||||
|
|
||||||
onLoad(async options => {
|
onLoad(async options => {
|
||||||
try {
|
try {
|
||||||
const params = getParams(options)
|
const params = getParams?.(options)
|
||||||
await checkRouterParam(params)
|
await checkRouterParam(params)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
@ -318,8 +315,8 @@ onShow(async () => {
|
|||||||
<!-- address info -->
|
<!-- address info -->
|
||||||
<template v-if="addressTabSelect === 1">
|
<template v-if="addressTabSelect === 1">
|
||||||
<view
|
<view
|
||||||
|
v-if="selectAddress"
|
||||||
class="address-row flex flex-ai__center flex-jc__sb"
|
class="address-row flex flex-ai__center flex-jc__sb"
|
||||||
v-if="address.length>0"
|
|
||||||
@click="gotoSelectAddress"
|
@click="gotoSelectAddress"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
@ -351,7 +348,7 @@ onShow(async () => {
|
|||||||
v-else
|
v-else
|
||||||
@click="gotoSelectAddress"
|
@click="gotoSelectAddress"
|
||||||
>
|
>
|
||||||
点击添加地址
|
点击选择地址
|
||||||
<image
|
<image
|
||||||
class="arrow-icon"
|
class="arrow-icon"
|
||||||
:src="nextIcon"
|
:src="nextIcon"
|
||||||
|
@ -12,18 +12,13 @@ const {push} = useRouter()
|
|||||||
export const useMainStore = defineStore('main', {
|
export const useMainStore = defineStore('main', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
user: null,
|
user: null,
|
||||||
address: [],
|
|
||||||
areaList: [],
|
areaList: [],
|
||||||
selectAddress: null,
|
selectAddress: null,
|
||||||
moreLoading: true,
|
moreLoading: true,
|
||||||
cartId: null,
|
cartId: null,
|
||||||
integralName: '积分'
|
integralName: '积分'
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {},
|
||||||
defaultAddress(state) {
|
|
||||||
return state.address?.filter(item => item.isDefault)?.[0]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
actions: {
|
actions: {
|
||||||
setAccessToken(user) {
|
setAccessToken(user) {
|
||||||
cookie.set('accessToken', user)
|
cookie.set('accessToken', user)
|
||||||
@ -37,25 +32,7 @@ export const useMainStore = defineStore('main', {
|
|||||||
this.user = res
|
this.user = res
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
restAddress() {
|
|
||||||
this.address = []
|
|
||||||
this.moreLoading = true
|
|
||||||
},
|
|
||||||
clearSelectAddress() {
|
|
||||||
this.selectAddress = null
|
|
||||||
},
|
|
||||||
async getAddressList(page) {
|
|
||||||
let res = await getAddressList({page: page})
|
|
||||||
if (res.length) {
|
|
||||||
this.address = this.address.concat(res)
|
|
||||||
} else {
|
|
||||||
this.moreLoading = false
|
|
||||||
}
|
|
||||||
// console.log('--> % getUserInfo % res:\n', res)
|
|
||||||
},
|
|
||||||
async getAddressCityList() {
|
|
||||||
this.areaList = await getAddressCityList()
|
|
||||||
},
|
|
||||||
init() {
|
init() {
|
||||||
let accessToken = cookie.get('accessToken')
|
let accessToken = cookie.get('accessToken')
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
|
@ -865,15 +865,6 @@ image {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.address::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
left: 35rpx;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 1rpx;
|
|
||||||
background: #e6e6e6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.address-icon {
|
.address-icon {
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
|
@ -281,9 +281,9 @@ function _aliPay(payInfo) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 余额支付
|
* 余额支付
|
||||||
* @param payInfo
|
|
||||||
* @return {Promise<never>}
|
* @return {Promise<never>}
|
||||||
* @private
|
* @private
|
||||||
|
* @param options
|
||||||
*/
|
*/
|
||||||
async function _balancePay(options) {
|
async function _balancePay(options) {
|
||||||
let from
|
let from
|
||||||
|
@ -31,14 +31,6 @@ export function formatRemainTime(time) {
|
|||||||
return `还剩${ remainTimeStr }自动确认`
|
return `还剩${ remainTimeStr }自动确认`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 正则检测大陆手机号
|
|
||||||
* @param phone
|
|
||||||
*/
|
|
||||||
export function checkPhone(phone) {
|
|
||||||
return /^1[3456789]\d{9}$/.test(phone);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个滚动动画
|
* 创建一个滚动动画
|
||||||
@ -261,3 +253,7 @@ export const filterParams = (obj) => {
|
|||||||
}
|
}
|
||||||
return newObj;
|
return newObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const checkPhone = (phone) => {
|
||||||
|
return /^1[3456789]\d{9}$/.test(phone)
|
||||||
|
}
|
||||||
|
@ -117,12 +117,12 @@ async function confirm() {
|
|||||||
payInfo: {orderId}
|
payInfo: {orderId}
|
||||||
})
|
})
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
push({url: '/views/account/balance/index'})
|
push?.({url: '/pages/payStatus/index?type=2'})
|
||||||
// #endif
|
// #endif
|
||||||
// 处理微信内h5
|
// 处理微信内h5
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
if (h5InWeChat()) {
|
if (h5InWeChat()) {
|
||||||
push({url: '/views/account/balance/index'})
|
push?.({url: '/pages/payStatus/index?type=2'})
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Reference in New Issue
Block a user