Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-h5-ailipay
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 3d81c261
authored
Dec 21, 2021
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit
1 parent
ff5aea9f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
231 additions
and
97 deletions
src/api/activityApi.js
src/api/liveApi.js
src/api/wxConfig.js
src/mixins/pageMixin.js
src/mixins/shareMixin.js
src/utils/util.js
src/views/activity/index.vue
src/views/coupon/index.vue
src/views/merchant/index.vue
src/api/activityApi.js
View file @
3d81c26
...
...
@@ -14,8 +14,7 @@ export default {
data
.
method
=
'scrm.api.shopmall.activity.get.shared'
return
window
.
$HTTP
({
url
,
data
,
returnAll
:
true
data
})
},
}
\ No newline at end of file
src/api/liveApi.js
View file @
3d81c26
...
...
@@ -13,8 +13,7 @@ export default {
data
.
method
=
'scrm.api.live.get.shared.code'
return
window
.
$HTTP
({
url
,
data
,
returnAll
:
true
data
})
},
}
\ No newline at end of file
src/api/wxConfig.js
View file @
3d81c26
...
...
@@ -302,11 +302,13 @@ const WxConfig = {
// desc: '', // 分享描述
// link: '', // 分享链接
// imgUrl: '' // 分享封面
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
invoke
(
"shareAppMessage"
,
obj
,
function
(
res
)
{
if
(
res
.
err_msg
==
"shareAppMessage:ok"
)
{
resolve
(
res
)
}
else
{
reject
(
res
)
}
}
)
...
...
@@ -322,7 +324,9 @@ const WxConfig = {
wx
.
invoke
(
'shareWechatMessage'
,
obj
,
function
(
res
)
{
if
(
res
.
err_msg
==
'shareWechatMessage:ok'
)
{
resolve
(
res
)
}
else
{
reject
(
res
)
}
}
)
...
...
src/mixins/pageMixin.js
View file @
3d81c26
...
...
@@ -11,7 +11,6 @@ export default {
},
mounted
()
{
let
{
tabIndex
}
=
this
.
getQuery
()
console
.
log
(
tabIndex
)
if
(
tabIndex
)
{
this
.
tabIndex
=
Number
(
tabIndex
)
this
.
updata
=
new
Date
().
getTime
()
...
...
src/mixins/shareMixin.js
View file @
3d81c26
import
{
wxConfig
}
from
'@/api'
import
{
shopmallApi
,
activityApi
,
couponApi
,
liveApi
,
boutiquecouponApi
,
equityApi
,
wxConfig
}
from
'@/api'
const
{
environment
}
=
window
.
$fetchConfig
import
{
Notify
}
from
'vant'
export
default
{
data
()
{
return
{
...
...
@@ -11,23 +13,171 @@ export default {
},
methods
:
{
wxInit
()
{
window
.
$wx
=
wxConfig
window
.
$wx
.
init
([
'shareAppMessage'
,
'sendChatMessage'
,
'getCurExternalContact'
,
'setClipboardData'
])
wxConfig
.
init
([
'shareAppMessage'
,
'sendChatMessage'
,
'getCurExternalContact'
])
},
showShareModel
(
i
)
{
let
{
tabIndex
}
=
this
if
(
tabIndex
==
0
&&
i
.
remainAmount
<
1
)
return
if
(
tabIndex
==
1
&&
i
.
residueAmount
<
1
)
return
window
.
$wx
.
getCurExternalContact
().
then
(
res
=>
{
console
.
log
(
'当前外部联系人'
,
res
)
i
.
userId
=
res
this
.
currentItem
=
i
this
.
showShare
=
true
}).
catch
(
err
=>
{
console
.
log
(
i
)
this
.
currentItem
=
i
this
.
showShare
=
true
wxConfig
.
getCurExternalContact
()
.
then
(
res
=>
{
console
.
log
(
'当前外部联系人'
,
res
)
i
.
is_contact
=
res
this
.
sendMessage
(
i
)
})
.
catch
(
err
=>
{
this
.
sendMessage
(
i
)
})
},
sendMessage
(
i
)
{
let
{
merchantId
}
=
this
.
getLocalStorage
(
'dj_scrm_userInfo'
)
let
{
tabIndex
}
=
this
let
{
name
}
=
this
.
$route
let
{
is_contact
,
userId
,
id
,
couponName
,
activityName
,
packageName
,
goodsName
,
goodsImage
}
=
i
let
shopmall_appId
=
environment
==
'beta'
?
'wx9f91c1ec493eb425'
:
'wxe10067a63c1856ac'
let
dj_appId
=
'wx06d1198e751435d1'
this
.
showLoading
()
/**is_contact 是否从侧边栏进入 */
switch
(
name
)
{
/**卡券 */
case
'coupon'
:
{
let
desc
=
'您的专属服务顾问为您发来了优惠券,请点击领取~'
let
imgUrl
=
'http://img01.glsx.com.cn/upload/biz/dracMini-yh-10004.png'
if
(
tabIndex
==
0
)
{
if
(
is_contact
)
this
.
sendChatMessage
({
appid
:
dj_appId
,
title
:
couponName
,
imgUrl
,
page
:
`/packagePersonal/pages/boutiquePages/gift/gift.html?id=
${
id
}
&userId=
${
userId
}
&employName=
${
this
.
toUnicode
(
i
.
employeeName
)}
`
})
else
{
boutiquecouponApi
.
getBoutiqueCoupon
({
id
}).
then
(
res
=>
{
this
.
shareAppMessage
(
res
,
desc
,
couponName
,
imgUrl
)
})
}
}
else
{
this
.
couponShare
(
i
,
res
=>
{
if
(
is_contact
)
this
.
sendChatMessage
({
appid
:
shopmall_appId
,
title
:
packageName
,
imgUrl
,
page
:
`/packageMall/pages/coupon/coupon.html?couponId=
${
id
}
&merchantId=
${
merchantId
}
`
})
else
this
.
shareAppMessage
(
res
,
desc
,
couponName
,
imgUrl
)
})
}
break
}
/**活动 */
case
'activity'
:
{
if
(
tabIndex
==
0
)
{
let
imgUrl
=
'http://img01.glsx.com.cn/upload/biz/dracMini-ms-10004.png'
if
(
is_contact
)
this
.
sendChatMessage
({
appid
:
shopmall_appId
,
title
:
activityName
,
imgUrl
,
page
:
`/packageMall/pages/detail/detail.html?isActivity=true&id=
${
id
}
&merchantId=
${
merchantId
}
`
})
else
{
activityApi
.
getShared
({
id
}).
then
(
res
=>
{
this
.
shareAppMessage
(
res
,
'您有一个秒杀活动可参加'
,
activityName
,
imgUrl
)
})
}
}
else
{
}
break
}
/**店铺 */
case
'merchant'
:
{
if
(
tabIndex
==
0
)
{
let
imgUrl
=
'http://img01.glsx.com.cn/upload/biz/dracMini-qy-10004.png'
if
(
is_contact
)
this
.
sendChatMessage
({
appid
:
shopmall_appId
,
title
:
packageName
,
imgUrl
,
page
:
`/packageEquity/pages/package/package?id=
${
id
}
&merchantId=
${
merchantId
}
`
})
else
{
equityApi
.
getEquityShared
({
id
}).
then
(
res
=>
{
this
.
shareAppMessage
(
res
.
url
,
'您的专属客服顾问为您发来了会员套餐,点击查看哦'
,
packageName
,
imgUrl
)
})
}
}
else
{
if
(
is_contact
)
this
.
sendChatMessage
({
appid
:
shopmall_appId
,
title
:
goodsName
,
imgUrl
:
goodsImage
,
page
:
`/packageMall/pages/detail/detail.html?id=
${
id
}
&merchantId=
${
merchantId
}
`
})
else
{
shopmallApi
.
getGoodsLink
({
id
}).
then
(
res
=>
{
this
.
shareAppMessage
(
res
,
''
,
goodsName
,
goodsImage
)
})
}
}
break
}
}
},
sendChatMessage
(
params
)
{
wxConfig
.
sendChatMessage
({
msgtype
:
'miniprogram'
,
miniprogram
:
params
,
enterChat
:
false
})
.
then
(()
=>
{
this
.
hideLoading
()
})
.
catch
(()
=>
{
this
.
hideLoading
()
})
},
shareAppMessage
(
link
,
desc
,
title
,
imgUrl
)
{
wxConfig
.
shareAppMessage
({
title
,
desc
,
link
,
imgUrl
})
.
then
(()
=>
{
this
.
hideLoading
()
})
.
catch
(()
=>
{
this
.
hideLoading
()
})
},
toUnicode
(
chineseStr
=
''
)
{
let
unicodeStr
=
''
for
(
let
i
=
0
,
iLength
=
chineseStr
.
length
;
i
<
iLength
;
i
++
)
{
unicodeStr
+=
'@'
+
chineseStr
.
charCodeAt
(
i
).
toString
(
16
)
}
return
unicodeStr
},
couponShare
(
item
,
callBack
)
{
let
{
userId
,
id
}
=
item
let
obj
=
{
couponId
:
id
,
shareType
:
1
}
if
(
userId
)
obj
.
userList
=
[
{
userId
}
]
else
obj
.
shareType
=
0
couponApi
.
getCouponShared
(
obj
).
then
(
res
=>
{
callBack
(
res
.
url
)
})
}
}
}
\ No newline at end of file
}
src/utils/util.js
View file @
3d81c26
import
Vue
from
'vue'
import
{
Toast
,
Dialog
}
from
'vant'
import
{
Toast
,
Dialog
}
from
'vant'
/**
* 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/
Date
.
prototype
.
format
=
function
(
fmt
)
{
Date
.
prototype
.
format
=
function
(
fmt
)
{
let
o
=
{
'M+'
:
this
.
getMonth
()
+
1
,
//月份
'd+'
:
this
.
getDate
(),
//日
'h+'
:
this
.
getHours
(),
//小时
'm+'
:
this
.
getMinutes
(),
//分
's+'
:
this
.
getSeconds
(),
//秒
//季度
'M+'
:
this
.
getMonth
()
+
1
,
//月份
'd+'
:
this
.
getDate
(),
//日
'h+'
:
this
.
getHours
(),
//小时
'm+'
:
this
.
getMinutes
(),
//分
's+'
:
this
.
getSeconds
(),
//秒
//季度
'q+'
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
'S'
:
this
.
getMilliseconds
()
//毫秒
}
;
S
:
this
.
getMilliseconds
()
//毫秒
}
if
(
/
(
y+
)
/
.
test
(
fmt
))
{
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
this
.
getFullYear
()
+
''
).
substr
(
4
-
RegExp
.
$1
.
length
))
}
for
(
let
k
in
o
)
{
if
(
new
RegExp
(
`(
${
k
}
)`
).
test
(
fmt
))
{
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
?
(
o
[
k
])
:
((
'00'
+
o
[
k
]).
substr
((
''
+
o
[
k
]).
length
)
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
==
1
?
o
[
k
]
:
(
'00'
+
o
[
k
]).
substr
((
''
+
o
[
k
]).
length
))
}
}
return
fmt
}
const
throttle
=
(
fn
,
gapTime
)
=>
{
if
(
gapTime
==
null
||
gapTime
==
undefined
)
{
gapTime
=
1500
}
let
_lastTime
=
null
return
function
()
{
let
_nowTime
=
+
new
Date
()
if
(
_nowTime
-
_lastTime
>
gapTime
||
!
_lastTime
)
{
fn
.
apply
(
this
,
arguments
)
_lastTime
=
_nowTime
}
if
(
gapTime
==
null
||
gapTime
==
undefined
)
{
gapTime
=
1500
}
let
_lastTime
=
null
return
function
()
{
let
_nowTime
=
+
new
Date
()
if
(
_nowTime
-
_lastTime
>
gapTime
||
!
_lastTime
)
{
fn
.
apply
(
this
,
arguments
)
_lastTime
=
_nowTime
}
}
/**防止重复点击 */
}
/**防止重复点击 */
const
showLoading
=
(
title
=
'加载中...'
)
=>
{
Toast
({
type
:
'loading'
,
...
...
@@ -52,27 +49,29 @@ const showLoading = (title = '加载中...') => {
})
}
const
hideLoading
=
()
=>
{
Toast
.
clear
()
}
/**num:要转换的数值,fixed:精确几位小数 */
console
.
log
(
'清除'
)
Toast
.
clear
()
}
/**num:要转换的数值,fixed:精确几位小数 */
const
decimal
=
(
num
,
fixed
)
=>
{
let
pow
=
Math
.
pow
(
10
,
fixed
)
return
Math
.
round
(
num
*
pow
)
/
pow
}
const
showToast
=
(
message
=
''
,
callBack
)
=>
{
let
params
=
{
message
,
forbidClick
:
tru
e
,
duration
:
1500
}
Toast
(
params
)
if
(
callBack
&&
typeof
callBack
==
'function'
)
{
setTimeout
(()
=>
{
callBack
()
},
1500
)
}
hideLoading
()
let
params
=
{
messag
e
,
forbidClick
:
true
,
duration
:
1500
}
Toast
(
params
)
if
(
callBack
&&
typeof
callBack
==
'function'
)
{
setTimeout
(()
=>
{
callBack
(
)
}
,
1500
)
}
/**触摸样式 */
}
/**触摸样式 */
const
touchstart
=
e
=>
{
e
.
target
.
classList
.
add
(
'btn-on-leave'
)
}
...
...
@@ -98,28 +97,28 @@ const removeLocalStorage = key => {
window
.
localStorage
.
removeItem
(
key
)
}
const
dialog
=
(
params
=
{})
=>
{
if
(
!
params
.
confirmButtonColor
)
params
.
confirmButtonColor
=
'#FF7336'
return
Dialog
.
confirm
(
params
)
}
/**拨打电话 */
if
(
!
params
.
confirmButtonColor
)
params
.
confirmButtonColor
=
'#FF7336'
return
Dialog
.
confirm
(
params
)
}
/**拨打电话 */
const
makePhoneCall
=
phoneNumber
=>
{
window
.
location
.
href
=
`tel://
${
phoneNumber
}
`
}
/**是否全面屏 */
const
isFullSucreen
=
()
=>
{
let
result
=
false
;
let
result
=
false
const
rate
=
window
.
screen
.
height
/
window
.
screen
.
width
let
limit
=
window
.
screen
.
height
==
window
.
screen
.
availHeight
?
1.8
:
1.65
// 临界判断值
let
limit
=
window
.
screen
.
height
==
window
.
screen
.
availHeight
?
1.8
:
1.65
// 临界判断值
result
=
rate
>
limit
return
result
}
const
jumpChildrenPage
=
(
to
,
params
)
=>
{
let
{
name
}
=
window
.
vm
.
_route
window
.
vm
.
$router
.
push
({
name
:
`
${
name
}
.
${
to
}
`
,
params
})
}
/**拷贝 */
let
{
name
}
=
window
.
vm
.
_route
window
.
vm
.
$router
.
push
({
name
:
`
${
name
}
.
${
to
}
`
,
params
})
}
/**拷贝 */
const
setClipboardData
=
data
=>
{
wx
.
setClipboardData
({
data
,
...
...
@@ -162,7 +161,6 @@ const watchPageBack = () => {
resolve
()
}
})
}
const
utils
=
{
removeLocalStorage
,
...
...
@@ -193,4 +191,4 @@ const utils = {
Object
.
keys
(
utils
).
map
(
key
=>
{
Vue
.
prototype
[
key
]
=
utils
[
key
]
})
export
default
utils
\ No newline at end of file
export
default
utils
src/views/activity/index.vue
View file @
3d81c26
...
...
@@ -77,12 +77,12 @@
<van-empty
description=
"暂无内容"
/>
</
template
>
</template>
<share
<
!-- <
share
:value="showShare"
:apiName="tabIndex == 0 ? 'activityApi':'liveApi'"
@cancel="showShare = false"
:currentItem="currentItem"
/>
/>
-->
</template>
<
template
v-else
>
<router-view></router-view>
...
...
@@ -94,16 +94,13 @@
import
{
shareMixin
,
pageMixin
}
from
'@/mixins'
import
{
activityApi
,
liveApi
}
from
'@/api'
export
default
{
name
:
''
,
name
:
'
activity
'
,
mixins
:
[
shareMixin
,
pageMixin
],
data
()
{
return
{
tabList
:
[
'秒杀活动'
]
}
},
mounted
()
{},
activated
()
{},
deactivated
()
{},
methods
:
{
getList_0
(
pageNum
)
{
let
{
list
}
=
this
...
...
src/views/coupon/index.vue
View file @
3d81c26
...
...
@@ -59,12 +59,12 @@
<van-empty
description=
"暂无内容"
/>
</
template
>
</template>
<share
<
!-- <
share
:value="showShare"
:apiName="tabIndex == 0?'boutiquecouponApi':'couponApi'"
@cancel="showShare = false"
:currentItem="currentItem"
/>
/>
-->
</template>
<
template
v-else
>
<router-view></router-view>
...
...
@@ -76,20 +76,11 @@
import
{
shareMixin
,
pageMixin
,
discountTypeMixin
}
from
'@/mixins'
import
{
couponApi
,
boutiquecouponApi
}
from
'@/api'
export
default
{
name
:
''
,
name
:
'
coupon
'
,
mixins
:
[
shareMixin
,
pageMixin
,
discountTypeMixin
],
data
()
{
return
{}
},
activated
()
{
console
.
log
(
'卡券activated'
)
this
.
watchPageBack
().
then
(()
=>
{
console
.
log
(
'子页面返回'
)
})
},
deactivated
()
{
console
.
log
(
'离开卡券页'
)
},
mounted
()
{},
methods
:
{
getList_0
(
pageNum
)
{
...
...
src/views/merchant/index.vue
View file @
3d81c26
...
...
@@ -64,12 +64,12 @@
<van-empty
description=
"暂无内容"
/>
</
template
>
</template>
<share
<
!-- <
share
:value="showShare"
:apiName="tabIndex == 0 ?'equityApi':'shopmallApi'"
@cancel="showShare = false"
:currentItem="currentItem"
/>
/>
-->
<vip-dialog
v-model=
"showVip"
@
cancel=
"showVip = false"
...
...
@@ -86,7 +86,7 @@
import
{
shareMixin
,
pageMixin
}
from
'@/mixins'
import
{
shopmallApi
,
equityApi
}
from
'@/api'
export
default
{
name
:
''
,
name
:
'
merchant
'
,
mixins
:
[
shareMixin
,
pageMixin
],
data
()
{
return
{
...
...
@@ -94,9 +94,6 @@ export default {
equity_id
:
null
}
},
mounted
()
{},
activated
()
{},
deactivated
()
{},
methods
:
{
getList_0
(
pageNum
)
{
let
{
list
}
=
this
...
...
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