|
|
@@ -242,22 +242,16 @@
|
|
|
|
|
|
<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 { updateShop as update, addShop as add } from '@/api/shop'
|
|
|
-import {mapActions} from "vuex";
|
|
|
-import {getDetail} from "@/api/shop"
|
|
|
+const validator = require('@/utils/formValidation.js')
|
|
|
+import { getDetail, updateShop as update, addShop as add } from '@/api/shop'
|
|
|
export default {
|
|
|
name: 'add',
|
|
|
components: {
|
|
|
TuiListCell,
|
|
|
- AppAvatarModule,
|
|
|
SimpleAddress,
|
|
|
- AppAreaSel,
|
|
|
- AppUploader
|
|
|
+ AppAreaSel
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -308,14 +302,17 @@ export default {
|
|
|
lat: 0,
|
|
|
long: 0
|
|
|
},
|
|
|
- regionData: [],
|
|
|
cityPickerValueDefault: [0, 0],
|
|
|
id:0,
|
|
|
hasMap:0 // 是否具备定位功能 0不具备 1具备
|
|
|
}
|
|
|
},
|
|
|
- onLoad() {
|
|
|
+ onLoad(option) {
|
|
|
+ this.option = option || {}
|
|
|
this.id = this.option.id ? this.option.id : 0
|
|
|
+ if (this.option.id) {
|
|
|
+ this._getDet()
|
|
|
+ }
|
|
|
},
|
|
|
onShow() {
|
|
|
if (this.option.id) {
|
|
|
@@ -329,83 +326,67 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapActions(['setUserShopAll']),
|
|
|
- init() {
|
|
|
- this._getDet()
|
|
|
- },
|
|
|
- _resultData(val) {
|
|
|
- console.log(val)
|
|
|
- this.form.img = val;
|
|
|
- },
|
|
|
+ init() {},
|
|
|
_getDet() {
|
|
|
-
|
|
|
if(this.option.id && !this.$util.isEmpty(this.option.id)){
|
|
|
- getDetail({shopId:this.option.id}).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]
|
|
|
+ getDetail({shopId:this.option.id})
|
|
|
+ .then(res=>{
|
|
|
+ let data = res.data.info
|
|
|
+ if (this.$util.isEmpty(data)) return
|
|
|
+ Object.keys(this.form).forEach((i) => {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ this.hasMap = data.hasMap || 0
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$msg('获取门店详情失败')
|
|
|
})
|
|
|
-
|
|
|
- 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
|
|
|
- }
|
|
|
- this.hasMap = data.hasMap || 0
|
|
|
- })
|
|
|
}
|
|
|
},
|
|
|
itemToClassChange(e){
|
|
|
- this.form.itemToClass = e.target.value ? 1 : 0
|
|
|
+ this.form.itemToClass = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
presellChange(e){
|
|
|
- this.form.presell = e.target.value ? 1 : 0
|
|
|
- },
|
|
|
- isHdChange(e){
|
|
|
- this.form.isHd = e.target.value ? 0 : 1
|
|
|
- },
|
|
|
- showStockChange(e){
|
|
|
- this.form.showStock = e.target.value ? 1 : 0
|
|
|
+ this.form.presell = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
cgUnitTypeChange(e){
|
|
|
- this.form.cgUnitType = e.target.value ? 1 : 0
|
|
|
+ this.form.cgUnitType = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
pfLevelChange(e){
|
|
|
- this.form.pfLevel = e.target.value ? 1 : 0
|
|
|
+ this.form.pfLevel = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
afterSaleChange(e){
|
|
|
- this.form.afterSale = e.target.value ? 1 : 0
|
|
|
- },
|
|
|
- showSoldChange(e){
|
|
|
- this.form.showSold = e.target.value ? 1 : 0
|
|
|
+ this.form.afterSale = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
carSaleChange(e){
|
|
|
- this.form.carSale = e.target.value ? 1 : 0
|
|
|
+ this.form.carSale = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
defaultChange(e){
|
|
|
- this.form.default = e.target.value ? 1 : 0
|
|
|
+ this.form.default = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
allowDebtChange(e){
|
|
|
- this.form.allowDebt = e.target.value ? 1 : 0
|
|
|
- },
|
|
|
- needCheckChange(e){
|
|
|
- this.form.needCheck = e.target.value ? 1 : 0
|
|
|
+ this.form.allowDebt = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
openChange(e) {
|
|
|
- this.visible = e.target.value ? true : false
|
|
|
- this.form.open = e.target.value ? 1 : 0
|
|
|
+ this.visible = e.detail.value ? true : false
|
|
|
+ this.form.open = e.detail.value ? 1 : 0
|
|
|
},
|
|
|
startTimeChange: function(e) {
|
|
|
this.start_time = e.detail.value
|
|
|
@@ -416,15 +397,15 @@ export default {
|
|
|
this.form.openEndTime = e.detail.value
|
|
|
},
|
|
|
joinChange(e){
|
|
|
- this.form.join = e.detail.value
|
|
|
+ this.form.join = Number(e.detail.value)
|
|
|
},
|
|
|
cutStyleChange(e){
|
|
|
- this.form.cutStyle = e.detail.value
|
|
|
- console.log(this.form.cutStyle)
|
|
|
+ this.form.cutStyle = Number(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
|
|
|
+ const selected = Number(e.detail.value)
|
|
|
+ this.openTimeVisible = selected === 0 ? false : true;
|
|
|
+ this.form.openType = selected === 0 ? 0 : 1; // openType: 0. 24小时 1. xx ~ xx
|
|
|
if (this.openTimeVisible) {
|
|
|
this.start_time = '09:00'
|
|
|
this.end_time = '18:00'
|
|
|
@@ -438,8 +419,8 @@ export default {
|
|
|
this.form.city = e.cityName
|
|
|
this.form.address = ''
|
|
|
this.form.showAddress = ''
|
|
|
- this.region.lat = 10
|
|
|
- this.region.long = 11
|
|
|
+ this.region.lat = 0
|
|
|
+ this.region.long = 0
|
|
|
},
|
|
|
selectRegion() {
|
|
|
if (!this.form.city) {
|
|
|
@@ -472,14 +453,20 @@ export default {
|
|
|
this.form.showAddress = this.form.city+this.form.address+this.form.floor
|
|
|
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)
|
|
|
- setTimeout(() => {
|
|
|
- this.$util.pageTo(1)
|
|
|
- }, 1000)
|
|
|
- })
|
|
|
+ hostFn(this.form)
|
|
|
+ .then(() => {
|
|
|
+ let promptText = this.option.id ? '修改成功' : '添加成功'
|
|
|
+ this.$msg(promptText)
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$util.pageTo(1)
|
|
|
+ }, 1000)
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.$msg('提交失败,请稍后重试')
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ uni.hideLoading()
|
|
|
+ })
|
|
|
},
|
|
|
// 表单验证
|
|
|
formSubmit(e) {
|
|
|
@@ -508,7 +495,7 @@ export default {
|
|
|
]
|
|
|
// 进行npm表单检查
|
|
|
let formData = e.detail.value
|
|
|
- let checkRes = form.validation(formData, rules)
|
|
|
+ let checkRes = validator.validation(formData, rules)
|
|
|
// 验证通过!
|
|
|
if (!checkRes) {
|
|
|
this.confirmFn()
|