huangsijun
2025-09-22 a78c011de350b188afb03beb2f26a73f35f71986
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<template>
  <el-dialog title="客户应用" :visible.sync="dialogVisible" @close='dialogFormVisible' :close-on-click-modal="false"
    :close-on-press-escape="false">
    <div class="plus-container" v-loading="loading2">
 
      <div class="search" v-if="!form.app">
          <el-input v-model="shopinfo.app_name" style="width: 200px;" placeholder="商城名称"></el-input>
          <el-button size="small" type="primary" @click="open_shop">开通商城</el-button>
      </div>
      <div class="search" v-else>
          <el-row>
            <el-col :span="8">商城名称:{{form.app.app_name}}</el-col>
            <el-col :span="5">账户:{{form.shopuser.user_name}}</el-col>
            <el-col :span="5" v-if="form.app.is_delete==0">密码:{{form.roleaccess.length>0?form.shopuser.real_password :'绑定应用才可查看'}}</el-col>
            <el-col :span="5" v-if="form.app.is_delete==1"><span style="color:red;">此商城已被删除,无法使用!</span></el-col>
            <el-col :span="6">
              <el-link v-if="form.app.is_delete==0" :href="'/shop#/login?from=admin'" target="_blank" type="text" size="small">进入商城</el-link>
             <el-popover
                placement="bottom"
                title="已有权限"
                width="200"
                trigger="click"
                >
                <el-tree :data="data" :props="defaultProps"></el-tree>
                <el-button slot="reference" size="mini" @click="show_access(form.app.app_id)">商城权限</el-button>
              </el-popover>
            </el-col>
          </el-row>
 
      </div>
      <div v-for="(item, index) in tableData" :key="index" class="mb16">
        <div class="common-form d-s-c">
          <span>{{item.category_name}}</span>
 
        </div>
        <div class="plus-list">
          <div class="item" v-for="(child, num) in item.children" :key="num">
            <div class="item-box pr">
              <a href="javascript:void(0);" class="close-btn">
 
               <el-button type="success" disabled v-if="check(child.id)" size="mini">已绑定</el-button>
               <el-button type="primary" v-else size="mini" @click="bangClick(child)" :loading="loading">绑定</el-button>
               <el-popover
                  placement="bottom"
                  title="应用权限"
                  width="200"
                  trigger="click"
                  >
                  <el-tree :data="applicdata" :props="defaultProps"></el-tree>
                  <el-button style="margin-top:5px;" slot="reference" size="mini" @click="show_applic_access(child.id)">应用权限</el-button>
                </el-popover>
              </a>
              <a href="javascript:void(0);">
                <!-- <span class="iconfont icon icon-tubiaozhizuomoban-"></span> -->
                <img style="width: 40px;height: 40px;border-radius: 4px;" :src="child.app_icon" >
 
                <div class="ml10">
                  <h3>{{child.app_name}}</h3>
                  <p>{{child.app_use}}</p>
                  <p style="color: red;" v-if="agentInfo.level==2">金钻价格:¥{{child.admin_money}}</p>
                  <p style="color: red;" v-if="agentInfo.level==1">钻石价格:¥{{child.supplier_money}}</p>
                  <p style="color: red;" v-if="agentInfo.level==0">金牌价格:¥{{child.shop}}</p>
                </div>
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </el-dialog>
</template>
 
<script>
import ApplicationApi from '@/api/application.js';
 
export default {
  data() {
    return {
      form: {},
      /*左边长度*/
      formLabelWidth: '120px',
      /*是否显示*/
      dialogVisible: false,
      /*是否正在加载*/
      loading: false,
      tableData: [],
      applicList:[],
      ischange:false,
      loading2:true,
      shopinfo:{app_name:''},
      data: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      applicdata:[],
      agentInfo:{}
    };
  },
  props: ['open_applic','curModel'],
  created() {
    this.dialogVisible = this.open_applic;
    this.form=this.curModel;
    this.form.applic_arr=[];
    /*获取列表*/
    this.getData();
    this.getClientDetail();
  },
  methods: {
    getClientDetail(){
      let self=this;
      ApplicationApi.getClientDetail({client_id:this.curModel.client_id}, true).then(res => {
          self.form.app=res.data.data.app;
          self.form.role=res.data.data.role;
          self.form.roleaccess=res.data.data.roleaccess;
          self.form.shopuser=res.data.data.shopuser;
          self.form.app_id=res.data.data.app_id;
          self.agentInfo=res.data.agentInfo;
        })
        .catch(error => {
 
        });
    },
    show_applic_access(id){
      let self=this;
      ApplicationApi.getApplicRole({id:id}, true).then(res => {
          self.applicdata=res.data.menus;
        })
        .catch(error => {
 
        });
    },
    show_access(){
      let self=this;
      ApplicationApi.getRoleList(self.form.shopuser, true).then(res => {
          self.data=res.data.menus;
        })
        .catch(error => {
 
        });
    },
    open_shop(){
      let self=this;
      if(self.shopinfo.app_name==''){
        self.$message({
          message: '请填写商城名称',
          type: 'error'
        });
        return;
      }
      let params={'app_name':self.shopinfo.app_name,'client_id':self.form.client_id};
      const loading =this.$loading({
        lock: true,
        text: '提交中...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      ApplicationApi.addShop(params, true).then(res => {
          loading.close();
          self.$message({
            message: '恭喜你,成功开通商城',
            type: 'success'
          });
          self.getClientDetail();
        })
        .catch(error => {
            loading.close();
        });
    },
    /*绑定应用*/
    bangClick(e) {
      let self = this;
      let params = this.form;
      params.applic_info=e;
      if(self.form.app_id<=0){
        self.$message({
          message: '请先开通商城',
          type: 'error'
        });
        return;
      }
      let money=e.shop;
      if(self.agentInfo.level==1){
        money=e.supplier_money;
      }else if(self.agentInfo.level==2){
        money=e.admin_money;
      }
        self.$confirm('代理商需扣款'+money+'元,确定绑定此应用吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
        .then(() => {
          self.loading = true;
          ApplicationApi.bangApplic({params: JSON.stringify(params)}, true).then(res => {
              self.loading = false;
              self.$message({
                message: '恭喜你,成功绑定此应用',
                type: 'success'
              });
              //self.dialogFormVisible(true);
              self.getData();
              self.getClientDetail();
            })
            .catch(error => {
              self.loading = false;
            });
         })
         .catch(() => {});
    },
    check(id){
      if(this.ischange){
        var applic_arr=this.form.applic_arr;
        var index=applic_arr.indexOf(id);
        if(index==-1){
           return false;
        }else{
           return true;;
        }
      }
      var list=this.applicList;
      var checked=false;
      console.log(list);
      var applic_arr=this.form.applic_arr;
      for(var i=0;i<list.length;i++){
        if(list[i].applic_id==id){
           checked=true;
           applic_arr.push(id);
        }
      }
      this.form.applic_arr=applic_arr;
      console.log(checked);
      return checked;
    },
    /*获取列表*/
    getData() {
      let self = this;
      let Params = {client_id:this.form.client_id};
      ApplicationApi.plugslist(Params, true)
        .then(res => {
          self.loading2 = false;
          self.applicList=res.data.applicList;
          self.tableData = res.data.accessList;
          self.totalDataNumber = res.data.list.total;
 
        })
        .catch(error => {
          self.loading2 = false;
        });
    },
    /*关闭弹窗*/
    dialogFormVisible(e) {
      if (e) {
        this.$emit('closeDialog', {
          type: 'success',
          openDialog: false
        })
      } else {
        this.$emit('closeDialog', {
          type: 'error',
          openDialog: false
        })
      }
    }
  }
};
</script>
 
<style>
.plus-container {
  min-height: 400px;
}
.plus-container .common-form .close-btn{ color: #CCCCCC;}
.plus-list {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.plus-list .item {
  width: 33%;
}
.plus-list .item .item-box {
  margin: 0 10px 20px;
  border:1px solid #FFFFFF;
}
.plus-list .item .item-box .close-btn{ position: absolute; padding-left: 0; width: 20px; height: 20px; top: 10px; right: 50px; color: #ff0000; display: block;}
.plus-list .item .item-box:hover{ border-radius: 8px; border:1px dashed #CCCCCC;}
/* .plus-list .item .item-box:hover .close-btn{display: block;} */
.plus-list .item .add-item-box {
  width: 40px;
  height: 40px;
  margin-left: 20px;
  border-radius: 8px;
  border: 1px solid #186eeb;
}
.plus-list .item a {
  display: flex;
  height: 80px;
  padding-left: 10px;
  justify-content: flex-start;
  align-items: center;
}
.plus-list .item a h3 {
  font-weight: normal;
  color: #333333;
}
.plus-list .item a:hover h3 {
  color: #3a8ee6;
}
.plus-list .item a p {
  font-size: 12px;
  color: #999999;
}
.plus-list .item .item-box .iconfont {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  line-height: 40px;
  background: #3a8ee6;
}
.plus-list .item a .iconfont.icon {
  font-size: 22px;
  color: #ffffff;
}
.plus-list .item .item-box .el-button{
  padding: 5px 10px;
}
.el-popover{
  max-height: 300px;overflow-y: scroll
}
</style>