Selaa lähdekoodia

feat: 提交新增赠送流量接口

Damon 11 kuukautta sitten
vanhempi
commit
531cdc2100
3 muutettua tiedostoa jossa 156 lisäystä ja 111 poistoa
  1. 95 78
      src/mixin/index.js
  2. 55 32
      src/utils/request.js
  3. 6 1
      src/views/operation/activity/index.vue

+ 95 - 78
src/mixin/index.js

@@ -1,16 +1,31 @@
-import { getClientTypeList } from "@/api/device/version";
+import {
+  getClientTypeList
+} from "@/api/device/version";
 
-import { audioType, platform } from "@/api/music/platform";
+import {
+  audioType,
+  platform
+} from "@/api/music/platform";
 
-import { options } from "@/api/music/radio";
+import {
+  options
+} from "@/api/music/radio";
 
-import { list as categoryList } from "@/api/device/category";
+import {
+  list as categoryList
+} from "@/api/device/category";
 
-import { list as functionList } from "@/api/device/function";
+import {
+  list as functionList
+} from "@/api/device/function";
 
-import { options as blogClass } from "@/api/music/blogclass";
+import {
+  options as blogClass
+} from "@/api/music/blogclass";
 
-import { options as mapList } from "@/api/operation/map";
+import {
+  options as mapList
+} from "@/api/operation/map";
 
 // 设备列表
 const devMixin = {
@@ -22,6 +37,7 @@ const devMixin = {
   methods: {
     getDevList(e) {
       getClientTypeList(e ? e : {}).then((res) => {
+        // console.log("获取设备列表==" + JSON.stringify(res));
         if (res.code === 0) {
           res.data.map((i) => {
             this.devOptions.push({
@@ -39,8 +55,7 @@ const devMixin = {
 const devModeMixin = {
   data() {
     return {
-      devModeOptions: [
-        {
+      devModeOptions: [{
           value: 1,
           label: "蓝牙",
           disabled: false,
@@ -74,7 +89,9 @@ const devCategoryMixin = {
   },
   methods: {
     getCateGory(status) {
-      categoryList({ status: status }).then((res) => {
+      categoryList({
+        status: status
+      }).then((res) => {
         res.data.map((i) => {
           this.categoryOptions.push({
             value: i.id,
@@ -90,8 +107,7 @@ const devCategoryMixin = {
 const devTypeMixin = {
   data() {
     return {
-      devTypeOptions: [
-        {
+      devTypeOptions: [{
           value: 0,
           label: "音响",
         },
@@ -133,8 +149,7 @@ const devFucMixin = {
 const yesOrNoMixin = {
   data() {
     return {
-      yesOrNoOptions: [
-        {
+      yesOrNoOptions: [{
           value: 0,
           label: "否",
         },
@@ -151,8 +166,7 @@ const yesOrNoMixin = {
 const serviceTimeMixin = {
   data() {
     return {
-      serviceTimeOptions: [
-        {
+      serviceTimeOptions: [{
           value: -1,
           label: "1天",
         },
@@ -205,8 +219,7 @@ const serviceTypeMixin = {
   data() {
     return {
       // 服务类型
-      serviceTypeOptions: [
-        {
+      serviceTypeOptions: [{
           value: 0,
           label: "签到",
         },
@@ -239,8 +252,7 @@ const serviceTypeMixin = {
 const isFreeMixin = {
   data() {
     return {
-      freeOptions: [
-        {
+      freeOptions: [{
           value: 0,
           label: "付费",
         },
@@ -257,8 +269,7 @@ const isFreeMixin = {
 const audioMixin = {
   data() {
     return {
-      audioOptions: [
-        {
+      audioOptions: [{
           value: 2,
           label: "广播电台",
         },
@@ -318,8 +329,7 @@ const audioMixin = {
 const sexMixin = {
   data() {
     return {
-      sexOptions: [
-        {
+      sexOptions: [{
           value: 0,
           label: "未知",
         },
@@ -340,8 +350,7 @@ const sexMixin = {
 const regionMixin = {
   data() {
     return {
-      regionOptions: [
-        {
+      regionOptions: [{
           value: 0,
           label: "内地",
         },
@@ -374,8 +383,7 @@ const regionMixin = {
 const languageMixin = {
   data() {
     return {
-      languageOptions: [
-        {
+      languageOptions: [{
           value: 1,
           label: "国语",
         },
@@ -456,8 +464,7 @@ const platformMixin = {
 const onOrOffMixin = {
   data() {
     return {
-      onOrOffOptions: [
-        {
+      onOrOffOptions: [{
           value: 1,
           label: "上架",
         },
@@ -474,8 +481,7 @@ const onOrOffMixin = {
 const disabledMixin = {
   data() {
     return {
-      disabledOptions: [
-        {
+      disabledOptions: [{
           value: 0,
           label: "上架",
         },
@@ -492,8 +498,7 @@ const disabledMixin = {
 const payTypeMixin = {
   data() {
     return {
-      payTypeOptions: [
-        {
+      payTypeOptions: [{
           value: 1,
           label: "免费",
         },
@@ -522,8 +527,7 @@ const payTypeMixin = {
 const albumTypeMixin = {
   data() {
     return {
-      albumTypeOptions: [
-        {
+      albumTypeOptions: [{
           value: 1,
           label: "Single",
         },
@@ -560,7 +564,9 @@ const addressMixin = {
   },
   methods: {
     getAddress() {
-      options({ type: 2 }).then((res) => {
+      options({
+        type: 2
+      }).then((res) => {
         if (res.code === 0) {
           res.data.map((i) => {
             this.addressOptions.push({
@@ -622,8 +628,7 @@ const blogClassMixin = {
 const currentMixin = {
   data() {
     return {
-      currentOptions: [
-        {
+      currentOptions: [{
           value: 0,
           label: "已生效",
         },
@@ -644,8 +649,7 @@ const currentMixin = {
 const coverMixin = {
   data() {
     return {
-      coverOptions: [
-        {
+      coverOptions: [{
           value: 0,
           label: "自定义封面",
         },
@@ -663,14 +667,11 @@ const channelMixin = {
   data() {
     return {
       channelOptions: {
-        2: [
-          {
-            value: 2,
-            label: "广播电台",
-          },
-        ],
-        6: [
-          {
+        2: [{
+          value: 2,
+          label: "广播电台",
+        }, ],
+        6: [{
             value: 6,
             label: "节目",
           },
@@ -679,8 +680,7 @@ const channelMixin = {
             label: "歌曲",
           },
         ],
-        8: [
-          {
+        8: [{
             value: 8,
             label: "播客专辑",
           },
@@ -693,18 +693,14 @@ const channelMixin = {
             label: "音乐专辑",
           },
         ],
-        16: [
-          {
-            value: 8,
-            label: "播客专辑",
-          },
-        ],
-        17: [
-          {
-            value: 2,
-            label: "广播电台",
-          },
-        ],
+        16: [{
+          value: 8,
+          label: "播客专辑",
+        }, ],
+        17: [{
+          value: 2,
+          label: "广播电台",
+        }, ],
       },
     };
   },
@@ -714,8 +710,7 @@ const channelMixin = {
 const systemMixin = {
   data() {
     return {
-      systemOptions: [
-        {
+      systemOptions: [{
           value: 1,
           label: "Android",
         },
@@ -761,21 +756,21 @@ const mapMixin = {
 
     areaFormatter(row) {
       if (this.mapOptions.length > 0) {
-        let province = row.province
-          ? this.mapOptions.find((i) => i.id == row.province)
-          : "";
+        let province = row.province ?
+          this.mapOptions.find((i) => i.id == row.province) :
+          "";
         let provinceName = province ? province.name : "";
 
         let city =
-          province && province.childList.length > 0
-            ? province.childList.find((i) => i.id == row.city)
-            : "";
+          province && province.childList.length > 0 ?
+          province.childList.find((i) => i.id == row.city) :
+          "";
         let cityName = city ? `-${city.name}` : "";
 
         let area =
-          city && city.childList.length > 0
-            ? city.childList.find((i) => i.id == row.area)
-            : "";
+          city && city.childList.length > 0 ?
+          city.childList.find((i) => i.id == row.area) :
+          "";
         let areaName = area ? `-${area.name}` : "";
         return `${provinceName}${cityName}${areaName}`;
       }
@@ -784,8 +779,30 @@ const mapMixin = {
 };
 
 export {
-  addressMixin, albumTypeMixin, audioMixin, blogClassMixin, channelMixin, contentMixin, coverMixin, currentMixin, devCategoryMixin, devFucMixin, devMixin,
-  devModeMixin, devTypeMixin, disabledMixin, isFreeMixin, languageMixin, mapMixin, onOrOffMixin, payTypeMixin, platformMixin, regionMixin, serviceTimeMixin,
-  serviceTypeMixin, sexMixin, systemMixin, yesOrNoMixin
+  addressMixin,
+  albumTypeMixin,
+  audioMixin,
+  blogClassMixin,
+  channelMixin,
+  contentMixin,
+  coverMixin,
+  currentMixin,
+  devCategoryMixin,
+  devFucMixin,
+  devMixin,
+  devModeMixin,
+  devTypeMixin,
+  disabledMixin,
+  isFreeMixin,
+  languageMixin,
+  mapMixin,
+  onOrOffMixin,
+  payTypeMixin,
+  platformMixin,
+  regionMixin,
+  serviceTimeMixin,
+  serviceTypeMixin,
+  sexMixin,
+  systemMixin,
+  yesOrNoMixin
 };
-

+ 55 - 32
src/utils/request.js

@@ -1,15 +1,29 @@
-import axios from 'axios'
-import { Notification, MessageBox, Message, Loading } from 'element-ui'
+import cache from '@/plugins/cache'
 import store from '@/store'
-import { getToken } from '@/utils/auth'
+import {
+  getToken
+} from '@/utils/auth'
 import errorCode from '@/utils/errorCode'
-import { tansParams, blobValidate } from "@/utils/ruoyi";
-import cache from '@/plugins/cache'
-import { saveAs } from 'file-saver'
+import {
+  blobValidate,
+  tansParams
+} from "@/utils/ruoyi"
+import axios from 'axios'
+import {
+  Loading,
+  Message,
+  MessageBox,
+  Notification
+} from 'element-ui'
+import {
+  saveAs
+} from 'file-saver'
 
 let downloadLoadingInstance;
 // 是否显示重新登录
-export let isRelogin = { show: false };
+export let isRelogin = {
+  show: false
+};
 
 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
 // 创建axios实例
@@ -46,10 +60,10 @@ service.interceptors.request.use(config => {
     if (sessionObj === undefined || sessionObj === null || sessionObj === '') {
       cache.session.setJSON('sessionObj', requestObj)
     } else {
-      const s_url = sessionObj.url;                  // 请求地址
-      const s_data = sessionObj.data;                // 请求数据
-      const s_time = sessionObj.time;                // 请求时间
-      const interval = 1000;                         // 间隔时间(ms),小于此时间视为重复提交
+      const s_url = sessionObj.url; // 请求地址
+      const s_data = sessionObj.data; // 请求数据
+      const s_time = sessionObj.time; // 请求时间
+      const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
       if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
         const message = '数据正在处理,请勿重复提交';
         console.warn(`[${s_url}]: ` + message)
@@ -61,8 +75,8 @@ service.interceptors.request.use(config => {
   }
   return config
 }, error => {
-    console.log(error)
-    Promise.reject(error)
+  console.log(error)
+  Promise.reject(error)
 })
 
 // 响应拦截器
@@ -71,8 +85,9 @@ service.interceptors.response.use(res => {
     const code = res.data.code || 200;
     // 获取错误信息
     const msg = errorCode[code] || res.data.msg || errorCode['default']
+
     // 二进制数据则直接返回
-    if(res.request.responseType ===  'blob' || res.request.responseType ===  'arraybuffer'){
+    if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
       return res.data
     }
     if (code === 401) {
@@ -82,16 +97,15 @@ service.interceptors.response.use(res => {
           confirmButtonText: '重新登录',
           cancelButtonText: '取消',
           type: 'warning'
-        }
-      ).then(() => {
-        isRelogin.show = false;
-        store.dispatch('LogOut').then(() => {
-          location.href = '/index';
-        })
-      }).catch(() => {
-        isRelogin.show = false;
-      });
-    }
+        }).then(() => {
+          isRelogin.show = false;
+          store.dispatch('LogOut').then(() => {
+            location.href = '/index';
+          })
+        }).catch(() => {
+          isRelogin.show = false;
+        });
+      }
       return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
     } else if (code === 500) {
       Message({
@@ -110,14 +124,15 @@ service.interceptors.response.use(res => {
   },
   error => {
     console.log('err' + error)
-    let { message } = error;
+    let {
+      message
+    } = error;
+
     if (message == "Network Error") {
       message = "后端接口连接异常";
-    }
-    else if (message.includes("timeout")) {
+    } else if (message.includes("timeout")) {
       message = "系统接口请求超时";
-    }
-    else if (message.includes("Request failed with status code")) {
+    } else if (message.includes("Request failed with status code")) {
       message = "系统接口" + message.substr(message.length - 3) + "异常";
     }
     Message({
@@ -131,10 +146,18 @@ service.interceptors.response.use(res => {
 
 // 通用下载方法
 export function download(url, params, filename) {
-  downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
+  downloadLoadingInstance = Loading.service({
+    text: "正在下载数据,请稍候",
+    spinner: "el-icon-loading",
+    background: "rgba(0, 0, 0, 0.7)",
+  })
   return service.post(url, params, {
-    transformRequest: [(params) => { return tansParams(params) }],
-    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+    transformRequest: [(params) => {
+      return tansParams(params)
+    }],
+    headers: {
+      'Content-Type': 'application/x-www-form-urlencoded'
+    },
     responseType: 'blob'
   }).then(async (data) => {
     const isLogin = await blobValidate(data);

+ 6 - 1
src/views/operation/activity/index.vue

@@ -198,7 +198,7 @@
             <el-option
               v-for="item in devOptions"
               :key="item.value"
-              :value="item.value"
+              :value="item.label"
               :label="item.label"
             />
           </el-select>
@@ -272,11 +272,16 @@ export default {
         deviceClientType: deviceClientType,
       };
 
+
+      console.log("操作参数==" + JSON.stringify(param));
       doExchange(param).then((res) => {
+        // 89860624650085884202
+        console.log("操作结果=" + JSON.stringify(param));
         if (res.code === 0) {
           this.dialogVisible = false;
           this.dialogData = {};
           this.$refs.dialogData.resetFields();
+          this.$message.success("操作成功!");
         }
       });
     },