瀏覽代碼

批量发放优惠券和消息的问题

YY 2 年之前
父節點
當前提交
f7899fb125

+ 3 - 0
src/store/index.js

@@ -47,6 +47,8 @@ import afterSale from './module/shop/afterSale';
 import getTransportInfo from './module/shop/getTransportInfo';
 import shopNotice from './module/shop/shopNotice';
 import goodsRate from './module/shop/goodsRate';
+// 批量发放优惠券
+import giveCoupon from './module/shop/giveCoupon';
 
 // 订单
 import order from './module/trade/order';
@@ -95,6 +97,7 @@ export default new Vuex.Store({
     admin,
     shop,
     address,
+    giveCoupon,
     goods,
     dictIndex,
     dictData,

+ 44 - 0
src/store/module/shop/giveCoupon.js

@@ -0,0 +1,44 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+const _ = require('lodash');
+Vue.use(Vuex);
+const api = {
+  url: '/point/v1/api/userCoupon/giveCoupon',
+};
+
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.url}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.url}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.url}/${payload}`);
+    return res;
+  },
+  async update({ commit }, payload) {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await this.$axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.url}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 2 - 2
src/views/platActivi/coupon/index.vue

@@ -161,12 +161,12 @@ export default {
       this.search(this.searchQuery);
     },
     toGrant({ data }) {
-      this.$set(this, `id`, data.id);
+      this.$set(this, `id`, data._id);
       this.$set(this, `view`, 'user');
     },
     // 修改
     async toEdit({ data }) {
-      this.$set(this, `id`, data.id);
+      this.$set(this, `id`, data._id);
       this.$set(this, `view`, 'info');
     },
     // 删除

+ 43 - 5
src/views/platActivi/coupon/parts/grantUser.vue

@@ -1,7 +1,7 @@
 <template>
   <div id="form-1">
     <el-row>
-      <el-col :span="24" class="main">
+      <el-col :span="24" class="main" v-loading="loadings" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
         <el-col class="top-btn">
           <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
         </el-col>
@@ -9,7 +9,7 @@
           <data-search :fields="searchFields" v-model="searchInfo" @query="search"> </data-search>
         </el-col>
         <el-col class="top-btn">
-          <el-button type="warning" size="mini" @click="toGrant()">批量发放</el-button>
+          <el-button type="warning" size="mini" @click="toGrants()">批量发放</el-button>
         </el-col>
         <el-col :span="24" class="four">
           <data-table
@@ -27,6 +27,11 @@
         </el-col>
       </el-col>
     </el-row>
+    <e-dialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="onSubmit"> </data-form>
+      </template>
+    </e-dialog>
   </div>
 </template>
 
@@ -36,12 +41,14 @@ const moment = require('moment');
 import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('users');
 const { mapActions: dictData } = createNamespacedHelpers('dictData');
+const { mapActions: giveCoupon } = createNamespacedHelpers('giveCoupon');
 export default {
   name: 'form-1',
   props: { id: { type: String } },
   components: {},
   data: function () {
     return {
+      loadings: true,
       // 列表
       opera: [{ label: '发放', method: 'grant', confirm: true }],
       // 多选值
@@ -76,10 +83,16 @@ export default {
       // 查询
       searchInfo: {},
       searchFields: [{ label: '用户姓名', model: 'name' }],
+      // 弹框
+      dialog: { title: '信息管理', show: false, type: '1' },
+      form: {},
+      infoFields: [{ label: '发放数量', model: 'num' }],
+      rules: { num: [{ required: true, message: '发放数量', trigger: 'blur' }] },
       // 性别
       genderList: [],
       // 用户状态
       useList: [],
+      user: [],
     };
   },
   async created() {
@@ -89,6 +102,7 @@ export default {
   methods: {
     ...dictData({ dictQuery: 'query' }),
     ...mapActions(['query', 'delete', 'fetch', 'update', 'create']),
+    ...giveCoupon({ giveCreate: 'create' }),
     // 查询
     async search({ skip = 0, limit = this.$limit, ...info } = {}) {
       let condition = _.cloneDeep(this.searchForm);
@@ -97,18 +111,42 @@ export default {
         this.$set(this, 'list', res.data);
         this.$set(this, 'total', res.total);
       }
+      this.loadings = false;
     },
     // 返回
     toBack() {
       this.$emit('toBack');
     },
     // 多选
-    handleSelect(data) {},
-    toGrant() {},
+    handleSelect(data) {
+      let arr = [];
+      for (const p1 of data) {
+        arr.push(p1._id);
+      }
+      this.$set(this, 'user', arr);
+    },
+    toGrant({ data }) {
+      if (data) this.user = [data._id];
+      this.dialog = { title: '信息管理', show: true, type: '1' };
+    },
+    toGrants() {
+      this.dialog = { title: '信息管理', show: true, type: '1' };
+    },
+    async onSubmit({ data }) {
+      data.users = this.user;
+      data.coupon = this.id;
+      let res = await this.giveCreate(data);
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `发放成功` });
+        this.toClose();
+      }
+    },
     // 重置
     toClose() {
-      this.fieldform = {};
+      this.form = {};
       this.search();
+      this.user = [];
+      this.dialog = { title: '信息管理', show: false, type: '1' };
     },
     async searchOther() {
       let res;

+ 17 - 3
src/views/selfShop/message/index.vue

@@ -2,7 +2,7 @@
   <div id="goods">
     <el-row>
       <el-col :span="24" class="main">
-        <el-col :span="8" class="left" v-loading="loadings" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
+        <el-col :span="8" class="left">
           <left-1 :roomList="roomList" @toView="toView"></left-1>
         </el-col>
         <el-col :span="16" class="non" v-if="show == '0'">
@@ -17,6 +17,9 @@
             @onSubmit="onSubmit"
             :form="form"
             :srcList="srcList"
+            :loadingRight="loadingRight"
+            @onMore="onMore"
+            :showMore="showMore"
           ></right-1>
         </el-col>
       </el-col>
@@ -38,6 +41,7 @@
 <script>
 const _ = require('lodash');
 const moment = require('moment');
+import * as util from '@/util/computed';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: room } = createNamespacedHelpers('room');
 const { mapActions: users } = createNamespacedHelpers('users');
@@ -53,9 +57,10 @@ export default {
   },
   data: function () {
     return {
-      loadings: false,
+      loadingRight: true,
       // 聊天房间列表
       roomList: [],
+      showMore: '0',
       // 聊天记录
       chatRecordList: [],
       // 用户信息
@@ -74,6 +79,7 @@ export default {
       // 判断显示聊天记录
       show: '0',
       message: {},
+      limit: 20,
     };
   },
   created() {
@@ -89,7 +95,6 @@ export default {
     async search() {
       const res = await this.roomQuery({ shop: this.user.shop._id });
       if (this.$checkRes(res)) this.$set(this, `roomList`, res.data);
-      this.loadings = false;
     },
     // 订单和售后跳转页面,联系买家
     async searchDetail() {
@@ -105,6 +110,12 @@ export default {
         }
       }
     },
+    onMore() {
+      this.limit = util.plus(this.limit, 20);
+      console.log(this.limit);
+      let data = { _id: this.form.room, customer: this.customer, shop: this.shop };
+      this.toView(data);
+    },
     // 查看
     async toView(data) {
       if (this.customer._id != data.customer._id) this.$set(this, `customer`, data.customer);
@@ -112,8 +123,10 @@ export default {
         this.$set(this, `form`, { room: data._id });
         // 处理已读
         let list = [];
+        // let res = await this.query({ room: data._id, limit: this.limit });
         let res = await this.query({ room: data._id });
         if (this.$checkRes(res)) {
+          // if (res.total > this.limit) this.showMore = '1';
           // 聊天记录列表
           let arr1 = res.data.reverse();
           this.$set(this, `chatRecordList`, arr1);
@@ -136,6 +149,7 @@ export default {
         }
       }
       this.show = '1';
+      this.loadingRight = false;
     },
     // 发送图片
     toUp() {

+ 21 - 2
src/views/selfShop/message/parts/right-1.vue

@@ -1,12 +1,15 @@
 <template>
   <div id="right-1">
     <el-row>
-      <el-col :span="24" class="main">
+      <el-col :span="24" class="main" v-loading="loadingRight" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
         <el-col :span="24" class="right_one">
           <p class="right_one_name">{{ customer.name }}</p>
         </el-col>
         <div id="scrolldIV" class="scroll-div" ref="scrollContent">
           <!-- <el-col :span="24" class="right_two"> -->
+          <!-- <el-col :span="24" class="more" v-if="showMore == '1'">
+            <span @click="onMore()">查看更多消息</span>
+          </el-col> -->
           <el-col :span="24" v-for="item in chatRecordList" :key="item._id">
             <el-col :span="24" class="right_time">{{ item.time }}</el-col>
             <el-col :span="24" class="right_left" v-if="item.speaker != user.shop._id">
@@ -66,6 +69,8 @@ export default {
     shop: { type: Object },
     form: { type: Object },
     srcList: { type: Array },
+    loadingRight: { type: Boolean },
+    // showMore: { type: String },
   },
   components: {},
   data: function () {
@@ -82,7 +87,7 @@ export default {
       setTimeout(() => {
         this.$nextTick(() => {
           //一定要在this.$nextTick进行设置
-          me.$refs.scrollContent.scrollTop = 100000;
+          me.$refs.scrollContent.scrollTop = 1000000000;
           var container = this.$el.querySelector('scrolldIV');
           // container.scrollTop = container.scrollHeight;
           // console.log(container.scrollHeight);
@@ -92,6 +97,14 @@ export default {
     toUp() {
       this.$emit('toUp');
     },
+    // onMore() {
+    //   this.$emit('onMore');
+    //   this.$nextTick(() => {
+    //     let msg = document.getElementById('scrolldIVs'); // 获取对象
+    //     let distanceFromBottom = msg.scrollHeight - msg.scrollTop - msg.clientHeight;
+    //     msg.scrollTop = distanceFromBottom; // 滚动高度
+    //   });
+    // },
     onSubmit(data) {
       this.$emit('onSubmit', data);
     },
@@ -139,6 +152,12 @@ export default {
   overflow: auto;
   margin: 0 15px;
 }
+.more {
+  text-align: center;
+  color: blue;
+  margin: 4px 0;
+  cursor: pointer;
+}
 // .right_two {
 //   background: rgb(246, 246, 246);
 //   height: 62vh;