rk
23 小时以前 609a1931953b2298016bd2b0d6b410666b5ad7b9
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
<template>
  <div class="tiktok-config">
    <!-- 第一步 -->
    <div class="step-section">
      <div class="step-desc">
        第一步:请在<el-link type="primary" href="https://developer.open-douyin.com" target="_blank">《抖音开放平台》</el-link>创建应用,并在<el-link type="primary" href="https://open-douyin.com" target="_blank">《抖音来客》</el-link>创建门店、完成服务应用授权,授权成功后在抖音开放平台自建应用的应用管理中获取对应的Appkey和Secret,在抖音来客个人中心获取门店ID(AccountId)
      </div>
      <el-form ref="form" :model="form" label-width="100px" class="config-form">
        <el-form-item label="Appkey" required>
          <el-input v-model="form.appkey" placeholder="请输入" style="width: 400px;"></el-input>
          <span class="form-tip">抖音开放平台自建应用的应用管理-应用设置中查看</span>
        </el-form-item>
        <el-form-item label="Secret" required>
          <el-input v-model="form.secret" placeholder="请输入" style="width: 400px;"></el-input>
          <span class="form-tip">抖音开放平台自建应用的应用管理-应用设置中查看</span>
        </el-form-item>
        <el-form-item label="AccountId" required>
          <el-input v-model="form.accountId" placeholder="请输入" style="width: 400px;"></el-input>
          <span class="form-tip">抖音开放平台自建应用的应用管理-应用设置中查看</span>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="saveStep1">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
 
    <!-- 第二步 -->
    <div class="step-section">
      <div class="step-desc">
        第二步:完成参数配置后,点击查询门店获取门店信息,并完成门店绑定
      </div>
      <el-form ref="storeForm" :model="storeForm" label-width="100px" class="config-form">
        <el-form-item label="门店名称">
          <el-select v-model="storeForm.poiId" placeholder="请点击右侧查询按钮获取门店信息" style="width: 400px;">
            <el-option v-for="item in storeList" :key="item" :label="item" :value="item"></el-option>
          </el-select>
          <el-button @click="queryStore" style="margin-left: 10px;">查询门店</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="saveStep2">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
 
<script>
import { getDouyinConfigDTO, updateDouyinAppConfigDTO, updateDouyinPoiIdDTO } from '@/api/business/dictData.js'
import { poiList } from '@/api/business/douyinVerify.js'
export default {
  name: 'TiktokConfiguration',
  data () {
    return {
      form: {
        appkey: '',
        secret: '',
        accountId: ''
      },
      storeForm: {
      poiId: ''
    },
    storeList: []
  }
  },
  created () {
    this.loadConfig()
  },
  methods: {
    loadConfig () {
      getDouyinConfigDTO({}).then(res => {
        if (res) {
          this.form.appkey = res.clientKey || ''
          this.form.secret = res.clientSecret || ''
          this.form.accountId = res.accountId || ''
          this.storeForm.poiId = res.poiId || ''
        }
      }).catch(e => {
        this.$tip.apiFailed(e)
      })
    },
    saveStep1 () {
      if (!this.form.appkey || !this.form.secret || !this.form.accountId) {
        this.$message.warning('请填写完整信息')
        return
      }
      updateDouyinAppConfigDTO({
        accountId: this.form.accountId,
        clientKey: this.form.appkey,
        clientSecret: this.form.secret
      }).then(() => {
        this.$message.success('保存成功')
      }).catch(e => {
        this.$tip.apiFailed(e)
      })
    },
    queryStore () {
      if (!this.form.appkey || !this.form.secret || !this.form.accountId) {
        this.$message.warning('请先完成第一步参数配置')
        return
      }
      poiList({}).then(res => {
        this.storeList = res || []
      })
    },
    saveStep2 () {
      if (!this.storeForm.poiId) {
        this.$message.warning('请先选择门店')
        return
      }
      updateDouyinPoiIdDTO(this.storeForm.poiId).then(() => {
        this.$message.success('保存成功')
      })
    }
  }
}
</script>
 
<style lang="scss" scoped>
.tiktok-config {
  padding: 20px;
  background: #fff;
}
 
.step-section {
  margin-bottom: 30px;
}
 
.step-desc {
  font-size: 14px;
  color: #606266;
  margin-bottom: 20px;
  line-height: 1.8;
}
 
.config-form {
  ::v-deep .el-form-item__label {
    font-weight: 500;
  }
}
 
.form-tip {
  font-size: 12px;
  color: #999;
  margin-left: 10px;
}
</style>