From 4b1ca750fca8947fe39b06a4bf48760efa7b4c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E7=9A=87?= <236220500@qq.com> Date: Wed, 3 Jun 2020 18:42:50 +0800 Subject: [PATCH] 1 --- src/pages/activity/addActivity.vue | 193 ++++++++---------- src/pages/shop/IncreaseWelcomeEdit.vue | 270 +++++++++++++------------ 2 files changed, 225 insertions(+), 238 deletions(-) diff --git a/src/pages/activity/addActivity.vue b/src/pages/activity/addActivity.vue index 18937dd..c99ad5e 100644 --- a/src/pages/activity/addActivity.vue +++ b/src/pages/activity/addActivity.vue @@ -1,109 +1,89 @@ @@ -112,7 +92,7 @@ import ActivityManager from "../../services/ActivityManager/ActivityManager"; import axios from "axios"; export default { name: "addActivity", - data () { + data() { return { dispalyModal: false, currentStep: 0, @@ -122,25 +102,26 @@ export default { loading: true, ruleValidate: { name: [ - { required: true, message: "活动名称不能为空", trigger: "blur" }, + { required: true, message: "活动名称不能为空", trigger: "blur" } ], description: [ - { required: true, message: "活动描述不能为空", trigger: "blur" }, + { required: true, message: "活动描述不能为空", trigger: "blur" } ], appId: [{ required: true, message: "appId不能为空", trigger: "blur" }], uri: [{ required: true, message: "URI不能为空", trigger: "blur" }], + welcome: [{ required: true, message: "请输入欢迎语", trigger: "blur" }] // uploadImg: [ // { required: true, message: '请上传活动图片', trigger: 'blur' } // ] - }, + } }; }, props: { addActivityModal: Boolean, - id: String, + id: String }, watch: { - addActivityModal (val) { + addActivityModal(val) { this.dispalyModal = val; if (val === true && this.id) { this.getActivityData(); @@ -162,16 +143,16 @@ export default { limitLower: "", limitUpper: "", name: "", - type: 0, - }, + type: 0 + } ]; } this.$forceUpdate(); - }, + } }, - mounted () { }, + mounted() {}, methods: { - addActivityInput () { + addActivityInput() { let params = [...this.formValidate.params]; params.push({ defaultVal: "", @@ -182,12 +163,12 @@ export default { limitLower: "", limitUpper: "", name: "", - type: 0, + type: 0 }); this.$set(this.formValidate, "params", params); this.$forceUpdate(); }, - delActivityInput (index) { + delActivityInput(index) { if (this.formValidate.params.length <= 1) { this.$Message.error("至少需要填写一个活动类型!"); return; @@ -195,22 +176,22 @@ export default { this.formValidate.params.splice(index, 1); this.$forceUpdate(); }, - cancel () { + cancel() { this.$emit("dispalyAddActivityModal", false, false); }, - getActivityData () { + getActivityData() { let that = this; let data = { - id: that.id, + id: that.id }; - ActivityManager.getActivityInfo(data, function (data) { + ActivityManager.getActivityInfo(data, function(data) { that.formValidate = data.data.results; }); }, - uploadImgSuccess (res, file) { + uploadImgSuccess(res, file) { this.imageName = file.name; }, - handleBeforeUpload (res) { + handleBeforeUpload(res) { const me = this; let data = new FormData(); data.append("file", res); @@ -219,9 +200,9 @@ export default { url: "/upload", data: data, headers: { - "Content-Type": "multipart/form-data", - }, - }).then(function (res) { + "Content-Type": "multipart/form-data" + } + }).then(function(res) { if (res.data.success) { // me.formValidate.logo = res.data.results; me.$set(me.formValidate, "logo", res.data.results.localPath); @@ -230,7 +211,7 @@ export default { }); return false; }, - save () { + save() { let that = this; that.modal_loading = true; let i = 0; @@ -264,13 +245,13 @@ export default { } } } - this.$refs["formValidate"].validate((valid) => { + this.$refs["formValidate"].validate(valid => { if (valid) { // param = JSON.stringify(param) let data = { ...that.formValidate, isGetActivityInfo: true }; data.categoryId = 0; data.categoryCode = "promotion"; - ActivityManager.addOreditActivity(data, function (data) { + ActivityManager.addOreditActivity(data, function(data) { that.addActivityModal = false; that.formValidate = {}; that.modal_loading = false; @@ -281,8 +262,8 @@ export default { that.$Message.error("表单验证失败!"); } }); - }, - }, + } + } }; diff --git a/src/pages/shop/IncreaseWelcomeEdit.vue b/src/pages/shop/IncreaseWelcomeEdit.vue index 079d0da..1543405 100644 --- a/src/pages/shop/IncreaseWelcomeEdit.vue +++ b/src/pages/shop/IncreaseWelcomeEdit.vue @@ -2,160 +2,140 @@
-
- - + + + - +
- APPID {{ index + 1 }} - - + APPID {{ index + 1 }} + + - URI {{ index + 1 }} - - + URI {{ index + 1 }} + + + + MediaId{{ index + 1 }} + +
- {{ item.name }}{{ index + 1 }} + {{ item.name }}{{ index + 1 }} - +
- +
- + - {{ welcome.stores[0].name }}等{{ welcome.stores.length }}家店铺 - + {{ welcome.stores[0].name }}等{{ welcome.stores.length }}家店铺 + - +
- + - +
- +
- + - +
- -
- - + + + +
- - + +
- -
- - + + + + - - + + + +
+ +
+
- - + +
- +
@@ -174,7 +154,7 @@ const validateUrl = (rule, value, callback) => { } }; export default { - data () { + data() { return { showStoreCheck: false, showWeb: false, @@ -212,12 +192,12 @@ export default { appid: [{ required: true, message: "请输入url", trigger: "blur" }], uri: [{ required: true, message: "请输入url", trigger: "blur" }] }, - miniForm: { appid: "", uri: "" } + miniForm: { appid: "", uri: "", limitLower: "", limitUpper: "" } }; }, watch: { welcome: { - handler () { + handler() { store.commit("SET_useData", { ...store.getters.useData, ...this.welcome @@ -227,7 +207,7 @@ export default { deep: true } }, - created () { + created() { this.id = this.$route.query.id; // store.commit("SET_useData", { ...store.getters.useData, ...this.welcome }); console.log(this.$route); @@ -239,14 +219,14 @@ export default { selectStoreStep }, methods: { - doShow () { + doShow() { this.showStoreCheck = false; this.welcome = store.getters.useData; }, - onExceededSize () { + onExceededSize() { console.log("失败"); }, - getDetail (instanceId) { + getDetail(instanceId) { let _this = this; ActivityManager.instanceDetail( { @@ -261,7 +241,7 @@ export default { } ); }, - showStores () { + showStores() { console.log({ ...store.getters.useData, ...this.welcome }); store.commit("SET_useData", { ...this.welcome, @@ -269,25 +249,26 @@ export default { }); this.showStoreCheck = true; }, - uploadImgSuccess (res, file) { }, - cancelWeb () { + uploadImgSuccess(res, file) {}, + miniUploadImgSuccess(res, file) {}, + cancelWeb() { this.showWeb = false; }, - doShowWeb () { + doShowWeb() { this.showWeb = true; this.webForm = { url: "" }; }, - doShowMini () { + doShowMini() { this.showMini = true; this.miniForm = { appid: "", uri: "" }; }, - cancelMini () { + cancelMini() { this.showMini = false; }, - okWeb () { + okWeb() { let _this = this; this.$refs["webForm"].validate(valid => { if (valid) { @@ -307,7 +288,7 @@ export default { } }); }, - okMini () { + okMini() { let _this = this; this.$refs["miniForm"].validate(valid => { if (valid) { @@ -317,8 +298,8 @@ export default { description: this.miniForm.uri, isRequired: 1, key: "mini", - limitLower: null, - limitUpper: null, + limitLower: this.miniForm.limitLower, + limitUpper: this.miniForm.limitUpper, name: "小程序消息", type: 3 }); @@ -327,15 +308,40 @@ export default { } }); }, - delActivityInput (index) { + delActivityInput(index) { this.welcome.params.splice(index, 1); this.$forceUpdate(); }, - handleBeforeUpload (res) { + handleBeforeUploadMini(res) { + const me = this; + let data = new FormData(); + data.append("file", res); + data.append("needMediaId", "true"); + console.log(data); + this.imageUploading = true; + axios({ + method: "post", + url: "/upload", + data: data, + headers: { + "Content-Type": "multipart/form-data" + } + }).then(function(res) { + me.imageUploading = false; + if (res.data.success) { + // me.formValidate.logo = res.data.results; + me.miniForm.limitLower = res.data.results.mediaId; + me.miniForm.limitUpper = res.data.results.localPath; + me.showMessageTypes = false; + } + }); + return false; + }, + handleBeforeUpload(res) { const me = this; let data = new FormData(); data.append("file", res); - data.append("needMediaId", "true") + data.append("needMediaId", "true"); console.log(data); this.imageUploading = true; axios({ @@ -345,7 +351,7 @@ export default { headers: { "Content-Type": "multipart/form-data" } - }).then(function (res) { + }).then(function(res) { me.imageUploading = false; if (res.data.success) { // me.formValidate.logo = res.data.results; @@ -365,7 +371,7 @@ export default { }); return false; }, - submit () { + submit() { let _this = this; if (this.welcome.stores.length <= 0) { _this.$Message.error("请至少选择一个店铺");