|
|
@@ -95,206 +95,205 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import TuiListCell from '@/components/plugin/list-cell'
|
|
|
- import AppAvatarModule from '@/components/module/app-avatar'
|
|
|
- import AppUploader from "@/components/app-uploader";
|
|
|
- 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 { updateShop as update, addShop as add } from '@/api/shop'
|
|
|
- export default {
|
|
|
- name: 'staff-add',
|
|
|
- components: {
|
|
|
- TuiListCell,
|
|
|
- AppAvatarModule,
|
|
|
- SimpleAddress,
|
|
|
- AppAreaSel,
|
|
|
- AppUploader
|
|
|
+import TuiListCell from '@/components/plugin/list-cell'
|
|
|
+import AppAvatarModule from '@/components/module/app-avatar'
|
|
|
+import AppUploader from "@/components/app-uploader";
|
|
|
+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 { updateShop as update, addShop as add } from '@/api/shop'
|
|
|
+export default {
|
|
|
+ name: 'staff-add',
|
|
|
+ components: {
|
|
|
+ TuiListCell,
|
|
|
+ AppAvatarModule,
|
|
|
+ SimpleAddress,
|
|
|
+ AppAreaSel,
|
|
|
+ AppUploader
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ visible: true,
|
|
|
+ openTimeVisible: false,
|
|
|
+ start_time: '00:00',
|
|
|
+ end_time: '00:00',
|
|
|
+ form: {
|
|
|
+ join:0,
|
|
|
+ shopName: '',
|
|
|
+ province: '',
|
|
|
+ city: '',
|
|
|
+ address: '',
|
|
|
+ floor: '',
|
|
|
+ open: 1,
|
|
|
+ openType: 0, // openType: 0. 表示 24小时营业 1. 表示 xx ~ xx
|
|
|
+ openStartTime: '',
|
|
|
+ openEndTime: '',
|
|
|
+ introduction: '',
|
|
|
+ mobile: '',
|
|
|
+ img: []
|
|
|
+ },
|
|
|
+ showRegion: false,
|
|
|
+ region: {
|
|
|
+ lat: 0,
|
|
|
+ long: 0
|
|
|
+ },
|
|
|
+ regionData: [],
|
|
|
+ cityPickerValueDefault: [0, 0],
|
|
|
+ img: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad() {
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ if (this.option.id) {
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
+ title: `修改门店`
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
+ title: `添加门店`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions(['setUserShopAll']),
|
|
|
+ init() {
|
|
|
+ this._getDet()
|
|
|
},
|
|
|
- data() {
|
|
|
- return {
|
|
|
- visible: true,
|
|
|
- openTimeVisible: false,
|
|
|
- start_time: '00:00',
|
|
|
- end_time: '00:00',
|
|
|
- form: {
|
|
|
- join:0,
|
|
|
- shopName: '',
|
|
|
- province: '',
|
|
|
- city: '',
|
|
|
- address: '',
|
|
|
- floor: '',
|
|
|
- open: 1,
|
|
|
- openType: 0, // openType: 0. 表示 24小时营业 1. 表示 xx ~ xx
|
|
|
- openStartTime: '',
|
|
|
- openEndTime: '',
|
|
|
- introduction: '',
|
|
|
- mobile: '',
|
|
|
- img: []
|
|
|
- },
|
|
|
- showRegion: false,
|
|
|
- region: {
|
|
|
- lat: 0,
|
|
|
- long: 0
|
|
|
- },
|
|
|
- regionData: [],
|
|
|
- cityPickerValueDefault: [0, 0],
|
|
|
- img: []
|
|
|
+ _getDet() {
|
|
|
+ let data = uni.getStorageSync('modifyShopB')
|
|
|
+ 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
|
|
|
+
|
|
|
+ // 营业时间初始化
|
|
|
+ this.visible = this.form.open == 1 ? true : false
|
|
|
+ this.openTimeVisible = true
|
|
|
+ this.form.openType = 1
|
|
|
+ this.start_time = this.form.openStartTime
|
|
|
+ this.end_time = this.form.openEndTime
|
|
|
+ if (data.openStartTime == '') {
|
|
|
+ this.openTimeVisible = false
|
|
|
+ this.form.openType = 0
|
|
|
+ this.start_time = '09:00'
|
|
|
+ this.form.openStartTime = this.start_time
|
|
|
+ }
|
|
|
+ if (data.openEndTime == '') {
|
|
|
+ this.end_time = '18:00'
|
|
|
+ this.form.openEndTime = this.end_time
|
|
|
+ }
|
|
|
+ },
|
|
|
+ openChange(e) {
|
|
|
+ this.visible = e.target.value ? true : false
|
|
|
+ this.form.open = e.target.value ? 1 : 0
|
|
|
+ },
|
|
|
+ startTimeChange: function(e) {
|
|
|
+ this.start_time = e.detail.value
|
|
|
+ this.form.openStartTime = e.detail.value
|
|
|
+ },
|
|
|
+ joinChange(e){
|
|
|
+ this.form.join = e.detail.value
|
|
|
+ },
|
|
|
+ endTimeChange: function(e) {
|
|
|
+ this.end_time = e.detail.value
|
|
|
+ this.form.openEndTime = e.detail.value
|
|
|
+ },
|
|
|
+ radioChange(e) {
|
|
|
+ this.openTimeVisible = e.detail.value == 0 ? false : true;
|
|
|
+ this.form.openType = e.detail.value == 0 ? 0 : 1; // openType: 0. 24小时 1. xx ~ xx
|
|
|
+ if (this.openTimeVisible) {
|
|
|
+ this.start_time = '09:00'
|
|
|
+ this.end_time = '18:00'
|
|
|
}
|
|
|
},
|
|
|
- onLoad() {
|
|
|
+ selectRegion() {
|
|
|
+ if (!this.form.city) {
|
|
|
+ this.$msg('请先选择城市!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ this.showRegion = true
|
|
|
+ },
|
|
|
+ _resultData(val) {
|
|
|
+ console.log(val)
|
|
|
+ this.form.img = val;
|
|
|
+ },
|
|
|
+ changeAreaFn(e) {
|
|
|
+ console.log('changeAreaFn', e)
|
|
|
+ this.form.address = e.title
|
|
|
+ this.region.lat = e.location.lat
|
|
|
+ this.region.long = e.location.lng
|
|
|
},
|
|
|
- onShow() {
|
|
|
+ // 省市联动
|
|
|
+ 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 hostFn = this.option.id ? update : add
|
|
|
if (this.option.id) {
|
|
|
- uni.setNavigationBarTitle({
|
|
|
- title: `修改门店`
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.setNavigationBarTitle({
|
|
|
- title: `添加门店`
|
|
|
- })
|
|
|
+ this.form.id = this.option.id
|
|
|
}
|
|
|
+ this.form = {...this.form,...this.region}
|
|
|
+ uni.showLoading({mask:true})
|
|
|
+ hostFn(this.form).then(res => {
|
|
|
+ uni.hideLoading()
|
|
|
+ let promptText = this.option.id ? '修改成功!' : '添加成功!'
|
|
|
+ this.$msg(promptText)
|
|
|
+ uni.removeStorageSync('modifyShopB')
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$util.pageTo(1)
|
|
|
+ }, 1000)
|
|
|
+ })
|
|
|
},
|
|
|
- methods: {
|
|
|
- ...mapActions(['setUserShopAll']),
|
|
|
- init() {
|
|
|
- this._getDet()
|
|
|
- },
|
|
|
- _getDet() {
|
|
|
- let data = uni.getStorageSync('modifyShopB')
|
|
|
- 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
|
|
|
-
|
|
|
- // 营业时间初始化
|
|
|
- this.visible = this.form.open == 1 ? true : false
|
|
|
- this.openTimeVisible = true
|
|
|
- this.form.openType = 1
|
|
|
- this.start_time = this.form.openStartTime
|
|
|
- this.end_time = this.form.openEndTime
|
|
|
- if (data.openStartTime == '') {
|
|
|
- this.openTimeVisible = false
|
|
|
- this.form.openType = 0
|
|
|
- this.start_time = '09:00'
|
|
|
- this.form.openStartTime = this.start_time
|
|
|
- }
|
|
|
- if (data.openEndTime == '') {
|
|
|
- this.end_time = '18:00'
|
|
|
- this.form.openEndTime = this.end_time
|
|
|
- }
|
|
|
- },
|
|
|
- openChange(e) {
|
|
|
- this.visible = e.target.value ? true : false
|
|
|
- this.form.open = e.target.value ? 1 : 0
|
|
|
- },
|
|
|
- startTimeChange: function(e) {
|
|
|
- this.start_time = e.detail.value
|
|
|
- this.form.openStartTime = e.detail.value
|
|
|
- },
|
|
|
- joinChange(e){
|
|
|
- this.form.join = e.detail.value
|
|
|
- },
|
|
|
- endTimeChange: function(e) {
|
|
|
- this.end_time = e.detail.value
|
|
|
- this.form.openEndTime = e.detail.value
|
|
|
- },
|
|
|
- radioChange(e) {
|
|
|
- this.openTimeVisible = e.detail.value == 0 ? false : true;
|
|
|
- this.form.openType = e.detail.value == 0 ? 0 : 1; // openType: 0. 24小时 1. xx ~ xx
|
|
|
- if (this.openTimeVisible) {
|
|
|
- this.start_time = '09:00'
|
|
|
- this.end_time = '18:00'
|
|
|
- }
|
|
|
- },
|
|
|
- selectRegion() {
|
|
|
- if (!this.form.city) {
|
|
|
- this.$msg('请先选择城市!')
|
|
|
- return false
|
|
|
- }
|
|
|
- this.showRegion = true
|
|
|
- },
|
|
|
- _resultData(val) {
|
|
|
- console.log(val)
|
|
|
- this.form.img = val;
|
|
|
- },
|
|
|
- changeAreaFn(e) {
|
|
|
- console.log('changeAreaFn', e)
|
|
|
- this.form.address = e.title
|
|
|
- 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 hostFn = this.option.id ? update : add
|
|
|
- if (this.option.id) {
|
|
|
- this.form.id = this.option.id
|
|
|
- }
|
|
|
- this.form = {...this.form,...this.region}
|
|
|
- uni.showLoading({mask:true})
|
|
|
- hostFn(this.form).then(res => {
|
|
|
- uni.hideLoading()
|
|
|
- this.setUserShopAll();
|
|
|
- let promptText = this.option.id ? '修改成功!' : '添加成功!'
|
|
|
- this.$msg(promptText)
|
|
|
- uni.removeStorageSync('modifyShopB')
|
|
|
- setTimeout(() => {
|
|
|
- this.$util.pageTo(1)
|
|
|
- }, 1000)
|
|
|
- })
|
|
|
- },
|
|
|
- // 表单验证
|
|
|
- formSubmit(e) {
|
|
|
- // 表单规则
|
|
|
- let rules = [
|
|
|
- {
|
|
|
- name: 'shopName',
|
|
|
- rule: ['required'],
|
|
|
- msg: ['请输入名称']
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'mobile',
|
|
|
- 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)
|
|
|
+ // 表单验证
|
|
|
+ formSubmit(e) {
|
|
|
+ // 表单规则
|
|
|
+ let rules = [
|
|
|
+ {
|
|
|
+ name: 'shopName',
|
|
|
+ rule: ['required'],
|
|
|
+ msg: ['请输入名称']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'mobile',
|
|
|
+ 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>
|