Files
soulspace/pages/component/commonComponents/address/index.vue
2025-03-05 15:16:45 +08:00

516 lines
12 KiB
Vue

<template>
<view class="">
<view
class="common_address_box"
:style="`${
backState != 1000 ? 'padding-bottom: 180rpx' : 'padding-bottom: 100rpx'
}`"
>
<z-nav-bar
navFontAlign="left"
title="我的收货地址"
>
<template slot="right"></template>
</z-nav-bar>
<view
class=""
style="padding: 20rpx; background-color: #f9f9f9; height: 100%"
>
<common-list
isCondition="true"
:dataList="addressList"
isNoIcon="true"
@hancleClick="selectAddress"
label="name"
class="common_radius_box color_shandow"
style="background-color: #fff"
>
<template slot="labelSlot" slot-scope="slotProps">
<view class="label_content AC_List">
<view style="width: 100%">
<view class="normal_logo">
{{ getName(slotProps.row.consigneeName) }}
</view>
<view :class="`right`">
<view class="normal_box">
<view class="normal_box_top">
<view class="user_info">
<text class="name">
{{ slotProps.row.consigneeName }}
</text>
<text class="tel">
{{ slotProps.row.consigneePhone }}
</text>
<text
v-if="slotProps.row.isDefault == 1"
class="isDefault"
>默认</text
>
</view>
<view class="curriulum_title"
>{{ slotProps.row.province }}{{ slotProps.row.city
}}{{ slotProps.row.county
}}{{ slotProps.row.detailAddress }}
</view>
</view>
</view>
<!-- 018F89 -->
<u-icon
class="editIcon"
name="edit-pen-fill"
color="#7dc1f0"
size="20"
@click.native.stop="handleClickEdit(slotProps.row)"
style="display: inline-block; margin-left: 10rpx"
></u-icon>
<u-icon
class="editIcon"
name="trash-fill"
color="red"
size="20"
@click.native.stop="handleClickDelete(slotProps.row.id)"
style="display: inline-block; margin-left: 10rpx"
></u-icon>
</view>
</view>
<view> </view>
</view>
</template>
<template slot="rightSlot" slot-scope="slotProps">
<view> </view>
</template>
</common-list>
</view>
<view class="goods_nav_box">
<uni-goods-nav
:fill="true"
:options="buyOptions"
:button-group="customButtonGroup1"
@click="onHandleClickIcon"
@buttonClick="onHandleClickBuy"
/>
</view>
</view>
<u-modal
:show="showModal"
:title="modalInfo.title"
:content="modalInfo.content"
showCancelButton
@confirm="deleteAddress"
@cancel="hancleModalCancel"
></u-modal>
</view>
</template>
<script>
import courseDescription from "@/pages/component/commonComponents/list";
import editAddress from "./edit.vue";
import $http from "@/config/requestConfig.js";
import { mapState } from "vuex";
export default {
components: {
courseDescription, //课程说明
editAddress, //编辑收货地址
},
props: ["backState", "type"],
data() {
return {
isEdit: false,
showModal: false,
addressData: {},
buyOptions: [],
customButtonGroup1: [
{
with: 200,
text: "+ 添加收货地址",
backgroundColor: "linear-gradient(90deg, #294a97 0%, #7dc1f0 80%)",
color: "#fff",
},
],
show: false,
addressList: [],
urlList: {
list: "common/userAddress/getUserAddress",
curriculumInfo: "app/phone.do?getCourseInfo",
detailInfo: "app/phoneDoctor.do?getTaiHuClassInfo_new",
delete: "common/userAddress/delete",
},
customButton: [
{
width: "340rpx",
text: "立即支付",
backgroundColor: "linear-gradient(90deg, #3AB3AE 0%, #117e4c 100%)",
color: "#fff",
},
],
modalInfo: {},
};
},
onLoad(options) {
this.options = options;
this.getData();
// this.getUserInfo()
// this.getCateList()
},
onHide() {
// this.showSearchList = false
// this.searchList = []
},
onShow() {
this.selectPayIndex = 0;
this.getData();
},
computed: {
...mapState(["userInfo"]),
},
methods: {
hancleModalCancel() {
this.showModal = false;
},
backClick() {
this.$emit("fresh");
},
handleFresh() {
this.getData();
},
onHandleClickIcon() {
this.isEdit = true;
},
onHandleClickBuy() {
uni.navigateTo({
url: "/pages/component/commonComponents/address/edit",
});
},
handleClickEdit(data) {
console.log("data at line 145:", data);
uni.navigateTo({
url: "/pages/component/commonComponents/address/edit?id=" + data.id,
});
},
deleteAddress() {
var data = {};
$http
.request({
url: `${this.urlList.delete}?id=${this.selectAddressId}`,
method: "Get",
data,
header: {
"Content-Type": "application/json",
},
})
.then((res) => {
console.log("res at line 252:", res);
this.showModal = false;
if (res.code == 0) {
this.getData();
}
});
},
handleClickDelete(id) {
this.modalInfo = { title: "提示信息", content: "确定要删除该地址吗?" };
this.selectAddressId = id;
this.showModal = true;
},
getName(name) {
console.log("name at line 140:", name);
if (name) {
if (name.length <= 2) {
return name;
} else {
return name.substring(0, 1);
}
}
},
open() {
this.getData();
},
fnCopy(value, title) {
this.$commonJS.handleMakingPhoneCalls(value, title);
},
gotoPhone() {
this.$commonJS.handleMakingPhoneCalls("022-24142321");
},
radioChange(index) {
this.selectPayIndex = index;
console.log("this.selectPayIndex at line 315:", this.selectPayIndex);
this.$forceUpdate();
},
handleValChange(e) {
console.log("e at line 424:", e);
},
buttonClick(e) {
console.log(e);
this.options[2].info++;
},
hancleModalConfirm() {
var data = {
values: {
customerType: "D",
token: uni.getStorageSync("token"),
customerOid: uni.getStorageSync("customerOid"),
...this.taiHuClassInfo,
},
};
},
selectAddress(v) {
// 当前页面
// 在源页面中使用 uni.navigateBack 返回上一页面并传递参数
if (this.options.type == "order") {
uni.$emit("returnData", v);
uni.navigateBack({
delta: 1, // 返回上一级页面
});
}
},
async getData() {
var data = {};
var that = this;
$http
.request({
url: `${this.urlList.list}?userId=${this.userInfo.id}`,
method: "POST",
data,
header: {
"Content-Type": "application/json",
},
})
.then(async (res) => {
console.log("res at line 374:", res);
if (res.code == 0) {
this.addressList = res.list;
}
this.$forceUpdate();
});
},
getPriceData() {
var that = this;
setTimeout(() => {
that.$nextTick(() => {
that.$refs.priceDetail.getData();
});
}, 100);
},
// 检查是有权限使用搜索功能
checkDisable() {
console.log("点击了");
},
// 获取用户详情
getUserInfo() {
// 用户详情
if (this.userInfo.id != undefined) {
this.$http.post("book/user/info/" + this.userInfo.id).then((res) => {
this.userMes = res.user;
this.getCateList();
console.log(this.userMes, "呼呼");
});
}
},
async handleselectCate(item, index) {
this.dataList = [];
var data = [];
console.log(item, index, 99999);
var that = this;
// curriculumInfo
this.$http
.post(this.urlList.curriculumInfo, {
customerType: "D",
token: uni.getStorageSync("token"),
customerOid: uni.getStorageSync("customerOid"),
oid: item.coid,
})
.then(async (res) => {
that.curriculumInfo = res.obj;
that.dataList = res.obj.courseList;
});
this.searchValue = "";
this.searchList = [];
this.showSearchList = false;
return data;
},
async getDetailInfo() {
var that = this;
this.searchValue = "";
this.searchList = [];
this.showSearchList = false;
return data;
},
async setOneCateIndex(item, index) {
this.allDataList = [];
console.log(index, 99999);
var that = this;
this.currentStatusIndex = index;
this.searchValue = "";
this.searchList = [];
this.showSearchList = false;
this.$nextTick(async () => {
await that.getData();
this.$forceUpdate();
});
},
transformData(inputData) {
const result = {};
inputData.forEach((item) => {
const { letter } = item;
if (!result[letter]) {
result[letter] = [];
}
result[letter].push(item);
});
return result;
},
getCateList(id) {
id ? "" : (id = 0);
this.twoCateList = [];
this.curTwoCateIndex = 0;
},
// 放大图片
previewImage(url) {
console.log(url);
uni.previewImage({
urls: [url],
longPressActions: {
itemList: ["很抱歉,暂不支持保存图片到本地"],
success: function (res) {
// console.log(res,'+++++')
},
},
});
},
},
onBackPress() {
// #ifdef APP-PLUS
plus.key.hideSoftKeybord();
// #endif
},
};
</script>
<style lang="scss" scoped>
@import '@/static/mixin.scss';
/deep/.list_item {
padding-left: 0 !important;
padding-right: 0 !important;
}
.AC_List {
width: 100%;
overflow: hidden;
display: flex;
align-items: center;
background-color: #fff;
}
.curriulum_title {
width: 100%;
font-weight: 500;
font-size: 28rpx;
white-space: wrap; /* 禁止文本换行 */
overflow: hidden;
margin-top: 10rpx;
float: left;
margin-bottom: 5rpx;
color: #b0b0b0;
// padding: 20rpx;
box-sizing: border-box;
text {
margin-right: 10rpx;
}
}
.right {
width: calc(100% - 100rpx);
display: flex;
align-items: center;
}
.user_info {
width: 100%;
float: left;
display: flex;
margin-top: 10rpx;
align-items: center;
font-size: 32rpx;
font-weight: 800;
.name {
max-width: calc(100% - 300rpx);
white-space: nowrap; /* 禁止文本换行 */
overflow: hidden; /* 隐藏超出容器的文本 */
text-overflow: ellipsis; /* 使用省略号代替隐藏的内容 */
display: inline-block;
color: #333;
margin-right: 10rpx;
}
.tel {
color: #000;
font-size: 28rpx;
font-weight: 600;
}
}
.common_address_box {
width: 100vw;
height: 100vh;
background-color: #fdfbfb;
}
.normal_box {
width: calc(100% - 60rpx);
height: auto;
float: left;
// overflow: hidden;
.normal_box_top {
width: 100%;
// display: flex;
height: auto;
margin-bottom: 40rpx;
}
.editIcon {
float: right;
}
}
.normal_logo {
width: 80rpx !important;
height: 80rpx !important;
border-radius: 80rpx;
background-color: $themeBgColor;
color: #7dc1f0;
font-size: 34rpx;
font-weight: bold;
text-align: center;
line-height: 80rpx;
float: left;
margin-right: 20rpx;
}
.isDefault {
color: #7dc1f0;
font-size: 22rpx;
font-weight: 600;
border: 1rpx solid $themeColor;
padding: 2rpx 10rpx;
border-radius: 6rpx;
line-height: 30rpx;
margin-left: 18rpx;
}
</style>