123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <view>
- <view>
- <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" back-icon-color="#fff" title-color="#fff"
- :background="background" title-width="300" :title="i18n('editConsignee')"></u-navbar>
- </view>
- <view style="background: #fff;box-sizing:border-box;padding: 20rpx;">
- <u-form :model="form" ref="uForm">
- <u-form-item label-width="140rpx" :label="$i18n.locale == 'zh' ? '姓名:' : 'Name:'">
- <u-input :placeholder="$i18n.locale == 'zh'? '请输入姓名': 'Please enter your name'" type="text"
- :border="border" v-model="form.name" />
- </u-form-item>
- <u-form-item label-width="140rpx" :label="$i18n.locale == 'zh' ? '手机号码:' : 'Phone:'">
- <u-input :placeholder="$i18n.locale == 'zh'? '请输入手机号码': 'Please enter your phone'" type="text"
- :border="border" v-model="form.phone" />
- </u-form-item>
- <u-form-item label-width="140rpx" :label="$i18n.locale == 'zh' ? '邮政编码:' : 'Code:'">
- <u-input :placeholder="$i18n.locale == 'zh'? '请输入邮政编码': 'Please enter your post code'" type="text"
- :border="border" v-model="form.postCode" />
- </u-form-item>
- <u-form-item v-if="$i18n.locale == 'zh'" label-width="140rpx"
- :label="$i18n.locale == 'zh' ? '所在区域:' : 'Area:'">
- <u-input :disabled='info' :placeholder="$i18n.locale == 'zh'? '请选择地区': 'Please select a region'"
- @tap='cancelInfo' :border="border" v-model="this.form.division"></u-input>
- <u-select v-model="show" mode="muitl-column-auto" child-name="child" value-name="id"
- label-name="name" :list="sysAreaList" @confirm="confirm">
- </u-select>
- <u-picker mode="region" v-model="show" :area-code='["11", "1101", "110101"]' @confirm="confirm">
- </u-picker>
- </u-form-item>
- <u-form-item label-width="140rpx" :label="$i18n.locale == 'zh' ? '详细地址:' : 'Detail:'">
- <u-input :placeholder="$i18n.locale == 'zh'? '请输入详细地址': 'Please enter detail address'" type="text"
- :border="border" v-model="form.address" />
- </u-form-item>
- <u-form-item>
- <u-checkbox-group>
- <u-checkbox v-model="form.status" shape="circle">
- {{$i18n.locale=='zh'?'设为默认地址':'Set as default address'}}
- </u-checkbox>
- </u-checkbox-group>
- </u-form-item>
- </u-form>
- <view>
- <u-button @click="save" shape="circle" type="primary">
- <text style="margin-left:20rpx">{{$i18n.locale=='zh'?'保存':'Save'}}</text>
- </u-button>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- addUmsUserCommodityAddresss,
- getUmsUserCommodityAddresss
- } from "@/api/address"
- export default {
- data() {
- return {
- info: true,
- background: {
- backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
- },
- backStyle: {
- color: '#FFFFFF',
- },
- name: "name",
- id: "id",
- child: "child",
- test: [],
- form: {
- name: '',
- phone: '',
- postCode: '',
- division: "",
- address: "",
- status: false,
- },
- border: true,
- show: false,
- userId: null,
- addressId: null,
- addressDetail: {},
- sysAreaList: [],
- }
- },
- onShow() {
- this.getAddressDetail()
- },
- onLoad() {
- let option = uni.getStorageSync("addressId");
- this.addressId = option
- },
- methods: {
- cancelInfo() {
- uni.hideKeyboard()
- this.show = true
- },
- navTo(route) {
- this.$mRouter.push({
- route
- });
- },
- i18n(data) {
- return this.$t('common.' + data);
- },
- getAddressDetail() {
- console.log(this.addressId, '111')
- getUmsUserCommodityAddresss(this.addressId).then(res => {
- console.log(res, '2222');
- this.addressDetail = res.data.umsUserCommodityAddresss[0]
- this.form.name = this.addressDetail.consignee;
- this.form.phone = this.addressDetail.mobile;
- this.form.postCode = this.addressDetail.postalCode;
- this.form.address = this.addressDetail.address;
- this.form.division = this.addressDetail.province + '/' + this.addressDetail.city + '/' + this
- .addressDetail.area;
- this.form.status = this.addressDetail.status == '1' ? true : false
- }).catch(e => {
- console.log("======>>>>", e);
- })
- },
- async save() {
- this.userId = JSON.parse(uni.getStorageSync("user"))
- let params = {
- id: this.addressId,
- // userId: this.userId.id,
- consignee: this.form.name,
- mobile: this.form.phone,
- province: this.test[0] ? this.test[0] : this.addressDetail.province,
- city: this.test[1] ? this.test[1] : this.addressDetail.city,
- area: this.test[2] ? this.test[2] : this.addressDetail.area,
- address: this.form.address,
- postalCode: this.form.postCode,
- status: this.form.status ? '1' : '0',
- };
- console.log(params)
- const tokendata = await this.$myRequest({
- url: '/sys/token',
- method: 'get'
- });
- addUmsUserCommodityAddresss(params, tokendata.data).then((res) => {
- if (res.status == '200') {
- this.navTo('/pages/profile/personIntegrate/userAddress')
- }
- });
- },
- confirm(e) {
- console.log(e)
- this.form.division = e.province.label + '/' + e.city.label + '/' + e.area.label;
- let str = e.province.label + '/' + e.city.label + '/' + e.area.label;
- this.test = str.split('/')
- }
- }
- }
- </script>
- <style>
- </style>
|