|
@@ -0,0 +1,185 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <view class="app-content">
|
|
|
|
|
+ <form @submit="formSubmit">
|
|
|
|
|
+ <view class="module-com input-line-wrap">
|
|
|
|
|
+
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="openAddres">
|
|
|
|
|
+ <view class="tui-title">城市</view>
|
|
|
|
|
+ <view class="tui-input" v-if="form.province || form.city">{{ form.province + '-' + form.city }}</view>
|
|
|
|
|
+ <view class="tui-placeholder" v-else>请选择</view>
|
|
|
|
|
+ <input v-model="form.province" name="province" hidden />
|
|
|
|
|
+ </tui-list-cell>
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="selectRegion">
|
|
|
|
|
+ <view class="tui-title">地址</view>
|
|
|
|
|
+ <view class="tui-input" v-if="form.address">{{ form.address }}</view>
|
|
|
|
|
+ <view class="tui-placeholder" v-else>请填写详细地址</view>
|
|
|
|
|
+ <input v-model="form.address" name="address" hidden />
|
|
|
|
|
+ </tui-list-cell>
|
|
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
|
|
+ <view class="tui-title ">门牌</view>
|
|
|
|
|
+ <input v-model="form.floor" placeholder-class="phcolor" class="tui-input" name="floor" placeholder="楼号门牌号(建议填写,方便查找)" />
|
|
|
|
|
+ </tui-list-cell>
|
|
|
|
|
+
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="confirm-btn">
|
|
|
|
|
+ <button class="admin-button-com big blue" formType="submit">提交</button>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ <!-- 省市联动 -->
|
|
|
|
|
+ <simple-address ref="simpleAddress" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onCityConfirm"></simple-address>
|
|
|
|
|
+ <!-- 选择地区 -->
|
|
|
|
|
+ <app-area-sel :show.sync="showRegion" :city="form.city" @change="changeAreaFn" />
|
|
|
|
|
+ </view>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+import TuiListCell from '@/components/plugin/list-cell'
|
|
|
|
|
+import AppAvatarModule from '@/components/module/app-avatar'
|
|
|
|
|
+import SimpleAddress from '@/components/plugin/simple-address'
|
|
|
|
|
+import AppAreaSel from '@/components/app-area-sel'
|
|
|
|
|
+import AppUploader from "@/components/app-uploader";
|
|
|
|
|
+const form = require('@/utils/formValidation.js')
|
|
|
|
|
+import { modifyAddress } from '@/api/custom'
|
|
|
|
|
+import {mapActions} from "vuex";
|
|
|
|
|
+export default {
|
|
|
|
|
+ name: 'add',
|
|
|
|
|
+ components: {
|
|
|
|
|
+ TuiListCell,
|
|
|
|
|
+ AppAvatarModule,
|
|
|
|
|
+ SimpleAddress,
|
|
|
|
|
+ AppAreaSel,
|
|
|
|
|
+ AppUploader
|
|
|
|
|
+ },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ form: {
|
|
|
|
|
+ province: '',
|
|
|
|
|
+ city: '',
|
|
|
|
|
+ address: '',
|
|
|
|
|
+ floor: '',
|
|
|
|
|
+ showAddress:''
|
|
|
|
|
+ },
|
|
|
|
|
+ showRegion: false,
|
|
|
|
|
+ region: {
|
|
|
|
|
+ lat: 0,
|
|
|
|
|
+ long: 0
|
|
|
|
|
+ },
|
|
|
|
|
+ regionData: [],
|
|
|
|
|
+ cityPickerValueDefault: [0, 0]
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ onLoad() {
|
|
|
|
|
+ if(this.option.name){
|
|
|
|
|
+ uni.setNavigationBarTitle({ title: this.option.name })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ onShow() {
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ ...mapActions(['setUserShopAll']),
|
|
|
|
|
+ init() {
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ // 选择城市
|
|
|
|
|
+ selectRegion() {
|
|
|
|
|
+ if (!this.form.city) {
|
|
|
|
|
+ this.$msg('请先选择城市!')
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ this.showRegion = true
|
|
|
|
|
+ },
|
|
|
|
|
+ changeAreaFn(e) {
|
|
|
|
|
+ this.form.address = e.title
|
|
|
|
|
+ this.form.showAddress = e.address
|
|
|
|
|
+ this.region.lat = e.location.lat
|
|
|
|
|
+ this.region.long = e.location.lng
|
|
|
|
|
+ },
|
|
|
|
|
+ //省市联动
|
|
|
|
|
+ openAddres() {
|
|
|
|
|
+ this.$refs.simpleAddress.open()
|
|
|
|
|
+ },
|
|
|
|
|
+ onCityConfirm(e) {
|
|
|
|
|
+ this.form.province = e.provinceName
|
|
|
|
|
+ this.form.city = e.cityName
|
|
|
|
|
+ this.form.address = ''
|
|
|
|
|
+ this.region.lat = 0
|
|
|
|
|
+ this.region.long = 0
|
|
|
|
|
+ },
|
|
|
|
|
+ confirmFn() {
|
|
|
|
|
+ let that = this
|
|
|
|
|
+ that.$util.confirmModal({content:'确认修改?'},() => {
|
|
|
|
|
+ this.form.id = this.option.id ? this.option.id : 0
|
|
|
|
|
+ this.form = {...this.form,...this.region}
|
|
|
|
|
+ uni.showLoading({mask:true})
|
|
|
|
|
+ modifyAddress(this.form).then(res=>{
|
|
|
|
|
+ if(res.code == 1){
|
|
|
|
|
+ that.$msg('修改成功')
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ uni.navigateBack({})
|
|
|
|
|
+ }, 1200)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ // 表单验证
|
|
|
|
|
+ formSubmit(e) {
|
|
|
|
|
+ // 表单规则
|
|
|
|
|
+ let rules = [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'province',
|
|
|
|
|
+ rule: ['required'],
|
|
|
|
|
+ msg: ['请选择城市']
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'address',
|
|
|
|
|
+ rule: ['required'],
|
|
|
|
|
+ msg: ['请填选地址']
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ let formData = e.detail.value
|
|
|
|
|
+ let checkRes = form.validation(formData, rules)
|
|
|
|
|
+ if (!checkRes) {
|
|
|
|
|
+ this.confirmFn()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$msg(checkRes)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
|
+ .app-content {
|
|
|
|
|
+ min-height: calc(100vh - 20upx);
|
|
|
|
|
+ padding-top: 20upx;
|
|
|
|
|
+ }
|
|
|
|
|
+ .prompt-text {
|
|
|
|
|
+ color: $fontColor3;
|
|
|
|
|
+ padding-left: 30upx;
|
|
|
|
|
+ margin-bottom: 30upx;
|
|
|
|
|
+ }
|
|
|
|
|
+ .module-com {
|
|
|
|
|
+ margin-bottom: 20upx;
|
|
|
|
|
+ .member-wrap {
|
|
|
|
|
+ .member-det {
|
|
|
|
|
+ font-size: 24upx;
|
|
|
|
|
+ margin-left: 20upx;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .remark-wrap {
|
|
|
|
|
+ align-items: flex-start;
|
|
|
|
|
+ .remark {
|
|
|
|
|
+ height: 180upx;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 按钮
|
|
|
|
|
+ .confirm-btn {
|
|
|
|
|
+ width: calc(100% - 60upx);
|
|
|
|
|
+ margin: 60upx 30upx 20upx;
|
|
|
|
|
+ .admin-button-com {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+</style>
|