|
|
@@ -0,0 +1,200 @@
|
|
|
+<template>
|
|
|
+ <view class="app-content">
|
|
|
+ <form @submit="formSubmit" @reset="formReset">
|
|
|
+ <view class="module-com input-line-wrap">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">名称</view>
|
|
|
+ <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请输入名称" maxlength="50" type="text" />
|
|
|
+ </tui-list-cell>
|
|
|
+ <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 SimpleAddress from '@/components/plugin/simple-address'
|
|
|
+import AppAreaSel from '@/components/app-area-sel'
|
|
|
+const form = require('@/utils/formValidation.js')
|
|
|
+import {mapActions} from "vuex";
|
|
|
+import {currentInfo,updateInfo} from "@/api/user"
|
|
|
+export default {
|
|
|
+ name: 'modify',
|
|
|
+ components: {
|
|
|
+ TuiListCell,
|
|
|
+ SimpleAddress,
|
|
|
+ AppAreaSel
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {
|
|
|
+ name: '',
|
|
|
+ province: '',
|
|
|
+ city: '',
|
|
|
+ address: '',
|
|
|
+ showAddress:'',
|
|
|
+ floor: '',
|
|
|
+ },
|
|
|
+ showRegion: false,
|
|
|
+ region: {
|
|
|
+ lat: 0,
|
|
|
+ long: 0
|
|
|
+ },
|
|
|
+ regionData: [],
|
|
|
+ cityPickerValueDefault: [0, 0]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad() {
|
|
|
+ this.getUserInfo()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init() {
|
|
|
+
|
|
|
+ },
|
|
|
+ getUserInfo() {
|
|
|
+ currentInfo().then(res=>{
|
|
|
+ let data = res.data.info
|
|
|
+ if (this.$util.isEmpty(data)){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ Object.keys(this.form).forEach((i, index) => {
|
|
|
+ this.form[i] = data[i]
|
|
|
+ })
|
|
|
+ this.region.lat = data.lat
|
|
|
+ this.region.long = data.long
|
|
|
+ })
|
|
|
+ },
|
|
|
+ selectRegion() {
|
|
|
+ if (!this.form.city) {
|
|
|
+ this.$msg('请先选择城市!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.showRegion = true
|
|
|
+ },
|
|
|
+ changeAreaFn(e) {
|
|
|
+ this.form.address = e.title
|
|
|
+ this.region.lat = e.location.lat
|
|
|
+ this.region.long = e.location.lng
|
|
|
+ this.form.showAddress = e.address
|
|
|
+ },
|
|
|
+ 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() {
|
|
|
+
|
|
|
+ if (this.option.id) {
|
|
|
+ this.form.id = this.option.id
|
|
|
+ }
|
|
|
+ this.form = {...this.form,...this.region}
|
|
|
+ uni.showLoading({mask:true})
|
|
|
+ updateInfo(this.form).then(res => {
|
|
|
+ uni.hideLoading()
|
|
|
+
|
|
|
+ uni.navigateBack({})
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ formSubmit(e) {
|
|
|
+ let rules = [
|
|
|
+ {
|
|
|
+ name: 'name',
|
|
|
+ rule: ['required'],
|
|
|
+ msg: ['请输入名称']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ padding-bottom:130upx;
|
|
|
+ }
|
|
|
+ .prompt-text {
|
|
|
+ color: $fontColor3;
|
|
|
+ padding-left: 30upx;
|
|
|
+ margin-bottom: 30upx;
|
|
|
+ }
|
|
|
+ .module-com {
|
|
|
+ margin-bottom: 20upx;
|
|
|
+ background-color: #fff;
|
|
|
+ .member-wrap {
|
|
|
+ .member-det {
|
|
|
+ font-size: 24upx;
|
|
|
+ margin-left: 20upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .remark-wrap {
|
|
|
+ align-items: flex-start;
|
|
|
+ .remark {
|
|
|
+ height: 100upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .module-tit {
|
|
|
+ padding: 20upx 30upx;
|
|
|
+ font-size: 28upx;
|
|
|
+ }
|
|
|
+ .module-det {
|
|
|
+ padding: 0 30upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .confirm-btn {
|
|
|
+ position:fixed;
|
|
|
+ bottom:0upx;
|
|
|
+ width: calc(100% - 60upx);
|
|
|
+ margin: 60upx 30upx 0upx;
|
|
|
+ z-index:99;
|
|
|
+ .admin-button-com {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|