Sfoglia il codice sorgente

1、新增商城首页弹窗配置

billisme 3 anni fa
parent
commit
0cd77639e4

+ 6 - 1
src/i18n/langs/zh_CN.js

@@ -1877,7 +1877,12 @@ const zhCn = {
     sensitiveAlert: '每个敏感词之间用中文逗号进行分割,只能输入中文以及中文逗号,请谨慎填写,该配置约五分钟起效。',
     prodAudit: '商品审核',
     prodAuditTip: '开启之后商家新发布的或是要上架的商品将默认处于待审核状态,由平台审核后正常上架。',
-    messgaeEncoding: '消息加解密'
+    messgaeEncoding: '消息加解密',
+    homePagePopupConfig: '小程序首页弹窗配置',
+    popupName: '弹窗名称',
+    popupPic: '弹窗图片地址',
+    popupPicToPage: '弹窗图片跳转页面'
+
   },
   recruit: {
     recruitPop: '招募推广',

+ 156 - 0
src/views/modules/sys/pset/home-page-popup-config.vue

@@ -0,0 +1,156 @@
+<template>
+  <div class="商城首页弹窗配置-set gray-box top-redius border-bottom-gray">
+    <div class="title">{{$t('sysManagement.homePagePopupConfig')}}</div>
+    <el-form
+      ref="dataForm"
+      label-width="180px"
+      size="mini"
+      class="set-form"
+      label-position="left"
+      @keyup.enter.native="dataFormSubmit()"
+      :rules="dataRule"
+      :model="dataForm"
+    >
+      <el-form-item :label="`${$t('sysManagement.popupName')}:`" style="width:640px" prop="popupName">
+        <el-input v-model="dataForm.popupName" :placeholder="`${$t('sysManagement.popupName')}`" controls-position="right"></el-input>
+      </el-form-item>
+      <el-form-item :label="`${$t('sysManagement.popupPic')}:`" style="width:640px" prop="popupPic">
+        <el-input v-model="dataForm.popupPic" :placeholder="`${$t('sysManagement.popupPic')}`" controls-position="right"></el-input>
+      </el-form-item>
+      <el-form-item :label="`${$t('sysManagement.popupPicToPage')}:`" style="width:640px" prop="popupPicToPage">
+        <el-input v-model="dataForm.popupPicToPage" :placeholder="`${$t('sysManagement.popupPicToPage')}`" controls-position="right"></el-input>
+      </el-form-item>
+      <el-form-item :label="$t('sysManagement.isActive')" style="width:640px" prop="isOpen">
+        <el-switch v-model="dataForm.isOpen" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
+      </el-form-item>
+
+      <div class="default-btn" @click="dataFormSubmit()">{{$t('sysManagement.save')}}</div>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <!-- <el-button @click="visible = false">取消</el-button> -->
+    </span>
+  </div>
+</template>
+
+<script>
+export default {
+  props: {
+    saveUrl: {
+      type: String,
+      default: '/sys/pconfig/save'
+    },
+    changeFlag: {
+      type: Boolean,
+      default: true
+    }
+  },
+  watch: {
+    changeFlag: function (newVal, oldVal) {
+      if (!this.activationEventOriginate) {
+        this.dataForm.isOpen = false
+      }
+      this.activationEventOriginate = false
+    }
+  },
+  data () {
+    return {
+      dataForm: {
+        // id: null,
+        // paramKey: 'HOME_PAGE_POPUP',
+        popupName: null,
+        popupPic: null,
+        popupPicToPage: null,
+        isOpen: true
+        // paramValue: null
+      },
+      activationEventOriginate: false,
+      homePagePopup: {
+        // eBusinessID: null,
+        // appKey: null,
+        // reqUrl: null
+      },
+      dataRule: {
+        popupPic: [
+          { required: true, message: `${this.$i18n.t('sysManagement.popupPic')} ${this.$i18n.t('sysManagement.nullTips')}`, trigger: 'blur' }
+        ],
+        popupPicToPage: [
+          { required: true, message: `${this.$i18n.t('sysManagement.popupPicToPage')} ${this.$i18n.t('sysManagement.nullTips')}`, trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  mounted () {
+    this.init()
+  },
+  methods: {
+    init () {
+      // this.$refs['dataForm'].resetFields()
+      this.$nextTick(() => {
+        this.$http({
+          url: this.$http.adornUrl('/sys/pconfig/info/' + 'HOME_PAGE_POPUP'),
+          method: 'get',
+          params: this.$http.adornParams()
+        }).then(({ data }) => {
+          if (data) {
+            this.dataForm = data
+          }
+        })
+        this.$refs['dataForm'].resetFields()
+      })
+    },
+    // 表单提交
+    dataFormSubmit () {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          this.getHomePagePopupParam()
+          this.$http({
+            url: this.$http.adornUrl(this.saveUrl),
+            method: 'post',
+            data: this.$http.adornData({
+              'paramKey': 'HOME_PAGE_POPUP',
+              'paramValue': JSON.stringify(this.dataForm),
+              'remark': this.$i18n.t('sysManagement.homePagePopupConfig')
+            })
+          }).then(({ data }) => {
+            if (data) {
+              this.init()
+            }
+            this.$message({
+              message: this.$i18n.t('publics.operation'),
+              type: 'success',
+              duration: 1500,
+              onClose: () => {
+                this.visible = false
+                if (this.dataForm.isOpen) {
+                  this.activationEventOriginate = true
+                  this.$emit('activationConfig')
+                }
+              }
+            })
+          })
+        }
+      })
+    },
+    /**
+     * dataform -> homePagePopup
+     */
+    getHomePagePopupParam () {
+      this.homePagePopup.popupName = this.dataForm.popupName
+      this.homePagePopup.popupPic = this.dataForm.popupPic
+      this.homePagePopup.popupPicToPage = this.dataForm.popupPicToPage
+    },
+    /**
+     *  homePagePopup -> dataform
+     */
+
+    getDataParam (data) {
+      // let obj = JSON.parse(data.paramValue)
+      this.dataForm.paramKey = data.paramKey
+      this.dataForm.paramValue = data.paramValue
+      this.dataForm.popupName = data.homePagePopup.popupName
+      this.dataForm.popupPic = data.homePagePopup.popupPic
+      this.dataForm.popupPicToPage = data.homePagePopup.popupPicToPage
+    }
+  }
+}
+</script>

+ 6 - 1
src/views/modules/sys/pset/pconfigs.vue

@@ -31,6 +31,9 @@
       <el-tab-pane :label="$t('sysManagement.sensitiveConfiguration')">
         <sensitive-word-config ref="sensitiveWordConfig"/>
       </el-tab-pane>
+      <el-tab-pane :label="$t('sysManagement.homePagePopupConfig')">
+        <home-page-popup-config ref="homePagePopupConfig"/>
+      </el-tab-pane>
     </el-tabs>
   </div>
 </template>
@@ -45,6 +48,7 @@ import QuickConfig from './quick-config'
 import ServiceConfig from './service-config.vue'
 import PaypalConfig from './paypal-config'
 import SensitiveWordConfig from './sensitive-word-config'
+import HomePagePopupConfig from './home-page-popup-config'
 
 export default {
   data () {
@@ -64,7 +68,8 @@ export default {
     QuickConfig,
     ServiceConfig,
     SensitiveWordConfig,
-    SysSwitchConfig
+    SysSwitchConfig,
+    HomePagePopupConfig
   }
 }
 </script>