123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- <template>
- <div>
- <div class="shipments_address_edit" :class="{'fix-sa-edit': inFix}">
- <div ref="addressContent" class="wrap" :class="{'height100': height100}">
- <div>
- <div class="form_line">
- <ul class="list-unstyled">
- <li class="clearfix">
- <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 class="clearfix">
- <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 class="clearfix">
- <div class="com_left pull-left">邮箱:</div>
- <div class="form_input">
- <input type="email" placeholder="请输入正确邮箱,用于接收订单提醒" v-model="params.email">
- </div>
- </li>
- <li class="clearfix">
- <div class="com_left pull-left"><span>*</span>所在地区:</div>
- <div class="form_input" @click="addressShow = true">
- <span v-text="params.area || '选择地区'">选择地区</span>
- <i class="iconfont icon-xiangyou"></i>
- </div>
- </li>
- <li class="clearfix">
- <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 class="clearfix">
- <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 v-show="!noClose" class="cancel" @click="storeInfosave('cancel')">取消</div>
- <div class="save" :class="{width100 : noClose}" @click="storeInfosave()">保存</div>
- </div>
- <div style="height: 0.2rem;position:relative"></div>
- </div>
- </div>
- </div>
- <select-address :className="className" :inFix="inFix" :isShow="addressShow" @closeAction="addressData"></select-address>
- <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
- </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: false,
- type: Boolean
- },
- inFix: {
- type: Boolean,
- default: false
- },
- className: {
- type: String,
- default: ''
- },
- height100: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- params: {
- area: '',
- detailAddress: '',
- email: '',
- tel: '',
- name: '',
- province: '',
- city: '',
- district: ''
- },
- isActive: false,
- addressShow: false,
- timeoutCount: 0,
- collectResult: ''
- }
- },
- watch: {
- 'data': {
- handler: function (newVal) {
- if (newVal) {
- newVal.num === 1 ? this.isActive = true : this.isActive = false
- this.params = this.baseUtils.deepCopy(newVal)
- }
- },
- immediate: true
- }
- },
- mounted () {
- this.$nextTick(() => {
- this.refleshSc()
- })
- },
- computed: {
- noClose () {
- let data = this.baseUtils.deepCopy(this.$store.state.mobileAddress.address.data)
- if (data && data.content && data.content.length > 0) {
- return false
- } else {
- return true
- }
- }
- },
- methods: {
- editClick (data) {
- this.$emit('isEditEvent', data || {}, 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') {
- if (!this.noClose) {
- 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(res => {
- this.setRemindText('保存成功')
- this.editClick(res.data)
- }).catch(err => {
- this.collectResult = err.response.data
- this.timeoutCount++
- this.params = this.data
- })
- },
- refleshSc () {
- if (this.BScroll) {
- this.BScroll.refresh()
- } else {
- this.BScroll = new BScroll(this.$refs.addressContent, {
- click: true
- })
- }
- }
- },
- components: {
- RemindBox,
- SelectAddress
- }
- }
- </script>
- <style lang="scss" scoped>
- .shipments_address_edit{
- .control {
- width: 90%;
- margin: 0.4rem auto 0rem;
- height: .88rem;
- line-height: 0.88rem;
- .width100{
- width: 100% !important;
- }
- .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:0 .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{
- position:relative;
- margin-left:1.85rem;
- padding-right:.2rem;
- span{
- line-height: .3rem;
- word-break: break-all;
- display: inline-block;
- margin-right: .2rem;
- vertical-align: middle;
- }
- i{
- position:absolute;
- top:0;
- right:0;
- color: #c1c1c6;
- font-size: .28rem;
- }
- input{
- width:100%;
- line-height: .3rem;
- height:.3rem;
- border:none;
- font-size: .28rem;
- }
- }
- }
- }
- }
- .wrap {
- height: 8.3rem;
- overflow-y: hidden;
- margin-top: 0.2rem;
- &.height100 {
- height: calc(100vh - 1.26rem - 0.98rem - 0.2rem);
- }
- }
- }
- .fix-sa-edit {
- .form_line {
- margin-top: 0;
- }
- }
- </style>
|