123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>详情-收货地址-创业帮</title>
- <meta name="keywords" content="详情-收货地址-创业帮">
- <meta name="description" content="详情-收货地址-创业帮">
- <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <meta content="telephone=no" name="format-detection">
- <meta content="email=no" name="format-detection">
- <meta name="apple-mobile-web-app-title" content="详情-收货地址-创业帮">
- <meta http-equiv="Cache-Control" content="no-siteapp">
- <link rel="stylesheet" href="./static/css/main.css">
- </head>
- <body class="bgc-back">
- <div id="app" v-cloak>
- <van-nav-bar class="user_rank_explan_title user_title_normal f16 rightbtn" :title="addresstype == 1? '新增收货地址':'修改收货地址'" v-if="toptitleisshow" @click-left="back" right-text="保存" @click-right="saveclick" left-arrow v-cloak>
- <template #left><img src="./static/images/icon-comback@2x.png" alt=""></template>
- </van-nav-bar>
- <div class="address-list" v-cloak>
- <van-address-edit class="itemaddress" :area-list="areaList" :address-info="addressinfo" show-delete show-set-default show-search-result :area-columns-placeholder="['请选择', '请选择', '请选择']" @save="onSave"></van-address-edit>
- </div>
- <van-popup v-model="show">内容</van-popup>
- </div>
- <script src="./static/js/arealist.js"></script>
- <script src="./static/js/klm-vv.min.js"></script>
- <script src="./static/js/appfunc.min.js"></script>
- <script src="./static/js/klm-axios-config.js"></script>
- <script src="./static/js/publicfn.js"></script>
- <script>
- // 通过 CDN 引入时不会自动注册 Lazyload 组件
- // 可以通过下面的方式手动注册
- Vue.use(vant.Lazyload);
-
- // 在 #app 标签下渲染一个按钮组件
- let app = new Vue({
- el: '#app',
- data() {
- return {
- toptitleisshow:false,
- areaList:areaList,
- //- searchResult: [],
- show: false,
- addresstype:1,
- areainfo:{
- //- 详细地址
- Address:'',
- //- 姓名
- RealName:'',
- //- 手机
- Mobile:'',
- //- 用户ID
- UserId:'',
- //- 地区
- Areas:'',
- //- 是否默认地址
- IsDefault:'',
- },
- addressinfo:{
- name:'', // 姓名
- tel:'', // 电话号码
- addressDetail:'', // 地址详情
- isDefault:'', // 是否为默认地址
- areaCode:'', // 地区编码
- },
- addressId:'',
- };
- },
- created() {
- this.toptitleisshow = toptitleisshow;
- this.addresstype = PublicLib.getCookieInfo('addresstype');
- if(this.addresstype !== '1') {
- this.getaddressdetail();
- };
- },
- methods: {
- saveclick(){
- document.querySelector(".van-button--danger").click();
- },
- async getaddressdetail(){
- this.addressId = PublicLib.getCookieInfo('editaddressId');
- const UserId = PublicLib.getCookieInfo('userId');
- const res = await getRequest('api/v1/useraddress/detail?t='+Math.random(6),JSON.stringify({Id:this.addressId,UserId}));
- if(res.status !== '1') return tips('获取收货地址详情失败,请重试!','middle');
- this.addressinfo.name = res.data.RealName;
- this.addressinfo.tel = res.data.Mobile;
- this.addressinfo.addressDetail = res.data.Address;
- this.addressinfo.isDefault = res.data.IsDefault === 1? true : false;
- this.getareaCode(res.data.Areas);
- },
- //- 识别当前用户地区函数
- getareaCode(str){
- const addresscounty = str.split(',')[str.split(',').length -1]
- const addresscity = str.split(',')[str.split(',').length -2]
-
- for(const key in areaList.county_list){
- if(addresscounty === areaList.county_list[key]){
- this.addressinfo.areaCode = key;
- return;
- };
- };
- for(const key in areaList.city_list){
- if(addresscity === areaList.city_list[key]){
- this.addressinfo.areaCode = key;
- };
- };
- },
- onSave(content) {
- this.areainfo.Address = content.addressDetail;
- this.areainfo.RealName = content.name;
- this.areainfo.Mobile = content.tel;
- this.areainfo.UserId = PublicLib.getCookieInfo('userId');
- this.areainfo.Areas = content.province + "," + content.city + "," + content.county;
- this.areainfo.IsDefault = content.isDefault ? 1 : 0;
- if(this.addresstype === '1') {
- this.saveaddress();
- }else{
- this.editaddress();
- };
- },
- //- 新增收货地址
- async saveaddress(){
- const res = await postRequest('api/v1/useraddress/add?t='+Math.random(6),JSON.stringify(this.areainfo));
- if(res.status !== '1') return tips('收货地址保存失败!','middle');
- tips('收货地址保存成功','middle')
- PublicLib.putCookieInfo('addaddressId', res.data.Id);
- setTimeout(()=>{
- this.back();
- },1000);
- },
- //- 修改收货地址
- async editaddress(){
- const res = await postRequest('api/v1/useraddress/update?t='+Math.random(6),JSON.stringify({...this.areainfo,Id:this.addressId}));
- if(res.status !== '1') return tips('收货地址修改失败!','middle');
- tips('收货地址修改成功','middle');
- PublicLib.putCookieInfo('addaddressId', res.data.Id);
- setTimeout(()=>{
- this.back();
- },1000);
- },
- //- 联想搜索保留
- //- onChangeDetail(val) {
- //- if (val=== "黄") {
- //- this.searchResult = [
- //- {
- //- name: '黄龙万科中心',
- //- address: '杭州市西湖区',
- //- },
- //- ];
- //- } else {
- //- this.searchResult = [];
- //- }
- //- },
- back(){
- PublicLib.GoBack({Level:1});
- }
- },
- });
- </script>
- </body>
- </html>
|