|
|
@@ -0,0 +1,247 @@
|
|
|
+<template>
|
|
|
+ <div class="shipments_address_edit">
|
|
|
+ <div class="form_line" ref="addressContent">
|
|
|
+ <ul class="list-unstyled" >
|
|
|
+ <li>
|
|
|
+ <div class="com_left pull-left"><span>*</span>发货人姓名:</div>
|
|
|
+ <div class="form_input">
|
|
|
+ <input type="text" placeholder="请输入您的姓名" v-model="params.name" maxlength="10">
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <div class="com_left pull-left"><span>*</span>联系电话:</div>
|
|
|
+ <div class="form_input">
|
|
|
+ <input type="tel" placeholder="请输入您的联系电话" v-model="params.tel" maxlength="11">
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <div class="com_left pull-left">邮箱:</div>
|
|
|
+ <div class="form_input">
|
|
|
+ <input type="email" placeholder="请输入正确邮箱,用于接收订单提醒" v-model="params.email">
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <div class="com_left pull-left"><span>*</span>所在地区:</div>
|
|
|
+ <div class="form_input" @click="addressShow = true">
|
|
|
+ <span v-text="params.area || '选择地区'">选择地区</span>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <div class="com_left pull-left"><span>*</span>详细地址:</div>
|
|
|
+ <div class="form_input">
|
|
|
+ <input type="text" placeholder="请您填写详细地址,街道名、门牌号等" v-model="params.detailAddress" maxlength="30">
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <div class="com_left pull-left"><span>*</span>默认地址:</div>
|
|
|
+ <div class="form_input">
|
|
|
+ <el-switch
|
|
|
+ v-model="isActive"
|
|
|
+ on-text="ON"
|
|
|
+ off-text="OFF">
|
|
|
+ </el-switch>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ <div class="control clearfix">
|
|
|
+ <div class="cancel" @click="storeInfosave('cancel')">取消</div>
|
|
|
+ <div class="save" @click="storeInfosave()">保存</div>
|
|
|
+ </div>
|
|
|
+ <select-address :isShow="addressShow" @closeAction="addressData"></select-address>
|
|
|
+ <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
|
|
|
+ <div v-if="storeI && false"></div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import BScroll from 'better-scroll'
|
|
|
+ import { RemindBox } from '~components/mobile/common'
|
|
|
+ import SelectAddress from './SelectAddress.vue'
|
|
|
+ export default {
|
|
|
+ name: 'AddressEditView',
|
|
|
+ props: {
|
|
|
+ data: {
|
|
|
+ type: Object,
|
|
|
+ default: {}
|
|
|
+ },
|
|
|
+ isSend: {
|
|
|
+ default: true,
|
|
|
+ type: Boolean
|
|
|
+ },
|
|
|
+ isPersonal: {
|
|
|
+ default: true,
|
|
|
+ type: Boolean
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ params: {
|
|
|
+ area: '',
|
|
|
+ detailAddress: '',
|
|
|
+ email: '',
|
|
|
+ tel: '',
|
|
|
+ name: '',
|
|
|
+ province: '',
|
|
|
+ city: '',
|
|
|
+ district: ''
|
|
|
+ },
|
|
|
+ isActive: false,
|
|
|
+ addressShow: false,
|
|
|
+ timeoutCount: 0,
|
|
|
+ collectResult: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ editClick () {
|
|
|
+ this.$store.dispatch('mobileAddress/loadAddressData', {count: 10, page: 1, isSend: this.isSend, sorting: { 'num': 'ASC' }})
|
|
|
+ this.$emit('isEditEvent', [], false)
|
|
|
+ },
|
|
|
+ addressData (type) {
|
|
|
+ this.addressShow = false
|
|
|
+ if (type) {
|
|
|
+ this.params.area = `${type.province},${type.city},${type.area}`
|
|
|
+ this.params.province = type.province
|
|
|
+ this.params.city = type.city
|
|
|
+ this.params.district = type.area
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setRemindText (str) {
|
|
|
+ this.collectResult = str
|
|
|
+ this.timeoutCount++
|
|
|
+ },
|
|
|
+ storeInfosave(_tp) {
|
|
|
+ this.BScroll.refresh()
|
|
|
+ if (_tp === 'cancel') {
|
|
|
+ this.editClick()
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!this.params.name || this.params.name === '') {
|
|
|
+ this.setRemindText('发货人姓名不能为空')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!this.params.tel || this.params.tel === '' || !/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(this.params.tel)) {
|
|
|
+ this.setRemindText('请输入正确的手机号码')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (this.params.email && !/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/.test(this.params.email)) {
|
|
|
+ this.setRemindText('请输入正确的邮箱')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!this.params.area || this.params.area === '') {
|
|
|
+ this.setRemindText('请选择所在地区')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!this.params.detailAddress || this.params.detailAddress === '') {
|
|
|
+ this.setRemindText('请填写详细地址信息')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.$http.post(`/trade/address/shipping/save?isPersonal=${this.isPersonal}&isSetTop=${this.isActive}&send=${this.isSend}`, this.params)
|
|
|
+ .then(() => {
|
|
|
+ this.setRemindText('保存成功')
|
|
|
+ this.editClick()
|
|
|
+ }).catch(err => {
|
|
|
+ this.collectResult = err.response.data
|
|
|
+ this.timeoutCount++
|
|
|
+ this.params = this.data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ storeI() {
|
|
|
+ let str = JSON.stringify(this.$store.state.option.storeStatus.data)
|
|
|
+ this.storeInfo = JSON.parse(str)
|
|
|
+ return ''
|
|
|
+ },
|
|
|
+ isAdmin () {
|
|
|
+ return this.user.data.userUU === this.user.data.enterprise.enAdminuu
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ RemindBox,
|
|
|
+ SelectAddress
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.data) {
|
|
|
+ this.params = this.baseUtils.deepCopy(this.data)
|
|
|
+ }
|
|
|
+ if (this.BScroll) {
|
|
|
+ this.BScroll.refresh()
|
|
|
+ } else {
|
|
|
+ this.BScroll = new BScroll(this.$refs.addressContent, {
|
|
|
+ click: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .shipments_address_edit{
|
|
|
+ .control {
|
|
|
+ width: 90%;
|
|
|
+ margin: 0.4rem auto 0rem;
|
|
|
+ height: .88rem;
|
|
|
+ line-height: 0.88rem;
|
|
|
+ .save {
|
|
|
+ border-radius: 3px;
|
|
|
+ width: 48%;
|
|
|
+ color: #fff;
|
|
|
+ text-align: center;
|
|
|
+ height: .88rem;
|
|
|
+ line-height: 0.88rem;
|
|
|
+ background: #3e82f5;
|
|
|
+ float: right;
|
|
|
+ }
|
|
|
+ .cancel {
|
|
|
+ border-radius: 3px;
|
|
|
+ width: 48%;
|
|
|
+ background: #acabab;
|
|
|
+ color: #fff;
|
|
|
+ text-align: center;
|
|
|
+ height: .88rem;
|
|
|
+ line-height: 0.88rem;
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .form_line{
|
|
|
+ margin:.2rem;
|
|
|
+ padding:.2rem;
|
|
|
+ background: #ffffff;
|
|
|
+ border-radius:.05rem;
|
|
|
+ ul{
|
|
|
+ li{
|
|
|
+ line-height: 1.2rem;
|
|
|
+ height:1.2rem;
|
|
|
+ border-bottom:1px solid #d3d3d3;
|
|
|
+ vertical-align: middle;
|
|
|
+ &:last-child{
|
|
|
+ border:none;
|
|
|
+ }
|
|
|
+ .com_left{
|
|
|
+ width:1.85rem;
|
|
|
+ color:#4c8cf7;
|
|
|
+ text-align: right;
|
|
|
+ font-size: .28rem;
|
|
|
+ span{
|
|
|
+ color:#ff3333;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .form_input{
|
|
|
+ margin-left:1.85rem;
|
|
|
+ padding-right:.2rem;
|
|
|
+ input{
|
|
|
+ width:100%;
|
|
|
+ line-height: .3rem;
|
|
|
+ height:.3rem;
|
|
|
+ border:none;
|
|
|
+ font-size: .28rem;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|