Files
lucky_shop/pages_tool/member/address_edit.vue
ZF sun 5f41febd70 chore(i18n): 清理死代码 + 遗留 lang 文件 + 旧工具
## 删除的死代码脚本
- scripts/i18n_class_c.py (脚本自承'新架构下永远输出 0',纯防御性)
- scripts/full_migrate_i18n.py (其产出违反 CLAUDE.md 1.2 中文 key 铁律,已标 DEPRECATED)
- scripts/__pycache__/ (Python 缓存)

## 删除的旧 per-page lang 文件
- lang/zh-cn/<page>/<file>.js (140 个)
- lang/en-us/<page>/<file>.js (139 个)
- 共 279 个文件,运行时不再加载,0 个 key 被 .vue 调用(经 diagnose_keys.py 验证)

## 删除的备份和迁移表
- lang/_backup/ (git 已跟踪原文件)
- lang/_migration_map.json / lang/_migration-map.json (运行时不用)

## 删除的中间产物 JSON
- docs/i18n-rename-*.json (smart_rename 中间产物,已用完)
- docs/i18n-ambiguous.json / i18n-audit.json / i18n-call-rewrite.log /
  i18n-clean-dead.log / i18n-file-texts.json / i18n-page-titles.json /
  i18n-vue-extract.json (前一会话残留,无引用方)
- docs/i18n-{naming,shadow,strict}-audit.json (脚本会自动重新生成)

## 删除的 modular lang 文件
- lang/zh-cn/*.js / lang/en-us/*.js (20 个模块文件,内容是上一会话产生的死代码)
- lang/zh-cn/index.js / lang/en-us/index.js (聚合入口)
- lang/DEPRECATED.md (已不再相关)

## 删除的不成熟脚本
- scripts/check_perpage.py (诊断用,已完成)
- scripts/diagnose_keys.py (诊断用,已完成)
- scripts/smart_rename_i18n.py (v1-v3 都 bug,未修完)

## 现状
- lang/ 现在只有 zh-cn.js + en-us.js (单文件,运行时实际加载)
- 这两个文件已被 smart_rename 部分修复: camelCase → snake_case (8 个 key)
- 命名违规从 8236 降到 3505 (剩余都在单文件,可独立 commit 修复)
- 1362 个 orphan () 调用仍存在,详见 docs/i18n-handoff.md
2026-06-25 10:48:15 +08:00

497 lines
21 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="address-edit-content" :style="themeColor">
<view class="edit-wrap">
<view class="tip">{{ $lang("member.address_edit.l4") }}</view>
<view class="edit-item">
<text class="tit">
{{ $lang('member.list.consignee') }}
<text>*</text>
</text>
<input
class="uni-input"
type="text"
placeholder-class="placeholder-class"
:placeholder="$lang('member.list.consignee_placeholder')"
maxlength="30"
name="name"
v-model="formData.name" />
</view>
<view class="edit-item">
<text class="tit">
{{ $lang('login.list.mobile') }}
<text>*</text>
</text>
<input class="uni-input" type="number" placeholder-class="placeholder-class" :placeholder="$lang('login.list.mobile_placeholder')" maxlength="11" v-model="formData.mobile" />
</view>
<view class="edit-item">
<text class="tit">{{ $lang('login.list.telephone') }}</text>
<input
class="uni-input"
type="text"
placeholder-class="placeholder-class"
:placeholder="$lang('login.list.telephone_placeholder')"
maxlength="20"
v-model="formData.telephone" />
</view>
<!-- 外卖地址区分 -->
<block v-if="localType == 2">
<view class="edit-item">
<text class="tit">
{{ $lang('common.list.receiving_city') }}
<text>*</text>
</text>
<view class="text_inp" :class="{ empty: !formData.full_address, 'color-tip': !formData.full_address }" @click="selectAddress">
{{ formData.full_address ? formData.full_address : $lang('member.address_edit.l44') }}
</view>
<text @click="selectAddress" class="padding-left iconfont icon-location"></text>
</view>
</block>
<block v-else>
<view class="edit-item">
<text class="tit">
{{ $lang('common.list.receiving_city') }}
<text>*</text>
</text>
<pick-regions :default-regions="defaultRegions" @getRegions="handleGetRegions">
<text class="select-address " :class="{ empty: !formData.full_address, 'color-tip': !formData.full_address }">
{{ formData.full_address ? formData.full_address : $lang('member.address_edit.l44') }}
</text>
</pick-regions>
</view>
</block>
<view class="edit-item">
<text class="tit" style="">
{{ $lang('address') }}
<text>*</text>
</text>
<input class="uni-input" type="text" placeholder-class="placeholder-class" :placeholder="$lang('member.list.address_placeholder')" maxlength="50" v-model="formData.address" />
<!-- <textarea class="uni-input " type="text" placeholder-class="placeholder-class" :placeholder="$lang('member.list.address_placeholder')" maxlength="50" v-model="formData.address" ></textarea> -->
</view>
</view>
<view class="btn">
<button type="primary" class="add" @click="saveAddress">{{ $lang('common.button.save') }}</button>
</view>
<loading-cover ref="loadingCover"></loading-cover>
</view>
</template>
<script>
import validate from 'common/js/validate.js';
import Config from '@/common/js/config.js';
export default {
data() {
return {
formData: {
id: 0,
name: '',
mobile: '',
telephone: '',
province_id: '',
city_id: '',
district_id: '',
community_id: '',
address: '',
full_address: '',
latitude: 0,
longitude: 0,
is_default: 1
},
address: '',
addressValue: '',
back: '', // 返回页
redirect: 'redirectTo', // 跳转方式
flag: false, //防重复标识
defaultRegions: [],
localType: 1
};
},
onLoad(option) {
if (option.back) this.back = option.back;
if (option.redirect) this.redirect = option.redirect;
if (option.type) this.localType = option.type;
if (option.id && !option.name) {
this.formData.id = option.id;
this.getAddressDetail();
} else if (option.name) {
if (uni.getStorageSync('addressInfo')) this.formData = uni.getStorageSync('addressInfo');
this.formData.address = option.name;
this.localType = 2;
this.getAddress(option.latng);
//给formData复制
var tempArr = this.getQueryVariable('latng').split(',');
this.formData.latitude = tempArr[0];
this.formData.longitude = tempArr[1];
} else {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
},
onBackPress() {
uni.setStorageSync('addressInfo', '');
},
onShow() {
if (this.formData.id) {
uni.setNavigationBarTitle({
title: $lang('member.address_edit.l138')
});
} else {
uni.setNavigationBarTitle({
title: $lang('member.address_edit.l142')
});
}
},
onReady() {
this.$refs.loadingCover.hide();
},
onHide() {
this.flag = false;
},
methods: {
// 获取地址信息
getAddressDetail() {
this.$api.sendRequest({
url: '/api/memberaddress/info',
data: {
id: this.formData.id
},
success: res => {
let data = res.data;
if (data != null) {
this.formData.name = data.name;
this.formData.mobile = data.mobile;
this.formData.telephone = data.telephone;
this.formData.address = data.address;
this.formData.full_address = data.full_address;
this.formData.latitude = data.latitude;
this.formData.longitude = data.longitude;
this.formData.is_default = data.is_default;
this.localType = data.type;
this.defaultRegions = [data.province_id, data.city_id, data.district_id];
}
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
},
fail: res => {
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
}
});
},
//获取详细地址
getAddress(value) {
this.$api.sendRequest({
url: '/api/memberaddress/tranAddressInfo',
data: {
latlng: value
},
success: res => {
if (res.code == 0) {
this.formData.full_address = '';
this.formData.full_address += res.data.province != undefined ? res.data.province : '';
this.formData.full_address += res.data.city != undefined ? '-' + res.data.city : '';
this.formData.full_address += res.data.district != undefined ? '-' + res.data.district : '';
this.addressValue = '';
this.addressValue += res.data.province_id != undefined ? res.data.province_id : '';
this.addressValue += res.data.city_id != undefined ? '-' + res.data.city_id : '';
this.addressValue += res.data.district_id != undefined ? '-' + res.data.district_id : '';
} else {
this.showToast({
title: $lang('member.address_edit.l200')
});
}
}
});
},
// 获取选择的地区
handleGetRegions(regions) {
this.formData.full_address = '';
this.formData.full_address += regions[0] != undefined ? regions[0].label : '';
this.formData.full_address += regions[1] != undefined ? '-' + regions[1].label : '';
this.formData.full_address += regions[2] != undefined ? '-' + regions[2].label : '';
this.addressValue = '';
this.addressValue += regions[0] != undefined ? regions[0].value : '';
this.addressValue += regions[1] != undefined ? '-' + regions[1].value : '';
this.addressValue += regions[2] != undefined ? '-' + regions[2].value : '';
},
selectAddress() {
// #ifdef MP
/* uni.chooseLocation({
success: res => {
this.formData.latitude = res.latitude;
this.formData.longitude = res.longitude;
this.formData.address = res.name;
this.getAddress(res.latitude + ',' + res.longitude);
},
fail(res) {
uni.getSetting({
success: function(res) {
var statu = res.authSetting;
if (!statu['scope.userLocation']) {
uni.showModal({
title: $lang('member.address_edit.l233'),
content: $lang('member.address_edit.l234'),
success(tip) {
if (tip.confirm) {
uni.openSetting({
success: function (data) {
if (data.authSetting['scope.userLocation'] === true) {
this.$util.showToast({
title: $lang('member.address_edit.l241')
});
//授权成功之后,再调用chooseLocation选择地方
setTimeout(function () {
uni.chooseLocation({
success: data => {
this.formData.latitude = res.latitude;
this.formData.longitude = res.longitude;
this.formData.address = res.name;
this.getAddress(res.latitude + ',' + res.longitude);
}
});
}, 1000);
}
}
});
} else {
this.$util.showToast({
title: $lang('member.address_edit.l259')
});
}
}
});
}
}
});
}
});*/
// #endif
// #ifdef H5
var urlencode = this.formData;
uni.setStorageSync('addressInfo', urlencode);
let backurl = Config.h5Domain + '/pages_tool/member/address_edit?type=' + this.localType;
if (this.formData.id) backurl += '&id=' + this.formData.id;
if (this.back) backurl += '&back=' + this.back;
window.location.href = 'https://apis.map.qq.com/tools/locpicker?search=1&type=0&backurl=' + encodeURIComponent(backurl) + '&key=' + Config.mpKey + '&referer=myapp';
// #endif
},
getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (pair[0] == variable) {
return pair[1];
}
}
return false;
},
vertify() {
this.formData.name = this.formData.name.trim();
this.formData.mobile = this.formData.mobile.trim();
this.formData.address = this.formData.address.trim();
var rule = [{
name: 'name',
checkType: 'required',
errorMsg: $lang('member.account_edit.l163')
},
{
name: 'mobile',
checkType: 'required',
errorMsg: $lang('common.ns-login.l16.t0')
},
{
name: 'mobile',
checkType: 'phoneno',
errorMsg: $lang('common.ns-login.l393.t0')
},
{
name: 'full_address',
checkType: 'required',
errorMsg: $lang('member.address_edit.l44')
},
{
name: 'address',
checkType: 'required',
errorMsg: $lang('member.address_edit.l319')
}
];
var checkRes = validate.check(this.formData, rule);
if (checkRes) {
return true;
} else {
this.$util.showToast({
title: validate.error
});
this.flag = false;
return false;
}
},
saveAddress() {
if (this.flag) return;
this.flag = true;
if (this.vertify()) {
let addressValueArr = this.addressValue.split('-'),
data = {},
url = '';
data = {
name: this.formData.name,
mobile: this.formData.mobile,
telephone: this.formData.telephone,
province_id: addressValueArr[0],
city_id: addressValueArr[1],
district_id: addressValueArr[2] ? addressValueArr[2] : '',
community_id: 0,
address: this.formData.address,
full_address: this.formData.full_address,
latitude: this.formData.latitude,
longitude: this.formData.longitude,
is_default: this.formData.is_default,
type: this.localType
};
url = 'add';
if (this.formData.id) {
url = 'edit';
data.id = this.formData.id;
if (this.back != '') data.is_default = 1;
}
this.$api.sendRequest({
url: '/api/memberaddress/' + url,
data: data,
success: res => {
this.flag = false;
if (res.code == 0) {
if (this.back != '') {
this.$util.redirectTo(this.back, {}, 'redirectTo');
} else {
this.$util.showToast({
title: res.message
});
uni.navigateBack({
delta: 1
});
}
uni.removeStorageSync('addressInfo');
} else {
this.$util.showToast({
title: res.message
});
}
},
fail: res => {
this.flag = false;
}
});
}
}
}
};
</script>
<style lang="scss">
::v-deep pick-regions,
.pick-regions {
flex: 1;
}
.edit-wrap {
background: #fff;
overflow: hidden;
.tip {
padding: 20rpx 30rpx 10rpx;
background-color: #f8f8f8;
color: $color-tip;
}
}
.edit-item {
display: flex;
align-items: center;
margin: 0 30rpx;
min-height: 100rpx;
background-color: #fff;
.text_inp {
margin-left: $margin-updown;
flex: 1;
}
.tit {
width: 148rpx;
text {
margin-left: 10rpx;
color: #ff4544;
}
&.margin_tit {
align-self: flex-start;
margin-top: 24rpx;
}
}
.icon-location {
color: #606266;
align-self: flex-start;
margin-top: 20rpx;
}
.select-address {
display: block;
margin-left: 10rpx;
&.empty {
color: #808080;
}
}
textarea,
input {
flex: 1;
font-size: $font-size-base;
margin-left: 20rpx;
padding: 0;
}
textarea {
margin-top: 6rpx;
height: 100rpx;
padding-bottom: 20rpx;
padding-top: 20rpx;
line-height: 50rpx;
}
}
.edit-wrap>.edit-item+.edit-item {
border-top: 2rpx solid #ebedf0;
}
.add {
margin-top: 60rpx;
height: 80rpx;
line-height: 80rpx !important;
border-radius: 80rpx;
font-weight: 500;
width: calc(100% - 60rpx);
margin-left: 30rpx;
font-size: 32rpx;
}
.btn {
position: fixed;
width: 100%;
bottom: 30rpx;
height: auto;
padding-bottom: constant(safe-area-inset-bottom);
/*兼容 IOS<11.2*/
padding-bottom: env(safe-area-inset-bottom);
/*兼容 IOS>11.2*/
}
</style>