From 8250384a6b443df940062f99064127d77e72c1ec Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 11 二月 2026 18:31:31 +0800
Subject: [PATCH] 提交
---
mini-program/pages/new-address/new-address.vue | 183 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 175 insertions(+), 8 deletions(-)
diff --git a/mini-program/pages/new-address/new-address.vue b/mini-program/pages/new-address/new-address.vue
index 1cb919c..d28ea31 100644
--- a/mini-program/pages/new-address/new-address.vue
+++ b/mini-program/pages/new-address/new-address.vue
@@ -13,10 +13,10 @@
<input type="text" placeholder="璇疯緭鍏ヨ仈绯荤數璇�" v-model="form.phone" />
</view>
</view>
- <view class="list-item">
+ <view class="list-item" @click="show = true">
<view class="list-item-label">鎵�鍦ㄥ湴鍖�</view>
<view class="list-item-sele">
- <text>璇烽�夋嫨</text>
+ <text :style="{ color: form.areaName ? '#333333' : '' }">{{form.areaName ? form.areaName : '璇烽�夋嫨'}}</text>
<u-icon name="arrow-right" color="#B2B2B2" size="16"></u-icon>
</view>
</view>
@@ -30,11 +30,34 @@
<view class="list-item-label">璁句负榛樿鍦板潃</view>
<u-switch v-model="form.isDefault" :activeValue="1" :inactiveValue="0"></u-switch>
</view>
- <view class="box-footer">
- <view class="btn1">鍒犻櫎</view>
- <view class="btn2">淇濆瓨</view>
+ <view class="box-footer" v-if="type === 1">
+ <view class="btn2" @click="submit">淇濆瓨</view>
+ </view>
+ <view class="box-footer" v-if="type === 2">
+ <view class="btn1" @click="show1 = true">鍒犻櫎</view>
+ <view class="btn2" @click="submit">淇濆瓨</view>
</view>
</view>
+ <!-- 鐪佸競鍖� -->
+ <u-picker
+ :show="show"
+ v-if="areaList && areaList.length > 0"
+ ref="uPicker"
+ confirmColor="#ff2c36"
+ keyName="text"
+ :columns="columns"
+ @confirm="confirm"
+ @change="changeHandler"
+ @cancel="show = false" />
+ <u-modal
+ :show="show1"
+ title="绯荤粺鎻愮ず"
+ content='纭鍒犻櫎褰撳墠鏀惰揣鍦板潃鍚�?'
+ confirmColor="#004096"
+ :showConfirmButton="true"
+ :showCancelButton="true"
+ @confirm="dele"
+ @cancel="show1 = false" />
</view>
</template>
@@ -42,8 +65,152 @@
export default {
data() {
return {
- value: 0
+ show: false,
+ show1: false,
+ areaList: [],
+ columns: [],
+
+ type: 1,
+
+ form: {
+ id: null,
+ name: '',
+ phone: '',
+ addr: '',
+ areaId: '',
+ areaName: '',
+ isDefault: 1
+ }
};
+ },
+ onLoad() {
+ const item = uni.getStorageSync('addr');
+ if (item) {
+ this.type = 2
+ uni.setNavigationBarTitle({
+ title: '缂栬緫鏀惰揣鍦板潃'
+ });
+ this.form.id = item.id
+ this.form.name = item.name
+ this.form.phone = item.phone
+ this.form.addr = item.addr
+ this.form.areaId = item.areaId
+ this.form.areaName = item.areaDetail
+ this.form.isDefault = Number(item.isDefault)
+ uni.removeStorageSync('addr');
+ }
+ this.getArea()
+ },
+ methods: {
+ dele() {
+ this.$u.api.deleteAddr({ id: this.form.id })
+ .then(res => {
+ if (res.code === 200) {
+ uni.showToast({ title: '鍒犻櫎鎴愬姛', icon: 'success', mask: true, duration: 1500 })
+ setTimeout(() => {
+ uni.navigateBack({
+ delta: 1
+ });
+ }, 1500)
+ }
+ })
+ },
+ submit() {
+ if (this.type === 1) {
+ this.$u.api.createAddr(this.form)
+ .then(res => {
+ if (res.code === 200) {
+ uni.navigateBack({
+ delta: 1
+ });
+ }
+ })
+ } else {
+ this.$u.api.updateAddr(this.form)
+ .then(res => {
+ if (res.code === 200) {
+ uni.navigateBack({
+ delta: 1
+ });
+ }
+ })
+ }
+ },
+ // 鐪佸競鍖虹‘瀹�
+ confirm(e) {
+ this.form.areaId = e.value[e.value.length - 1].id
+ this.form.areaName = e.value[0].text + e.value[1].text + e.value[2].text
+ this.show = false
+ },
+ changeHandler(e) {
+ const {
+ columnIndex,
+ value,
+ indexs,
+ values, // values涓哄綋鍓嶅彉鍖栧垪鐨勬暟缁勫唴瀹�
+ index,
+ // 寰俊灏忕▼搴忔棤娉曞皢picker瀹炰緥浼犲嚭鏉ワ紝鍙兘閫氳繃ref鎿嶄綔
+ picker = this.$refs.uPicker
+ } = e
+ if (columnIndex === 0) {
+ // 甯�
+ let city = this.areaList[indexs[0]].childList.map(item => {
+ return {
+ id: item.id,
+ text: item.name
+ }
+ })
+ // 鍖�
+ let qu = this.areaList[indexs[0]].childList[0].childList.map(item => {
+ return {
+ id: item.id,
+ text: item.name
+ }
+ })
+ picker.setColumnValues(1, city)
+ picker.setColumnValues(2, qu)
+ } else if (columnIndex === 1) {
+ // 鍖�
+ let qu = this.areaList[indexs[0]].childList[indexs[1]].childList.map(item => {
+ return {
+ id: item.id,
+ text: item.name
+ }
+ })
+ picker.setColumnValues(2, qu)
+ }
+ },
+ getArea() {
+ this.$u.api.treeList({
+ type: 0,
+ flag: 1
+ }).then(res => {
+ if (res.code === 200) {
+ this.areaList = res.data
+ // 鐪�
+ this.columns[0] = this.areaList.map(item => {
+ return {
+ id: item.id,
+ text: item.name
+ }
+ })
+ // 甯�
+ this.columns[1] = this.areaList[0].childList.map(item => {
+ return {
+ id: item.id,
+ text: item.name
+ }
+ })
+ // 鍖�
+ this.columns[2] = this.areaList[0].childList[0].childList.map(item => {
+ return {
+ id: item.id,
+ text: item.name
+ }
+ })
+ }
+ })
+ }
}
}
</script>
@@ -78,8 +245,8 @@
border-radius: 44rpx;
font-weight: 500;
font-size: 32rpx;
- color: #004096;
- border: 1rpx solid #004096;
+ color: #E4001D;
+ border: 1rpx solid #E4001D;
margin-right: 22rpx;
}
.btn2 {
--
Gitblit v1.9.3