zhaoxiaoqiang
2023-04-14 a5604d778ca31451a95d8dabdf94f7ebc78e5c55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!--
 
  门店管理-主页
 
-->
<template>
  <div class="stores-box h-100-g">
    <v-navbar title="门店管理" fixed></v-navbar>
    <van-search class="search" placeholder="请输入门店名称/负责人姓名/负责人手机号/渠道编码" v-model="value" shape='round' @search="onSearch" />
    <div class="item-box">
      <van-list v-model="loading" :finished="finished" immediate-check='false' offset="50" finished-text="没有更多了" @load="onLoad">
        <div class="stores-item flex-start-g" v-for="(item, index) in list" :key="index" @click="go(item.storeId)">
          <p class="icon-box flex-center-g">
            <svg class="icon" aria-hidden="true" style="width:25px;height:25px;fill:#fff">
              <use xlink:href="#iconyonghu"></use>
            </svg>
          </p>
          <div>
            <p class="name" v-text="item.storeName || ''">门店名称</p>
            <p class="c-text-666-g font-12-g" v-text="item.priMblNo || ''">13586695442</p>
          </div>
          <van-button :style="{background:$store.state.backColor}" class="opr-btn" @click.stop="goStoreOprs(item.storeId)" v-if="orgType != 2">店员管理</van-button>
        </div>
      </van-list>
    </div>
 
    <van-button class="btn" @click="$router.push(`/mine/stores-add?merId=${merId}`)" v-if='isShowAdd'>
      <div class="inner">
        <van-icon name="plus" />
        <span class="text">新增</span>
      </div>
    </van-button>
 
  </div>
</template>
 
<script>
import { mapState, mapGetters } from "vuex";
export default {
  name: "stores",
  data() {
    return {
      value: '',
      list: [],
      loading: false,
      finished: false,
      storeId: '',
      merId: '',
      merIdType:''//区分当前是商户进入当前页面或者门店进入当前页面
    }
  },
  computed: {
    ...mapState(['userinfo']),
    ...mapGetters(["orgType"]),
    isShowAdd(){
      return (this.orgType==1&&this.merIdType)||this.orgType==3;
    }
  },
  created() {
    this.merId = this.$route.query.merId ? this.$route.query.merId : this.userinfo.orgId;
    this.merIdType = this.$route.query.merId;
    this.init();
  },
  methods: {
    init() {
      this.loading = true
      let objForm = {}
      if (this.orgType == 1 && !this.$route.query.merId) {
        objForm = {
          searchKey: this.value,
           storeId: this.storeId,
        }
      } else {
        objForm = {
          searchKey: this.value,
          storeId: this.storeId,
          merId: this.merId,
        }
      }
      this.$api.storeStoreList(objForm).then((res) => {
        if (res.body.storeList.length < 10) {
          this.list = [...this.list, ...res.body.storeList]
          this.storeId = ''
          this.finished = true
          this.loading = false
        } else {
          this.list = [...this.list, ...res.body.storeList]
          this.storeId = this.list[this.list.length - 1].storeId
          this.finished = false
          this.loading = false
        }
      })
    },
    goStoreOprs(storeId) {
      this.$router.push({
        path: '/mine/storesOprs',
        query: {
          storeId: storeId
        }
      })
    },
    go(id) {
      this.$router.push({ path: '/mine/stores-detail', query: { storeId: id } });
    },
 
    onLoad() {
      this.init()
    },
    onSearch(val) {
      this.list = []
      this.loading = true
        let objForm = {}
      if (this.orgType == 1 && !this.$route.query.merId) {
        objForm = {
          searchKey: this.value,
          // storeId: this.storeId,
        }
      } else {
        objForm = {
          searchKey: this.value,
          // storeId: this.storeId,
          merId: this.merId,
        }
      }
      this.$api.storeStoreList(objForm).then(res => {
        if (res.body.storeList.length < 10) {
          this.list = [...this.list, ...res.body.storeList]
          this.storeId = ''
          this.finished = true
          this.loading = false
        } else {
          this.list = [...this.list, ...res.body.storeList]
          this.storeId = this.list[this.list.length - 1].storeId
          this.finished = false
          this.loading = false
        }
      })
    }
 
 
  }
}
</script>
 
<style scoped lang="less">
.stores-box {
  background-color: @c-bg-f5;
  padding-top: 44px;
 
  .btn {
    position: fixed;
    width: 50px;
    height: 50px;
    padding: 0;
    right: 8px;
    bottom: 68px;
    border-radius: 50%;
    color: @c-text-f5;
    z-index: @zIndex-50;
    box-shadow: 0px 5px 9px 0px rgba(80, 47, 183, 0.2);
    background: linear-gradient(
      0deg,
      rgba(106, 79, 188, 1),
      rgba(137, 110, 219, 1)
    );
 
    .inner {
      display: flex;
      flex-direction: column;
    }
 
    .text {
      .lh(15px);
    }
  }
 
  //搜索框
  .search {
    margin-top: 10px;
    padding: 15px 8px;
  }
 
  .item-box {
    background-color: @c-bg-fff;
    padding-bottom: 25px;
  }
 
  .stores-item {
    height: 67px;
    margin: 0 8px 10px;
    padding-left: 12px;
    box-shadow: 0px 0px 5px 0px rgba(66, 61, 93, 0.08);
    border-radius: 3px;
 
    .icon-box {
      width: 32px;
      height: 32px;
      margin-right: 15px;
      border-radius: 50%;
      background-color: @c-bg-black;
    }
 
    .name {
      margin-bottom: 5px;
      font-weight: bold;
      width: 200px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
 
    .opr-btn {
      .lh(25px);
      margin-right: 0px;
      padding: 0 12px;
      background: @c-bg-default;
      border-radius: 13px;
      color: @c-text-fff;
    }
  }
}
</style>