index.vue
10.8 KB
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<template>
<div class="short-link-container">
<div class="title">小程序短链</div>
<div class="wrapper">
<glsxCombiForm :isInline="false" :formRules="editRule" labelWidth="154px" defaultWidth="474px" :formObj="editForm" :formData="editFormDataPro">
<div slot="tip" class="tip_widget">
<div class="left">常用页面路径:</div>
<div class="right">
<div v-for="(item, index) in tipList" :key="index" class="right_page_title">{{ item.confName }}:{{ item.confId }}</div>
</div>
</div>
<div slot="btn" class="btn_wrap">
<el-button size="medium " @click="resetParam">重置</el-button>
<el-button size="medium " :disabled="btnDisable" type="primary" @click="comfirmShortLink">生成短链</el-button>
</div>
<div v-if="shortLink" slot="links" class="link_wrap">{{shortLink}}</div>
</glsxCombiForm>
</div>
<!-- <div v-if="shortLink" class="cell flex_sc">
<div class="default_w">小程序短链</div>
<el-input size="small" class="default_r_w" :value="shortLink" disabled></el-input>
<el-button class="copyBtn" size="small" type="primary" @click="copyLink">复制</el-button>
</div> -->
</div>
</template>
<script>
import glsxCombiForm from '@/components/glsx-combi-form'
const ENVVersion = ['trial', 'release']
const GH_MINI_APPID = 'wxfe82b8d65d07808f'
const DJ_MINI_APPID = 'wxe10067a63c1856ac'
const DJ_MINI_BEAT_APPID = 'wx9f91c1ec493eb425'
const ENVLIST = [
{
confId: 1,
confName: '体验版'
},
{
confId: 2,
confName: '线上版'
}
]
const MINI = [
{
confId: GH_MINI_APPID,
confName: '广汇车生活'
},
{
confId: DJ_MINI_APPID,
confName: '车生活助手'
},
{
confId: DJ_MINI_BEAT_APPID,
confName: '嘀加智享车生活体验版'
}
]
const MINIPAGELIST = [
{
confId: 'pages/tab/index/index',
djConfId: 'pages/tab/shopMall/index',
confName: '首页',
pageType: 1,
params:'tabIndex=0'
},
{
confId: 'pages/tab/equity/equity',
djConfId: 'pages/tab/shopMall/index',
confName: '权益首页',
pageType: 1,
params:'tabIndex=1'
},
{
confId: 'pages/tab/mall/mall',
djConfId: 'pages/tab/shopMall/index',
confName: '商城首页',
pageType: 1,
params:'tabIndex=2'
},
{
confId: 'packageEquity/pages/freecard/freecard',
djConfId: 'packageShopmall/packageEquity/pages/freecard/freecard',
confName: '试用会员领取页',
params:''
},
{
confId: 'packageEquity/pages/reviceVip/reviceVip',
djConfId: 'packageShopmall/packageEquity/pages/reviceVip/reviceVip',
confName: '无忧会员领取页',
params:''
}
]
const cloneText = message => {
let input = document.createElement('input')
input.value = message
document.body.appendChild(input)
input.select()
input.setSelectionRange(0, input.value.length), document.execCommand('Copy')
document.body.removeChild(input)
}
export default {
name: '',
components: {
glsxCombiForm
},
data() {
return {
shortLink: '',
btnDisable: false,
tipList: MINIPAGELIST,
editForm: {
env: '',
miniPrograme: '',
path: '',
merchantId: '',
query: ''
},
editFormDataPro: [
{
label: '小程序',
name: 'miniPrograme',
type: 'select',
isClear: true,
noFilter: true,
optionId: 'confId',
optionLabel: 'confName',
optionList: MINI,
changeAttr: val => {
this.resetShortLink()
this.resetPartQuery()
}
},
{
label: '小程序环境',
name: 'env',
type: 'select',
isClear: true,
noFilter: true,
optionId: 'confId',
optionLabel: 'confName',
optionList: ENVLIST,
isDisabled: false,
changeAttr: val => {
this.resetShortLink()
}
},
{
label: '小程序页面路径',
name: 'path',
type: 'input',
isClear: true,
inputBlur:(e)=>{
let target = MINIPAGELIST.find(item => (item.confId==this.editForm.path && item.pageType==1))
const href = window.location.host
this.editForm.query = (target && this.editForm.miniPrograme!=GH_MINI_APPID) ? target.params : ''
const queryTarget = this.editFormDataPro.find(item => item.name==='query')
queryTarget.isDisabled = target && this.editForm.miniPrograme!=GH_MINI_APPID
}
},
{
label: '',
name: 'tip',
addHtml: 'tip'
},
{
label: '商户号',
name: 'merchantId',
type: 'input',
isClear: true,
maxlength:8
},
{
label: '页面参数',
name: 'query',
type: 'input',
isClear: true,
placeholder: '如:name=vendor&color=black',
},
{
label: '',
name: 'btn',
addHtml: 'btn'
},
{
label: '',
name: 'links',
addHtml: 'links'
},
],
editRule:{
miniPrograme:[{ required: true, message: '请选择小程序', trigger: 'change' }],
env:[{ required: true, message: '请选择小程序环境', trigger: 'change' }],
path:[{ required: true, message: '请输入小程序页面路径', trigger: 'change' }],
merchantId:[
{ required: true, message: '请输入小程序商户号', trigger: 'change' },
{
validator: (rule, value, callback) => {
return /^[-\\+]?([0-9]+\\.?)?[0-9]{8}$/.test(value) ? callback() : callback(new Error('请输入8位数字'))
},
trigger: 'change'
}
],
}
}
},
watch: {
'editForm.merchantId'() {
this.resetShortLink()
},
'editForm.query'() {
this.resetShortLink()
}
},
created(){
// const href = window.location.host
// this.tipList = href.indexOf('cgacar') != -1 ? [...MINIPAGELIST] : [...DJMINIPAGELIST]
},
mounted() {
},
methods: {
// 切换小程序appID重置参数
resetPartQuery(){
this.editForm.path = ''
this.editForm.query = ''
this.editForm.env = ''
this.editForm.merchantId = ''
const queryTarget = this.editFormDataPro.find(item => item.name==='query')
queryTarget.isDisabled = false
},
// 重置页面
resetParam() {
this.editForm = {
env: '',
miniPrograme: '',
path: '',
merchantId: '',
query: ''
}
this.shortLink = ''
this.editFormDataPro[1].isDisabled = false
this.resetPartQuery()
},
resetShortLink() {
this.shortLink = null
this.btnDisable = false
},
// 自动匹配参数
matchParams(path) {
console.log(path)
// let para = {}
// let query = ''
// let arr = []
// for (let key in para) {
// arr.push(`${key}=${JSON.stringify(para[key])}`)
// }
// query = arr.join('&')
// this.editForm.query = query
},
comfirmShortLink() {
const { env, miniPrograme, path, merchantId, storeCode, query } = this.editForm
if (!miniPrograme) return this.toastMessage('请选择小程序')
if (!env) return this.toastMessage('请选择环境')
if (!path) return this.toastMessage('请输入小程序页面路径')
if (!merchantId) return this.toastMessage('请输入商户号')
if(merchantId.length<8)return this.toastMessage('请输入8位数的商户号')
if(!(/^[-\\+]?([0-9]+\\.?)?[0-9]{8}$/.test(merchantId)))return this.toastMessage('请输入8位数字的商户号')
let base_info = `merchantId=${merchantId}`
// if (miniPrograme == GH_MINI_APPID && !storeCode) return this.toastMessage('广汇小程序必须填入门店对应的sapCode')
// if (miniPrograme == GH_MINI_APPID && env == 3) return this.toastMessage('广汇小程序暂时没有预发布环境')
// if (storeCode) {
// base_info = `${base_info}&storeCode=${storeCode}`
// }
let target = MINIPAGELIST.find(item => (item.confId==this.editForm.path && item.pageType==1))
const href = window.location.host
let otherPath = (target && this.editForm.miniPrograme!=GH_MINI_APPID) ? target.djConfId : path
const params = {
envVersion: ENVVersion[env - 1],
appId: miniPrograme,
param: `${base_info}${query ? '&' : ''}${query}`,
path: otherPath,
merchantId
}
this.$apis.orderApi.getShortLinkUUID(params).then(res=>{
if(res.code==0){
this.shortLink = res.data
this.btnDisable = true
}else{
this.toastMessage(res.message)
}
})
// this.createShortLink(params).then(res => {
// if (res.code == 0) {
// this.shortLink = res.data
// this.btnDisable = true
// }
// })
// const qrPara = {
// appId: miniPrograme,
// qrcodeType,
// path,
// scene: query
// }
// if (!qrcodeType) return
// this.createQrCodeImage(qrPara).then(res => {
// if (res.code == 0) {
// this.qrcode = res.data
// }
// })
},
toastMessage(message, type = 3) {
const MESSAGE = ['info', 'success', 'warning', 'error']
this.$message({
message,
type: MESSAGE[type]
})
}
}
}
</script>
<style lang="scss" scoped>
.short-link-container {
background: white;
height: calc(100vh - 80px);
.title {
padding: 15px 20px;
font-weight: 500;
font-size: 16px;
color: #333333;
line-height: 28px;
border-bottom: 1px solid #e5e5e5;
}
.wrapper {
padding: 32px 19px;
.tip_widget {
width: 474px;
background: #f9f9f9;
border-radius: 4px;
box-sizing: border-box;
padding: 10px 20px;
margin: 20px 0 0px 0;
// display: flex;
.left,
.right_page_title {
font-weight: 400;
font-size: 12px;
color: #666666;
}
.right_page_title {
height: 20px;
}
.right,
.left {
line-height: 20px;
}
}
.btn_wrap{
display: flex;
}
.link_wrap{
width: 474px;
height: 80px;
background: #F4F6FC;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 400;
font-size: 14px;
color: #333333;
}
}
/deep/ .el-form-item__label {
padding-right: 0px !important;
}
/deep/ .el-form-item{
margin-bottom: 20px !important;
}
/deep/ .el-form-item:nth-child(3) {
margin-bottom: 0 !important;
}
}
.flex_sc {
display: flex;
align-items: center;
}
</style>