Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a539fd5a
authored
Jan 19, 2023
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
短链小程序展示页面
1 parent
4ec29ce2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
248 additions
and
56 deletions
linkwe-uniapp/api/intelligentShortLink.js
linkwe-uniapp/pages.json
linkwe-uniapp/pages/index/index.vue
linkwe-uniapp/pages/index/mixin.js
linkwe-uniapp/utils/request.js
linkwe-uniapp/api/intelligentShortLink.js
0 → 100644
View file @
a539fd5
import
request
from
'@/utils/request'
import
config
from
'@/config.js'
const
service
=
config
.
services
.
wecom
+
'/short/link'
// 智能短链
// 列表
export
function
getList
(
data
)
{
return
request
({
url
:
service
+
'/list'
,
params
:
data
,
})
}
// 通过短链接获取短链详情
export
function
getDetail
(
path
)
{
return
request
({
url
:
service
+
'/getByShort/'
+
path
,
})
}
// 删除
export
function
remove
(
id
)
{
return
request
({
url
:
service
+
'/delete/'
+
id
,
method
:
'DELETE'
,
})
}
// 新增
export
function
add
(
data
)
{
return
request
({
url
:
service
+
'/add'
,
method
:
'POST'
,
data
,
})
}
// 修改
export
function
update
(
data
)
{
return
request
({
url
:
service
+
'/update/'
+
id
,
method
:
'PUT'
,
data
,
})
}
// 短链数据统计(传ID查单个)
export
function
getAnalysis
(
id
)
{
return
request
({
url
:
service
+
'/data/statistics'
,
params
:
{
id
},
})
}
/**
* 短链折线统计
* {
beginTime,,string,false,,开始时间
endTime,,string,false,,结束时间
id,,integer,false,,主键id
}
*/
export
function
getLineAnalysis
(
data
)
{
return
request
({
url
:
service
+
'/line/statistics'
,
params
:
data
,
})
}
// 通过短链接获取短链详情
export
function
getDetailByUrl
(
shortUrl
)
{
return
request
({
url
:
service
+
'/getByShort/'
+
shortUrl
,
})
}
linkwe-uniapp/pages.json
View file @
a539fd5
{
{
"pages"
:
[
//pages数组中第一项表示应用启动页,参考:https
:
//uniapp.dcloud.io/collocation/pages
"pages"
:
[
//pages数组中第一项表示应用启动页,参考:https
:
//uniapp.dcloud.io/collocation/pages
{
{
"path"
:
"pages/index/index"
,
"path"
:
"pages/index/index"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"uni-app
"
"navigationBarTitleText"
:
"linkWeChat
"
}
}
}
}
],
],
"globalStyle"
:
{
"globalStyle"
:
{
"navigationBarTextStyle"
:
"black"
,
"navigationBarTextStyle"
:
"black"
,
"navigationBarTitleText"
:
"uni-app
"
,
"navigationBarTitleText"
:
"linkWeChat
"
,
"navigationBarBackgroundColor"
:
"#F8F8F8"
,
"navigationBarBackgroundColor"
:
"#F8F8F8"
,
"backgroundColor"
:
"#F8F8F8"
"backgroundColor"
:
"#F8F8F8"
},
},
...
...
linkwe-uniapp/pages/index/index.vue
View file @
a539fd5
<
template
>
<
template
>
<view
class=
"content"
>
<view
class=
"content"
>
<image
class=
"logo"
src=
"/static/logo.png"
></image>
<template
v-if=
"data.type == 0"
>
<view
class=
"text-area"
>
<div
class=
"mask"
style=
"position: absolute"
>
<text
class=
"title"
>
{{
title
}}
</text>
<div
class=
"cc ac g-card g-pad20"
style=
"width: 70%"
>
公众号文章示例
</div>
</view>
</div>
</
template
>
<
template
v-else-if=
"[7, 9, 10].includes(+data.type)"
>
<div
class=
"g-card g-pad20 cc ac"
style=
"width: 80%"
>
小程序
<image
style=
"width: 120px; height: 120px"
:src=
"data.avatar"
error=
"头像"
fit=
"fit"
></image>
<button
type=
"primary"
>
点击打开小程序
</button>
</div>
</
template
>
<
template
v-else
>
<div
class=
"g-card g-pad20 cc ac"
style=
"width: 80%"
>
<div
class=
"al bfc-o"
>
<image
class=
"fl mr10"
style=
"width: 50px; height: 50px"
:src=
"data.avatar"
error=
"头像"
fit=
"fit"
></image>
<div
class=
"toe"
>
{{
data
.
name
||
'名称'
}}
</div>
<div
class=
"tips mt20 toe"
>
{{
data
.
describe
||
'描述'
}}
</div>
</div>
<image
style=
"width: 120px; height: 120px; margin: 20px 0"
:src=
"data.qrCode"
fit=
"fit"
></image>
<div
class=
"mt20"
>
长按二维码
{{
touchTypeDict
[
data
.
type
].
previewMobileTitle
}}
</div>
</div>
</
template
>
</view>
</view>
</template>
</template>
<
script
>
<
script
>
export
default
{
import
{
getDetail
}
from
'@/api/intelligentShortLink'
import
{
touchTypeDict
}
from
'./mixin'
export
default
{
data
()
{
data
()
{
return
{
return
{
title
:
'Hello'
loading
:
false
,
data
:
{},
touchTypeDict
,
}
}
},
},
onLoad
()
{
onLoad
()
{},
created
()
{
// let id = this.$route.query.id
var
pages
=
getCurrentPages
()
var
page
=
pages
[
pages
.
length
-
1
]
// console.log(1,page.route)
this
.
getDetail
(
page
.
route
)
},
},
methods
:
{
methods
:
{
getDetail
(
path
)
{
}
this
.
loading
=
true
}
getDetail
(
path
)
.
then
(({
data
})
=>
{
this
.
data
=
data
uni
.
setNavigationBarTitle
({
title
:
touchTypeDict
[
data
.
type
].
previewMobileTitle
,
})
})
.
catch
(()
=>
{})
.
finally
(()
=>
{
this
.
loading
=
false
})
},
},
}
</
script
>
</
script
>
<
style
>
<
style
lang=
"scss"
scoped
></
style
>
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
}
.logo
{
height
:
200
rpx
;
width
:
200
rpx
;
margin-top
:
200
rpx
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-bottom
:
50
rpx
;
}
.text-area
{
display
:
flex
;
justify-content
:
center
;
}
.title
{
font-size
:
36
rpx
;
color
:
#8f8f94
;
}
</
style
>
linkwe-uniapp/pages/index/mixin.js
0 → 100644
View file @
a539fd5
export
const
typeDict
=
Object
.
freeze
({
1
:
{
name
:
'公众号'
,
touchType
:
{
0
:
{
name
:
'文章'
,
allName
:
'跳入微信-公众号-文章'
,
tip
:
'跳转进入微信后,打开一篇公众号文章'
,
previewMobileTitle
:
'公众号标题'
,
},
1
:
{
name
:
'二维码'
,
allName
:
'跳入微信-公众号-二维码'
,
tip
:
'跳转进入微信后,展示一张公众号二维码,长按引导关注'
,
previewMobileTitle
:
'添加公众号'
,
},
},
},
2
:
{
name
:
'个人微信'
,
touchType
:
{
2
:
{
name
:
'个人二维码'
,
allName
:
'跳入微信-个人微信-个人二维码'
,
tip
:
'跳转进入微信后,展示一张个人二维码,长按扫码添加好友'
,
previewMobileTitle
:
'添加微信'
,
},
3
:
{
name
:
'群二维码'
,
allName
:
'跳入微信-个人微信-群二维码'
,
tip
:
'跳转进入微信后,展示一张微信群二维码,长按扫码入群'
,
previewMobileTitle
:
'添加微信群'
,
},
},
},
3
:
{
name
:
'企业微信'
,
touchType
:
{
4
:
{
name
:
'员工活码'
,
allName
:
'跳入微信-企业微信-员工活码'
,
tip
:
'跳转进入微信后,展示一张企微员工活码,长按扫码添加企业员工'
,
previewMobileTitle
:
'添加企业员工'
,
},
5
:
{
name
:
'客群活码'
,
allName
:
'跳入微信-企业微信-客群活码'
,
tip
:
'跳转进入微信后,展示一张企微客群活码,长按扫码入群'
,
previewMobileTitle
:
'添加企业客群'
,
},
6
:
{
name
:
'门店导购活码'
,
allName
:
'跳入微信-企业微信-门店导购码'
,
tip
:
'跳转进入微信后,展示一张门店导购码,长按扫码添加附近门店的导购'
,
previewMobileTitle
:
'添加门店导购'
,
},
8
:
{
name
:
'门店群活码'
,
allName
:
'跳入微信-企业微信-门店群活码'
,
tip
:
'跳转进入微信后,展示一张门店群活码,长按扫码进入附近的门店群'
,
previewMobileTitle
:
'添加门店群'
,
},
},
},
4
:
{
name
:
'小程序'
,
touchType
:
{
7
:
{
name
:
'个人小程序'
,
allName
:
'跳入微信-小程序-个人小程序'
,
tip
:
'跳转进入微信后,直接打开一个个人小程序'
,
previewMobileTitle
:
'打开小程序'
,
},
9
:
{
name
:
'企业小程序'
,
allName
:
'跳入微信-小程序-企业小程序'
,
tip
:
'跳转进入微信后,直接打开一个企业小程序'
,
previewMobileTitle
:
'打开小程序'
,
},
10
:
{
name
:
'小程序二维码'
,
allName
:
'跳入微信-小程序-小程序二维码'
,
tip
:
'跳转进入微信后,展示一张小程序二维码,长按扫码打开小程序'
,
previewMobileTitle
:
'打开小程序'
,
},
},
},
})
const
touchTypeDict
=
{}
Object
.
values
(
typeDict
).
forEach
((
element
)
=>
Object
.
assign
(
touchTypeDict
,
element
.
touchType
))
export
{
touchTypeDict
}
linkwe-uniapp/utils/request.js
View file @
a539fd5
import
Request
from
'@/js_sdk/luch-request/index.js'
import
Request
from
'@/js_sdk/luch-request/
luch-request/
index.js'
import
cfg
from
'@/config.js'
import
cfg
from
'@/config.js'
const
http
=
new
Request
()
const
http
=
new
Request
()
http
.
interceptors
.
request
.
use
((
config
)
=>
{
// 可使用async await 做异步操作
http
.
interceptors
.
request
.
use
(
(
config
)
=>
{
// 可使用async await 做异步操作
// config.header = {
// config.header = {
// ...config.header,
// ...config.header,
// a: 1 // 演示拦截器header加参
// a: 1 // 演示拦截器header加参
...
@@ -22,28 +24,34 @@ http.interceptors.request.use((config) => { // 可使用async await 做异步操
...
@@ -22,28 +24,34 @@ http.interceptors.request.use((config) => { // 可使用async await 做异步操
}
}
**/
**/
return
config
return
config
},
config
=>
{
// 可使用async await 做异步操作
},
(
config
)
=>
{
// 可使用async await 做异步操作
return
Promise
.
reject
(
config
)
return
Promise
.
reject
(
config
)
})
},
)
http
.
interceptors
.
response
.
use
((
response
)
=>
{
http
.
interceptors
.
response
.
use
(
(
response
)
=>
{
/* 对响应成功做点什么 可使用async await 做异步操作*/
/* 对响应成功做点什么 可使用async await 做异步操作*/
let
data
=
response
.
data
let
data
=
response
.
data
if
(
data
.
code
==
200
||
data
.
code
!=
0
&&
data
.
code
!=
500
)
{
if
(
data
.
code
==
200
||
(
data
.
code
!=
0
&&
data
.
code
!=
500
)
)
{
return
data
.
result
||
data
.
record
||
data
.
data
return
data
.
result
||
data
.
record
||
data
.
data
}
}
uni
.
hideLoading
();
uni
.
hideLoading
()
uni
.
showToast
({
uni
.
showToast
({
icon
:
'none'
,
icon
:
'none'
,
title
:
data
.
msg
,
title
:
data
.
msg
,
duration
:
2000
duration
:
2000
,
})
})
return
Promise
.
reject
(
response
)
// return Promise.reject 可使promise状态进入catch
return
Promise
.
reject
(
response
)
// return Promise.reject 可使promise状态进入catch
},
(
response
)
=>
{
},
(
response
)
=>
{
/* 对响应错误做点什么 (statusCode !== 200)*/
/* 对响应错误做点什么 (statusCode !== 200)*/
console
.
log
(
response
)
console
.
log
(
response
)
return
Promise
.
reject
(
response
)
return
Promise
.
reject
(
response
)
})
},
)
export
async
function
post
(
url
,
data
)
{
export
async
function
post
(
url
,
data
)
{
return
http
.
request
({
return
http
.
request
({
...
@@ -59,12 +67,11 @@ export async function get(url, params) {
...
@@ -59,12 +67,11 @@ export async function get(url, params) {
})
})
}
}
export
default
function
(
config
=
{
export
default
function
(
config
=
{})
{
method
:
'get'
})
{
config
.
baseURL
=
cfg
.
BASE_API
config
.
baseURL
=
cfg
.
BASE_API
if
(
config
.
method
.
toLowerCase
()
===
'get'
&&
!
config
.
params
)
{
// 兼容get方法使用data传参
if
((
config
.
method
||
'get'
).
toLowerCase
()
===
'get'
&&
!
config
.
params
)
{
config
.
params
=
config
.
data
config
.
params
=
config
.
data
}
}
return
request
(
config
)
return
http
.
request
(
config
)
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment