# Conflicts:
#	pages.json
This commit is contained in:
18631081161 2025-06-22 13:29:49 +08:00
commit 9cbf0c071f
32 changed files with 2693 additions and 385 deletions

View File

@ -49,5 +49,28 @@ const onRefresh = async (paging) => {
};
</script>
<style lang="scss" scoped></style>
```
# 新文件3 下拉刷新
```vue
<template>
<PageContainer ref="pageContainer" title="我的地址管理" show-back :show-not-data="showNotData" :refresh="onRefresh">
</PageContainer>
</template>
<script setup>
let pageContainer = ref(null);
let showNotData = ref(false);
// 刷新方法
const onRefresh = async (paging) => {
await yds.sleep(500);
paging.complete();
};
</script>
<style lang="scss" scoped></style>
```

63
common/server/address.js Normal file
View File

@ -0,0 +1,63 @@
import HttpRequest from "../system/request";
/**
* 添加收货地址
* @param {Object} data 地址信息
* @returns {Promise}
*/
export const addAddress = async (data) => {
return await HttpRequest.post('/addAddress', data);
};
/**
* 更新收货地址
* @param {Object} data 地址信息
* @returns {Promise}
*/
export const updateAddress = async (data) => {
return await HttpRequest.post('/updateAddress', data);
};
/**
* 获取默认收货地址
* @returns {Promise}
*/
export const getDefaultAddress = async () => {
return await HttpRequest.get('/getDefaultAddress');
};
/**
* 获取收货地址列表
* @returns {Promise}
*/
export const getAddressList = async () => {
return await HttpRequest.get('/getAddressList');
};
/**
* 删除收货地址
* @param {Object} data 包含地址ID的对象
* @returns {Promise}
*/
export const deleteAddress = async (data) => {
return await HttpRequest.post('/deleteAddress', data);
};
/**
* 设置默认收货地址
* @param {Object} data 包含地址ID的对象
* @returns {Promise}
*/
export const setDefaultAddress = async (data) => {
return await HttpRequest.post('/setDefaultAddress', data);
};
/**
* 获取地址详情
* @param {Object} data 包含地址ID的对象
* @returns {Promise}
*/
export const getAddressDetail = async (id) => {
return await HttpRequest.get('/getAddressDetail', { id });
};

View File

@ -0,0 +1,90 @@
## 1.9.62025-01-08
- 修复 示例中过期图片地址
## 1.9.52024-10-15
- 修复 微信小程序中的getSystemInfo警告
## 1.9.22024-09-21
- 修复 uni-popup在android上的重复点击弹出位置不正确的bug
## 1.9.12024-04-02
- 修复 uni-popup-dialog vue3下使用value无法进行绑定的bug(双向绑定兼容旧写法)
## 1.9.02024-03-28
- 修复 uni-popup-dialog 双向绑定时初始化逻辑修正
## 1.8.92024-03-20
- 修复 uni-popup-dialog 数据输入时修正为双向绑定
## 1.8.82024-02-20
- 修复 uni-popup 在微信小程序下出现文字向上闪动的bug
## 1.8.72024-02-02
- 新增 uni-popup-dialog 新增属性focusinput模式下是否自动自动聚焦
## 1.8.62024-01-30
- 新增 uni-popup-dialog 新增属性maxLength:限制输入框字数
## 1.8.52024-01-26
- 新增 uni-popup-dialog 新增属性showClose:控制关闭按钮的显示
## 1.8.42023-11-15
- 新增 uni-popup 支持uni-app-x 注意暂时仅支持 `maskClick` `@open` `@close`
## 1.8.32023-04-17
- 修复 uni-popup 重复打开时的 bug
## 1.8.22023-02-02
- uni-popup-dialog 组件新增 inputType 属性
## 1.8.12022-12-01
- 修复 nvue 下 v-show 报错
## 1.8.02022-11-29
- 优化 主题样式
## 1.7.92022-04-02
- 修复 弹出层内部无法滚动的bug
## 1.7.82022-03-28
- 修复 小程序中高度错误的bug
## 1.7.72022-03-17
- 修复 快速调用open出现问题的Bug
## 1.7.62022-02-14
- 修复 safeArea 属性不能设置为false的bug
## 1.7.52022-01-19
- 修复 isMaskClick 失效的bug
## 1.7.42022-01-19
- 新增 cancelText \ confirmText 属性 ,可自定义文本
- 新增 maskBackgroundColor 属性 ,可以修改蒙版颜色
- 优化 maskClick属性 更新为 isMaskClick ,解决微信小程序警告的问题
## 1.7.32022-01-13
- 修复 设置 safeArea 属性不生效的bug
## 1.7.22021-11-26
- 优化 组件示例
## 1.7.12021-11-26
- 修复 vuedoc 文字错误
## 1.7.02021-11-19
- 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-popup](https://uniapp.dcloud.io/component/uniui/uni-popup)
## 1.6.22021-08-24
- 新增 支持国际化
## 1.6.12021-07-30
- 优化 vue3下事件警告的问题
## 1.6.02021-07-13
- 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.5.02021-06-23
- 新增 mask-click 遮罩层点击事件
## 1.4.52021-06-22
- 修复 nvue 平台中间弹出后点击内容再点击遮罩无法关闭的Bug
## 1.4.42021-06-18
- 修复 H5平台中间弹出后点击内容再点击遮罩无法关闭的Bug
## 1.4.32021-06-08
- 修复 错误的 watch 字段
- 修复 safeArea 属性不生效的问题
- 修复 点击内容再点击遮罩无法关闭的Bug
## 1.4.22021-05-12
- 新增 组件示例地址
## 1.4.12021-04-29
- 修复 组件内放置 input 、textarea 组件,无法聚焦的问题
## 1.4.0 2021-04-29
- 新增 type 属性的 left\right 值,支持左右弹出
- 新增 open(String:type) 方法参数 ,可以省略 type 属性 ,直接传入类型打开指定弹窗
- 新增 backgroundColor 属性,可定义主窗口背景色,默认不显示背景色
- 新增 safeArea 属性,是否适配底部安全区
- 修复 App\h5\微信小程序底部安全区占位不对的Bug
- 修复 App 端弹出等待的Bug
- 优化 提升低配设备性能,优化动画卡顿问题
- 优化 更简单的组件自定义方式
## 1.2.92021-02-05
- 优化 组件引用关系通过uni_modules引用组件
## 1.2.82021-02-05
- 调整为uni_modules目录规范
## 1.2.72021-02-05
- 调整为uni_modules目录规范
- 新增 支持 PC 端
- 新增 uni-popup-message 、uni-popup-dialog扩展组件支持 PC 端

View File

@ -0,0 +1,45 @@
// #ifdef H5
export default {
name: 'Keypress',
props: {
disable: {
type: Boolean,
default: false
}
},
mounted () {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
space: [' ', 'Spacebar'],
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
delete: ['Backspace', 'Delete', 'Del']
}
const listener = ($event) => {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, {})
}, 0)
}
}
document.addEventListener('keyup', listener)
this.$once('hook:beforeDestroy', () => {
document.removeEventListener('keyup', listener)
})
},
render: () => {}
}
// #endif

View File

@ -0,0 +1,316 @@
<template>
<view class="uni-popup-dialog">
<view class="uni-dialog-title">
<text class="uni-dialog-title-text" :class="['uni-popup__'+dialogType]">{{titleText}}</text>
</view>
<view v-if="mode === 'base'" class="uni-dialog-content">
<slot>
<text class="uni-dialog-content-text">{{content}}</text>
</slot>
</view>
<view v-else class="uni-dialog-content">
<slot>
<input class="uni-dialog-input" :maxlength="maxlength" v-model="val" :type="inputType"
:placeholder="placeholderText" :focus="focus">
</slot>
</view>
<view class="uni-dialog-button-group">
<view class="uni-dialog-button" v-if="showClose" @click="closeDialog">
<text class="uni-dialog-button-text">{{closeText}}</text>
</view>
<view class="uni-dialog-button" :class="showClose?'uni-border-left':''" @click="onOk">
<text class="uni-dialog-button-text uni-button-color">{{okText}}</text>
</view>
</view>
</view>
</template>
<script>
import popup from '../uni-popup/popup.js'
import {
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from '../uni-popup/i18n/index.js'
const {
t
} = initVueI18n(messages)
/**
* PopUp 弹出层-对话框样式
* @description 弹出层-对话框样式
* @tutorial https://ext.dcloud.net.cn/plugin?id=329
* @property {String} value input 模式下的默认值
* @property {String} placeholder input 模式下输入提示
* @property {Boolean} focus input模式下是否自动聚焦默认为true
* @property {String} type = [success|warning|info|error] 主题样式
* @value success 成功
* @value warning 提示
* @value info 消息
* @value error 错误
* @property {String} mode = [base|input] 模式
* @value base 基础对话框
* @value input 可输入对话框
* @showClose {Boolean} 是否显示关闭按钮
* @property {String} content 对话框内容
* @property {Boolean} beforeClose 是否拦截取消事件
* @property {Number} maxlength 输入
* @event {Function} confirm 点击确认按钮触发
* @event {Function} close 点击取消按钮触发
*/
export default {
name: "uniPopupDialog",
mixins: [popup],
emits: ['confirm', 'close', 'update:modelValue', 'input'],
props: {
inputType: {
type: String,
default: 'text'
},
showClose: {
type: Boolean,
default: true
},
// #ifdef VUE2
value: {
type: [String, Number],
default: ''
},
// #endif
// #ifdef VUE3
modelValue: {
type: [Number, String],
default: ''
},
// #endif
placeholder: {
type: [String, Number],
default: ''
},
type: {
type: String,
default: 'error'
},
mode: {
type: String,
default: 'base'
},
title: {
type: String,
default: ''
},
content: {
type: String,
default: ''
},
beforeClose: {
type: Boolean,
default: false
},
cancelText: {
type: String,
default: ''
},
confirmText: {
type: String,
default: ''
},
maxlength: {
type: Number,
default: -1,
},
focus: {
type: Boolean,
default: true,
}
},
data() {
return {
dialogType: 'error',
val: ""
}
},
computed: {
okText() {
return this.confirmText || t("uni-popup.ok")
},
closeText() {
return this.cancelText || t("uni-popup.cancel")
},
placeholderText() {
return this.placeholder || t("uni-popup.placeholder")
},
titleText() {
return this.title || t("uni-popup.title")
}
},
watch: {
type(val) {
this.dialogType = val
},
mode(val) {
if (val === 'input') {
this.dialogType = 'info'
}
},
value(val) {
if (this.maxlength != -1 && this.mode === 'input') {
this.val = val.slice(0, this.maxlength);
} else {
this.val = val
}
},
val(val) {
// #ifdef VUE2
// TODO vue2
this.$emit('input', val);
// #endif
// #ifdef VUE3
// TODO  vue3
this.$emit('update:modelValue', val);
// #endif
}
},
created() {
//
this.popup.disableMask()
// this.popup.closeMask()
if (this.mode === 'input') {
this.dialogType = 'info'
this.val = this.value;
// #ifdef VUE3
this.val = this.modelValue;
// #endif
} else {
this.dialogType = this.type
}
},
methods: {
/**
* 点击确认按钮
*/
onOk() {
if (this.mode === 'input') {
this.$emit('confirm', this.val)
} else {
this.$emit('confirm')
}
if (this.beforeClose) return
this.popup.close()
},
/**
* 点击取消按钮
*/
closeDialog() {
this.$emit('close')
if (this.beforeClose) return
this.popup.close()
},
close() {
this.popup.close()
}
}
}
</script>
<style lang="scss">
.uni-popup-dialog {
width: 300px;
border-radius: 11px;
background-color: #fff;
}
.uni-dialog-title {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
padding-top: 25px;
}
.uni-dialog-title-text {
font-size: 16px;
font-weight: 500;
}
.uni-dialog-content {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
padding: 20px;
}
.uni-dialog-content-text {
font-size: 14px;
color: #6C6C6C;
}
.uni-dialog-button-group {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
border-top-color: #f5f5f5;
border-top-style: solid;
border-top-width: 1px;
}
.uni-dialog-button {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex: 1;
flex-direction: row;
justify-content: center;
align-items: center;
height: 45px;
}
.uni-border-left {
border-left-color: #f0f0f0;
border-left-style: solid;
border-left-width: 1px;
}
.uni-dialog-button-text {
font-size: 16px;
color: #333;
}
.uni-button-color {
color: #007aff;
}
.uni-dialog-input {
flex: 1;
font-size: 14px;
border: 1px #eee solid;
height: 40px;
padding: 0 10px;
border-radius: 5px;
color: #555;
}
.uni-popup__success {
color: #4cd964;
}
.uni-popup__warn {
color: #f0ad4e;
}
.uni-popup__error {
color: #dd524d;
}
.uni-popup__info {
color: #909399;
}
</style>

View File

@ -0,0 +1,143 @@
<template>
<view class="uni-popup-message">
<view class="uni-popup-message__box fixforpc-width" :class="'uni-popup__'+type">
<slot>
<text class="uni-popup-message-text" :class="'uni-popup__'+type+'-text'">{{message}}</text>
</slot>
</view>
</view>
</template>
<script>
import popup from '../uni-popup/popup.js'
/**
* PopUp 弹出层-消息提示
* @description 弹出层-消息提示
* @tutorial https://ext.dcloud.net.cn/plugin?id=329
* @property {String} type = [success|warning|info|error] 主题样式
* @value success 成功
* @value warning 提示
* @value info 消息
* @value error 错误
* @property {String} message 消息提示文字
* @property {String} duration 显示时间设置为 0 则不会自动关闭
*/
export default {
name: 'uniPopupMessage',
mixins:[popup],
props: {
/**
* 主题 success/warning/info/error 默认 success
*/
type: {
type: String,
default: 'success'
},
/**
* 消息文字
*/
message: {
type: String,
default: ''
},
/**
* 显示时间设置为 0 则不会自动关闭
*/
duration: {
type: Number,
default: 3000
},
maskShow:{
type:Boolean,
default:false
}
},
data() {
return {}
},
created() {
this.popup.maskShow = this.maskShow
this.popup.messageChild = this
},
methods: {
timerClose(){
if(this.duration === 0) return
clearTimeout(this.timer)
this.timer = setTimeout(()=>{
this.popup.close()
},this.duration)
}
}
}
</script>
<style lang="scss" >
.uni-popup-message {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
}
.uni-popup-message__box {
background-color: #e1f3d8;
padding: 10px 15px;
border-color: #eee;
border-style: solid;
border-width: 1px;
flex: 1;
}
@media screen and (min-width: 500px) {
.fixforpc-width {
margin-top: 20px;
border-radius: 4px;
flex: none;
min-width: 380px;
/* #ifndef APP-NVUE */
max-width: 50%;
/* #endif */
/* #ifdef APP-NVUE */
max-width: 500px;
/* #endif */
}
}
.uni-popup-message-text {
font-size: 14px;
padding: 0;
}
.uni-popup__success {
background-color: #e1f3d8;
}
.uni-popup__success-text {
color: #67C23A;
}
.uni-popup__warn {
background-color: #faecd8;
}
.uni-popup__warn-text {
color: #E6A23C;
}
.uni-popup__error {
background-color: #fde2e2;
}
.uni-popup__error-text {
color: #F56C6C;
}
.uni-popup__info {
background-color: #F2F6FC;
}
.uni-popup__info-text {
color: #909399;
}
</style>

View File

@ -0,0 +1,188 @@
<template>
<view class="uni-popup-share">
<view class="uni-share-title"><text class="uni-share-title-text">{{shareTitleText}}</text></view>
<view class="uni-share-content">
<view class="uni-share-content-box">
<view class="uni-share-content-item" v-for="(item,index) in bottomData" :key="index" @click.stop="select(item,index)">
<image class="uni-share-image" :src="item.icon" mode="aspectFill"></image>
<text class="uni-share-text">{{item.text}}</text>
</view>
</view>
</view>
<view class="uni-share-button-box">
<button class="uni-share-button" @click="close">{{cancelText}}</button>
</view>
</view>
</template>
<script>
import popup from '../uni-popup/popup.js'
import {
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from '../uni-popup/i18n/index.js'
const { t } = initVueI18n(messages)
export default {
name: 'UniPopupShare',
mixins:[popup],
emits:['select'],
props: {
title: {
type: String,
default: ''
},
beforeClose: {
type: Boolean,
default: false
}
},
data() {
return {
// TODO
bottomData: [{
text: '微信',
icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
name: 'wx'
},
{
text: '支付宝',
icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
name: 'ali'
},
{
text: 'QQ',
icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
name: 'qq'
},
{
text: '新浪',
icon: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
name: 'sina'
},
// {
// text: '',
// icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/1ec6e920-50bf-11eb-8a36-ebb87efcf8c0.png',
// name: 'copy'
// },
// {
// text: '',
// icon: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/2e0fdfe0-50bf-11eb-b997-9918a5dda011.png',
// name: 'more'
// }
]
}
},
created() {},
computed: {
cancelText() {
return t("uni-popup.cancel")
},
shareTitleText() {
return this.title || t("uni-popup.shareTitle")
}
},
methods: {
/**
* 选择内容
*/
select(item, index) {
this.$emit('select', {
item,
index
})
this.close()
},
/**
* 关闭窗口
*/
close() {
if(this.beforeClose) return
this.popup.close()
}
}
}
</script>
<style lang="scss" >
.uni-popup-share {
background-color: #fff;
border-top-left-radius: 11px;
border-top-right-radius: 11px;
}
.uni-share-title {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
height: 40px;
}
.uni-share-title-text {
font-size: 14px;
color: #666;
}
.uni-share-content {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
padding-top: 10px;
}
.uni-share-content-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
flex-wrap: wrap;
width: 360px;
}
.uni-share-content-item {
width: 90px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
padding: 10px 0;
align-items: center;
}
.uni-share-content-item:active {
background-color: #f5f5f5;
}
.uni-share-image {
width: 30px;
height: 30px;
}
.uni-share-text {
margin-top: 10px;
font-size: 14px;
color: #3B4144;
}
.uni-share-button-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
padding: 10px 15px;
}
.uni-share-button {
flex: 1;
border-radius: 50px;
color: #666;
font-size: 16px;
}
.uni-share-button::after {
border-radius: 50px;
}
</style>

View File

@ -0,0 +1,7 @@
{
"uni-popup.cancel": "cancel",
"uni-popup.ok": "ok",
"uni-popup.placeholder": "pleace enter",
"uni-popup.title": "Hint",
"uni-popup.shareTitle": "Share to"
}

View File

@ -0,0 +1,8 @@
import en from './en.json'
import zhHans from './zh-Hans.json'
import zhHant from './zh-Hant.json'
export default {
en,
'zh-Hans': zhHans,
'zh-Hant': zhHant
}

View File

@ -0,0 +1,7 @@
{
"uni-popup.cancel": "取消",
"uni-popup.ok": "确定",
"uni-popup.placeholder": "请输入",
"uni-popup.title": "提示",
"uni-popup.shareTitle": "分享到"
}

View File

@ -0,0 +1,7 @@
{
"uni-popup.cancel": "取消",
"uni-popup.ok": "確定",
"uni-popup.placeholder": "請輸入",
"uni-popup.title": "提示",
"uni-popup.shareTitle": "分享到"
}

View File

@ -0,0 +1,45 @@
// #ifdef H5
export default {
name: 'Keypress',
props: {
disable: {
type: Boolean,
default: false
}
},
mounted () {
const keyNames = {
esc: ['Esc', 'Escape'],
tab: 'Tab',
enter: 'Enter',
space: [' ', 'Spacebar'],
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
delete: ['Backspace', 'Delete', 'Del']
}
const listener = ($event) => {
if (this.disable) {
return
}
const keyName = Object.keys(keyNames).find(key => {
const keyName = $event.key
const value = keyNames[key]
return value === keyName || (Array.isArray(value) && value.includes(keyName))
})
if (keyName) {
// 避免和其他按键事件冲突
setTimeout(() => {
this.$emit(keyName, {})
}, 0)
}
}
document.addEventListener('keyup', listener)
// this.$once('hook:beforeDestroy', () => {
// document.removeEventListener('keyup', listener)
// })
},
render: () => {}
}
// #endif

View File

@ -0,0 +1,26 @@
export default {
data() {
return {
}
},
created(){
this.popup = this.getParent()
},
methods:{
/**
* 获取父元素实例
*/
getParent(name = 'uniPopup') {
let parent = this.$parent;
let parentName = parent.$options.name;
while (parentName !== name) {
parent = parent.$parent;
if (!parent) return false
parentName = parent.$options.name;
}
return parent;
},
}
}

View File

@ -0,0 +1,90 @@
<template>
<view class="popup-root" v-if="isOpen" v-show="isShow" @click="clickMask">
<view @click.stop>
<slot></slot>
</view>
</view>
</template>
<script>
type CloseCallBack = ()=> void;
let closeCallBack:CloseCallBack = () :void => {};
export default {
emits:["close","clickMask"],
data() {
return {
isShow:false,
isOpen:false
}
},
props: {
maskClick: {
type: Boolean,
default: true
},
},
watch: {
// 设置show = true 时,如果没有 open 需要设置为 open
isShow:{
handler(isShow) {
// console.log("isShow",isShow)
if(isShow && this.isOpen == false){
this.isOpen = true
}
},
immediate:true
},
// 设置isOpen = true 时,如果没有 isShow 需要设置为 isShow
isOpen:{
handler(isOpen) {
// console.log("isOpen",isOpen)
if(isOpen && this.isShow == false){
this.isShow = true
}
},
immediate:true
}
},
methods:{
open(){
// ...funs : CloseCallBack[]
// if(funs.length > 0){
// closeCallBack = funs[0]
// }
this.isOpen = true;
},
clickMask(){
if(this.maskClick == true){
this.$emit('clickMask')
this.close()
}
},
close(): void{
this.isOpen = false;
this.$emit('close')
closeCallBack()
},
hiden(){
this.isShow = false
},
show(){
this.isShow = true
}
}
}
</script>
<style>
.popup-root {
position: fixed;
top: 0;
left: 0;
width: 750rpx;
height: 100%;
flex: 1;
background-color: rgba(0, 0, 0, 0.3);
justify-content: center;
align-items: center;
z-index: 99;
}
</style>

View File

@ -0,0 +1,518 @@
<template>
<view v-if="showPopup" class="uni-popup" :class="[popupstyle, isDesktop ? 'fixforpc-z-index' : '']">
<view @touchstart="touchstart">
<uni-transition key="1" v-if="maskShow" name="mask" mode-class="fade" :styles="maskClass"
:duration="duration" :show="showTrans" @click="onTap" />
<uni-transition key="2" :mode-class="ani" name="content" :styles="transClass" :duration="duration"
:show="showTrans" @click="onTap">
<view class="uni-popup__wrapper" :style="getStyles" :class="[popupstyle]" @click="clear">
<slot />
</view>
</uni-transition>
</view>
<!-- #ifdef H5 -->
<keypress v-if="maskShow" @esc="onTap" />
<!-- #endif -->
</view>
</template>
<script>
// #ifdef H5
import keypress from './keypress.js'
// #endif
/**
* PopUp 弹出层
* @description 弹出层组件为了解决遮罩弹层的问题
* @tutorial https://ext.dcloud.net.cn/plugin?id=329
* @property {String} type = [top|center|bottom|left|right|message|dialog|share] 弹出方式
* @value top 顶部弹出
* @value center 中间弹出
* @value bottom 底部弹出
* @value left 左侧弹出
* @value right 右侧弹出
* @value message 消息提示
* @value dialog 对话框
* @value share 底部分享示例
* @property {Boolean} animation = [true|false] 是否开启动画
* @property {Boolean} maskClick = [true|false] 蒙版点击是否关闭弹窗(废弃)
* @property {Boolean} isMaskClick = [true|false] 蒙版点击是否关闭弹窗
* @property {String} backgroundColor 主窗口背景色
* @property {String} maskBackgroundColor 蒙版颜色
* @property {String} borderRadius 设置圆角(左上右上右下和左下) 示例:"10px 10px 10px 10px"
* @property {Boolean} safeArea 是否适配底部安全区
* @event {Function} change 打开关闭弹窗触发e={show: false}
* @event {Function} maskClick 点击遮罩触发
*/
export default {
name: 'uniPopup',
components: {
// #ifdef H5
keypress
// #endif
},
emits: ['change', 'maskClick'],
props: {
//
animation: {
type: Boolean,
default: true
},
// top: bottomcenter
// message: ; dialog :
type: {
type: String,
default: 'center'
},
// maskClick
isMaskClick: {
type: Boolean,
default: null
},
// TODO 2 使 isMaskClick
maskClick: {
type: Boolean,
default: null
},
backgroundColor: {
type: String,
default: 'none'
},
safeArea: {
type: Boolean,
default: true
},
maskBackgroundColor: {
type: String,
default: 'rgba(0, 0, 0, 0.4)'
},
borderRadius:{
type: String,
}
},
watch: {
/**
* 监听type类型
*/
type: {
handler: function(type) {
if (!this.config[type]) return
this[this.config[type]](true)
},
immediate: true
},
isDesktop: {
handler: function(newVal) {
if (!this.config[newVal]) return
this[this.config[this.type]](true)
},
immediate: true
},
/**
* 监听遮罩是否可点击
* @param {Object} val
*/
maskClick: {
handler: function(val) {
this.mkclick = val
},
immediate: true
},
isMaskClick: {
handler: function(val) {
this.mkclick = val
},
immediate: true
},
// H5
showPopup(show) {
// #ifdef H5
// fix by mehaotian h5 穿
document.getElementsByTagName('body')[0].style.overflow = show ? 'hidden' : 'visible'
// #endif
}
},
data() {
return {
duration: 300,
ani: [],
showPopup: false,
showTrans: false,
popupWidth: 0,
popupHeight: 0,
config: {
top: 'top',
bottom: 'bottom',
center: 'center',
left: 'left',
right: 'right',
message: 'top',
dialog: 'center',
share: 'bottom'
},
maskClass: {
position: 'fixed',
bottom: 0,
top: 0,
left: 0,
right: 0,
backgroundColor: 'rgba(0, 0, 0, 0.4)'
},
transClass: {
backgroundColor: 'transparent',
borderRadius: this.borderRadius || "0",
position: 'fixed',
left: 0,
right: 0
},
maskShow: true,
mkclick: true,
popupstyle: 'top'
}
},
computed: {
getStyles() {
let res = { backgroundColor: this.bg };
if (this.borderRadius || "0") {
res = Object.assign(res, { borderRadius: this.borderRadius })
}
return res;
},
isDesktop() {
return this.popupWidth >= 500 && this.popupHeight >= 500
},
bg() {
if (this.backgroundColor === '' || this.backgroundColor === 'none') {
return 'transparent'
}
return this.backgroundColor
}
},
mounted() {
const fixSize = () => {
// #ifdef MP-WEIXIN
const {
windowWidth,
windowHeight,
windowTop,
safeArea,
screenHeight,
safeAreaInsets
} = uni.getWindowInfo()
// #endif
// #ifndef MP-WEIXIN
const {
windowWidth,
windowHeight,
windowTop,
safeArea,
screenHeight,
safeAreaInsets
} = uni.getSystemInfoSync()
// #endif
this.popupWidth = windowWidth
this.popupHeight = windowHeight + (windowTop || 0)
// TODO fix by mehaotian ,ios app ios
if (safeArea && this.safeArea) {
// #ifdef MP-WEIXIN
this.safeAreaInsets = screenHeight - safeArea.bottom
// #endif
// #ifndef MP-WEIXIN
this.safeAreaInsets = safeAreaInsets.bottom
// #endif
} else {
this.safeAreaInsets = 0
}
}
fixSize()
// #ifdef H5
// window.addEventListener('resize', fixSize)
// this.$once('hook:beforeDestroy', () => {
// window.removeEventListener('resize', fixSize)
// })
// #endif
},
// #ifndef VUE3
// TODO vue2
destroyed() {
this.setH5Visible()
},
// #endif
// #ifdef VUE3
// TODO vue3
unmounted() {
this.setH5Visible()
},
// #endif
activated() {
this.setH5Visible(!this.showPopup);
},
deactivated() {
this.setH5Visible(true);
},
created() {
// this.mkclick = this.isMaskClick || this.maskClick
if (this.isMaskClick === null && this.maskClick === null) {
this.mkclick = true
} else {
this.mkclick = this.isMaskClick !== null ? this.isMaskClick : this.maskClick
}
if (this.animation) {
this.duration = 300
} else {
this.duration = 0
}
// TODO message
this.messageChild = null
// TODO
this.clearPropagation = false
this.maskClass.backgroundColor = this.maskBackgroundColor
},
methods: {
setH5Visible(visible = true) {
// #ifdef H5
// fix by mehaotian h5 穿
document.getElementsByTagName('body')[0].style.overflow = visible ? "visible" : "hidden";
// #endif
},
/**
* 公用方法不显示遮罩层
*/
closeMask() {
this.maskShow = false
},
/**
* 公用方法遮罩层禁止点击
*/
disableMask() {
this.mkclick = false
},
// TODO nvue
clear(e) {
// #ifndef APP-NVUE
e.stopPropagation()
// #endif
this.clearPropagation = true
},
open(direction) {
// fix by mehaotian
if (this.showPopup) {
return
}
let innerType = ['top', 'center', 'bottom', 'left', 'right', 'message', 'dialog', 'share']
if (!(direction && innerType.indexOf(direction) !== -1)) {
direction = this.type
}
if (!this.config[direction]) {
console.error('缺少类型:', direction)
return
}
this[this.config[direction]]()
this.$emit('change', {
show: true,
type: direction
})
},
close(type) {
this.showTrans = false
this.$emit('change', {
show: false,
type: this.type
})
clearTimeout(this.timer)
// //
// this.customOpen && this.customClose()
this.timer = setTimeout(() => {
this.showPopup = false
}, 300)
},
// TODO
touchstart() {
this.clearPropagation = false
},
onTap() {
if (this.clearPropagation) {
// fix by mehaotian nvue
this.clearPropagation = false
return
}
this.$emit('maskClick')
if (!this.mkclick) return
this.close()
},
/**
* 顶部弹出样式处理
*/
top(type) {
this.popupstyle = this.isDesktop ? 'fixforpc-top' : 'top'
this.ani = ['slide-top']
this.transClass = {
position: 'fixed',
left: 0,
right: 0,
backgroundColor: this.bg,
borderRadius:this.borderRadius || "0"
}
// TODO type
if (type) return
this.showPopup = true
this.showTrans = true
this.$nextTick(() => {
this.showPoptrans()
if (this.messageChild && this.type === 'message') {
this.messageChild.timerClose()
}
})
},
/**
* 底部弹出样式处理
*/
bottom(type) {
this.popupstyle = 'bottom'
this.ani = ['slide-bottom']
this.transClass = {
position: 'fixed',
left: 0,
right: 0,
bottom: 0,
paddingBottom: this.safeAreaInsets + 'px',
backgroundColor: this.bg,
borderRadius:this.borderRadius || "0",
}
// TODO type
if (type) return
this.showPoptrans()
},
/**
* 中间弹出样式处理
*/
center(type) {
this.popupstyle = 'center'
//
// #ifdef MP-WEIXIN
this.ani = ['fade']
// #endif
// #ifndef MP-WEIXIN
this.ani = ['zoom-out', 'fade']
// #endif
this.transClass = {
position: 'fixed',
/* #ifndef APP-NVUE */
display: 'flex',
flexDirection: 'column',
/* #endif */
bottom: 0,
left: 0,
right: 0,
top: 0,
justifyContent: 'center',
alignItems: 'center',
borderRadius:this.borderRadius || "0"
}
// TODO type
if (type) return
this.showPoptrans()
},
left(type) {
this.popupstyle = 'left'
this.ani = ['slide-left']
this.transClass = {
position: 'fixed',
left: 0,
bottom: 0,
top: 0,
backgroundColor: this.bg,
borderRadius:this.borderRadius || "0",
/* #ifndef APP-NVUE */
display: 'flex',
flexDirection: 'column'
/* #endif */
}
// TODO type
if (type) return
this.showPoptrans()
},
right(type) {
this.popupstyle = 'right'
this.ani = ['slide-right']
this.transClass = {
position: 'fixed',
bottom: 0,
right: 0,
top: 0,
backgroundColor: this.bg,
borderRadius:this.borderRadius || "0",
/* #ifndef APP-NVUE */
display: 'flex',
flexDirection: 'column'
/* #endif */
}
// TODO type
if (type) return
this.showPoptrans()
},
showPoptrans(){
this.$nextTick(()=>{
this.showPopup = true
this.showTrans = true
})
}
}
}
</script>
<style lang="scss">
.uni-popup {
position: fixed;
/* #ifndef APP-NVUE */
z-index: 99;
/* #endif */
&.top,
&.left,
&.right {
/* #ifdef H5 */
top: var(--window-top);
/* #endif */
/* #ifndef H5 */
top: 0;
/* #endif */
}
.uni-popup__wrapper {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
position: relative;
/* iphonex 等安全区设置,底部安全区适配 */
/* #ifndef APP-NVUE */
// padding-bottom: constant(safe-area-inset-bottom);
// padding-bottom: env(safe-area-inset-bottom);
/* #endif */
&.left,
&.right {
/* #ifdef H5 */
padding-top: var(--window-top);
/* #endif */
/* #ifndef H5 */
padding-top: 0;
/* #endif */
flex: 1;
}
}
}
.fixforpc-z-index {
/* #ifndef APP-NVUE */
z-index: 999;
/* #endif */
}
.fixforpc-top {
top: 0;
}
</style>

View File

@ -0,0 +1,90 @@
{
"id": "uni-popup",
"displayName": "uni-popup 弹出层",
"version": "1.9.6",
"description": " Popup 组件,提供常用的弹层",
"keywords": [
"uni-ui",
"弹出层",
"弹窗",
"popup",
"弹框"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
},
"uni_modules": {
"dependencies": [
"uni-scss",
"uni-transition"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y",
"alipay": "n"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "y",
"app-harmony": "u",
"app-uvue": "u"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
}
}

View File

@ -0,0 +1,17 @@
## Popup 弹出层
> **组件名uni-popup**
> 代码块: `uPopup`
> 关联组件:`uni-transition`
弹出层组件,在应用中弹出一个消息提示窗口、提示框等
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-popup)
#### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839

View File

@ -1,6 +1,5 @@
{
"pages": [
{
"pages": [{
"path": "pages/index/index",
"style": {
"navigationStyle": "custom"
@ -71,9 +70,22 @@
}
},
{
"path" : "pages/mall/product-detail",
"style" :
{
"path": "pages/mall/product-detail",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/address/address-list",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/address/address-edit",
"style": {
"navigationStyle": "custom"
}
}
@ -89,8 +101,7 @@
"selectedColor": "#333333",
"borderStyle": "black",
"height": "48px",
"list": [
{
"list": [{
"pagePath": "pages/news/news",
"text": "资讯",
"iconPath": "/static/tabbar/news.png",

View File

@ -0,0 +1,331 @@
<template>
<PageContainer ref="pageContainer" title="编辑地址" show-back :show-not-data="showNotData" :refresh="onRefresh">
<view class="address-form">
<view class="form-item">
<view class="form-label required">收货人</view>
<input class="form-input" type="text" v-model="addressData.receiver_name" placeholder="收货人姓名" />
</view>
<view class="form-item">
<view class="form-label required">电话</view>
<input class="form-input" type="number" v-model="addressData.receiver_phone" placeholder="收货人电话"
maxlength="11" />
</view>
<view class="form-item address-item">
<view class="form-label required address-label">详细地址</view>
<textarea class="form-textarea" v-model="addressData.detailed_address" placeholder="请填写详细地址"
auto-height />
</view>
<view class="form-item switch-item">
<view class="form-label">设为默认</view>
<switch :checked="addressData.is_default === 1" @change="switchChange" color="#1296db" />
</view>
</view>
<view class="btn-save" @click="saveAddress">
<text>保存</text>
</view>
<view class="btn-delete" v-if="isEdit" @click="showDeleteConfirm">
<text>删除</text>
</view>
</PageContainer>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { addAddress, updateAddress, deleteAddress, getAddressDetail } from '@/common/server/address';
let pageContainer = ref(null);
let showNotData = ref(false);
let isEdit = ref(false);
let addressId = ref(null);
let addressData = reactive({
receiver_name: '',
receiver_phone: '',
detailed_address: '',
is_default: 0
});
//
const onRefresh = async (paging) => {
await yds.sleep(500);
paging.complete();
};
//
const getAddressDetailData = async () => {
try {
uni.showLoading({
title: '加载中...'
});
const res = await getAddressDetail(addressId.value);
uni.hideLoading();
if (res.status === 1 && res.data) {
// API
addressData.receiver_name = res.data.receiver_name;
addressData.receiver_phone = res.data.receiver_phone;
addressData.detailed_address = res.data.detailed_address;
addressData.is_default = res.data.is_default === 1 ? 1 : 0;
} else {
uni.showToast({
title: res.msg || '获取地址详情失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('获取地址详情失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
};
//
const switchChange = (e) => {
addressData.is_default = e.detail.value ? 1 : 0;
};
//
const saveAddress = async () => {
//
if (!addressData.receiver_name) {
return uni.showToast({
title: '请输入收货人姓名',
icon: 'none'
});
}
if (!addressData.receiver_phone) {
return uni.showToast({
title: '请输入联系电话',
icon: 'none'
});
}
//
const phoneReg = /^1[3-9]\d{9}$/;
if (!phoneReg.test(addressData.receiver_phone)) {
return uni.showToast({
title: '手机号格式不正确',
icon: 'none'
});
}
if (!addressData.detailed_address) {
return uni.showToast({
title: '请输入详细地址',
icon: 'none'
});
}
try {
uni.showLoading({
title: '保存中...'
});
let res;
if (isEdit.value) {
//
res = await updateAddress({
...addressData,
id: addressId.value
});
} else {
//
res = await addAddress(addressData);
}
uni.hideLoading();
if (res.status === 1) {
uni.showToast({
title: '保存成功',
icon: 'success'
});
//
setTimeout(() => {
//
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: res.msg || '保存失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('保存地址失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
};
//
const showDeleteConfirm = () => {
uni.showModal({
title: '提示',
content: '确定要删除该收货地址吗?',
success: async (res) => {
if (res.confirm) {
await deleteAddressData();
}
}
});
};
//
const deleteAddressData = async () => {
try {
uni.showLoading({
title: '删除中...'
});
const res = await deleteAddress({
id: addressId.value
});
uni.hideLoading();
if (res.code === 200) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
//
setTimeout(() => {
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: res.msg || '删除失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('删除地址失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
};
//
onMounted(() => {
const query = uni.getLaunchOptionsSync().query;
//
if (query && query.id) {
isEdit.value = true;
addressId.value = query.id;
//
getAddressDetailData();
}
});
</script>
<style lang="scss" scoped>
.address-form {
background-color: #fff;
padding: 0 30rpx;
.form-item {
display: flex;
align-items: center;
min-height: 100rpx;
border-bottom: 1px solid #eee;
.form-label {
width: 180rpx;
font-size: 30rpx;
color: #333;
&.required::before {
content: '*';
color: #ff4d4f;
margin-right: 4rpx;
}
}
.form-input {
flex: 1;
height: 100rpx;
font-size: 30rpx;
}
.form-textarea {
flex: 1;
width: 100%;
min-height: 100rpx;
font-size: 30rpx;
padding: 20rpx 0;
}
&.switch-item {
justify-content: space-between;
}
&.address-item {
flex-direction: column;
align-items: flex-start;
.address-label {
margin-top: 20rpx;
margin-bottom: 10rpx;
}
.form-textarea {
width: 100%;
margin-top: 10rpx;
}
}
}
}
.btn-save {
position: fixed;
bottom: 140rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 90rpx;
background-color: #1296db;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
font-weight: bold;
border-radius: 45rpx;
}
.btn-delete {
position: fixed;
bottom: 30rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 90rpx;
background-color: #fff;
color: #666;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
border-radius: 45rpx;
border: 1px solid #ddd;
}
</style>

View File

@ -0,0 +1,282 @@
<template>
<PageContainer ref="pageContainer" title="我的地址管理" show-back :show-not-data="showNotData" :refresh="onRefresh">
<view class="address-list">
<view v-for="(item, index) in addressList" :key="index" class="address-item">
<view class="address-content">
<view class="address-top">
<text class="name">{{ item.receiver_name }}</text>
<text class="phone">{{ item.receiver_phone }}</text>
<text v-if="item.is_default === 1" class="default-tag">默认</text>
</view>
<view class="address-bottom">
<text class="address-text">{{ item.detailed_address }}</text>
</view>
</view>
<view class="edit-btn" @click="editAddress(item)">
<image src="/static/app-plus/edit.png" mode="widthFix" style="width:32px;height: 32px;"></image>
</view>
<view class="delete-btn" @click="showDeleteConfirm(item)">
<image src="/static/app-plus/del.png" mode="widthFix" style="width: 32px;height: 32px;"></image>
</view>
</view>
<view v-if="addressList.length === 0" class="empty-tip">
<text>暂无收货地址</text>
</view>
</view>
<view class="add-btn" @click="addNewAddress">
<text>新增地址</text>
</view>
</PageContainer>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { getAddressList, deleteAddress } from '@/common/server/address';
const pageContainer = ref(null);
const showNotData = ref(false);
const addressList = ref([]);
//
const onRefresh = async (paging) => {
await loadAddressList();
paging.complete();
};
//
const loadAddressList = async () => {
try {
const res = await getAddressList();
if (res.status === 1 && res.data) {
addressList.value = res.data;
showNotData.value = addressList.value.length === 0;
} else {
uni.showToast({
title: res.msg || '获取地址列表失败',
icon: 'none'
});
}
} catch (error) {
console.error('获取地址列表失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
};
//
const editAddress = (item) => {
uni.navigateTo({
url: '/pages/address/address-edit?id=' + item.id
});
};
//
const addNewAddress = () => {
uni.navigateTo({
url: '/pages/address/address-edit'
});
};
//
const showDeleteConfirm = (item) => {
uni.showModal({
title: '提示',
content: '确定要删除该收货地址吗?',
success: async (res) => {
if (res.confirm) {
await deleteAddressItem(item.id);
}
}
});
};
//
const deleteAddressItem = async (id) => {
try {
uni.showLoading({
title: '删除中...'
});
const res = await deleteAddress({
id: id
});
uni.hideLoading();
if (res.status === 1) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
//
loadAddressList();
} else {
uni.showToast({
title: res.msg || '删除失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('删除地址失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
};
//
onMounted(() => {
loadAddressList();
});
</script>
<style lang="scss" scoped>
.address-list {
padding: 20rpx;
background-color: #f5f5f5;
min-height: calc(100vh - 120rpx);
.address-item {
display: flex;
align-items: center;
padding: 30rpx;
margin-bottom: 20rpx;
border-radius: 12rpx;
background-color: #fff;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
&:active {
transform: scale(0.98);
box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.03);
}
&:last-child {
margin-bottom: 100rpx;
}
.address-content {
flex: 1;
margin: 0 20rpx;
.address-top {
margin-bottom: 16rpx;
display: flex;
align-items: center;
flex-wrap: wrap;
.name {
font-size: 34rpx;
font-weight: 600;
margin-right: 20rpx;
color: #333;
}
.phone {
font-size: 28rpx;
color: #666;
}
.default-tag {
display: inline-block;
font-size: 22rpx;
color: #fff;
background-color: #1296db;
padding: 4rpx 16rpx;
border-radius: 30rpx;
margin-left: 16rpx;
}
}
.address-bottom {
.address-text {
font-size: 28rpx;
color: #666;
line-height: 1.6;
}
}
}
.edit-btn,
.delete-btn {
width: 70rpx;
height: 70rpx;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
transition: background-color 0.2s ease;
&:active {
background-color: #f0f0f0;
}
image {
width: 36rpx;
height: 36rpx;
}
}
}
.empty-tip {
text-align: center;
padding: 120rpx 0;
color: #999;
font-size: 28rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
&::before {
content: "";
width: 160rpx;
height: 160rpx;
margin-bottom: 30rpx;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="%23cccccc"><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm-5-7h10v2H7v-2zm0-3h10v2H7v-2zm0-3h10v2H7V7z"/></svg>');
background-position: center;
background-repeat: no-repeat;
background-size: contain;
opacity: 0.5;
}
}
}
.add-btn {
position: fixed;
bottom: 40rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 90rpx;
background: linear-gradient(to right, #1296db, #0e80c0);
color: #fff;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
font-weight: 600;
border-radius: 45rpx;
box-shadow: 0 6rpx 16rpx rgba(18, 150, 219, 0.3);
transition: transform 0.2s ease, box-shadow 0.2s ease;
&:active {
transform: translateX(-50%) scale(0.98);
box-shadow: 0 3rpx 8rpx rgba(18, 150, 219, 0.2);
}
&::before {
content: "+";
font-size: 40rpx;
margin-right: 10rpx;
font-weight: 400;
}
}
</style>

View File

@ -89,6 +89,9 @@ const loadMenu = async () => {
}, {
id: 4,
title: "收货地址管理",
onClick: (res) => {
navigateTo("/pages/address/address-list");
}
},
{
id: 5,

366
static/address_edit.vue Normal file
View File

@ -0,0 +1,366 @@
<template>
<page-container title="编辑地址" :showBack="true">
<view class="address-form">
<view class="form-item">
<view class="form-label required">收货人</view>
<input class="form-input" type="text" v-model="addressData.receiver_name" placeholder="收货人姓名" />
</view>
<view class="form-item">
<view class="form-label required">电话</view>
<input class="form-input" type="number" v-model="addressData.receiver_phone" placeholder="收货人电话"
maxlength="11" />
</view>
<view class="form-item address-item">
<view class="form-label required address-label">详细地址</view>
<textarea class="form-textarea" v-model="addressData.detailed_address" placeholder="请填写详细地址"
auto-height />
</view>
<view class="form-item switch-item">
<view class="form-label">设为默认</view>
<switch :checked="addressData.is_default === 1" @change="switchChange" color="#1296db" />
</view>
</view>
<view class="btn-save" @click="saveAddress">
<text>保存</text>
</view>
<view class="btn-delete" v-if="isEdit" @click="showDeleteConfirm">
<text>删除</text>
</view>
</page-container>
</template>
<script>
import PageContainer from '@/components/page-container/page-container.vue'
import { addAddress, updateAddress, deleteAddress, getAddressDetail } from '@/common/server/userAddress.js'
export default {
components: {
PageContainer
},
data() {
return {
isEdit: false,
addressId: null,
addressData: {
receiver_name: '',
receiver_phone: '',
detailed_address: '',
is_default: 0
},
eventChannel: null
}
},
onLoad(options) {
this.eventChannel = this.getOpenerEventChannel();
//
if (options && options.id) {
this.isEdit = true;
this.addressId = options.id;
//
this.getAddressDetail();
}
},
methods: {
//
async getAddressDetail() {
try {
uni.showLoading({
title: '加载中...'
});
const res = await getAddressDetail(this.addressId);
uni.hideLoading();
if (res.status === 1 && res.data) {
// API
this.addressData = {
receiver_name: res.data.receiver_name,
receiver_phone: res.data.receiver_phone,
detailed_address: res.data.detailed_address,
is_default: res.data.is_default === 1 ? 1 : 0
};
} else {
uni.showToast({
title: res.msg || '获取地址详情失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('获取地址详情失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
},
//
switchChange(e) {
this.addressData.is_default = e.detail.value ? 1 : 0;
},
//
async saveAddress() {
//
if (!this.addressData.receiver_name) {
return uni.showToast({
title: '请输入收货人姓名',
icon: 'none'
});
}
if (!this.addressData.receiver_phone) {
return uni.showToast({
title: '请输入联系电话',
icon: 'none'
});
}
//
const phoneReg = /^1[3-9]\d{9}$/;
if (!phoneReg.test(this.addressData.receiver_phone)) {
return uni.showToast({
title: '手机号格式不正确',
icon: 'none'
});
}
if (!this.addressData.detailed_address) {
return uni.showToast({
title: '请输入详细地址',
icon: 'none'
});
}
try {
uni.showLoading({
title: '保存中...'
});
let res;
if (this.isEdit) {
//
res = await updateAddress({
...this.addressData,
id: this.addressId
});
} else {
//
res = await addAddress(this.addressData);
}
uni.hideLoading();
if (res.status === 1) {
uni.showToast({
title: '保存成功',
icon: 'success'
});
//
setTimeout(() => {
//
const pages = getCurrentPages();
const prevPage = pages[pages.length - 2];
if (prevPage && prevPage.$vm) {
// load
prevPage.$vm.load && prevPage.$vm.load();
}
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: res.msg || '保存失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('保存地址失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
},
//
showDeleteConfirm() {
uni.showModal({
title: '提示',
content: '确定要删除该收货地址吗?',
success: async (res) => {
if (res.confirm) {
await this.deleteAddress();
}
}
});
},
//
async deleteAddress() {
try {
uni.showLoading({
title: '删除中...'
});
const res = await deleteAddress({
id: this.addressId
});
uni.hideLoading();
if (res.code === 200) {
uni.showToast({
title: '删除成功',
icon: 'success'
});
//
setTimeout(() => {
//
const pages = getCurrentPages();
const prevPage = pages[pages.length - 2];
if (prevPage && prevPage.$vm) {
// load
prevPage.$vm.load && prevPage.$vm.load();
}
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: res.msg || '删除失败',
icon: 'none'
});
}
} catch (error) {
uni.hideLoading();
console.error('删除地址失败', error);
uni.showToast({
title: '网络异常,请稍后再试',
icon: 'none'
});
}
}
}
}
</script>
<style lang="scss">
.address-form {
background-color: #fff;
padding: 0 30rpx;
.form-item {
display: flex;
align-items: center;
min-height: 100rpx;
border-bottom: 1px solid #eee;
.form-label {
width: 180rpx;
font-size: 30rpx;
color: #333;
&.required::before {
content: '*';
color: #ff4d4f;
margin-right: 4rpx;
}
}
.form-input {
flex: 1;
height: 100rpx;
font-size: 30rpx;
}
.form-textarea {
flex: 1;
width: 100%;
min-height: 100rpx;
font-size: 30rpx;
padding: 20rpx 0;
}
.form-value {
flex: 1;
display: flex;
justify-content: space-between;
align-items: center;
height: 100rpx;
font-size: 30rpx;
.placeholder {
color: #999;
}
.arrow {
color: #ccc;
margin-left: 10rpx;
}
}
&.switch-item {
justify-content: space-between;
}
&.address-item {
flex-direction: column;
align-items: flex-start;
.address-label {
margin-top: 20rpx;
margin-bottom: 10rpx;
}
.form-textarea {
width: 100%;
margin-top: 10rpx;
}
}
}
}
.btn-save {
position: fixed;
bottom: 140rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 90rpx;
background-color: #1296db;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
font-weight: bold;
border-radius: 45rpx;
}
.btn-delete {
position: fixed;
bottom: 30rpx;
left: 50%;
transform: translateX(-50%);
width: 90%;
height: 90rpx;
background-color: #fff;
color: #666;
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
border-radius: 45rpx;
border: 1px solid #ddd;
}
</style>

BIN
static/app-plus/del.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

BIN
static/app-plus/edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

View File

@ -1,371 +0,0 @@
<template>
<view class="content">
<uni-nav-bar left-icon="left" color="#000000" backgroundColor="transparent" :fixed="true" :statusBar="true"
:border="false" @clickLeft="$common.back">
<view style="width: 100%; font-size: 32rpx; display: flex; align-items: center; justify-content: center; font-weight: 600;">
优惠券
</view>
</uni-nav-bar>
<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback"
@up="getList">
<view class="tab-list">
<view @click="tabChange(i)" v-for="(item, i) in tabList" :key="i" class="tab-list-item"
:class="{ active: tabCur == i }">
{{ item.title }}
<view v-if="tabCur == i" class="arrow"></view>
</view>
</view>
<view class="list-item common_bg" v-for="(item, i) in listData" :key="i"
:class="{ dis: tabList[tabCur].type1 == 2 }">
<view class="money">
¥
<text>{{ Number(item.price) }}</text>
</view>
<view class="info">
<view class="title">{{ item.man_price }}{{ item.price }}</view>
<view class="time">{{ item.end_time }}到期</view>
</view>
<view v-if="tabList[tabCur].type1 == 1" @click="toUse(item)" class="btn">
去使用
</view>
<view v-if="tabList[tabCur].type1 == 2" class="btn">
{{ item.mark }}
</view>
</view>
</mescroll-body>
</view>
</template>
<script>
export default {
data() {
return {
optData: '',
tabList: [{
id: 0,
title: '可使用',
type1: 1
},
{
id: 0,
title: '不可用',
type1: 2
}
],
tabCur: 0,
downOption: {
auto: false //
},
//
upOption: {
page: {
size: 10 // ,10
}
},
listData: [],
pageType: 1
}
},
onLoad(options) {
this.optData = options
if (options.type) {
this.pageType = options.type
}
// setTimeout(() => {
// this.listData = [
// {
// price: '23',
// man_price: '23',
// end_time: '2333-23-23 23:23:23',
// type1: 1,
// mark: '使'
// },
// {
// price: '23',
// man_price: '23',
// end_time: '2333-23-23 23:23:23',
// type1: 2,
// mark: '使'
// }
// ]
// }, 1000)
},
methods: {
toUse(item) {
if (this.pageType == 1) {
this.$customRouter.navigateTo('/pages/main/index', {}, 'switchTab');
}
if (this.pageType == 2) {
uni.$emit('chooseCoupon', item)
uni.navigateBack({
delta: 1
})
}
},
tabChange(i) {
this.tabCur = i
this.listData = []
this.mescroll.resetUpScroll()
this.mescroll.scrollTo(0, 0)
},
getList({
num,
size
}) {
let data = {
page: num,
type: this.pageType,
type1: this.tabList[this.tabCur].type1,
status: this.tabList[this.tabCur].id
}
if (this.pageType == 2) {
data.total_price = this.optData.total_price
}
this.req({
url: 'used',
data,
Loading: true,
success: res => {
if (res.status == 1) {
if (num == 1) {
this.listData = []
}
this.listData = this.listData.concat(res.data.data)
console.log(this.listData)
this.mescroll.endByPage(res.data.data.length, res.data.last_page)
}
}
})
},
back() {
uni.navigateBack()
}
}
}
</script>
<style lang="scss">
.content {
padding: 0 0 30rpx;
background-color: #F7F7F7;
.tab-list {
display: flex;
padding: 30rpx;
.tab-list-item {
margin-right: 40rpx;
position: relative;
padding: 16rpx 18rpx;
font-size: 20rpx;
// font-family: Source Han Sans CN;
font-weight: 400;
border-radius: 8rpx;
color: #cccccc;
// .arrow {
// position: absolute;
// left: 50%;
// bottom: -14rpx;
// transform: translateX(-50%);
// width: 18rpx;
// height: 8rpx;
// background: #333333;
// border-radius: 28rpx;
// }
&.active {
font-size: 20rpx;
color: #333333;
background-color: #E6F791;
}
}
}
.list-item {
width: 710rpx;
box-sizing: border-box;
padding: 40rpx 30rpx 40rpx 10rpx;
display: flex;
align-items: center;
margin: 0 auto 20rpx;
background: url($imgurl+'my/coupon.png') no-repeat 0 0 / 100% 100%;
.money {
width: 160rpx;
text-align: center;
position: relative;
font-size: 26rpx;
font-family: Source Han Sans CN;
font-weight: 400;
color: #F39205;
text {
font-weight: 400;
font-size: 70rpx;
color: #F39205;
}
&::after {
content: '';
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
width: 1rpx;
height: 116rpx;
background: #666666;
}
}
.info {
flex: 1;
padding-left: 20rpx;
.title {
font-size: 25rpx;
font-family: Source Han Sans CN;
font-weight: 400;
color: #333333;
}
.time {
margin-top: 20rpx;
font-size: 16rpx;
font-family: Source Han Sans CN;
font-weight: 400;
color: #8A8A8A;
}
}
.btn {
width: 108rpx;
height: 56rpx;
background: #E6F791;
border-radius: 16rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 20rpx;
font-family: Source Han Sans CN;
font-weight: 400;
color: #333333;
}
&.dis {
position: relative;
&::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.4);
}
}
}
// .coupon {
// width: 690rpx;
// margin: 30rpx auto 0;
// display: flex;
// align-items: center;
// position: relative;
// padding: 20rpx 0;
// &.dis {
// filter: grayscale(1);
// }
// .tag {
// position: absolute;
// left: 0;
// top: 0;
// border-radius: 20rpx 0 20rpx 0;
// overflow: hidden;
// background: linear-gradient(0deg, #85b9ff 0%, #b01bff 100%);
// height: 36rpx;
// padding: 0 10rpx;
// display: flex;
// align-items: center;
// font-size: 22rpx;
// font-family: Source Han Sans CN;
// font-weight: 400;
// color: #ffffff;
// }
// .coupon-l {
// width: 198rpx;
// height: 146rpx;
// display: flex;
// justify-content: center;
// align-items: center;
// border-right: 1rpx dashed #eeeeee;
// font-size: 24rpx;
// font-family: Source Han Sans CN;
// font-weight: 500;
// color: #ffffff;
// text {
// font-size: 40rpx;
// }
// }
// .coupon-info {
// width: 360rpx;
// box-sizing: border-box;
// padding-left: 20rpx;
// .rule {
// font-size: 28rpx;
// font-family: Source Han Sans CN;
// font-weight: 500;
// color: #ffffff;
// }
// .time {
// margin-top: 20rpx;
// font-size: 24rpx;
// font-family: Source Han Sans CN;
// font-weight: 400;
// color: #ffffff;
// }
// }
// .coupon-r {
// flex: 1;
// text-align: center;
// font-size: 28rpx;
// font-family: Source Han Sans CN;
// font-weight: 500;
// color: #ffffff;
// }
// }
}
</style>

View File

@ -1 +1 @@
{"version":3,"file":"assets.js","sources":["static/app-plus/news/prev.png","static/app-plus/icon_108.png","../../../static/app-plus/arrow-right.png","static/ic_back.png","static/app-plus/news/next.png","static/ic_box.png","static/app-plus/copy.png","static/ic_arrow.png"],"sourcesContent":["export default \"__VITE_ASSET__aff33104__\"","export default \"__VITE_ASSET__80d335cf__\"","export default \"/static/app-plus/arrow-right.png\"","export default \"__VITE_ASSET__188f0ac5__\"","export default \"__VITE_ASSET__7180813e__\"","export default \"__VITE_ASSET__3d61de0b__\"","export default \"__VITE_ASSET__7ddd6aa1__\"","export default \"__VITE_ASSET__f0e37cf1__\""],"names":[],"mappings":"gCAAe,sDCAA,qDCAA,wDCAA,yCCAA,sDCAA,0CCAA,+CCAA"}
{"version":3,"file":"assets.js","sources":["static/app-plus/news/prev.png","static/app-plus/icon_108.png","../../../static/app-plus/arrow-right.png","static/ic_back.png","static/app-plus/edit.png","static/app-plus/news/next.png","static/ic_box.png","static/app-plus/copy.png","static/app-plus/del.png","static/ic_arrow.png"],"sourcesContent":["export default \"__VITE_ASSET__aff33104__\"","export default \"__VITE_ASSET__80d335cf__\"","export default \"/static/app-plus/arrow-right.png\"","export default \"__VITE_ASSET__188f0ac5__\"","export default \"__VITE_ASSET__6a7a1284__\"","export default \"__VITE_ASSET__7180813e__\"","export default \"__VITE_ASSET__3d61de0b__\"","export default \"__VITE_ASSET__7ddd6aa1__\"","export default \"__VITE_ASSET__6e883b63__\"","export default \"__VITE_ASSET__f0e37cf1__\""],"names":[],"mappings":"gCAAe,sDCAA,qDCAA,wDCAA,2CCAA,+CCAA,sDCAA,0CCAA,iDCAA,8CCAA"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,9 @@
"pages/other/agreement",
"pages/me/account-info",
"pages/other/coupon",
"pages/mall/product-detail"
"pages/mall/product-detail",
"pages/address/address-list",
"pages/address/address-edit"
],
"tabBar": {
"color": "#C6C6C6",

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
"use strict";const e=require("../../page-popup.js"),n=require("../../common/vendor.js"),o=require("../../common/assets.js"),t=require("../../common/server/user.js"),i=require("../../common/system/router.js"),s=require("../../common/yds.js");if(!Array){(0,e.__unplugin_components_3)()}const a={__name:"me",setup(e){let a=n.ref(null);const r=n.ref([]);let u=n.ref(null);n.onShow((async()=>{s.yds.showLoading();const e=await t.getUserInfo();n.index.__f__("log","at pages/me/me.vue:70","res",e),u.value=e,c(),s.yds.hideLoading()}));const c=async()=>{const e=[{id:1,title:"消费记录"},{id:2,title:"我的收藏"},{id:3,title:"优惠券",onClick:e=>{i.navigateTo("/pages/other/coupon")}},{id:4,title:"收货地址管理"},{id:5,title:"用户协议",onClick:e=>{s.yds.navigateToAgreement("user")}},{id:6,title:"隐私政策",onClick:e=>{s.yds.navigateToAgreement("privacy")}}];s.yds.userInfo.isAccountLogin()&&e.push({id:7,title:"退出登录",onClick:async e=>{const{confirm:n}=await a.value.showModal("退出登录","确定退出登录吗?");n&&(s.yds.userInfo.logout(),u.value=null,c(),i.navigateTo("/pages/me/account-login"))}},{id:8,title:"注销账号",onClick:e=>{i.navigateTo("/pages/me/account-deletion")}}),r.value=e};return(e,t)=>n.e({a:n.unref(u)},n.unref(u)?{b:n.unref(u).userIcon,c:n.t(n.unref(u).username),d:n.t(n.unref(u).days),e:n.o((e=>{n.unref(i.navigateTo)("/pages/me/account-info")}))}:{f:n.o((e=>{n.unref(i.navigateToAccountLogin)()}))},{g:n.o((e=>{n.unref(i.navigateTo)("/pages/mall/order-list")})),h:n.f(n.unref(r),((e,o,t)=>({a:n.t(e.title),b:e.id,c:n.o((n=>e.onClick?e.onClick(e):null),e.id)}))),i:o._imports_2,j:n.sr(a,"1e9a094d-0",{k:"_pagePopup"})})}};wx.createPage(a);
"use strict";const e=require("../../page-popup.js"),n=require("../../common/vendor.js"),o=require("../../common/assets.js"),t=require("../../common/server/user.js"),i=require("../../common/system/router.js"),s=require("../../common/yds.js");if(!Array){(0,e.__unplugin_components_3)()}const a={__name:"me",setup(e){let a=n.ref(null);const r=n.ref([]);let u=n.ref(null);n.onShow((async()=>{s.yds.showLoading();const e=await t.getUserInfo();n.index.__f__("log","at pages/me/me.vue:70","res",e),u.value=e,c(),s.yds.hideLoading()}));const c=async()=>{const e=[{id:1,title:"消费记录"},{id:2,title:"我的收藏"},{id:3,title:"优惠券",onClick:e=>{i.navigateTo("/pages/other/coupon")}},{id:4,title:"收货地址管理",onClick:e=>{i.navigateTo("/pages/address/address-list")}},{id:5,title:"用户协议",onClick:e=>{s.yds.navigateToAgreement("user")}},{id:6,title:"隐私政策",onClick:e=>{s.yds.navigateToAgreement("privacy")}}];s.yds.userInfo.isAccountLogin()&&e.push({id:7,title:"退出登录",onClick:async e=>{const{confirm:n}=await a.value.showModal("退出登录","确定退出登录吗?");n&&(s.yds.userInfo.logout(),u.value=null,c(),i.navigateTo("/pages/me/account-login"))}},{id:8,title:"注销账号",onClick:e=>{i.navigateTo("/pages/me/account-deletion")}}),r.value=e};return(e,t)=>n.e({a:n.unref(u)},n.unref(u)?{b:n.unref(u).userIcon,c:n.t(n.unref(u).username),d:n.t(n.unref(u).days),e:n.o((e=>{n.unref(i.navigateTo)("/pages/me/account-info")}))}:{f:n.o((e=>{n.unref(i.navigateToAccountLogin)()}))},{g:n.o((e=>{n.unref(i.navigateTo)("/pages/mall/order-list")})),h:n.f(n.unref(r),((e,o,t)=>({a:n.t(e.title),b:e.id,c:n.o((n=>e.onClick?e.onClick(e):null),e.id)}))),i:o._imports_2,j:n.sr(a,"1e9a094d-0",{k:"_pagePopup"})})}};wx.createPage(a);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/me/me.js.map

View File

@ -33,7 +33,8 @@ export default defineConfig({
Components({
dirs: [
'components/youdas-container',
'components/uni-nav-bar'
'components/uni-nav-bar',
'components/uni-popup'
], // 指定组件目录
extensions: ['vue'],
dts: true, // 生成类型声明文件(可选)