Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
20ea711a
Commit
20ea711a
authored
Apr 22, 2019
by
Junling Bu
Browse files
chore[litemall-vue]: 继续简化代码
parent
21cfee12
Changes
41
Hide whitespace changes
Inline
Side-by-side
litemall-vue/.env.deployment
0 → 100644
View file @
20ea711a
# just a flag
ENV = 'production'
# base api
VUE_APP_BASE_API = 'http://192.168.0.101:8080/'
\ No newline at end of file
litemall-vue/.env.development
0 → 100644
View file @
20ea711a
# just a flag
ENV = 'development'
# base api
VUE_APP_BASE_API = 'http://localhost:8080/'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
# It only does one thing by converting all import() to require().
# This configuration can significantly increase the speed of hot updates,
# when you have a large number of pages.
# Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
VUE_CLI_BABEL_TRANSPILE_MODULES = true
\ No newline at end of file
litemall-vue/.env.production
0 → 100644
View file @
20ea711a
# just a flag
ENV = 'production'
# base api
VUE_APP_BASE_API = 'https://www.example.com/'
\ No newline at end of file
litemall-vue/package.json
View file @
20ea711a
...
...
@@ -8,19 +8,19 @@
"scripts"
:
{
"dev"
:
"vue-cli-service serve"
,
"serve"
:
"vue-cli-service serve"
,
"build"
:
"vue-cli-service build"
,
"build:dep"
:
"vue-cli-service build"
,
"build:prod"
:
"vue-cli-service build"
,
"build"
:
"vue-cli-service build
--mode production
"
,
"build:dep"
:
"vue-cli-service build
--mode deployment
"
,
"build:prod"
:
"vue-cli-service build
--mode production
"
,
"lint"
:
"vue-cli-service lint"
},
"dependencies"
:
{
"@
xkeshi
/vue-countdown"
:
"^1.
0.1
"
,
"@
chenfengyuan
/vue-countdown"
:
"^1.
1.2
"
,
"axios"
:
"^0.18.0"
,
"dayjs"
:
"^1.7.7"
,
"js-md5"
:
"^0.7.3"
,
"lodash"
:
"^4.17.11"
,
"vant"
:
"^1.
4.4
"
,
"vant"
:
"^1.
6.15
"
,
"vee-validate"
:
"^2.1.4"
,
"vue"
:
"^2.5.17"
,
"js-cookie"
:
"2.2.0"
,
...
...
litemall-vue/src/api/api.js
0 → 100644
View file @
20ea711a
import
request
from
'
@/utils/request
'
const
IndexUrl
=
'
wx/home/index
'
;
//首页数据接口
export
function
getHome
()
{
return
request
({
url
:
IndexUrl
,
method
:
'
get
'
})
}
const
CatalogList
=
'
wx/catalog/index
'
;
//分类目录全部分类数据接口
export
function
catalogList
()
{
return
request
({
url
:
CatalogList
,
method
:
'
get
'
})
}
const
CatalogCurrent
=
'
wx/catalog/current
'
;
//分类目录当前分类数据接口
export
function
catalogCurrent
(
query
)
{
return
request
({
url
:
CatalogCurrent
,
method
:
'
get
'
,
params
:
query
})
}
const
AuthLoginByWeixin
=
'
wx/auth/login_by_weixin
'
;
//微信登录
const
AuthLoginByAccount
=
'
wx/auth/login
'
;
//账号登录
export
function
authLoginByAccount
(
data
)
{
return
request
({
url
:
AuthLoginByAccount
,
method
:
'
post
'
,
data
})
}
const
AuthLogout
=
'
wx/auth/logout
'
;
//账号登出
export
function
authLogout
()
{
return
request
({
url
:
AuthLogout
,
method
:
'
post
'
})
}
const
AuthRegister
=
'
wx/auth/register
'
;
//账号注册
const
AuthReset
=
'
wx/auth/reset
'
;
//账号密码重置
const
AuthRegisterCaptcha
=
'
wx/auth/regCaptcha
'
;
//验证码
const
AuthBindPhone
=
'
wx/auth/bindPhone
'
;
//绑定微信手机号
const
GoodsCount
=
'
wx/goods/count
'
;
//统计商品总数
export
function
goodsCount
()
{
return
request
({
url
:
GoodsCount
,
method
:
'
get
'
})
}
const
GoodsList
=
'
wx/goods/list
'
;
//获得商品列表
export
function
goodsList
(
query
)
{
return
request
({
url
:
GoodsList
,
method
:
'
get
'
,
params
:
query
})
}
const
GoodsCategory
=
'
wx/goods/category
'
;
//获得分类数据
export
function
goodsCategory
(
query
)
{
return
request
({
url
:
GoodsCategory
,
method
:
'
get
'
,
params
:
query
})
}
const
GoodsDetail
=
'
wx/goods/detail
'
;
//获得商品的详情
export
function
goodsDetail
(
query
)
{
return
request
({
url
:
GoodsDetail
,
method
:
'
get
'
,
params
:
query
})
}
const
GoodsRelated
=
'
wx/goods/related
'
;
//商品详情页的关联商品(大家都在看)
const
BrandList
=
'
wx/brand/list
'
;
//品牌列表
const
BrandDetail
=
'
wx/brand/detail
'
;
//品牌详情
const
CartList
=
'
wx/cart/index
'
;
//获取购物车的数据
export
function
cartList
(
query
)
{
return
request
({
url
:
CartList
,
method
:
'
get
'
,
params
:
query
})
}
const
CartAdd
=
'
wx/cart/add
'
;
// 添加商品到购物车
export
function
cartAdd
(
data
)
{
return
request
({
url
:
CartAdd
,
method
:
'
post
'
,
data
})
}
const
CartFastAdd
=
'
wx/cart/fastadd
'
;
// 立即购买商品
export
function
cartFastAdd
(
data
)
{
return
request
({
url
:
CartFastAdd
,
method
:
'
post
'
,
data
})
}
const
CartUpdate
=
'
wx/cart/update
'
;
// 更新购物车的商品
export
function
cartUpdate
(
data
)
{
return
request
({
url
:
cartUpdate
,
method
:
'
post
'
,
data
})
}
const
CartDelete
=
'
wx/cart/delete
'
;
// 删除购物车的商品
export
function
cartDelete
(
data
)
{
return
request
({
url
:
CartDelete
,
method
:
'
post
'
,
data
})
}
const
CartChecked
=
'
wx/cart/checked
'
;
// 选择或取消选择商品
export
function
cartChecked
(
data
)
{
return
request
({
url
:
CartChecked
,
method
:
'
post
'
,
data
})
}
const
CartGoodsCount
=
'
wx/cart/goodscount
'
;
// 获取购物车商品件数
export
function
cartGoodsCount
()
{
return
request
({
url
:
CartGoodsCount
,
method
:
'
get
'
})
}
const
CartCheckout
=
'
wx/cart/checkout
'
;
// 下单前信息确认
const
CollectList
=
'
wx/collect/list
'
;
//收藏列表
const
CollectAddOrDelete
=
'
wx/collect/addordelete
'
;
//添加或取消收藏
export
function
collectAddOrDelete
(
data
)
{
return
request
({
url
:
CollectAddOrDelete
,
method
:
'
post
'
,
data
})
}
const
CommentList
=
'
wx/comment/list
'
;
//评论列表
const
CommentCount
=
'
wx/comment/count
'
;
//评论总数
const
CommentPost
=
'
wx/comment/post
'
;
//发表评论
const
TopicList
=
'
wx/topic/list
'
;
//专题列表
const
TopicDetail
=
'
wx/topic/detail
'
;
//专题详情
const
TopicRelated
=
'
wx/topic/related
'
;
//相关专题
const
SearchIndex
=
'
wx/search/index
'
;
//搜索关键字
const
SearchResult
=
'
wx/search/result
'
;
//搜索结果
const
SearchHelper
=
'
wx/search/helper
'
;
//搜索帮助
const
SearchClearHistory
=
'
wx/search/clearhistory
'
;
//搜索历史清楚
const
AddressList
=
'
wx/address/list
'
;
//收货地址列表
const
AddressDetail
=
'
wx/address/detail
'
;
//收货地址详情
const
AddressSave
=
'
wx/address/save
'
;
//保存收货地址
const
AddressDelete
=
'
wx/address/delete
'
;
//保存收货地址
const
ExpressQuery
=
'
wx/express/query
'
;
//物流查询
const
RegionList
=
'
wx/region/list
'
;
//获取区域列表
const
OrderSubmit
=
'
wx/order/submit
'
;
// 提交订单
const
OrderPrepay
=
'
wx/order/prepay
'
;
// 订单的预支付会话
const
OrderList
=
'
wx/order/list
'
;
//订单列表
const
OrderDetail
=
'
wx/order/detail
'
;
//订单详情
const
OrderCancel
=
'
wx/order/cancel
'
;
//取消订单
const
OrderRefund
=
'
wx/order/refund
'
;
//退款取消订单
const
OrderDelete
=
'
wx/order/delete
'
;
//删除订单
const
OrderConfirm
=
'
wx/order/confirm
'
;
//确认收货
const
OrderGoods
=
'
wx/order/goods
'
;
// 代评价商品信息
const
OrderComment
=
'
wx/order/comment
'
;
// 评价订单商品信息
const
FeedbackAdd
=
'
wx/feedback/submit
'
;
//添加反馈
const
FootprintList
=
'
wx/footprint/list
'
;
//足迹列表
const
FootprintDelete
=
'
wx/footprint/delete
'
;
//删除足迹
const
UserFormIdCreate
=
'
wx/formid/create
'
;
//用户FromId,用于发送模版消息
const
GroupOnList
=
'
wx/groupon/list
'
;
//团购列表
const
GroupOn
=
'
wx/groupon/query
'
;
//团购API-查询
const
GroupOnMy
=
'
wx/groupon/my
'
;
//团购API-我的团购
const
GroupOnDetail
=
'
wx/groupon/detail
'
;
//团购API-详情
const
GroupOnJoin
=
'
wx/groupon/join
'
;
//团购API-详情
const
CouponList
=
'
wx/coupon/list
'
;
//优惠券列表
const
CouponMyList
=
'
wx/coupon/mylist
'
;
//我的优惠券列表
const
CouponSelectList
=
'
coupon/selectlist
'
;
//当前订单可用优惠券列表
const
CouponReceive
=
'
wx/coupon/receive
'
;
//优惠券领取
export
function
couponReceive
(
data
)
{
return
request
({
url
:
CouponReceive
,
method
:
'
post
'
,
data
})
}
const
CouponExchange
=
'
wx/coupon/exchange
'
;
//优惠券兑换
const
StorageUpload
=
'
wx/torage/upload
'
;
//图片上传,
const
UserIndex
=
'
wx/user/index
'
;
//个人页面用户相关信息
export
function
userIndex
()
{
return
request
({
url
:
UserIndex
,
method
:
'
get
'
})
}
const
IssueList
=
'
wx/issue/list
'
;
//帮助信息
litemall-vue/src/api/goods.js
View file @
20ea711a
...
...
@@ -5,3 +5,36 @@ export const GOODS_CATEGORY = '/wx/catalog/index';
export
const
GOODS_CHANNGE_CATEGORY
=
'
/wx/catalog/current?id=
'
;
export
const
GOODS_SEARCH
=
'
/moreGoods
'
;
export
const
GOODS_DETAIL
=
'
/details
'
;
export
function
goodsCategory
(
query
)
{
return
request
({
url
:
'
/wx/catalog/index
'
,
method
:
'
get
'
,
params
:
query
})
}
export
function
goodsChannelCategory
(
query
)
{
return
request
({
url
:
'
/wx/catalog/index
'
,
method
:
'
get
'
,
params
:
query
})
}
export
function
goodsSearch
(
query
)
{
return
request
({
url
:
'
/wx/catalog/current?id=
'
,
method
:
'
get
'
,
params
:
query
})
}
export
function
goodsDetail
(
query
)
{
return
request
({
url
:
'
/wx/catalog/index
'
,
method
:
'
get
'
,
params
:
query
})
}
\ No newline at end of file
litemall-vue/src/api/order.js
View file @
20ea711a
import
request
from
'
@/utils/request
'
export
const
ORDER_LIST
=
'
/order-list
'
;
export
const
ELE_COUPON_LIST
=
'
/electronic-list
'
;
...
...
litemall-vue/src/api/promotion.js
View file @
20ea711a
import
request
from
'
@/utils/request
'
litemall-vue/src/api/shop.js
View file @
20ea711a
export
const
HOME_module
=
'
/home
'
;
export
const
ALL_GOODS
=
'
/moreGoods
'
;
export
const
SHOPINFO
=
'
/shop-info
'
;
// 运费模板
export
const
POST_FEE
=
''
;
import
request
from
'
@/utils/request
'
export
const
HOME_module
=
'
/home
'
;
export
const
ALL_GOODS
=
'
/moreGoods
'
;
export
const
SHOPINFO
=
'
/shop-info
'
;
// 运费模板
export
const
POST_FEE
=
''
;
export
function
getHome
(
query
)
{
return
request
({
url
:
'
/wx/home/index
'
,
method
:
'
get
'
,
params
:
query
})
}
litemall-vue/src/api/user.js
View file @
20ea711a
import
request
from
'
@/utils/request
'
// 登录
export
const
USER_LOGIN
=
'
/wx/auth/login
'
;
export
const
USER_LOGOUT
=
''
;
...
...
@@ -17,8 +19,6 @@ export const ADDRESS_DEFAULT = '/address-default';
// 收藏
export
const
GOODS_COLLECT_LIST
=
'
/moreGoods
'
;
import
request
from
'
@/utils/request
'
export
function
loginByUsername
(
data
)
{
return
request
({
url
:
'
/wx/auth/login
'
,
...
...
litemall-vue/src/assets/scss/iconfont/iconfont.css
View file @
20ea711a
...
...
@@ -5,7 +5,7 @@
@font-face
{
font-family
:
"vanIcon"
;
src
:
url(https://
b
.yzcdn.cn/
z
an
ui/icon
/vant-icon-
4c3245
.ttf)
format
(
'truetype'
);
src
:
url(
'
https://
img
.yzcdn.cn/
v
an
t
/vant-icon-
66a14a
.ttf
'
)
format
(
'truetype'
);
}
.van-icon
{
...
...
litemall-vue/src/components/infinity-scroll/index.vue
View file @
20ea711a
...
...
@@ -19,6 +19,7 @@ import { List } from 'vant';
import
{
get
}
from
'
lodash
'
;
import
IsEmpty
from
'
@/components/is-empty
'
;
import
loadMore
from
'
@/mixin/load-more
'
;
import
{
goodsList
}
from
'
@/api/api
'
;
const
DEFAULT_CONFIG
=
{
params
:
{},
...
...
@@ -68,9 +69,7 @@ export default {
const
prePage
=
this
.
perPage
||
this
.
pages
.
perPage
;
console
.
log
(
params
);
console
.
log
(
headers
);
const
res
=
await
this
.
$reqGet
(
'
/wx/goods/list
'
,
{
goodsList
({
// 'per-page': prePage,
page
:
this
.
pages
.
currPage
,
size
:
100
,
...
...
litemall-vue/src/main.js
View file @
20ea711a
...
...
@@ -2,18 +2,17 @@ import Vue from 'vue';
import
App
from
'
./App.vue
'
;
import
router
from
'
./router
'
;
import
store
from
'
./store
'
import
'
./assets/scss/global.scss
'
;
import
'
vant/lib/icon/local.css
'
;
import
'
@/assets/scss/global.scss
'
;
import
'
@/assets/scss/iconfont/iconfont.css
'
;
import
VeeValidate
,
{
Validator
}
from
'
vee-validate
'
;
import
VueCountdown
from
'
@
/plugins
/vue-countdown
'
;
import
VueCountdown
from
'
@
chenfengyuan
/vue-countdown
'
;
import
zhCN
from
'
vee-validate/dist/locale/zh_CN
'
;
import
axios
from
'
@/plugins/axios
'
;
import
filters
from
'
@/filter
'
;
Vue
.
use
(
VueCountdown
);
Vue
.
use
(
axios
);
Vue
.
component
(
VueCountdown
.
name
,
VueCountdown
);
Vue
.
use
(
filters
);
Validator
.
localize
(
'
zh-CN
'
,
zhCN
);
...
...
litemall-vue/src/plugins/axios.js
deleted
100644 → 0
View file @
21cfee12
import
axios
from
'
axios
'
;
import
_
from
'
lodash
'
;
import
qs
from
'
qs
'
;
import
{
Dialog
,
Toast
}
from
'
vant
'
;
import
Vue
from
'
vue
'
;
Vue
.
use
(
Toast
);
const
instance
=
axios
.
create
({
timeout
:
5000
,
baseURL
:
''
});
instance
.
interceptors
.
request
.
use
(
config
=>
{
if
(
!
config
.
headers
[
'
X-Litemall-Token
'
])
{
config
.
headers
[
'
X-Litemall-Token
'
]
=
`
${
window
.
localStorage
.
getItem
(
'
Authorization
'
)
||
''
}
`
;
}
return
config
;
},
err
=>
Promise
.
reject
(
err
)
);
instance
.
interceptors
.
response
.
use
(
res
=>
{
let
litemall
=
_
.
has
(
res
.
data
,
'
errno
'
)
&&
res
.
data
.
errno
!==
0
;
let
oldmall
=
_
.
has
(
res
.
data
,
'
success
'
)
&&
!
res
.
data
.
success
;
if
(
litemall
||
oldmall
)
{
switch
(
res
.
data
.
code
||
res
.
data
.
errno
)
{
case
422
:
{
const
flag
=
Array
.
isArray
(
res
.
data
.
data
)
&&
res
.
data
.
data
.
length
;
Dialog
.
alert
({
message
:
flag
?
res
.
data
.
data
[
0
].
message
:
res
.
data
.
message
});
break
;
}
case
401
:
break
;
case
404
:
break
;
case
740
:
{
Toast
.
fail
(
'
优惠券已经领取过
'
);
break
;
}
case
501
:
{
Toast
.
fail
(
'
请登录
'
);
setTimeout
(()
=>
{
window
.
location
=
'
#/login/
'
},
1500
)
break
;
}
default
:
Toast
.
fail
(
res
.
data
.
errmsg
)
}
return
Promise
.
reject
(
res
);
}
return
res
;
},
error
=>
{
Dialog
.
alert
({
title
:
'
警告
'
,
message
:
error
.
message
});
return
Promise
.
reject
(
error
);
}
);
const
post
=
(
url
,
data
,
config
=
{})
=>
instance
.
post
(
url
,
data
,
config
);
const
put
=
(
url
,
data
,
config
=
{})
=>
instance
.
put
(
url
,
data
,
config
);
const
get
=
(
url
,
params
,
config
=
{})
=>
instance
.
get
(
url
,
{
params
,
...
config
});
const
deleteMethod
=
(
url
,
config
=
{})
=>
instance
({
url
,
method
:
'
delete
'
,
...
config
});
export
default
{
install
(
Vue
)
{
Vue
.
prototype
.
$reqGet
=
get
;
Vue
.
prototype
.
$reqPost
=
post
;
Vue
.
prototype
.
$reqPut
=
put
;
Vue
.
prototype
.
$reqDel
=
deleteMethod
;
}
};
litemall-vue/src/plugins/vue-countdown.js
deleted
100644 → 0
View file @
21cfee12
import
VueCountdown
from
'
@xkeshi/vue-countdown
'
;
export
default
{
install
(
Vue
)
{
Vue
.
component
(
'
countdown
'
,
VueCountdown
);
}
};
litemall-vue/src/router/index.js
View file @
20ea711a
...
...
@@ -15,11 +15,10 @@ const RouterModel = new Router({
});
RouterModel
.
beforeEach
((
to
,
from
,
next
)
=>
{
const
{
Authorization
,
user_id
}
=
getLocalStorage
(
'
Authorization
'
,
'
user_id
'
const
{
Authorization
}
=
getLocalStorage
(
'
Authorization
'
);
if
(
!
Authorization
&&
!
user_id
)
{
if
(
!
Authorization
)
{
if
(
to
.
meta
.
login
)
{
next
({
name
:
'
login
'
,
query
:
{
redirect
:
to
.
name
}
});
return
;
...
...
litemall-vue/src/router/items.js
View file @
20ea711a
const
Tabbar
=
()
=>
import
(
/* webpackChunkName: "Tabbar" */
'
@/components/Tabbar/
'
);
const
Tabbar
=
()
=>
import
(
'
@/components/Tabbar/
'
);
export
default
[
{
...
...
litemall-vue/src/router/user.js
View file @
20ea711a
const
tab_user
=
()
=>
import
(
'
@/views/user/tabbar-user
'
);
const
UserCollect
=
()
=>
import
(
'
@/views/user/module-collect
'
);
const
UserInvitation
=
()
=>
import
(
'
@/views/user/module-invitation
'
);
const
UserAddress
=
()
=>
import
(
'
@/views/user/module-address
'
);
const
UserAddressEdit
=
()
=>
import
(
'
@/views/user/module-address-edit
'
);
const
UserServer
=
()
=>
import
(
'
@/views/user/module-server
'
);
...
...
@@ -34,14 +33,6 @@ export default [
},
component
:
UserCollect
},
{
path
:
'
/user/invitation
'
,
name
:
'
invitation
'
,
meta
:
{
login
:
true
},
component
:
UserInvitation
},
{
path
:
'
/user/address
'
,
name
:
'
address
'
,
...
...
litemall-vue/src/utils/request.js
View file @
20ea711a
...
...
@@ -3,7 +3,7 @@ import { Dialog, Toast } from 'vant';
// create an axios instance
const
service
=
axios
.
create
({
baseURL
:
process
.
env
.
BASE_API
,
// api 的 base_url
baseURL
:
process
.
env
.
VUE_APP_
BASE_API
,
// api 的 base_url
timeout
:
5000
// request timeout
})
...
...
@@ -34,7 +34,13 @@ service.interceptors.response.use(
}
else
if
(
res
.
errno
===
502
)
{
Toast
.
alert
(
'
网站内部错误,请联系网站维护人员
'
)
return
Promise
.
reject
(
'
error
'
)
}
else
if
(
res
.
errno
!==
0
)
{
}
if
(
res
.
errno
===
401
)
{
Toast
.
fail
(
'
参数不对
'
);
return
Promise
.
reject
(
'
error
'
)
}
if
(
res
.
errno
===
402
)
{
Toast
.
fail
(
'
参数值不对
'
);
return
Promise
.
reject
(
'
error
'
)
}
else
if
(
res
.
errno
!==
0
)
{
// 非5xx的错误属于业务错误,留给具体页面处理
return
Promise
.
reject
(
response
)
}
else
{
...
...
litemall-vue/src/views/home/tabbar-home.vue
View file @
20ea711a
...
...
@@ -4,6 +4,7 @@
<van-search
placeholder=
"点击前往搜索"
@
click=
"$router.push(
{ name: 'search' })"/>
<div
class=
"tal_class_searchMask"
></div>
</div>
<!-- 品牌商 -->
<van-swipe
:autoplay=
"3000"
indicator-color=
"white"
>
<van-swipe-item
v-for=
"(image, index) in brandList"
:key=
"index"
>
<img
:src=
"image"
style=
"height:230px"
>
...
...
@@ -46,7 +47,6 @@
</van-panel>
<van-panel
title=
"团购专区"
>
<!--
{{
shopInfos
.
grouponList
}}
-->
<van-card
:thumb-link=
"goDetail(groupGood.goods.id)"
v-for=
"(groupGood ,index) in shopInfos.grouponList"
...
...
@@ -64,7 +64,6 @@
</van-panel>
<van-panel
title=
"新品首发"
>
<!--
{{
shopInfos
.
grouponList
}}
-->
<van-row
gutter
>
<van-col
span=
"12"
v-for=
"(newGood ,index) in shopInfos.newGoodsList"
:key=
"index"
>
<router-link
:to=
"
{ path: `/items/detail/${newGood.id}`}">
...
...
@@ -81,7 +80,6 @@
</van-panel>
<van-panel
title=
"人气推荐"
>
<!--
{{
shopInfos
.
grouponList
}}
-->
<van-card
:thumb-link=
"goDetail(groupGood.id)"
v-for=
"(groupGood ,index) in shopInfos.hotGoodsList"
...
...
@@ -96,69 +94,16 @@
<!--
<div
slot=
"footer"
>
添加日期
{{
item
.
addTime
}}
</div>
-->
</van-card>
</van-panel>
<!--
<van-list
v-model=
"loading"
class=
"scroll-load"
:finished=
"finished"
:immediate-check=
"false"
:offset=
"100"
@
load=
"loadMore"
>
<item-group
v-for=
"( group, key ) in itemGroup"
v-if=
"group"
:key=
"key"
class=
"interval_bot"
:setting=
"group.setting"
>
<component
v-for=
"item in group.items"
:goods=
"item"
:key=
"item.id"
:is=
"getStyle(group.setting.style)"
@
click=
"toGoods(item)"
>
<div
slot=
"mask"
v-if=
"lootAll(item)"
>
<img
src=
"../../assets/images/not_enough.png"
alt=
"已抢光"
>
</div>
<div
slot=
"leftTopIcon"
v-if=
"item.as_status
<
2"
>
<img
:src=
"mxStatus(item.as_status)"
alt=
"秒杀"
>
</div>
</component>
</item-group>
</van-list>
-->
</div>
</
template
>
<
script
>
import
{
HOME_module
,
ALL_GOODS
}
from
'
@/api/shop
'
;
import
getLocationParam
from
'
@/utils/location-param
'
;
import
mx_be_to
from
'
@/assets/images/mx_be_to.png
'
;
import
mx_start
from
'
@/assets/images/mx_start.png
'
;
import
SignBoard
from
'
./tabbar-home-sign-board
'
;
import
ShopInfoGroup
from
'
./tabbar-home-shop-info
'
;
import
ItemGroup
from
'
@/components/item-group/
'
;
import
ItemCardVert
from
'
@/components/item-card-vert/
'
;
import
ItemCardHori
from
'
@/components/item-card-hori/
'
;
import
{
getHome
,
goodsCategory
,
couponReceive
}
from
'
@/api/api
'
;
import
loadMore
from
'
@/mixin/list-load-more
'
;
import
scrollFixed
from
'
@/mixin/scroll-fixed
'
;
import
_
from
'
lodash
'
;
const
coupon
=
{
available
:
1
,
discount
:
0
,
denominations
:
150
,
originCondition
:
0
,
reason
:
''
,
value
:
150
,
name
:
'
优惠券名称
'
,
startAt
:
1489104000
,
endAt
:
1514592000
};
import
{
List
,
Swipe
,
...
...
@@ -179,84 +124,37 @@ export default {
mixins
:
[
loadMore
,
scrollFixed
],
data
()
{
const
shop_id
=
getLocationParam
(
'
shop_id
'
);
return
{
shop_id
,
brandList
:
[],
shopInfos
:
[],
shopInfo
:
null
,
coupons
:
[
coupon
],
itemGroup
:
{
mx_goods
:
null
,
activity_seckill
:
null
,
shop_recommend
:
null
,
goods
:
null
},
mx_be_to
,
mx_start
,
isLoading
:
false
};
},
computed
:
{
location
()
{
const
shopInfo
=
this
.
shopInfo
;
const
local
=
{
name
:
shopInfo
.
shop_name
,
lat
:
shopInfo
.
lat
,
lng
:
shopInfo
.
lng
};
return
local
.
lat
&&
local
.
lng
?
local
:
null
;
}
},
created
()
{
// this.initViews();
this
.
initNewViews
();
this
.
initViews
();
},
methods
:
{
goDetail
(
id
)
{
return
`#/items/detail/
${
id
}
`
;
},
async
getCoupon
(
id
)
{
let
errmsg
=
await
this
.
$reqPost
(
'
/wx/coupon/receive
'
,
{
couponId
:
id
});
Toast
.
success
(
'
领取成功
'
);
getCoupon
(
id
)
{
couponReceive
({
couponId
:
id
}).
then
(
res
=>
{
Toast
.
success
(
'
领取成功
'
);
})
},
async
changeTabbar
(
o
)
{
let
{
data
}
=
await
this
.
$reqGet
(
`/wx/
goods
/c
ategory
?id=
${
o
.
id
}
`
)
;
let
categoryId
=
data
.
data
.
currentCategory
.
id
;
this
.
$router
.
push
({
path
:
`items/list?keyword=&itemClass=
${
categoryId
}
`
})
;
changeTabbar
(
o
)
{
let
that
=
this
goods
C
ategory
({
id
:
o
.
id
}).
then
(
res
=>
{
let
categoryId
=
res
.
data
.
data
.
currentCategory
.
id
;
this
.
$router
.
push
({
path
:
`items/list?keyword=&itemClass=
${
categoryId
}
`
});
})
},
initViews
()
{
this
.
$reqGet
(
HOME_module
,
{
shop_id
:
this
.
shop_id
,
'
per-page
'
:
this
.
pages
.
perPage
,
page
:
1
}).
then
(
res
=>
{
const
{
shop_info
,
page
}
=
res
.
data
.
data
;
const
{
mx_goods
,
shop_recommend
,
activity_seckill
,
goods
}
=
this
.
decorate
(
res
.
data
.
data
);
this
.
shopInfo
=
shop_info
;
this
.
itemGroup
.
mx_goods
=
mx_goods
;
this
.
itemGroup
.
shop_recommend
=
shop_recommend
;
this
.
itemGroup
.
activity_seckill
=
activity_seckill
;
this
.
itemGroup
.
goods
=
goods
;
this
.
setPages
(
page
);
});
},
initNewViews
()
{
this
.
$reqGet
(
'
/wx/home/index
'
).
then
(
res
=>
{
getHome
().
then
(
res
=>
{
this
.
shopInfos
=
res
.
data
.
data
;
this
.
brandList
=
[];
_
.
each
(
res
.
data
.
data
.
brandList
,
v
=>
{
...
...
@@ -265,18 +163,6 @@ export default {
});
},
initData
()
{
// return this.$reqGet(ALL_GOODS, {
// shop_id: this.shop_id,
// 'per-page': this.pages.perPage,
// page: this.pages.currPage
// }).then(res => {
// const { items, page } = res.data.data;
// this.itemGroup.goods && this.itemGroup.goods.items.push(...items);
// return page;
// });
},
toGoods
(
item
)
{
// 如果是秒杀商品, 并且已经抢光
if
(
this
.
lootAll
(
item
))
{
...
...
@@ -300,42 +186,10 @@ export default {
return
style
?
'
item-card-vert
'
:
'
item-card-hori
'
;
},
decorate
({
mx_goods
,
shop_recommend
,
activity_seckill
,
goods
})
{
if
(
mx_goods
)
{
mx_goods
.
setting
.
icon
=
'
n4
'
;
mx_goods
.
setting
.
title_desc
=
'
分享得金豆
'
;
mx_goods
.
setting
.
title_color
=
'
#db3d3c
'
;
mx_goods
.
setting
.
item_len
=
mx_goods
.
items
.
length
;
}
if
(
shop_recommend
)
{
shop_recommend
.
setting
.
icon
=
'
good
'
;
shop_recommend
.
setting
.
item_len
=
shop_recommend
.
items
.
length
;
}
if
(
activity_seckill
)
{
activity_seckill
.
setting
.
icon
=
'
naozhong
'
;
activity_seckill
.
setting
.
title_color
=
'
#db3d3c
'
;
activity_seckill
.
setting
.
item_len
=
activity_seckill
.
items
.
length
;
}
if
(
goods
)
{
goods
.
setting
.
icon
=
'
list
'
;
goods
.
setting
.
item_len
=
goods
.
items
.
length
;
}
return
{
mx_goods
,
shop_recommend
,
activity_seckill
,
goods
};
},
lootAll
(
item
)
{
return
(
typeof
item
.
as_status
!==
'
undefined
'
&&
item
.
sold_num
==
item
.
total
);
},
mxStatus
(
as_status
)
{
return
as_status
?
this
.
mx_start
:
this
.
mx_be_to
;
}
},
...
...
@@ -353,12 +207,7 @@ export default {
[
Swipe
.
name
]:
Swipe
,
[
SwipeItem
.
name
]:
SwipeItem
,
[
Tabbar
.
name
]:
Tabbar
,
[
TabbarItem
.
name
]:
TabbarItem
,
[
SignBoard
.
name
]:
SignBoard
,
[
ShopInfoGroup
.
name
]:
ShopInfoGroup
,
[
ItemGroup
.
name
]:
ItemGroup
,
[
ItemCardVert
.
name
]:
ItemCardVert
,
[
ItemCardHori
.
name
]:
ItemCardHori
[
TabbarItem
.
name
]:
TabbarItem
}
};
</
script
>
...
...
@@ -399,7 +248,6 @@ export default {
line-height
:
1
;
color
:
#333
;
}
van-tabbar-item
.van-coupon-cell--selected
{
color
:
#323233
;
}
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
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