初始化

This commit is contained in:
魏啾
2024-03-21 15:43:18 +08:00
parent 08c5d22de6
commit fab2d5f480
534 changed files with 76501 additions and 1 deletions

325
pages/my/address/edit.vue Normal file
View File

@@ -0,0 +1,325 @@
<template>
<view class="content" :style="[theme]">
<view class="content_box">
<view class="content_box_item flex-start">
<view class="content_box_item_one">
联系人
</view>
<view class="content_box_item_tow">
<input type="text" v-model="form.name" placeholder="请填写收货人姓名" />
</view>
</view>
<view class="content_box_item flex-start">
<view class="content_box_item_one">
联系电话
</view>
<view class="content_box_item_tow">
<input type="number" v-model="form.mobile" maxlength="11"
placeholder="请填写收货人手机号码" />
</view>
</view>
<pick-regions :defaultRegion="defaultRegionCode" @getRegion="handleGetRegion">
<view class="content_box_item flex-start">
<view class="content_box_item_one">
所在地区
</view>
<view class="content_box_item_tow flex-start">
<input type="text" v-model="regionName" disabled="disabled" placeholder="省市区、乡镇等" />
<!-- <image class="content_box_itemimage" @click="chooseLocation" src="@/static/address.png" mode="aspectFill">
</image> -->
</view>
</view>
</pick-regions>
<!-- <view class="content_box_item flex-start">
<view class="content_box_item_one">
所在街道
</view>
<view class="content_box_item_tow">
<input type="text" v-model="form.name" placeholder="填写街道" />
</view>
</view> -->
<view class="content_box_item flex-start">
<view class="content_box_item_one">
详细地址
</view>
<view class="content_box_item_tow">
<input type="text" v-model="form.address" placeholder="请填写详细地址" />
</view>
</view>
</view>
<view class="content_box_tow flex-between">
<view class="content_box_tow_one">
设为默认地址
</view>
<u-switch v-model="showis_default" size="20" @change="change"></u-switch>
</view>
<view class="positionfixed flex-center" @click="usereditaddress">
保存
</view>
</view>
</template>
<script>
import pickRegions from '@/components/pick-regions/pick-regions.vue'
export default {
components: {
pickRegions
},
data() {
return {
region: [],
showis_default: true,
defaultRegionCode: '610112', //默认未央区
height: '',
form: {
regionName: '',
type: ''
},
valueswitch: false
};
},
async onLoad(e) {
this.form.id = e.id
if (e.type == 1) {
uni.setNavigationBarTitle({
title: '添加地址'
})
} else {
uni.setNavigationBarTitle({
title: '修改地址'
})
let res = await this.api.usereaddressshow({
id: this.form.id
})
console.log(res)
if (res) {
this.form = res
if (res.is_default == 1) {
this.showis_default = true
} else {
this.showis_default = false
}
}
}
this.form.type = e.type
},
onShow() {},
watch: {},
computed: {
theme() {
return this.$store.getters.theme
},
regionName() {
// 转为字符串
let res = null
if (this.region.length == 0) {
res = this.form.province + this.form.city + this.form.area
} else {
res = this.region.map(item => item.name).join(' ')
}
return res
}
},
methods: {
change(e) {
this.showis_default = e
console.log('change', e);
},
async usereditaddress() {
if (this.form.name == null || this.form.name == '') {
uni.showToast({
title: '请输入姓名',
icon: 'none'
});
return false;
}
if (this.form.mobile == null || this.form.mobile == '') {
uni.showToast({
title: '请输入电话号码',
icon: 'none'
});
return false;
}
if (this.form.province == null || this.form.province == '') {
uni.showToast({
title: '请选择省,市,区',
icon: 'none'
});
return false;
}
if (this.form.address == null || this.form.address == '') {
uni.showToast({
title: '请输入详细地址',
icon: 'none'
});
return false;
}
let res = await this.api.usereditaddress({
id: this.form.id, //地址ID
province: this.form.province, //省
city: this.form.city, //市
area: this.form.area, //区
address: this.form.address, //详细地址
name: this.form.name, //姓名
mobile: this.form.mobile, //电话
lng: this.form.lng, //经度
is_default: this.showis_default == true ? 1 : '', //1 默认
lat: this.form.lat, //维度
type: this.form.type //1 添加 2修改
})
console.log(res)
if (res == 1) {
uni.showToast({
title: this.form.type == 1 ? '添加成功' : '修改成功',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack()
}, 1000);
}
},
handleGetRegion(region) {
console.log(111, region)
this.region = region
this.form.province = region[0].name
this.form.city = region[1].name
this.form.area = region[2].name
},
chooseLocation() {
uni.chooseAddress({
success: (res) => {
console.log(res)
this.form.address = res.address
this.form.lat = res.latitude
this.form.lng = res.longitude
this.lnglat = res.latitude + '-' + res.longitude
console.log('位置名称:' + res.name);
console.log('详细地址:' + res.address);
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
},
fail: (e) => {
console.log(e)
// uni.getSetting({
// success: function(res) {
// var statu = res.authSetting;
// console.log(statu);
// if (!statu['scope.userLocation']) {
// console.log(123);
// uni.showModal({
// title: '是否授权当前位置',
// content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
// success(tip) {
// if (tip.confirm) {
// uni.authorize({
// scope: 'scope.userLocation',
// success:()=> {
// this.chooseLocation()
// }
// })
// } else {
// uni.showToast({
// title: '授权失败',
// icon: 'none',
// duration: 1000
// })
// }
// }
// })
// }
// }
// })
}
})
},
edit(e) {
uni.pro.navigateTo('my/address/edit', e.id)
}
}
}
</script>
<style lang="scss">
page {
background: #F9F9F9;
}
.content {
padding: 0 30rpx;
.content_box {
padding-left: 40rpx;
background: #FFF;
.content_box_item {
margin-top: 24rpx;
width: 100%;
padding: 32rpx;
border-bottom: 1rpx solid #F6F6F6;
.content_box_item_one {
width: 112rpx;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
}
.content_box_item_tow {
flex: auto;
padding-left: 80rpx;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #CCCCCC;
input {
flex: auto;
height: 100%;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #CCCCCC;
}
}
.content_box_itemimage {
width: 40rpx;
height: 40rpx;
}
}
}
.content_box_tow {
margin-top: 24rpx;
padding: 34rpx 44rpx;
background: #FFF;
.content_box_tow_one {
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
}
}
.positionfixed {
position: fixed;
background: #f6f6f6;
width: 90%;
bottom: 50rpx;
left: 5%;
padding: 24rpx 34rpx;
text-align: center;
background: var(--bg-color-button);
border-radius: 46rpx;
font-size: 30rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #FFFFFF;
}
}
</style>

248
pages/my/address/index.vue Normal file
View File

@@ -0,0 +1,248 @@
<template>
<view class="content" :style="[theme]">
<view class="contentitem" v-for="(item,index) in list" :key="index" @click.stop="order_fn(item)">
<view class="contentitemone flex-start">
<view class="contentitemone_textone">
{{item.name}}
</view>
<view class="contentitemone_textyow">
{{item.mobile.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')}}
</view>
</view>
<view class="contentitemtow ">
{{item.province}}{{item.area}}{{item.city}}{{item.address}}
</view>
<view class="contentitemthere flex-between">
<view class="contentitemthereone flex-start" @click.stop="edit(item)">
<u-icon v-if="item.is_default == 1" style="margin-right: 10rpx;" name="checkmark-circle-fill"
color="##9397c1" size="18"></u-icon>
<view v-else class="contentitemthereonecircle">
</view>
默认地址
</view>
<view class="contentitemtheretow flex-start">
<text @click.stop="edit(item)">编辑</text>
<text style="margin-left: 60rpx;" @click.stop="clickdelete(item)">删除</text>
</view>
</view>
</view>
<view class="positionfixed flex-center" @click="add">
<u-icon name="plus" color="#FFF" size="14"></u-icon>
<view style="margin-left: 20rpx;">添加地址</view>
</view>
<view v-if="list.length==0 && is_end == true" class="flex-colum">
<image style="margin-top: 100rpx;" :src="bgnothave" mode="aspectFill">
</image>
</view>
<u-loadmore :status="form.status" />
<view :style="{height:height}"></view>
</view>
</template>
<script>
export default {
data() {
return {
bgnothave: uni.getStorageSync('bgnothave'),
height: '',
is_order: 0,
list: [],
is_end: false,
form: {
page: 1,
status: 'loadmore',
},
};
},
onLoad(e) {
this.is_order = e.order
},
onReachBottom() {
this.usermyaddresslist()
},
computed: {
theme() {
return this.$store.getters.theme
},
},
mounted() {
var query = uni.createSelectorQuery().in(this).select('.positionfixed')
query.boundingClientRect(ele => {
var that = this;
uni.getSystemInfo({
success(res) {
that.height = ele.height + 50 + "px";
that = null;
}
})
}).exec();
},
onShow() {
this.inif()
},
methods: {
async usermyaddresslist() {
let res = await this.api.usermyaddresslist({
page: this.form.page
})
if (res.length == 0) {
this.is_end = true
this.form.status = 'nomore'
return false;
} else {
this.form.status = 'loading';
this.form.page = ++this.form.page;
setTimeout(() => {
this.list = [...this.list, ...res];
if (res.length == 10) {
this.form.status = 'loading';
} else {
this.is_end = true;
this.form.status = 'nomore';
}
}, 500)
}
},
order_fn(item) {
if (this.is_order == 1) {
uni.$emit('update', JSON.stringify(item));
uni.navigateBack({
delta: 1
})
}
},
add() {
uni.pro.navigateTo('my/address/edit', {
type: 1
})
},
edit(e) {
uni.pro.navigateTo('my/address/edit', {
type: 2,
id: e.id
})
},
inif() {
this.list = []
this.is_end = false,
this.form = {
page: 1,
status: 'loadmore',
},
this.usermyaddresslist()
},
async clickdelete(e) {
var this_ = this
uni.showModal({
title: '提示',
content: '确认删除该地址吗?',
async success(data) {
if (data.confirm) {
let res = await this_.api.useredeleteaddress({
id: e.id
})
if (res) {
this_.inif()
}
}
}
})
}
}
}
</script>
<style lang="scss">
page {
background: #F9F9F9;
}
.content {
padding: 0 30rpx;
.positionfixed {
position: fixed;
background: #f6f6f6;
width: 80%;
bottom: 50rpx;
left: 10%;
padding: 24rpx 34rpx;
text-align: center;
background: var(--bg-color-button);
border-radius: 46rpx;
font-size: 30rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #FFFFFF;
}
.contentitem {
padding: 32rpx 40rpx;
margin-top: 24rpx;
width: 100%;
background: #ffffff;
border-radius: 18rpx;
.contentitemone {
.contentitemone_textone {
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
}
.contentitemone_textyow {
margin-left: 40rpx;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
}
}
.contentitemtow {
margin-top: 12rpx;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.contentitemtow::after {
display: inline-block;
content: '';
margin: 32rpx 0 20rpx 0;
width: 100%;
height: 1rpx;
background: #f6f6f6;
}
.contentitemthere {
.contentitemthereone {
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #5C685D;
}
.contentitemthereonecircle {
margin-right: 10rpx;
border-radius: 50%;
width: 28rpx;
height: 28rpx;
border: 2rpx solid #666666;
}
.contentitemtheretow {
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
}
}
}
</style>