Просмотр исходного кода

花掌柜(hd-App)限购处理与相关展示修改

shizhongqi 4 месяцев назад
Родитель
Сommit
09b3286d40

+ 12 - 6
hdApp/src/admin/item/detail.vue

@@ -80,19 +80,20 @@
         <view class="limit-buy-wrap">
           <tui-list-cell class="line-cell limit-buy-line" :hover="false">
             <view class="tui-title">每人限购</view>
-            <input v-model="form.limitBuy" style="width:300upx;" @focus="form.limitBuy=''" placeholder-class="phcolor" class="tui-input" name="limitBuy" placeholder="请填写,填0不限购" maxlength="50" type="number" />
+            <input v-model="form.limitBuy" style="width:160upx;" @focus="form.limitBuy=''" placeholder-class="phcolor" class="tui-input" name="limitBuy" placeholder="0不限购" maxlength="50" type="number" />
 
             <button v-if="productData.id > 0 && form.limitBuy>0" class="admin-button-com blue middle" @click.stop="clearBuyCache()" style="width:150upx;">清已购</button>
             <button v-else class="admin-button-com default middle" style="width:150upx;" @click.stop="">清已购</button>
+            <button v-if="productData.id > 0" class="admin-button-com blue middle" style="width:180upx;margin-left:10upx;" @click.stop="hasBuyList">已购列表</button>
           </tui-list-cell>
           <tui-list-cell v-if="showClearTime" class="line-cell limit-buy-line" :hover="false">
             <view class="tui-title">清空时间</view>
-            <uni-datetime-picker
+            <datetime-picker
               v-model="form.limitBuyClearTime"
               type="datetime"
               return-type="string"
               class="limit-time-picker"
-              placeholder="请选择时间,空则不自动清空"
+              placeholder="空则不自动清空"
             />
           </tui-list-cell>
         </view>
@@ -479,7 +480,7 @@
 import TuiListCell from "@/components/plugin/list-cell";
 const form = require("@/utils/formValidation.js");
 import { getAllItemClass } from "@/api/item-class";
-import { applyAuth,modifyCgStaff,setLosing,modifyUnit,modifyRatio,modifyWeight,clearLimitBuy,changeVirtualStock } from '@/api/item';
+import { applyAuth,modifyCgStaff,modifyUnit,modifyRatio,modifyWeight,clearLimitBuy,changeVirtualStock } from '@/api/item';
 import { getAllUnit } from "@/api/unit";
 import { addProduct,updateProduct,getProductDetail,py,print,modifyOnStockFn,delStatusUpdate,changeBelongCost,modifyPartAcceptItem } from "@/api/product";
 import { getPtItemDetail } from "@/api/pt-item";
@@ -487,6 +488,7 @@ import { wastage } from "@/api/order";
 import { mapGetters } from "vuex"
 //图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
 import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
+import DatetimePicker from "@/components/mx-datepicker/datetime-picker.vue"
 import ModalModule from "@/components/plugin/modal"
 import { getAllStaff } from "@/api/shop-admin";
 import { partItem } from "@/api/part";
@@ -495,7 +497,8 @@ export default {
   components: {
     TuiListCell,
     htzImageUpload,
-    ModalModule
+    ModalModule,
+    DatetimePicker
   },
   data() {
     return {
@@ -1468,8 +1471,11 @@ export default {
       } else {
         this.$msg(checkRes);
       }
+    },
+    hasBuyList(){
+      this.$util.pageTo({url: '/admin/item/hasLimitBuyCustom?id='+this.productData.id})
     }
-  }
+  },
 };
 </script>
 <style lang="scss" scoped>

+ 243 - 0
hdApp/src/admin/item/hasLimitBuyCustom.vue

@@ -0,0 +1,243 @@
+<template>
+  <div class="app-main app-content">
+    <block v-if="!$util.isEmpty(customList)">
+      <block v-for="(item, index) in customList" :key="index">
+        <tui-list-cell>
+          <div class="tui-msg-box">
+            <img :src="item.smallAvatar" class="tui-msg-pic" mode="widthFix" />
+            <div class="tui-msg-item">
+              <div class="tui-msg-name">
+                <div class="tui-user-name">
+                  {{ item.name }}
+                  <text v-if="item.level == 2" class="super-man">大客户</text>
+                </div>
+              </div>
+              <div class="tui-msg-content">
+                <span>{{ item.visitTime.substr(5,11) }}</span>
+                <span style="color:black;margin-left:20upx;">已购 {{ item.hasLimitBuyNum }}</span>
+                <span style="color:black;margin-left:20upx;color:red;font-weight:bold;" v-if="item.hasReachLimitBuyNum == 1">已不能购买</span>
+              </div>
+            </div>
+            <button class="admin-button-com blue middle" @click="clearBuy(item)">清空已购</button>
+          </div>
+        </tui-list-cell>
+      </block>
+    </block>
+    <block v-else>
+      <app-wrapper-empty :is-empty="$util.isEmpty(customList)" title="暂无记录" />
+    </block>
+  </div>
+</template>
+<script>
+import TuiListCell from "@/components/plugin/list-cell";
+import BadgeModule from "@/components/plugin/badge";
+import AppWrapperEmpty from "@/components/app-wrapper-empty";
+import appVipModule from "@/components/module/app-vip";
+import AppTag from "@/components/module/app-tag.vue";
+import AppSearchModule from "@/components/module/app-search";
+import { list } from "@/mixins";
+import { hasLimitBuyCustomList, clearOneLimitBuy } from "@/api/item";
+export default {
+  name: "hasLimitBuyCustom",
+  components: {
+    TuiListCell,
+    BadgeModule,
+    AppWrapperEmpty,
+    appVipModule,
+    AppTag,
+    AppSearchModule
+  },
+  mixins: [list],
+  data() {
+    return {
+      customList:[]
+    };
+  },
+  methods: {
+    init() {
+      hasLimitBuyCustomList({id:this.option.id}).then(res=>{
+        if(res.code == 1){
+          this.customList = res.data.customList ? res.data.customList : []
+        }
+      })
+    },
+    clearBuy(info){
+      this.$util.confirmModal({content:'确认清空?清空后客户可重新下单'},() => {
+        clearOneLimitBuy({customId:info.id,productId:this.option.id}).then(res=>{
+          if(res.code == 1){
+            this.$msg('清空成功')
+            this.init()
+          }
+        })
+      })
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.app-content {
+  padding-top: 10upx;
+  padding-bottom: 20upx;
+}
+.tabs-wrap {
+  position: fixed;
+  .tabs-left {
+    width: 80%;
+  }
+  .tabs-right {
+    width: 19%;
+    border-left: $borderColor;
+    @include disFlex(center, center);
+  }
+}
+  .input-wrap_box {
+    background-color: #fff;
+    position: fixed;
+    top: 0;
+    z-index: 10;
+    width: 100%;
+    height: 100upx;
+    display: flex;
+    align-items: center;
+    padding: 0 30upx;
+    & > view:nth-child(1) {
+      flex: 1;
+    }
+  }
+.tui-list-cell {
+  width: 100%;
+}
+.tui-msg-box {
+  width: 100%;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  .tui-msg-pic {
+    width: 80upx;
+    height: 80upx;
+    border-radius: 50%;
+    margin-right: 20upx;
+  }
+
+  .tui-msg-item {
+    flex: 1;
+    min-width: 0;
+    max-width: 500upx;
+    min-height: 80upx;
+    overflow: hidden;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+    & > div {
+      @include disFlex(center, flex-start);
+      & > div:first-child {
+        margin-right: 8upx;
+      }
+    }
+    .level-img {
+      ::v-deep.vip-text {
+        left: 70upx;
+        top: 8upx;
+      }
+    }
+    .normal-img {
+      width: 70upx;
+      padding: 2upx 6upx;
+      color: #999;
+      background-color: #f0f2f6;
+      border-radius: 20upx;
+      .vip-text {
+        font-size: 24upx;
+        transform: scale(0.6);
+        position: relative;
+        top: -2upx;
+        left: -8upx;
+      }
+    }
+    .member-img {
+      width: 70upx;
+      padding: 2upx 6upx;
+      color: green;
+      background-color: #f0f2f6;
+      border-radius: 20upx;
+      .vip-text {
+        font-size: 24upx;
+        transform: scale(0.6);
+        position: relative;
+        top: -2upx;
+        left: -8upx;
+      }
+    }
+    .iconfont {
+      color: #00aaed;
+    }
+  }
+
+  .tui-msg-name {
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+    font-size: 30upx;
+    line-height: 1;
+    color: #262b3a;
+    .tui-user-name {
+      overflow: hidden;
+      text-overflow: ellipsis;
+      white-space: nowrap;
+      width: 290upx;
+      .super-man{
+        margin-left:20upx;
+        color:red;
+        font-size:24upx;
+        display:inline-block;
+        color:white;
+        border:1upx solid green;
+        padding:8upx 10upx;
+        background-color: green;
+        border-radius: 11upx;
+      }
+    }
+  }
+
+  .tui-msg-content {
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+    font-size: 24upx;
+    line-height: 1;
+    color: #9397a4;
+    .debt-amount{
+      margin-left:20upx;
+      .amount_num{
+        color:red;
+        margin-left:6upx;
+        font-weight:bold;
+      }
+    }
+  }
+  .admin-button-com {
+    margin-left: 20upx;
+    white-space: nowrap;
+  }
+}
+.tui-msg-right {
+  max-width: 120upx;
+  height: 80upx;
+  margin-left: auto;
+  margin-right: 24upx;
+  text-align: right;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+.user_tag {
+  border: 1upx solid #cccccc;
+  padding: 5upx 12upx 5upx 12upx;
+  border-radius: 25upx;
+  color: #bbbbbb;
+  margin-right: 10upx;
+  margin-bottom: 12upx;
+  display: inline-block;
+  font-size: 30upx;
+}
+</style>

+ 12 - 0
hdApp/src/api/item/index.js

@@ -26,4 +26,16 @@ export const changeFrontHide = data => {
 
 export const changeVirtualStock = data => {
 	return https.get('/item/change-virtual-stock', data)
+}
+
+export const clearLimitBuy = data => {
+	return https.get('/item/clear-limit-buy', data)
+}
+
+export const clearOneLimitBuy = data => {
+	return https.get('/item/clear-one-limit-buy', data)
+}
+
+export const hasLimitBuyCustomList = data => {
+	return https.get('/item/has-limit-buy-custom-list', data)
 }

+ 139 - 0
hdApp/src/components/mx-datepicker/datetime-picker.vue

@@ -0,0 +1,139 @@
+<template>
+  <view class="uni-datetime-picker-wrap">
+    <picker mode="date" :value="dateValue" @change="onDateChange">
+      <view class="picker-item">
+        <text :class="dateText ? 'picker-value' : 'picker-placeholder'">
+          {{ dateText || placeholder }}
+        </text>
+      </view>
+    </picker>
+    <picker mode="time" :value="timeValue" @change="onTimeChange">
+      <view class="picker-item picker-item-time">
+        <text :class="timeText ? 'picker-value' : 'picker-placeholder'">
+          {{ timeText || '小时:分钟' }}
+        </text>
+      </view>
+    </picker>
+  </view>
+</template>
+
+<script>
+export default {
+  name: "UniDatetimePicker",
+  props: {
+    value: {
+      type: [String, Number],
+      default: ""
+    },
+    modelValue: {
+      type: [String, Number],
+      default: ""
+    },
+    type: {
+      type: String,
+      default: "datetime"
+    },
+    returnType: {
+      type: String,
+      default: "string"
+    },
+    placeholder: {
+      type: String,
+      default: "请选择日期"
+    }
+  },
+  data() {
+    return {
+      innerValue: ""
+    };
+  },
+  computed: {
+    currentValue() {
+      if (this.modelValue !== undefined && this.modelValue !== null && this.modelValue !== "") {
+        return String(this.modelValue);
+      }
+      if (this.value !== undefined && this.value !== null && this.value !== "") {
+        return String(this.value);
+      }
+      return this.innerValue;
+    },
+    dateText() {
+      if (!this.currentValue) return "";
+      return this.currentValue.split(" ")[0] || "";
+    },
+    timeText() {
+      if (!this.currentValue) return "";
+      const t = this.currentValue.split(" ")[1] || "";
+      if (!t) return "";
+      return t.length >= 5 ? t.slice(0, 5) : t;
+    },
+    dateValue() {
+      return this.dateText || this.formatDate(new Date());
+    },
+    timeValue() {
+      return this.timeText || "00:00";
+    }
+  },
+  watch: {
+    currentValue: {
+      immediate: true,
+      handler(val) {
+        this.innerValue = val || "";
+      }
+    }
+  },
+  methods: {
+    formatDate(dateObj) {
+      const y = dateObj.getFullYear();
+      const m = `${dateObj.getMonth() + 1}`.padStart(2, "0");
+      const d = `${dateObj.getDate()}`.padStart(2, "0");
+      return `${y}-${m}-${d}`;
+    },
+    emitValue(dateStr, timeStr) {
+      const next = `${dateStr} ${timeStr}:00`;
+      this.innerValue = next;
+      this.$emit("input", next);
+      this.$emit("update:modelValue", next);
+      this.$emit("change", next);
+    },
+    onDateChange(e) {
+      const dateStr = e.detail.value;
+      const timeStr = this.timeText || "00:00";
+      this.emitValue(dateStr, timeStr);
+    },
+    onTimeChange(e) {
+      const timeStr = e.detail.value;
+      const dateStr = this.dateText || this.formatDate(new Date());
+      this.emitValue(dateStr, timeStr);
+    }
+  }
+};
+</script>
+
+<style scoped lang="scss">
+.uni-datetime-picker-wrap {
+  width: 470upx;
+  display: flex;
+  align-items: center;
+}
+.picker-item {
+  height: 62upx;
+  border: 1upx solid #d9d9d9;
+  border-radius: 8upx;
+  padding: 0 18upx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+.picker-item-time {
+  margin-left: 12upx;
+}
+.picker-placeholder {
+  color: #b8b8b8;
+  font-size: 24upx;
+}
+.picker-value {
+  color: #333333;
+  font-size: 26upx;
+}
+</style>

+ 2 - 1
hdApp/src/pages.json

@@ -97,7 +97,8 @@
 				{"path": "detail","style": {"navigationBarTitleText": "花材详情"}},
 				{"path": "add","style": {"navigationBarTitleText": "添加花材"}},
 				{"path": "selectItem","style": {"navigationBarTitleText": "选择花材"}},
-				{"path": "picTextAdd-Edit","style": {"navigationBarTitleText": "修改简介"}}
+				{"path": "picTextAdd-Edit","style": {"navigationBarTitleText": "修改简介"}},
+				{"path": "hasLimitBuyCustom","style": {"navigationBarTitleText": "已购列表"}}
 			]
 		},
 		{