Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
402a60ed
Commit
402a60ed
authored
Feb 27, 2023
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
选择门店
parent
6641f197
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
716 additions
and
397 deletions
+716
-397
src/api/shop.js
+21
-17
src/components/common/StoreAddr.vue
+171
-0
src/components/tabbarPage.vue
+12
-7
src/main.js
+1
-2
src/pages/home/index.vue
+25
-13
src/pages/index/index.vue
+17
-2
src/pages/order/index.vue
+6
-0
src/store/mutations.js
+0
-3
src/store/state.js
+0
-1
src/utils/mayi.js
+460
-349
src/utils/request.js
+3
-3
No files found.
src/api/shop.js
View file @
402a60ed
import
{
requestPOST
,
requestPOST1
}
from
"@/utils/request.js"
;
export
default
{
getShopInfo
()
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/shop/get_shop_info`
);
...
...
@@ -12,14 +11,13 @@ export default {
},
addWxMiniSubscribeMessageRecord
(
data
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/shop/addWxMiniSubscribeMessageRecord`
,
data
`
${
process
.
env
.
OLSHOP_URL
}
/shop/addWxMiniSubscribeMessageRecord`
,
data
);
},
// 页面数据
themePagesInfo
(
params
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/cms/get_shop_install_pages?homePageFlag=
${
params
.
homePageFlag
||
false
}
`
,
params
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/cms/get_shop_install_pages?homePageFlag=
${
params
.
homePageFlag
||
false
}
&shopMixId=
${
params
.
shopMixId
}
`
,
);
},
checkShowCondition
(
params
)
{
...
...
@@ -30,12 +28,9 @@ export default {
},
// 获取新版会员卡列表
getV3CardList
(
params
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/user/membership_card_list`
,
{
params
}
);
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/user/membership_card_list`
,
{
params
});
},
// 领取新版无门槛会员卡
drawV3Card
(
params
)
{
...
...
@@ -45,13 +40,22 @@ export default {
},
//获取shop配置
get_shop_configuration
(){
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/shop/get_shop_configuration`
);
get_shop_configuration
()
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/shop/get_shop_configuration`
);
},
// 获取系统配置
get_system_config_by_code
(
params
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/common/get_system_config_by_code?code=
${
params
.
code
}
`
)
},
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/common/get_system_config_by_code?code=
${
params
.
code
}
`
);
},
// 首页获取线下门店列表
getThousandsStoresOfflineStore
(
data
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/shop/get_thousands_stores_offline_store`
,
data
);
}
};
src/components/common/StoreAddr.vue
0 → 100644
View file @
402a60ed
<
template
>
<div
class=
"storeAddr flex"
v-if=
"openThousandsStoresFlag"
>
<div
class=
"left flex"
>
<div
class=
"logo"
>
<image
:src=
"shopLogo"
alt=
""
></image>
</div>
<div
class=
"contentInfo flex"
v-if=
"name != ''"
>
<p
class=
"info"
>
{{
name
}}
</p>
<p
class=
"change"
@
click=
"pushStorePage"
>
[切换]
</p>
</div>
</div>
</div>
</
template
>
<
script
>
import
shop
from
"@/api/shop"
;
import
{
DFSImg
}
from
"@/utils/index"
;
import
{
setStoreInfo
,
getStoreInfo
}
from
"@/utils/mayi"
const
app
=
getApp
();
export
default
{
data
()
{
return
{
show
:
false
,
name
:
""
,
storeList
:
[],
userLatitude
:
""
,
//纬度
userLongitude
:
""
,
//经度
offlineStoreReq
:
{
latitude
:
""
,
longitude
:
""
,
pageNum
:
0
,
pageSize
:
100
,
shopName
:
""
,
whetherOnlineShop
:
1
//是否网店(0:不是,1:是) 给1 或 null
}
};
},
onLoad
()
{
this
.
getShopList
();
},
computed
:
{
shopName
()
{
return
app
.
globalData
.
shopInfo
.
shopName
;
},
shopLogo
()
{
return
DFSImg
(
app
.
globalData
.
shopInfo
.
logoUrl
,
400
,
400
);
},
// 开启连锁商城(千店千面)
openThousandsStoresFlag
()
{
return
app
.
globalData
.
shopInfo
.
openThousandsStoresFlag
==
1
}
},
methods
:
{
getShopList
()
{
if
(
!
this
.
openThousandsStoresFlag
)
{
// 未开启连锁商城初始化
setStoreInfo
({
offlineShopCode
:
""
,
offlineShopName
:
""
,
});
return
;
};
shop
.
getThousandsStoresOfflineStore
(
this
.
offlineStoreReq
).
then
(
res1
=>
{
let
res
=
res1
.
data
;
if
(
res
.
code
==
200
)
{
if
(
res
.
data
&&
res
.
data
.
length
!=
0
)
{
this
.
storeList
=
res
.
data
;
let
isStore
=
false
;
let
{
offlineShopName
,
offlineShopCode
}
=
getStoreInfo
();
console
.
log
(
offlineShopName
,
offlineShopCode
,
'------------------sa114'
)
this
.
storeList
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
shopName
==
offlineShopName
)
{
isStore
=
true
;
}
else
if
(
offlineShopCode
==
""
)
{
isStore
=
true
;
}
});
console
.
log
(
offlineShopName
,
isStore
,
"sa97"
);
if
(
offlineShopName
&&
isStore
)
{
console
.
log
(
"判断列表中是否存在(未关闭网店)"
);
this
.
name
=
offlineShopName
;
// this.$emit("toUpdate");
}
else
{
console
.
log
(
"如果关闭网店,重新选择列表第一个"
);
setStoreInfo
({
offlineShopCode
:
this
.
storeList
[
0
].
shopCode
,
offlineShopName
:
this
.
storeList
[
0
].
shopName
,
});
this
.
name
=
this
.
storeList
[
0
].
shopName
;
// this.$emit("toUpdate");
}
// this.$emit("toUpdate");
}
else
{
console
.
log
(
"如果列表为空--选择商城"
);
setStoreInfo
({
offlineShopCode
:
""
,
offlineShopName
:
this
.
shopName
,
});
this
.
name
=
this
.
shopName
;
}
}
});
},
// 去切换门店页面
pushStorePage
()
{
app
.
$themeToLink
({
type
:
1
,
link
:
`/chooseStores`
,
})
}
}
};
</
script
>
<
style
lang=
"scss"
scoped
>
.storeAddr
{
padding
:
6px
12px
;
justify-content
:
space-between
;
.left,
.right
{
align-items
:
center
;
i.iconfont
{
font-size
:
22px
;
margin
:
0
5px
;
}
}
.left
{
align-items
:
center
;
.contentInfo
{
align-items
:
flex-start
;
.info
{
font-size
:
14px
;
color
:
#999
;
flex
:
1
;
}
.change
{
flex-shrink
:
0
;
padding-left
:
6px
;
color
:
#333
;
font-size
:
14px
;
}
}
.logo
{
width
:
30px
;
height
:
30px
;
border-radius
:
50%
;
overflow
:
hidden
;
margin-right
:
10px
;
image
{
width
:
100%
;
height
:
100%
;
object-fit
:
cover
;
}
}
}
.right
{
i.iconfont
{
font-size
:
24px
;
}
}
}
</
style
>
\ No newline at end of file
src/components/tabbarPage.vue
View file @
402a60ed
...
...
@@ -18,6 +18,7 @@ import {
getUrlofQuery
}
from
"../utils/mayi.js"
;
import
{
serialize
,
DFSImg
}
from
"@/utils/index"
;
import
{
getStoreInfo
}
from
"@/utils/mayi.js"
;
const
app
=
getApp
();
const
{
log
}
=
app
;
...
...
@@ -42,15 +43,19 @@ export default {
},
computed
:
{
pageUrl
()
{
console
.
log
(
this
.
link
,
'******'
,
this
.
page
,
'-------'
,
this
.
params
,
'++++++++'
)
return
(
this
.
link
+
this
.
page
+
this
.
params
+
console
.
log
(
this
.
link
,
'******'
,
this
.
page
,
'-------'
,
this
.
params
,
'++++++++'
)
this
.
params
+=
`&native_test=1&tabbar=
${
this
.
index
}
&location_obj=
${
wx
.
getStorageSync
(
"location"
)}
`
+
this
.
ss
+
this
.
timestamp
)}
`
// url添加门店信息参数
let
{
offlineShopCode
,
offlineShopName
}
=
getStoreInfo
();
if
(
offlineShopCode
)
{
this
.
params
+=
`&offlineShopCode=
${
offlineShopCode
}
&offlineShopName=
${
offlineShopName
}
`
}
return
(
this
.
link
+
this
.
page
+
this
.
params
+
this
.
ss
+
this
.
timestamp
);
}
},
...
...
src/main.js
View file @
402a60ed
...
...
@@ -143,7 +143,7 @@ mpApp.DFSImg = DFSImg;
mpApp
.
concatUrl
=
concatUrl
;
mpApp
.
spokesmanApi
=
spokesmanApi
mpApp
.
getThemePage
=
getThemePage
//
mpApp.getThemePage = getThemePage
mpApp
.
themeColor
=
{}
mpApp
.
log
=
log
...
...
@@ -152,7 +152,6 @@ mpApp.tool = tool
function
getThemePage
({
mixid
,
shopid
})
{
shop
.
themePagesInfo
({
shopid
,
shopMixId
:
mixid
,
homePageFlag
:
true
})
...
...
src/pages/home/index.vue
View file @
402a60ed
<
template
>
<div
class=
"domain"
:style=
"
{'--main-color':themeColor['--main-color'],'--minor-color':themeColor['--minor-color']}">
<!--
<view
class=
"ant-daipinglun"
>
1
</view>
-->
<!--
<goods-list
id=
"goodsList"
></goods-list>
-->
<!--
<scroll-view
@
scroll=
"scrolls"
@
scrolltolower=
"scrolltolower"
style=
"height:100vh;overflow-y:auto;"
scroll-y=
"true"
>
-->
<div
style=
"position:relative;"
>
<div
v-if=
"showSpokesManHome"
>
<get-index-homepage
class=
"getIndexHomePage"
></get-index-homepage>
</div>
<ThemeDataPlant></ThemeDataPlant>
<StoreAddr></StoreAddr>
<div
v-for=
"(item,index) in pageData"
:key=
"index"
>
<div
v-if=
"item.componentCode=='banner' && item.componentInfo.visible == 1"
>
<banner
:datas=
"item"
></banner>
...
...
@@ -173,11 +171,12 @@ import memberInfo from "../../components/basicTool/member-info";
import
GoodsFliters
from
"../../components/common/GoodsFliters"
;
import
SelectGoods
from
"../../components/common/SelectGoods"
;
import
TwoBAddCart
from
"../../components/common/TwoBAddCart"
;
import
{
setTabBarActive
,
checkTabbarPage
,
themeColor
,
checkShowConditionIds
}
from
"../../utils/mayi.js"
;
import
{
setTabBarActive
,
checkTabbarPage
,
themeColor
,
checkShowConditionIds
,
setStoreInfo
}
from
"../../utils/mayi.js"
;
import
indexApi
from
"@/api/index.js"
;
import
{
throttle
,
concatUrl
}
from
"../../utils/index.js"
import
mpvueCropper
from
'@/components/mpvue-cropper'
import
tool
from
'../../utils/tool.js'
import
StoreAddr
from
"@/components/common/StoreAddr.vue"
;
const
app
=
getApp
();
const
{
log
}
=
app
;
export
default
{
...
...
@@ -219,8 +218,8 @@ export default {
shopPopup
,
bottomCont
,
ThemeDataPlant
,
'text-text'
:
text
,
'img-text'
:
imgText
,
"text-text"
:
text
,
"img-text"
:
imgText
,
coupon
,
integralTurntable
,
transverseLabel
,
...
...
@@ -232,14 +231,15 @@ export default {
birthPopup
,
mpvueCropper
,
woTimeout
,
'custom-list'
:
customList
,
'rich-text'
:
richText
,
'member-info'
:
memberInfo
,
"custom-list"
:
customList
,
"rich-text"
:
richText
,
"member-info"
:
memberInfo
,
GoodsFliters
,
SelectGoods
,
TwoBAddCart
,
brandList
},
brandList
,
StoreAddr
},
computed
:
{
applySucessEntryFlag
()
{
// 高意匠不展示
...
...
@@ -320,8 +320,18 @@ export default {
})
},
onLoad
(
options
)
{
console
.
log
(
new
Date
().
getTime
(),
'load-----home-onLoad'
)
console
.
log
(
options
,
'---------home----options'
)
log
.
info
(
options
,
'---------home----options'
)
log
.
info
(
options
,
'---------home----options'
)
let
h5Params
=
options
&&
options
.
params
?
JSON
.
parse
(
decodeURIComponent
(
options
.
params
))
:
""
;
console
.
log
(
h5Params
,
'--h5Params'
)
if
(
h5Params
)
{
// 存储h5url门店信息
setStoreInfo
({
offlineShopCode
:
h5Params
.
offlineShopCode
,
offlineShopName
:
h5Params
.
offlineShopName
,
});
}
//进页面存储需要绑定的信息
if
(
options
.
userId
||
options
.
spokesmanRelId
)
{
wx
.
setStorage
({
...
...
@@ -457,8 +467,10 @@ export default {
console
.
log
(
'storageGoodsList---detory'
);
},
onShow
()
{
onShow
(
options
)
{
console
.
log
(
new
Date
().
getTime
(),
'load-----home-onShow'
)
// 设置显示条件
console
.
log
(
new
Date
().
getTime
(),
'--------on--------------show'
)
log
.
info
(
'--------on--------------show'
)
//分销隔流
if
(
this
.
toHomePage
)
{
...
...
src/pages/index/index.vue
View file @
402a60ed
...
...
@@ -11,6 +11,7 @@ import shop from "@/api/shop.js";
import
indexApi
from
"@/api/index.js"
;
import
{
serialize
,
getQueryVariable
,
DFSImg
}
from
"@/utils/index"
;
import
login
from
"@/api/login"
;
import
{
getStoreInfo
}
from
"@/utils/mayi.js"
;
const
app
=
getApp
();
const
{
log
}
=
app
;
export
default
{
...
...
@@ -66,6 +67,11 @@ export default {
if
(
wx
.
getStorageSync
(
"enterpriseAccount"
)){
this
.
params
+=
`&enterpriseAccount=
${
wx
.
getStorageSync
(
"enterpriseAccount"
)}
`
;
}
// url添加门店信息参数
let
{
offlineShopCode
,
offlineShopName
}
=
getStoreInfo
();
if
(
offlineShopCode
)
{
this
.
params
+=
`&offlineShopCode=
${
offlineShopCode
}
&offlineShopName=
${
offlineShopName
}
`
}
console
.
log
(
this
.
link
,
'======='
,
this
.
page
,
'++++++++++++++'
,
this
.
params
,
'************'
)
let
pageUrl1
=
(
this
.
page
.
startsWith
(
'http://'
)
||
this
.
page
.
startsWith
(
'https://'
))?
(
this
.
page
+
this
.
params
)
:
this
.
link
+
this
.
page
+
this
.
params
console
.
log
(
pageUrl1
,
'--------pageUrl1--'
)
...
...
@@ -81,6 +87,7 @@ export default {
return
;
}
this
.
newPageUrl
=
this
.
pageUrl
;
console
.
log
(
'------------------index----2'
)
// 进入直播页面调用不息屏api
console
.
log
(
this
.
pageUrl
,
this
.
pageUrl
.
includes
(
'/liveBroadcast/lived'
),
"this.pageUrl.includes('/liveBroadcast/lived')"
)
if
(
this
.
pageUrl
.
includes
(
'/liveBroadcast/lived'
)){
...
...
@@ -139,7 +146,15 @@ export default {
this
.
options
=
options
;
log
.
info
(
this
.
options
,
'----------------index-----options'
)
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
let
h5Params
=
options
&&
options
.
params
?
JSON
.
parse
(
decodeURIComponent
(
options
.
params
))
:
""
;
console
.
log
(
h5Params
,
'--h5Params'
)
if
(
h5Params
)
{
// 存储h5url门店信息
setStoreInfo
({
offlineShopCode
:
h5Params
.
offlineShopCode
,
offlineShopName
:
h5Params
.
offlineShopName
,
});
}
if
(
wx
.
getStorageSync
(
"workBox"
)){
this
.
params
+=
`&workBox=
${
wx
.
getStorageSync
(
"workBox"
)}
`
}
...
...
@@ -429,7 +444,7 @@ export default {
// var query = options.query.dentistId; // 参数二维码传递过来的场景参数
}
this
.
newPageUrl
=
this
.
pageUrl
;
//
this.newPageUrl = this.pageUrl;
this
.
init
();
},
onShow
(){
...
...
src/pages/order/index.vue
View file @
402a60ed
...
...
@@ -9,6 +9,7 @@
<
script
type=
"text/ecmascript-6"
>
let
forUrlAddKey
=
require
(
"mayi-front-tools/forUrlAddKey"
).
default
;
import
{
serialize
,
getQueryVariable
,
DFSImg
}
from
"@/utils/index"
;
import
{
getStoreInfo
}
from
"@/utils/mayi.js"
;
const
app
=
getApp
();
const
{
log
}
=
app
;
export
default
{
...
...
@@ -32,6 +33,11 @@ export default {
if
(
wx
.
getStorageSync
(
"enterpriseAccount"
))
{
this
.
params
+=
`&enterpriseAccount=
${
wx
.
getStorageSync
(
"enterpriseAccount"
)}
`
;
}
// url添加门店信息参数
let
{
offlineShopCode
,
offlineShopName
}
=
getStoreInfo
();
if
(
offlineShopCode
)
{
this
.
params
+=
`&offlineShopCode=
${
offlineShopCode
}
&offlineShopName=
${
offlineShopName
}
`
}
console
.
log
(
this
.
baseUrl
,
'======='
,
this
.
page
,
'++++++++++++++'
,
this
.
params
,
'************'
)
let
pageUrl1
=
(
this
.
page
.
startsWith
(
'http://'
)
||
this
.
page
.
startsWith
(
'https://'
))
?
(
this
.
page
+
this
.
params
)
:
this
.
baseUrl
+
this
.
page
+
this
.
params
console
.
log
(
pageUrl1
,
'--------pageUrl1--'
)
...
...
src/store/mutations.js
View file @
402a60ed
...
...
@@ -10,9 +10,6 @@ const mutations = {
setSubscribeMessageObj
(
state
,
subscribeMessageObj
)
{
state
.
subscribeMessageObj
=
subscribeMessageObj
;
},
setOfflineShopCode
(
state
,
code
)
{
state
.
offlineShopCode
=
code
;
},
//设置登录状态
setLoginStatus
(
state
,
val
){
...
...
src/store/state.js
View file @
402a60ed
...
...
@@ -17,7 +17,6 @@ const state = {
spokesmanRelId
:
""
,
userId
:
""
,
subscribeMessageObj
:
{},
offlineShopCode
:
""
,
isLogin
,
userInfo
,
shopUserInfo
:
{},
...
...
src/utils/mayi.js
View file @
402a60ed
import
cart
from
"@/api/cart"
import
shop
from
"@/api/shop"
import
cart
from
"@/api/cart"
;
import
shop
from
"@/api/shop"
;
import
coupon
from
"@/api/coupon"
;
import
goods
from
'@/api/goods'
;
import
goods
from
"@/api/goods"
;
import
classificationApi
from
"@/api/classification"
;
// 登录白名单 name
export
const
noLoginList
=
[
"index"
,
"media-video"
,
"goods-goodsInfo"
,
"goods-commodityMenu"
,
"goodsSearch-goodsSearch"
,
"contentSearch-contentSearch"
,
"chooseStores"
,
"activty-receivingGift"
,
"activty"
,
"login-register"
,
"login-phoneLogin"
,
"login-authInformation"
,
"login-forgetPassWord"
,
"login-accountLogin"
,
"login-wxRegister"
,
"pay-payList"
,
"comment-evaluateList"
,
"goods-commonProblemList"
,
"article-articlePage"
,
"article-articleList"
,
"goods-posters"
,
"liveBroadcast"
,
"liveBroadcast-list"
,
"personalCenter-coupon-getCoupon"
,
"buyerShow-showDetail"
,
"goods-addGoodsList"
,
"personalCenter-CDkey-exchange"
,
"giftCards-linkReceive"
,
"giftCoupon-preview"
,
"smartForm"
,
"shopCart-shareShopCart"
,
"groupBuying-beInvite"
,
"brandTopics"
,
"personalCenter-spokesmanCenter"
,
"personalCenter-spokesmanCenter-mine-spokesmanHomePage"
,
"liveBroadcast-lived"
,
"personalCenter-spokesmanCenter-mine-getBusinessCard"
,
"changeAdr"
];
export
const
noLoginList
=
[
"index"
,
"media-video"
,
"goods-goodsInfo"
,
"goods-commodityMenu"
,
"goodsSearch-goodsSearch"
,
"contentSearch-contentSearch"
,
"chooseStores"
,
"activty-receivingGift"
,
"activty"
,
"login-register"
,
"login-phoneLogin"
,
"login-authInformation"
,
"login-forgetPassWord"
,
"login-accountLogin"
,
"login-wxRegister"
,
"pay-payList"
,
"comment-evaluateList"
,
"goods-commonProblemList"
,
"article-articlePage"
,
"article-articleList"
,
"goods-posters"
,
"liveBroadcast"
,
"liveBroadcast-list"
,
"personalCenter-coupon-getCoupon"
,
"buyerShow-showDetail"
,
"goods-addGoodsList"
,
"personalCenter-CDkey-exchange"
,
"giftCards-linkReceive"
,
"giftCoupon-preview"
,
"smartForm"
,
"shopCart-shareShopCart"
,
"groupBuying-beInvite"
,
"brandTopics"
,
"personalCenter-spokesmanCenter"
,
"personalCenter-spokesmanCenter-mine-spokesmanHomePage"
,
"liveBroadcast-lived"
,
"personalCenter-spokesmanCenter-mine-getBusinessCard"
,
"changeAdr"
];
// path
export
const
noLoginListPath
=
noLoginList
.
map
(
item
=>
{
item
=
item
.
replace
(
/-/g
,
'/'
)
item
=
'/'
+
item
item
==
"/index"
&&
(
item
=
"/"
)
return
item
})
item
=
item
.
replace
(
/-/g
,
"/"
);
item
=
"/"
+
item
;
item
==
"/index"
&&
(
item
=
"/"
);
return
item
;
})
;
// 有底部栏页面
export
const
containFooterPage
=
[
"/"
,
"/goods/commodityMenu"
,
"/shopCart/shoppingCart"
,
"/personalCenter"
]
export
const
containFooterPage
=
[
"/"
,
"/goods/commodityMenu"
,
"/shopCart/shoppingCart"
,
"/personalCenter"
];
// 主题色
export
let
themeColor
=
{
"--main-color"
:
"#ffffff"
,
"--minor-color"
:
"#ffffff"
}
"--main-color"
:
"#ffffff"
,
"--minor-color"
:
"#ffffff"
}
;
// 获取link 中页面地址(link兼容 有object或者string)
export
function
getUrlofLink
(
data
)
{
if
(
typeof
data
==
'object'
&&
data
.
link
){
return
data
.
link
.
split
(
'?'
)[
0
]
}
if
(
typeof
data
==
'string'
){
return
data
.
split
(
'?'
)[
0
]
}
if
(
typeof
data
==
"object"
&&
data
.
link
)
{
return
data
.
link
.
split
(
"?"
)[
0
];
}
if
(
typeof
data
==
"string"
)
{
return
data
.
split
(
"?"
)[
0
];
}
}
export
function
getUrlofQuery
(
data
)
{
return
data
.
link
.
split
(
'?'
)[
1
]
||
''
return
data
.
link
.
split
(
"?"
)[
1
]
||
""
;
}
// 全局跳转 data:link数据 option:是否为底部栏触发
export
function
$themeToLink
(
data
,
option
)
{
// console.log(currentPage,'currentPage',getUrlofLink(data))
// if(getUrlofLink(data).includes(currentPage)) return
//
let
app
=
getApp
();
let
type
=
data
.
type
;
// 登录拦截和底部导航栏拦截(非功能项)
if
(
type
!=
2
)
{
// 登录拦截
let
parseLink
=
getUrlofLink
(
data
);
let
parseQuery
=
getUrlofQuery
(
data
);
// console.log(currentPage,'currentPage',getUrlofLink(data))
// if(getUrlofLink(data).includes(currentPage)) return
let
noLogin
=
noLoginListPath
.
includes
(
parseLink
)
||
parseLink
.
substr
(
0
,
7
)
==
"/goods/"
||
parseLink
.
includes
(
'/brandTopics'
);
if
(
!
noLogin
&&
!
wx
.
getStorageSync
(
"sessionid"
))
{
let
url
=
`/pages/login/main?back=
${
parseLink
}
`
;
wx
.
navigateTo
({
url
});
return
}
//判断是否市跳转到tabbar页面 替换首页位置
let
isTabbarIndex
=
checkTabbarPage
(
parseLink
);
if
(
isTabbarIndex
>=
0
)
{
// 无底部栏h5页面
// if (!containFooterPage.includes(parseLink)) {
// toPage(getUrlofLink(data), getUrlofQuery(data))
// return
// }
//
let
app
=
getApp
();
let
type
=
data
.
type
;
// 登录拦截和底部导航栏拦截(非功能项)
if
(
type
!=
2
)
{
// 登录拦截
let
parseLink
=
getUrlofLink
(
data
);
let
parseQuery
=
getUrlofQuery
(
data
);
let
noLogin
=
noLoginListPath
.
includes
(
parseLink
)
||
parseLink
.
substr
(
0
,
7
)
==
"/goods/"
||
parseLink
.
includes
(
"/brandTopics"
);
if
(
!
noLogin
&&
!
wx
.
getStorageSync
(
"sessionid"
))
{
let
url
=
`/pages/login/main?back=
${
parseLink
}
`
;
wx
.
navigateTo
({
url
});
return
;
}
//判断是否市跳转到tabbar页面 替换首页位置
let
isTabbarIndex
=
checkTabbarPage
(
parseLink
);
if
(
isTabbarIndex
>=
0
)
{
// 无底部栏h5页面
// if (!containFooterPage.includes(parseLink)) {
// toPage(getUrlofLink(data), getUrlofQuery(data))
// return
// }
isTabbarIndex
=
isTabbarIndex
==
0
?
checkTabbarPage
(
'/'
)
:
isTabbarIndex
;
let
url
=
parseLink
==
'/'
?
`/pages/home/main`
:
`/pages/tabBar
${
isTabbarIndex
}
/main`
;
let
routes
=
getCurrentPages
();
let
currentPage
=
routes
[
routes
.
length
-
1
].
route
;
if
(
currentPage
==
url
)
return
isTabbarIndex
=
isTabbarIndex
==
0
?
checkTabbarPage
(
"/"
)
:
isTabbarIndex
;
let
url
=
parseLink
==
"/"
?
`/pages/home/main`
:
`/pages/tabBar
${
isTabbarIndex
}
/main`
;
let
routes
=
getCurrentPages
();
let
currentPage
=
routes
[
routes
.
length
-
1
].
route
;
if
(
currentPage
==
url
)
return
;
let
query
=
parseQuery
?
`?
${
parseQuery
}
`
:
''
;
wx
.
reLaunch
({
url
:
url
+
query
})
return
}
let
query
=
parseQuery
?
`?
${
parseQuery
}
`
:
""
;
wx
.
reLaunch
({
url
:
url
+
query
});
return
;
}
}
// 历史数据
if
(
type
==
undefined
||
type
==
'undefined'
)
{
if
(
data
.
length
>
0
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
}
return
// 历史数据
if
(
type
==
undefined
||
type
==
"undefined"
)
{
if
(
data
.
length
>
0
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
));
}
// -----------------
if
(
type
==
0
)
{
//无链接
return
}
else
if
(
type
==
1
)
{
//h5页面
//兼容
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
}
else
{
if
(
data
.
link
.
startsWith
(
'http'
)
||
data
.
link
.
startsWith
(
'https'
))
{
wx
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
data
.
link
)
});
}
}
}
else
if
(
type
==
1.1
)
{
//小程序页面 可能增加登录态拦截
wx
.
navigateTo
({
url
:
data
.
link
});
}
else
if
(
type
==
1.2
)
{
//第三方链接
if
(
data
.
link
==
'outerChain:businessCenter'
)
{
// 进入商家中心外链
let
url
=
`
${
config
.
GUIDE_URL
}
/login?mixid=
${
this
.
$nuxt
.
$route
.
query
.
mixid
}
&back=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
;
wx
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
url
)
});
return
}
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
}
else
{
wx
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
data
.
link
)
});
}
}
else
if
(
type
==
2
)
{
//功能
let
featureType
=
data
.
feature
.
type
;
if
(
featureType
==
'themeCouponClick'
||
featureType
==
0
)
{
//优惠券
// this.$themeCouponClick(data.feature.value.couponCode, data.feature.value);
}
else
if
(
featureType
==
1
)
{
//分享
console
.
log
(
'是分享了。。。。'
);
app
.
shareInit
({
itemList
:
data
.
feature
.
value
});
}
else
if
(
featureType
==
"themeMemberCardClick"
||
featureType
==
2
)
{
//会员卡
// this.$themeMemberCardClick(data.feature.value);
}
}
else
if
(
type
==
3
)
{
//小程序跳转到小程序
wx
.
navigateTo
({
url
:
`/pages/toMini/main?weappPage=
${
encodeURIComponent
(
data
.
link
)}
&weappAppId=
${
data
.
name
}
`
,
})
return
;
}
// -----------------
if
(
type
==
0
)
{
//无链接
return
;
}
else
if
(
type
==
1
)
{
//h5页面
//兼容
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
));
}
else
{
//向后兼容
if
(
data
.
length
>
0
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
}
if
(
data
.
link
.
startsWith
(
"http"
)
||
data
.
link
.
startsWith
(
"https"
))
{
wx
.
navigateTo
({
url
:
"/pages/wxArticle/main?link="
+
encodeURIComponent
(
data
.
link
)
});
}
}
}
export
function
$themeAddToCard
(
item
,
callback
=
()
=>
{
})
{
let
errorMsg
=
""
;
if
(
item
.
productNature
==
5
)
{
errorMsg
=
"电子卡券不可加入购物车"
;
}
else
if
(
type
==
1.1
)
{
//小程序页面 可能增加登录态拦截
wx
.
navigateTo
({
url
:
data
.
link
});
}
else
if
(
type
==
1.2
)
{
//第三方链接
if
(
data
.
link
==
"outerChain:businessCenter"
)
{
// 进入商家中心外链
let
url
=
`
${
config
.
GUIDE_URL
}
/login?mixid=
${
this
.
$nuxt
.
$route
.
query
.
mixid
}
&back=
${
encodeURIComponent
(
window
.
location
.
href
)}
`
;
wx
.
navigateTo
({
url
:
"/pages/wxArticle/main?link="
+
encodeURIComponent
(
url
)
});
return
;
}
if
(
item
.
productNature
==
3
)
{
errorMsg
=
"会员卡不可加入购物车"
;
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
));
}
else
{
wx
.
navigateTo
({
url
:
"/pages/wxArticle/main?link="
+
encodeURIComponent
(
data
.
link
)
});
}
if
(
item
.
productNature
==
2
)
{
errorMsg
=
"虚拟商品不可加入购物车"
;
}
else
if
(
type
==
2
)
{
//功能
let
featureType
=
data
.
feature
.
type
;
if
(
featureType
==
"themeCouponClick"
||
featureType
==
0
)
{
//优惠券
// this.$themeCouponClick(data.feature.value.couponCode, data.feature.value);
}
else
if
(
featureType
==
1
)
{
//分享
console
.
log
(
"是分享了。。。。"
);
app
.
shareInit
({
itemList
:
data
.
feature
.
value
});
}
else
if
(
featureType
==
"themeMemberCardClick"
||
featureType
==
2
)
{
//会员卡
// this.$themeMemberCardClick(data.feature.value);
}
if
(
errorMsg
)
{
wx
.
showToast
({
title
:
errorMsg
,
icon
:
'none'
,
});
}
else
if
(
type
==
3
)
{
//小程序跳转到小程序
wx
.
navigateTo
({
url
:
`/pages/toMini/main?weappPage=
${
encodeURIComponent
(
data
.
link
)}
&weappAppId=
${
data
.
name
}
`
});
}
else
{
//向后兼容
if
(
data
.
length
>
0
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
));
}
cart
.
addCart
([
{
productGoodsId
:
item
.
minProductGoodsId
,
qty
:
item
.
plusPurchaseMultiple
}
])
.
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
wx
.
showToast
({
title
:
"加入购物车成功"
,
icon
:
"none"
});
}
callback
();
});
}
}
export
function
$themeAddToCard
(
item
,
callback
=
()
=>
{})
{
let
errorMsg
=
""
;
if
(
item
.
productNature
==
5
)
{
errorMsg
=
"电子卡券不可加入购物车"
;
}
if
(
item
.
productNature
==
3
)
{
errorMsg
=
"会员卡不可加入购物车"
;
}
if
(
item
.
productNature
==
2
)
{
errorMsg
=
"虚拟商品不可加入购物车"
;
}
if
(
errorMsg
)
{
wx
.
showToast
({
title
:
errorMsg
,
icon
:
"none"
});
}
cart
.
addCart
([
{
productGoodsId
:
item
.
minProductGoodsId
,
qty
:
item
.
plusPurchaseMultiple
}
])
.
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
wx
.
showToast
({
title
:
"加入购物车成功"
,
icon
:
"none"
});
}
callback
();
});
}
function
toPage
(
backPath
,
backParams
=
""
)
{
console
.
log
(
backPath
,
backParams
,
'--------------------------159'
);
wx
.
navigateTo
({
url
:
`../index/main?from=themeLink&backpath=
${
encodeURIComponent
(
backPath
)}
¶ms=
${
encodeURIComponent
(
backParams
)}
`
});
console
.
log
(
backPath
,
backParams
,
"--------------------------159"
);
wx
.
navigateTo
({
url
:
`../index/main?from=themeLink&backpath=
${
encodeURIComponent
(
backPath
)}
¶ms=
${
encodeURIComponent
(
backParams
)}
`
});
}
// check 链接是否为底部导航栏页面 返回索引
export
function
checkTabbarPage
(
link
)
{
let
app
=
getApp
()
if
(
!
app
.
globalData
.
footerVal
)
return
-
1
let
footerVal
=
app
.
globalData
.
footerVal
.
componentData
.
list
;
let
isFooter
=
footerVal
.
findIndex
(
item
=>
{
return
getUrlofLink
(
item
.
link
)
==
link
.
split
(
'?'
)[
0
]
})
return
isFooter
let
app
=
getApp
();
if
(
!
app
.
globalData
.
footerVal
)
return
-
1
;
let
footerVal
=
app
.
globalData
.
footerVal
.
componentData
.
list
;
let
isFooter
=
footerVal
.
findIndex
(
item
=>
{
return
getUrlofLink
(
item
.
link
)
==
link
.
split
(
"?"
)[
0
];
});
return
isFooter
;
}
// 当前底部栏选中项
export
function
setTabBarActive
(
data
)
{
// console.log(data,'sssssssssss',this.$mp.page.getTabBar(),data)
if
(
data
<
0
||
!
this
.
$mp
.
page
)
return
if
(
typeof
this
.
$mp
.
page
.
getTabBar
===
'function'
&&
this
.
$mp
.
page
.
getTabBar
())
{
this
.
$mp
.
page
.
getTabBar
().
setData
({
selected
:
data
})
}
// console.log(data,'sssssssssss',this.$mp.page.getTabBar(),data)
if
(
data
<
0
||
!
this
.
$mp
.
page
)
return
;
if
(
typeof
this
.
$mp
.
page
.
getTabBar
===
"function"
&&
this
.
$mp
.
page
.
getTabBar
()
)
{
this
.
$mp
.
page
.
getTabBar
().
setData
({
selected
:
data
});
}
}
// 遍历所有组件有显示条件的id 是否包含地区导航组件
export
function
checkShowConditionIds
(
list
)
{
let
allCondition
=
[];
let
isAreaNavigation
=
false
;
list
.
forEach
(
element
=>
{
// 有地区导航组件
if
(
element
.
componentCode
==
'area-navigation'
)
{
isAreaNavigation
=
true
}
pollCondition
(
element
)
});
function
pollCondition
(
object
)
{
if
(
Object
.
prototype
.
toString
.
call
(
object
)
===
'[object Object]'
)
{
if
(
object
.
condition
!=
''
&&
object
.
condition
!=
undefined
)
{
allCondition
.
push
(
object
.
condition
);
}
for
(
const
key
in
object
)
{
if
(
object
.
hasOwnProperty
(
key
))
{
const
element
=
object
[
key
];
if
(
Object
.
prototype
.
toString
.
call
(
element
)
===
'[object Object]'
)
{
if
(
element
.
condition
!=
''
&&
element
.
condition
!=
undefined
)
{
allCondition
.
push
(
element
.
condition
);
}
pollCondition
(
element
)
}
else
if
(
Object
.
prototype
.
toString
.
call
(
element
)
===
'[object Array]'
&&
element
.
length
>
0
)
{
element
.
forEach
((
item
)
=>
{
pollCondition
(
item
)
})
}
}
let
allCondition
=
[];
let
isAreaNavigation
=
false
;
list
.
forEach
(
element
=>
{
// 有地区导航组件
if
(
element
.
componentCode
==
"area-navigation"
)
{
isAreaNavigation
=
true
;
}
pollCondition
(
element
);
});
function
pollCondition
(
object
)
{
if
(
Object
.
prototype
.
toString
.
call
(
object
)
===
"[object Object]"
)
{
if
(
object
.
condition
!=
""
&&
object
.
condition
!=
undefined
)
{
allCondition
.
push
(
object
.
condition
);
}
for
(
const
key
in
object
)
{
if
(
object
.
hasOwnProperty
(
key
))
{
const
element
=
object
[
key
];
if
(
Object
.
prototype
.
toString
.
call
(
element
)
===
"[object Object]"
)
{
if
(
element
.
condition
!=
""
&&
element
.
condition
!=
undefined
)
{
allCondition
.
push
(
element
.
condition
);
}
pollCondition
(
element
);
}
else
if
(
Object
.
prototype
.
toString
.
call
(
element
)
===
"[object Array]"
&&
element
.
length
>
0
)
{
element
.
forEach
(
item
=>
{
pollCondition
(
item
);
});
}
}
}
}
return
{
allCondition
:
[...
new
Set
(
allCondition
)],
isAreaNavigation
}
}
return
{
allCondition
:
[...
new
Set
(
allCondition
)],
isAreaNavigation
};
}
export
function
$themeArticleLike
(
item
,
callback
)
{
let
query
=
{
articleId
:
item
.
id
};
classificationApi
.
addLike
(
query
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
"200"
)
{
if
(
res
.
data
.
data
==
'true'
)
{
callback
(
"true"
);
}
else
{
callback
(
"false"
);
}
}
else
{
}
});
}
export
function
getCoupon
(
code
,
item
)
{
console
.
log
(
"--------------------239"
);
let
usingIntegrals
=
(
item
.
consumeIntegral
-
0
).
toFixed
(
0
);
let
couponCode
=
code
;
console
.
log
(
item
,
"------------------------242"
);
if
(
item
.
receiveCostType
==
1
)
{
wx
.
showModal
({
confirmColor
:
"#CA173B"
,
content
:
`是否消耗
${
usingIntegrals
}
积分领取`
})
.
then
(()
=>
{
useCoupon
(
2
,
couponCode
,
usingIntegrals
);
})
.
catch
(()
=>
{
// on cancel
});
return
;
let
query
=
{
articleId
:
item
.
id
};
classificationApi
.
addLike
(
query
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
"200"
)
{
if
(
res
.
data
.
data
==
"true"
)
{
callback
(
"true"
);
}
else
{
callback
(
"false"
);
}
}
else
{
useCoupon
(
1
,
couponCode
,
usingIntegrals
);
}
};
});
}
export
function
getCoupon
(
code
,
item
)
{
console
.
log
(
"--------------------239"
);
let
usingIntegrals
=
(
item
.
consumeIntegral
-
0
).
toFixed
(
0
);
let
couponCode
=
code
;
console
.
log
(
item
,
"------------------------242"
);
if
(
item
.
receiveCostType
==
1
)
{
wx
.
showModal
({
confirmColor
:
"#CA173B"
,
content
:
`是否消耗
${
usingIntegrals
}
积分领取`
})
.
then
(()
=>
{
useCoupon
(
2
,
couponCode
,
usingIntegrals
);
})
.
catch
(()
=>
{
// on cancel
});
return
;
}
else
{
useCoupon
(
1
,
couponCode
,
usingIntegrals
);
}
}
function
useCoupon
(
val
,
couponCode
,
usingIntegrals
)
{
coupon
.
receive_coupon
(
couponCode
).
then
(
res
=>
{
console
.
log
(
res
,
"cou137"
);
...
...
@@ -277,161 +349,201 @@ function useCoupon(val, couponCode, usingIntegrals) {
}
// item.receive=false;
}
else
{
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
// item.receive=true;
}
});
}
;
}
export
function
themeMemberCardClick
(
item
)
{
let
query
=
{
portalCardId
:
item
.
id
};
shop
.
getV3CardList
(
query
).
then
(
res
=>
{
console
.
log
(
res
,
'--------------------282'
)
if
(
res
.
data
.
code
==
200
)
{
let
cardData
=
""
;
res
.
data
.
data
.
forEach
(
innerItem
=>
{
if
(
innerItem
.
id
==
item
.
id
)
{
cardData
=
innerItem
;
}
});
let
cardId
=
cardData
.
id
;
let
userInfo
=
wx
.
getStorageSync
(
"userInfo"
)
?
JSON
.
parse
(
wx
.
getStorageSync
(
"userInfo"
))
:
""
;
if
(
cardData
.
receiveWay
==
0
)
{
// 无门槛
let
query
=
{
portalCardId
:
item
.
id
};
shop
.
getV3CardList
(
query
).
then
(
res
=>
{
console
.
log
(
res
,
"--------------------282"
);
if
(
res
.
data
.
code
==
200
)
{
let
cardData
=
""
;
res
.
data
.
data
.
forEach
(
innerItem
=>
{
if
(
innerItem
.
id
==
item
.
id
)
{
cardData
=
innerItem
;
}
});
let
cardId
=
cardData
.
id
;
let
userInfo
=
wx
.
getStorageSync
(
"userInfo"
)
?
JSON
.
parse
(
wx
.
getStorageSync
(
"userInfo"
))
:
""
;
if
(
cardData
.
receiveWay
==
0
)
{
// 无门槛
shop
.
drawV3Card
(
cardId
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
wx
.
showToast
({
content
:
`开通【
${
cardData
.
title
}
】成功`
,
showCancel
:
false
,
confirmColor
:
''
,
success
:
res
=>
{
let
backParams
=
`&cardId=
${
cardData
.
id
}
`
;
if
(
userInfo
.
mobilephone
)
{
backParams
+=
`&userTel=
${
userInfo
.
mobilephone
}
`
;
}
toPage
(
"/personalCenter/membershipCard"
,
backParams
);
content
:
`开通【
${
cardData
.
title
}
】成功`
,
showCancel
:
false
,
confirmColor
:
""
,
success
:
res
=>
{
let
backParams
=
`&cardId=
${
cardData
.
id
}
`
;
if
(
userInfo
.
mobilephone
)
{
backParams
+=
`&userTel=
${
userInfo
.
mobilephone
}
`
;
}
})
toPage
(
"/personalCenter/membershipCard"
,
backParams
);
}
});
}
else
{
if
(
res
.
data
.
msg
==
"不能重复领卡"
)
{
console
.
log
(
"---------------------------to-----1"
)
let
backParams
=
`&cardId=
${
cardData
.
id
}
`
;
if
(
userInfo
.
mobilephone
)
{
backParams
+=
`&userTel=
${
userInfo
.
mobilephone
}
`
;
}
toPage
(
"/personalCenter/membershipCard"
,
backParams
);
}
else
{
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
}
if
(
res
.
data
.
msg
==
"不能重复领卡"
)
{
console
.
log
(
"---------------------------to-----1"
);
let
backParams
=
`&cardId=
${
cardData
.
id
}
`
;
if
(
userInfo
.
mobilephone
)
{
backParams
+=
`&userTel=
${
userInfo
.
mobilephone
}
`
;
}
toPage
(
"/personalCenter/membershipCard"
,
backParams
);
}
else
{
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
}
}
});
}
else
if
(
cardData
.
receiveWay
==
1
)
{
}
else
if
(
cardData
.
receiveWay
==
1
)
{
// 自动领取
console
.
log
(
"自动领取"
);
}
else
if
(
cardData
.
receiveWay
==
2
)
{
}
else
if
(
cardData
.
receiveWay
==
2
)
{
// 付费购买
if
(
cardData
.
receiveStatus
==
0
)
{
console
.
log
(
"---------------------------to-----2"
)
let
backParams
=
`&cardId=
${
cardData
.
id
}
`
;
toPage
(
"/pay/payCard"
,
backParams
);
console
.
log
(
"---------------------------to-----2"
);
let
backParams
=
`&cardId=
${
cardData
.
id
}
`
;
toPage
(
"/pay/payCard"
,
backParams
);
}
else
{
console
.
log
(
"---------------------------to-----3"
)
let
backParams
=
`&cardId=
${
cardData
.
id
}
`
;
if
(
userInfo
.
mobilephone
)
{
backParams
+=
`&userTel=
${
userInfo
.
mobilephone
}
`
;
}
toPage
(
"/personalCenter/membershipCard"
,
backParams
);
console
.
log
(
"---------------------------to-----3"
);
let
backParams
=
`&cardId=
${
cardData
.
id
}
`
;
if
(
userInfo
.
mobilephone
)
{
backParams
+=
`&userTel=
${
userInfo
.
mobilephone
}
`
;
}
toPage
(
"/personalCenter/membershipCard"
,
backParams
);
}
}
else
{
console
.
error
(
"无效的领取方式"
);
}
}
else
{
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
if
(
res
.
data
.
code
==
300
)
{
console
.
log
(
'----------334'
)
// 未登录
setTimeout
(()
=>
{
let
url
=
`/pages/login/main?back=
${
encodeURIComponent
(
'/'
)}
`
;
wx
.
navigateTo
({
url
:
url
});
},
200
);
}
wx
.
showToast
({
title
:
res
.
data
.
msg
,
icon
:
"none"
});
if
(
res
.
data
.
code
==
300
)
{
console
.
log
(
"----------334"
);
// 未登录
setTimeout
(()
=>
{
let
url
=
`/pages/login/main?back=
${
encodeURIComponent
(
"/"
)}
`
;
wx
.
navigateTo
({
url
:
url
});
},
200
);
}
}
});
}
;
}
// 扫码
export
function
themeScanningCodeClick
()
{
let
app
=
getApp
()
let
{
$themeToLink
}
=
app
;
console
.
log
(
"themeScanningCodeClick"
)
wx
.
scanCode
({
success
(
res
)
{
console
.
log
(
res
,
'-----scanCode-success'
)
let
{
scanType
,
path
,
result
}
=
res
;
// 所有一维码类型
const
barCodeTypes
=
[
'AZTEC'
,
'CODABAR'
,
'CODE_39'
,
'CODE_93'
,
'CODE_128'
,
'EAN_8'
,
'EAN_13'
,
'ITF'
,
'MAXICODE'
,
'RSS_14'
,
'RSS_EXPANDED'
,
'UPC_A'
,
'UPC_E'
,
'UPC_EAN_EXTENSION'
,
'CODE_25'
];
if
(
scanType
==
'WX_CODE'
)
{
// 微信二维码
$themeToLink
({
type
:
1.1
,
link
:
path
[
0
]
==
'/'
?
path
:
`/
${
path
}
`
});
}
else
if
(
scanType
==
'QR_CODE'
)
{
// 二维码
// http链接或h5链接
// type 1h5页面 1.1小程序页面 1.2http链接
if
(
result
.
startsWith
(
'http'
)
||
result
.
startsWith
(
'/'
))
{
// 链接跳转
$themeToLink
({
type
:
result
.
startsWith
(
'http'
)?
1.2
:
1
,
link
:
result
})
}
else
{
// 跳转搜索页
$themeToLink
({
type
:
1
,
link
:
'/contentSearch/contentSearch?placeHolderText='
+
result
})
}
}
else
if
(
barCodeTypes
.
includes
(
scanType
))
{
// 一维码类型
const
data
=
{
"searchWord"
:
result
,
"page"
:
1
,
"rows"
:
10
}
goods
.
selectProductInfoOnEs
(
data
).
then
(
response
=>
{
const
res
=
response
.
data
.
data
;
if
(
res
.
total
>
1
)
{
// 多个 SKU 跳转商品搜索结果页,搜索框显示扫码内容,页面自动展示搜索结果;
$themeToLink
({
type
:
1
,
link
:
`/goodsSearch/goodsSearch?placeHolderText=
${
result
}
&search_txt=
${
result
}
`
})
}
else
if
(
res
.
total
==
1
)
{
const
item
=
res
.
list
[
0
];
// 唯一 SKU 跳转商品详情
$themeToLink
({
type
:
1
,
link
:
`/goods/
${
item
.
productId
}
?terminalProductId=
${
item
.
terminalProductId
}
`
});
}
else
{
// 提示:对不起,无法正确识别该条形码。请直接联系导购员;
wx
.
showModal
({
content
:
'对不起 无法正确识别该条形码
\
n请直接联系导购员'
,
showCancel
:
false
});
}
}).
catch
(
console
.
log
);
let
app
=
getApp
();
let
{
$themeToLink
}
=
app
;
console
.
log
(
"themeScanningCodeClick"
);
wx
.
scanCode
({
success
(
res
)
{
console
.
log
(
res
,
"-----scanCode-success"
);
let
{
scanType
,
path
,
result
}
=
res
;
// 所有一维码类型
const
barCodeTypes
=
[
"AZTEC"
,
"CODABAR"
,
"CODE_39"
,
"CODE_93"
,
"CODE_128"
,
"EAN_8"
,
"EAN_13"
,
"ITF"
,
"MAXICODE"
,
"RSS_14"
,
"RSS_EXPANDED"
,
"UPC_A"
,
"UPC_E"
,
"UPC_EAN_EXTENSION"
,
"CODE_25"
];
if
(
scanType
==
"WX_CODE"
)
{
// 微信二维码
$themeToLink
({
type
:
1.1
,
link
:
path
[
0
]
==
"/"
?
path
:
`/
${
path
}
`
});
}
else
if
(
scanType
==
"QR_CODE"
)
{
// 二维码
// http链接或h5链接
// type 1h5页面 1.1小程序页面 1.2http链接
if
(
result
.
startsWith
(
"http"
)
||
result
.
startsWith
(
"/"
))
{
// 链接跳转
$themeToLink
({
type
:
result
.
startsWith
(
"http"
)
?
1.2
:
1
,
link
:
result
});
}
else
{
// 跳转搜索页
$themeToLink
({
type
:
1
,
link
:
"/contentSearch/contentSearch?placeHolderText="
+
result
});
}
}
else
if
(
barCodeTypes
.
includes
(
scanType
))
{
// 一维码类型
const
data
=
{
searchWord
:
result
,
page
:
1
,
rows
:
10
};
goods
.
selectProductInfoOnEs
(
data
)
.
then
(
response
=>
{
const
res
=
response
.
data
.
data
;
if
(
res
.
total
>
1
)
{
// 多个 SKU 跳转商品搜索结果页,搜索框显示扫码内容,页面自动展示搜索结果;
$themeToLink
({
type
:
1
,
link
:
`/goodsSearch/goodsSearch?placeHolderText=
${
result
}
&search_txt=
${
result
}
`
});
}
else
if
(
res
.
total
==
1
)
{
const
item
=
res
.
list
[
0
];
// 唯一 SKU 跳转商品详情
$themeToLink
({
type
:
1
,
link
:
`/goods/
${
item
.
productId
}
?terminalProductId=
${
item
.
terminalProductId
}
`
});
}
else
{
// 提示:对不起,无法正确识别该条形码。请直接联系导购员;
wx
.
showModal
({
content
:
"对不起 无法正确识别该条形码
\
n请直接联系导购员"
,
showCancel
:
false
});
}
},
fail
(
res
)
{
console
.
log
(
res
,
'-----scanCode-fail'
)
},
complete
(
res
)
{
console
.
log
(
res
,
'-----scanCode-complete'
)
},
});
}
\ No newline at end of file
})
.
catch
(
console
.
log
);
}
},
fail
(
res
)
{
console
.
log
(
res
,
"-----scanCode-fail"
);
},
complete
(
res
)
{
console
.
log
(
res
,
"-----scanCode-complete"
);
}
});
}
/**
* 缓存门店code、name
*/
export
function
setStoreInfo
({
offlineShopCode
,
offlineShopName
})
{
console
.
log
(
offlineShopCode
,
offlineShopName
,
'--setStoreInfo'
);
wx
.
setStorageSync
(
"offlineShopCode"
,
offlineShopCode
);
wx
.
setStorageSync
(
"offlineShopName"
,
offlineShopName
);
}
/**
*
* 获取门店code、name
*/
export
function
getStoreInfo
()
{
return
{
offlineShopCode
:
wx
.
getStorageSync
(
"offlineShopCode"
)
||
""
,
offlineShopName
:
wx
.
getStorageSync
(
"offlineShopName"
)
||
""
};
}
src/utils/request.js
View file @
402a60ed
...
...
@@ -13,7 +13,7 @@ export async function requestGET(url, options) {
method
:
"GET"
,
header
:
{
"Shop-Mixid"
:
store
.
state
.
mixid
,
"Offline-Shop-Code"
:
store
.
state
.
offlineShopCode
,
"Offline-Shop-Code"
:
wx
.
getStorageSync
(
'offlineShopCode'
)
||
""
,
"Authorization"
:
wx
.
getStorageSync
(
'sessionid'
)
||
""
,
"Region-id"
:
wx
.
getStorageSync
(
'location'
)
?
JSON
.
parse
(
wx
.
getStorageSync
(
'location'
)).
systemRegionId
:
''
,
"Area-Id"
:
wx
.
getStorageSync
(
'location'
)
?
JSON
.
parse
(
wx
.
getStorageSync
(
'location'
)).
id
:
''
,
...
...
@@ -38,7 +38,7 @@ export async function requestPOST(url, options) {
header
:
{
"Shop-Mixid"
:
store
.
state
.
mixid
,
"Authorization"
:
wx
.
getStorageSync
(
'sessionid'
)
||
""
,
"Offline-Shop-Code"
:
store
.
state
.
offlineShopCode
,
"Offline-Shop-Code"
:
wx
.
getStorageSync
(
'offlineShopCode'
)
||
""
,
"openId"
:
wx
.
getStorageSync
(
"openid"
)
||
''
,
"Region-id"
:
wx
.
getStorageSync
(
'location'
)
?
JSON
.
parse
(
wx
.
getStorageSync
(
'location'
)).
systemRegionId
:
''
,
"Area-Id"
:
wx
.
getStorageSync
(
'location'
)
?
JSON
.
parse
(
wx
.
getStorageSync
(
'location'
)).
id
:
''
,
...
...
@@ -64,7 +64,7 @@ export function requestPOST1(url, options) {
"Content-Type"
:
"application/x-www-form-urlencoded"
,
"Shop-Mixid"
:
store
.
state
.
mixid
,
Authorization
:
wx
.
getStorageSync
(
'sessionid'
)
||
""
,
"Offline-Shop-Code"
:
store
.
state
.
offlineShopCode
,
"Offline-Shop-Code"
:
wx
.
getStorageSync
(
'offlineShopCode'
)
||
""
,
"Region-id"
:
wx
.
getStorageSync
(
'location'
)
?
JSON
.
parse
(
wx
.
getStorageSync
(
'location'
)).
systemRegionId
:
''
,
"Area-Id"
:
wx
.
getStorageSync
(
'location'
)
?
JSON
.
parse
(
wx
.
getStorageSync
(
'location'
)).
id
:
''
,
// "dubbo-tag": "ljx"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment