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
eb158458
Commit
eb158458
authored
Jul 22, 2018
by
Menethil
Browse files
添加自动更新,部分页面支持下拉刷新
parent
96979025
Changes
11
Hide whitespace changes
Inline
Side-by-side
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java
View file @
eb158458
...
@@ -559,7 +559,7 @@ public class WxOrderController {
...
@@ -559,7 +559,7 @@ public class WxOrderController {
* 这里微信的短信平台对参数长度有限制,所以将订单号只截取后6位
* 这里微信的短信平台对参数长度有限制,所以将订单号只截取后6位
*
*
*/
*/
notifyService
.
notifySmsTemplate
(
order
.
getMobile
(),
NotifyType
.
PAY_SUCCEED
,
new
String
[]{
orderSn
.
substring
(
8
,
14
)});
notifyService
.
notifySmsTemplate
Sync
(
order
.
getMobile
(),
NotifyType
.
PAY_SUCCEED
,
new
String
[]{
orderSn
.
substring
(
8
,
14
)});
return
WxPayNotifyResponse
.
success
(
"处理成功!"
);
return
WxPayNotifyResponse
.
success
(
"处理成功!"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
litemall-wx/app.js
View file @
eb158458
...
@@ -4,6 +4,19 @@ var user = require('./utils/user.js');
...
@@ -4,6 +4,19 @@ var user = require('./utils/user.js');
App
({
App
({
onLaunch
:
function
()
{
onLaunch
:
function
()
{
const
updateManager
=
wx
.
getUpdateManager
();
wx
.
getUpdateManager
().
onUpdateReady
(
function
()
{
wx
.
showModal
({
title
:
'
更新提示
'
,
content
:
'
新版本已经准备好,是否重启应用?
'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager
.
applyUpdate
()
}
}
})
})
},
},
onShow
:
function
(
options
)
{
onShow
:
function
(
options
)
{
user
.
checkLogin
().
then
(
res
=>
{
user
.
checkLogin
().
then
(
res
=>
{
...
...
litemall-wx/app.json
View file @
eb158458
...
@@ -35,10 +35,10 @@
...
@@ -35,10 +35,10 @@
"window"
:
{
"window"
:
{
"navigationBarBackgroundColor"
:
"#FFFFFF"
,
"navigationBarBackgroundColor"
:
"#FFFFFF"
,
"navigationBarTitleText"
:
"litemall小程序商城"
,
"navigationBarTitleText"
:
"litemall小程序商城"
,
"enablePullDownRefresh"
:
true
,
"navigationBarTextStyle"
:
"black"
,
"navigationBarTextStyle"
:
"black"
,
"backgroundColor"
:
"#FFFFFF"
,
"backgroundColor"
:
"#FFFFFF"
,
"backgroundTextStyle"
:
"dark"
,
"backgroundTextStyle"
:
"dark"
"enablePullDownRefresh"
:
false
},
},
"tabBar"
:
{
"tabBar"
:
{
"backgroundColor"
:
"#fafafa"
,
"backgroundColor"
:
"#fafafa"
,
...
...
litemall-wx/config/api.js
View file @
eb158458
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
// 云平台部署时使用
// 云平台部署时使用
var
WxApiRoot
=
'
http://122.152.206.172:8082/wx/
'
;
var
WxApiRoot
=
'
http://122.152.206.172:8082/wx/
'
;
// 云平台上线时使用
// 云平台上线时使用
// var WxApiRoot = 'https://www.
example
.com/wx/';
// var WxApiRoot = 'https://www.
menethil
.com
.cn
/wx/';
// 以下是图片存储服务器API地址
// 以下是图片存储服务器API地址
// 本机开发时使用
// 本机开发时使用
...
@@ -16,75 +16,76 @@ var WxApiRoot = 'http://122.152.206.172:8082/wx/';
...
@@ -16,75 +16,76 @@ var WxApiRoot = 'http://122.152.206.172:8082/wx/';
// 云平台部署时使用
// 云平台部署时使用
var
StorageApi
=
'
http://122.152.206.172:8081/os/storage/create
'
;
var
StorageApi
=
'
http://122.152.206.172:8081/os/storage/create
'
;
// 云平台上线时使用
// 云平台上线时使用
// var StorageApi = 'https://www.
example
.com/os/storage/create';
// var StorageApi = 'https://www.
menethil
.com
.cn
/os/storage/create';
module
.
exports
=
{
module
.
exports
=
{
IndexUrl
:
WxApiRoot
+
'
home/index
'
,
//首页数据接口
IndexUrl
:
WxApiRoot
+
'
home/index
'
,
//首页数据接口
CatalogList
:
WxApiRoot
+
'
catalog/index
'
,
//分类目录全部分类数据接口
CatalogList
:
WxApiRoot
+
'
catalog/index
'
,
//分类目录全部分类数据接口
CatalogCurrent
:
WxApiRoot
+
'
catalog/current
'
,
//分类目录当前分类数据接口
CatalogCurrent
:
WxApiRoot
+
'
catalog/current
'
,
//分类目录当前分类数据接口
AuthLoginByWeixin
:
WxApiRoot
+
'
auth/login_by_weixin
'
,
//微信登录
AuthLoginByWeixin
:
WxApiRoot
+
'
auth/login_by_weixin
'
,
//微信登录
AuthLoginByAccount
:
WxApiRoot
+
'
auth/login
'
,
//账号登录
AuthLoginByAccount
:
WxApiRoot
+
'
auth/login
'
,
//账号登录
AuthRegister
:
WxApiRoot
+
'
auth/register
'
,
//账号注册
AuthRegister
:
WxApiRoot
+
'
auth/register
'
,
//账号注册
AuthReset
:
WxApiRoot
+
'
auth/reset
'
,
//账号密码重置
AuthReset
:
WxApiRoot
+
'
auth/reset
'
,
//账号密码重置
AuthRegisterCaptcha
:
WxApiRoot
+
'
auth/regCaptcha
'
,
//验证码
GoodsCount
:
WxApiRoot
+
'
goods/count
'
,
//统计商品总数
GoodsList
:
WxApiRoot
+
'
goods/list
'
,
//获得商品列表
GoodsCount
:
WxApiRoot
+
'
goods/count
'
,
//统计商品总数
GoodsCategory
:
WxApiRoot
+
'
goods/category
'
,
//获得分类数据
GoodsList
:
WxApiRoot
+
'
goods/list
'
,
//获得商品列表
GoodsDetail
:
WxApiRoot
+
'
goods/detail
'
,
//获得商品的详情
GoodsCategory
:
WxApiRoot
+
'
goods/category
'
,
//获得分类数据
GoodsNew
:
WxApiRoot
+
'
goods/new
'
,
//新品
GoodsDetail
:
WxApiRoot
+
'
goods/detail
'
,
//获得商品的详情
GoodsHot
:
WxApiRoot
+
'
goods/hot
'
,
//热门
GoodsNew
:
WxApiRoot
+
'
goods/new
'
,
//新品
GoodsRelated
:
WxApiRoot
+
'
goods/related
'
,
//商品详情页的关联商品(大家都在看)
GoodsHot
:
WxApiRoot
+
'
goods/hot
'
,
//热门
GoodsRelated
:
WxApiRoot
+
'
goods/related
'
,
//商品详情页的关联商品(大家都在看)
BrandList
:
WxApiRoot
+
'
brand/list
'
,
//品牌列表
BrandDetail
:
WxApiRoot
+
'
brand/detail
'
,
//品牌详情
BrandList
:
WxApiRoot
+
'
brand/list
'
,
//品牌列表
BrandDetail
:
WxApiRoot
+
'
brand/detail
'
,
//品牌详情
CartList
:
WxApiRoot
+
'
cart/index
'
,
//获取购物车的数据
CartAdd
:
WxApiRoot
+
'
cart/add
'
,
// 添加商品到购物车
CartList
:
WxApiRoot
+
'
cart/index
'
,
//获取购物车的数据
CartFastAdd
:
WxApiRoot
+
'
cart/fastadd
'
,
// 立即购买商品
CartAdd
:
WxApiRoot
+
'
cart/add
'
,
// 添加商品到购物车
CartUpdate
:
WxApiRoot
+
'
cart/update
'
,
// 更新购物车的商品
CartFastAdd
:
WxApiRoot
+
'
cart/fastadd
'
,
// 立即购买商品
CartDelete
:
WxApiRoot
+
'
cart/delete
'
,
// 删除购物车的商品
CartUpdate
:
WxApiRoot
+
'
cart/update
'
,
// 更新购物车的商品
CartChecked
:
WxApiRoot
+
'
cart/checked
'
,
// 选择或取消选择商品
CartDelete
:
WxApiRoot
+
'
cart/delete
'
,
// 删除购物车的商品
CartGoodsCount
:
WxApiRoot
+
'
cart/goodscount
'
,
// 获取购物车商品件数
CartChecked
:
WxApiRoot
+
'
cart/checked
'
,
// 选择或取消选择商品
CartCheckout
:
WxApiRoot
+
'
cart/checkout
'
,
// 下单前信息确认
CartGoodsCount
:
WxApiRoot
+
'
cart/goodscount
'
,
// 获取购物车商品件数
CartCheckout
:
WxApiRoot
+
'
cart/checkout
'
,
// 下单前信息确认
CollectList
:
WxApiRoot
+
'
collect/list
'
,
//收藏列表
CollectAddOrDelete
:
WxApiRoot
+
'
collect/addordelete
'
,
//添加或取消收藏
CollectList
:
WxApiRoot
+
'
collect/list
'
,
//收藏列表
CollectAddOrDelete
:
WxApiRoot
+
'
collect/addordelete
'
,
//添加或取消收藏
CommentList
:
WxApiRoot
+
'
comment/list
'
,
//评论列表
CommentCount
:
WxApiRoot
+
'
comment/count
'
,
//评论总数
CommentList
:
WxApiRoot
+
'
comment/list
'
,
//评论列表
CommentPost
:
WxApiRoot
+
'
comment/post
'
,
//发表评论
CommentCount
:
WxApiRoot
+
'
comment/count
'
,
//评论总数
CommentPost
:
WxApiRoot
+
'
comment/post
'
,
//发表评论
TopicList
:
WxApiRoot
+
'
topic/list
'
,
//专题列表
TopicDetail
:
WxApiRoot
+
'
topic/detail
'
,
//专题详情
TopicList
:
WxApiRoot
+
'
topic/list
'
,
//专题列表
TopicRelated
:
WxApiRoot
+
'
topic/related
'
,
//相关专题
TopicDetail
:
WxApiRoot
+
'
topic/detail
'
,
//专题详情
TopicRelated
:
WxApiRoot
+
'
topic/related
'
,
//相关专题
SearchIndex
:
WxApiRoot
+
'
search/index
'
,
//搜索关键字
SearchResult
:
WxApiRoot
+
'
search/result
'
,
//搜索结果
SearchIndex
:
WxApiRoot
+
'
search/index
'
,
//搜索关键字
SearchHelper
:
WxApiRoot
+
'
search/helper
'
,
//搜索帮助
SearchResult
:
WxApiRoot
+
'
search/result
'
,
//搜索结果
SearchClearHistory
:
WxApiRoot
+
'
search/clearhistory
'
,
//搜索历史清楚
SearchHelper
:
WxApiRoot
+
'
search/helper
'
,
//搜索帮助
SearchClearHistory
:
WxApiRoot
+
'
search/clearhistory
'
,
//搜索历史清楚
AddressList
:
WxApiRoot
+
'
address/list
'
,
//收货地址列表
AddressDetail
:
WxApiRoot
+
'
address/detail
'
,
//收货地址详情
AddressList
:
WxApiRoot
+
'
address/list
'
,
//收货地址列表
AddressSave
:
WxApiRoot
+
'
address/save
'
,
//保存收货地址
AddressDetail
:
WxApiRoot
+
'
address/detail
'
,
//收货地址详情
AddressDelete
:
WxApiRoot
+
'
address/delete
'
,
//保存收货地址
AddressSave
:
WxApiRoot
+
'
address/save
'
,
//保存收货地址
AddressDelete
:
WxApiRoot
+
'
address/delete
'
,
//保存收货地址
ExpressQuery
:
WxApiRoot
+
'
express/query
'
,
//物流查询
ExpressQuery
:
WxApiRoot
+
'
express/query
'
,
//物流查询
RegionList
:
WxApiRoot
+
'
region/list
'
,
//获取区域列表
RegionList
:
WxApiRoot
+
'
region/list
'
,
//获取区域列表
OrderSubmit
:
WxApiRoot
+
'
order/submit
'
,
// 提交订单
OrderPrepay
:
WxApiRoot
+
'
order/prepay
'
,
// 订单的预支付会话
OrderSubmit
:
WxApiRoot
+
'
order/submit
'
,
// 提交订单
OrderList
:
WxApiRoot
+
'
order/list
'
,
//订单列表
OrderPrepay
:
WxApiRoot
+
'
order/prepay
'
,
// 订单的预支付会话
OrderDetail
:
WxApiRoot
+
'
order/detail
'
,
//订单详情
OrderList
:
WxApiRoot
+
'
order/list
'
,
//订单列表
OrderCancel
:
WxApiRoot
+
'
order/cancel
'
,
//取消订单
OrderDetail
:
WxApiRoot
+
'
order/detail
'
,
//订单详情
OrderRefund
:
WxApiRoot
+
'
order/refund
'
,
//退款取消订单
OrderCancel
:
WxApiRoot
+
'
order/cancel
'
,
//取消订单
OrderDelete
:
WxApiRoot
+
'
order/delete
'
,
//删除订单
OrderRefund
:
WxApiRoot
+
'
order/refund
'
,
//退款取消订单
OrderConfirm
:
WxApiRoot
+
'
order/confirm
'
,
//确认收货
OrderDelete
:
WxApiRoot
+
'
order/delete
'
,
//删除订单
OrderComment
:
WxApiRoot
+
'
order/comment
'
,
// 代评价商品信息
OrderConfirm
:
WxApiRoot
+
'
order/confirm
'
,
//确认收货
OrderComment
:
WxApiRoot
+
'
order/comment
'
,
// 代评价商品信息
FootprintList
:
WxApiRoot
+
'
footprint/list
'
,
//足迹列表
FootprintDelete
:
WxApiRoot
+
'
footprint/delete
'
,
//删除足迹
FootprintList
:
WxApiRoot
+
'
footprint/list
'
,
//足迹列表
FootprintDelete
:
WxApiRoot
+
'
footprint/delete
'
,
//删除足迹
StorageUpload
:
StorageApi
,
//图片上传
StorageUpload
:
StorageApi
,
//图片上传
};
};
\ No newline at end of file
litemall-wx/pages/cart/cart.js
View file @
eb158458
...
@@ -5,286 +5,299 @@ var user = require('../../utils/user.js');
...
@@ -5,286 +5,299 @@ var user = require('../../utils/user.js');
var
app
=
getApp
();
var
app
=
getApp
();
Page
({
Page
({
data
:
{
data
:
{
cartGoods
:
[],
cartGoods
:
[],
cartTotal
:
{
cartTotal
:
{
"
goodsCount
"
:
0
,
"
goodsCount
"
:
0
,
"
goodsAmount
"
:
0.00
,
"
goodsAmount
"
:
0.00
,
"
checkedGoodsCount
"
:
0
,
"
checkedGoodsCount
"
:
0
,
"
checkedGoodsAmount
"
:
0.00
"
checkedGoodsAmount
"
:
0.00
},
isEditCart
:
false
,
checkedAllStatus
:
true
,
editCartList
:
[],
hasLogin
:
false
},
},
onLoad
:
function
(
options
)
{
isEditCart
:
false
,
// 页面初始化 options为页面跳转所带来的参数
checkedAllStatus
:
true
,
},
editCartList
:
[],
onReady
:
function
()
{
hasLogin
:
false
// 页面渲染完成
},
},
onLoad
:
function
(
options
)
{
onShow
:
function
()
{
// 页面初始化 options为页面跳转所带来的参数
// 页面显示
},
if
(
app
.
globalData
.
hasLogin
){
onReady
:
function
()
{
this
.
getCartList
();
// 页面渲染完成
}
},
onPullDownRefresh
()
{
this
.
setData
({
wx
.
showNavigationBarLoading
()
//在标题栏中显示加载
hasLogin
:
app
.
globalData
.
hasLogin
this
.
getCartList
();
});
wx
.
hideNavigationBarLoading
()
//完成停止加载
wx
.
stopPullDownRefresh
()
//停止下拉刷新
},
onShow
:
function
()
{
// 页面显示
if
(
app
.
globalData
.
hasLogin
)
{
this
.
getCartList
();
}
},
this
.
setData
({
onHide
:
function
()
{
hasLogin
:
app
.
globalData
.
hasLogin
// 页面隐藏
});
},
onUnload
:
function
()
{
// 页面关闭
},
goLogin
()
{
wx
.
navigateTo
({
url
:
"
/pages/auth/login/login
"
});
},
getCartList
:
function
()
{
let
that
=
this
;
util
.
request
(
api
.
CartList
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
cartGoods
:
res
.
data
.
cartList
,
cartTotal
:
res
.
data
.
cartTotal
});
that
.
setData
({
},
checkedAllStatus
:
that
.
isCheckedAll
()
onHide
:
function
()
{
});
// 页面隐藏
}
},
});
onUnload
:
function
()
{
},
// 页面关闭
isCheckedAll
:
function
()
{
},
//判断购物车商品已全选
goLogin
()
{
return
this
.
data
.
cartGoods
.
every
(
function
(
element
,
index
,
array
)
{
wx
.
navigateTo
({
if
(
element
.
checked
==
true
)
{
url
:
"
/pages/auth/login/login
"
return
true
;
});
}
else
{
},
return
false
;
getCartList
:
function
()
{
}
let
that
=
this
;
util
.
request
(
api
.
CartList
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
cartGoods
:
res
.
data
.
cartList
,
cartTotal
:
res
.
data
.
cartTotal
});
});
},
doCheckedAll
:
function
()
{
let
checkedAll
=
this
.
isCheckedAll
()
this
.
setData
({
checkedAllStatus
:
this
.
isCheckedAll
()
});
},
checkedItem
:
function
(
event
)
{
let
itemIndex
=
event
.
target
.
dataset
.
itemIndex
;
let
that
=
this
;
let
productIds
=
[];
that
.
setData
({
productIds
.
push
(
that
.
data
.
cartGoods
[
itemIndex
].
productId
);
checkedAllStatus
:
that
.
isCheckedAll
()
if
(
!
this
.
data
.
isEditCart
)
{
});
util
.
request
(
api
.
CartChecked
,
{
productIds
:
productIds
,
isChecked
:
that
.
data
.
cartGoods
[
itemIndex
].
checked
?
0
:
1
},
'
POST
'
).
then
(
function
(
res
)
{
}
if
(
res
.
errno
===
0
)
{
});
that
.
setData
({
},
cartGoods
:
res
.
data
.
cartList
,
isCheckedAll
:
function
()
{
cartTotal
:
res
.
data
.
cartTotal
//判断购物车商品已全选
});
return
this
.
data
.
cartGoods
.
every
(
function
(
element
,
index
,
array
)
{
}
if
(
element
.
checked
==
true
)
{
return
true
;
that
.
setData
({
}
else
{
checkedAllStatus
:
that
.
isCheckedAll
()
return
false
;
});
}
});
});
}
else
{
},
//编辑状态
doCheckedAll
:
function
()
{
let
tmpCartData
=
this
.
data
.
cartGoods
.
map
(
function
(
element
,
index
,
array
)
{
let
checkedAll
=
this
.
isCheckedAll
()
if
(
index
==
itemIndex
){
this
.
setData
({
element
.
checked
=
!
element
.
checked
;
checkedAllStatus
:
this
.
isCheckedAll
()
}
});
},
return
element
;
checkedItem
:
function
(
event
)
{
});
let
itemIndex
=
event
.
target
.
dataset
.
itemIndex
;
let
that
=
this
;
that
.
setData
({
let
productIds
=
[];
cartGoods
:
tmpCartData
,
productIds
.
push
(
that
.
data
.
cartGoods
[
itemIndex
].
productId
);
checkedAllStatus
:
that
.
isCheckedAll
(),
if
(
!
this
.
data
.
isEditCart
)
{
'
cartTotal.checkedGoodsCount
'
:
that
.
getCheckedGoodsCount
()
util
.
request
(
api
.
CartChecked
,
{
});
productIds
:
productIds
,
isChecked
:
that
.
data
.
cartGoods
[
itemIndex
].
checked
?
0
:
1
},
'
POST
'
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
cartGoods
:
res
.
data
.
cartList
,
cartTotal
:
res
.
data
.
cartTotal
});
}
}
},
getCheckedGoodsCount
:
function
(){
that
.
setData
({
let
checkedGoodsCount
=
0
;
checkedAllStatus
:
that
.
isCheckedAll
()
this
.
data
.
cartGoods
.
forEach
(
function
(
v
)
{
if
(
v
.
checked
===
true
)
{
checkedGoodsCount
+=
v
.
number
;
}
});
});
console
.
log
(
checkedGoodsCount
);
});
return
checkedGoodsCount
;
}
else
{
},
//编辑状态
checkedAll
:
function
()
{
let
tmpCartData
=
this
.
data
.
cartGoods
.
map
(
function
(
element
,
index
,
array
)
{
let
that
=
this
;
if
(
index
==
itemIndex
)
{
element
.
checked
=
!
element
.
checked
;
}
if
(
!
this
.
data
.
isEditCart
)
{
return
element
;
var
productIds
=
this
.
data
.
cartGoods
.
map
(
function
(
v
)
{
});
return
v
.
productId
;
});
util
.
request
(
api
.
CartChecked
,
{
productIds
:
productIds
,
isChecked
:
that
.
isCheckedAll
()
?
0
:
1
},
'
POST
'
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
console
.
log
(
res
.
data
);
that
.
setData
({
cartGoods
:
res
.
data
.
cartList
,
cartTotal
:
res
.
data
.
cartTotal
});
}
that
.
setData
({
that
.
setData
({
checkedAllStatus
:
that
.
isCheckedAll
()
cartGoods
:
tmpCartData
,
});
checkedAllStatus
:
that
.
isCheckedAll
(),
});
'
cartTotal.checkedGoodsCount
'
:
that
.
getCheckedGoodsCount
()
}
else
{
});
//编辑状态
}
let
checkedAllStatus
=
that
.
isCheckedAll
();
},
let
tmpCartData
=
this
.
data
.
cartGoods
.
map
(
function
(
v
)
{
getCheckedGoodsCount
:
function
()
{
v
.
checked
=
!
checkedAllStatus
;
let
checkedGoodsCount
=
0
;
return
v
;
this
.
data
.
cartGoods
.
forEach
(
function
(
v
)
{
});
if
(
v
.
checked
===
true
)
{
checkedGoodsCount
+=
v
.
number
;
}
});
console
.
log
(
checkedGoodsCount
);
return
checkedGoodsCount
;
},
checkedAll
:
function
()
{
let
that
=
this
;
that
.
setData
({
if
(
!
this
.
data
.
isEditCart
)
{
cartGoods
:
tmpCartData
,
var
productIds
=
this
.
data
.
cartGoods
.
map
(
function
(
v
)
{
checkedAllStatus
:
that
.
isCheckedAll
(),
return
v
.
productId
;
'
cartTotal.checkedGoodsCount
'
:
that
.
getCheckedGoodsCount
()
});
});
util
.
request
(
api
.
CartChecked
,
{
productIds
:
productIds
,
isChecked
:
that
.
isCheckedAll
()
?
0
:
1
},
'
POST
'
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
console
.
log
(
res
.
data
);
that
.
setData
({
cartGoods
:
res
.
data
.
cartList
,
cartTotal
:
res
.
data
.
cartTotal
});
}
}
},
that
.
setData
({
editCart
:
function
()
{
checkedAllStatus
:
that
.
isCheckedAll
()
var
that
=
this
;
});
if
(
this
.
data
.
isEditCart
)
{
});
this
.
getCartList
();
}
else
{
this
.
setData
({
//编辑状态
isEditCart
:
!
this
.
data
.
isEditCart
let
checkedAllStatus
=
that
.
isCheckedAll
();
});
let
tmpCartData
=
this
.
data
.
cartGoods
.
map
(
function
(
v
)
{
}
else
{
v
.
checked
=
!
checkedAllStatus
;
//编辑状态
return
v
;
let
tmpCartList
=
this
.
data
.
cartGoods
.
map
(
function
(
v
)
{
});
v
.
checked
=
false
;
return
v
;
});
this
.
setData
({
editCartList
:
this
.
data
.
cartGoods
,
cartGoods
:
tmpCartList
,
isEditCart
:
!
this
.
data
.
isEditCart
,
checkedAllStatus
:
that
.
isCheckedAll
(),
'
cartTotal.checkedGoodsCount
'
:
that
.
getCheckedGoodsCount
()
});
}
},
that
.
setData
({
updateCart
:
function
(
productId
,
goodsId
,
number
,
id
)
{
cartGoods
:
tmpCartData
,
let
that
=
this
;
checkedAllStatus
:
that
.
isCheckedAll
(),
'
cartTotal.checkedGoodsCount
'
:
that
.
getCheckedGoodsCount
()
});
}
util
.
request
(
api
.
CartUpdate
,
{
},
productId
:
productId
,
editCart
:
function
()
{
goodsId
:
goodsId
,
var
that
=
this
;
number
:
number
,
if
(
this
.
data
.
isEditCart
)
{
id
:
id
this
.
getCartList
();
},
'
POST
'
).
then
(
function
(
res
)
{
this
.
setData
({
that
.
setData
({
isEditCart
:
!
this
.
data
.
isEditCart
checkedAllStatus
:
that
.
isCheckedAll
()
});
});
}
else
{
});
//编辑状态
let
tmpCartList
=
this
.
data
.
cartGoods
.
map
(
function
(
v
)
{
v
.
checked
=
false
;
return
v
;
});
this
.
setData
({
editCartList
:
this
.
data
.
cartGoods
,
cartGoods
:
tmpCartList
,
isEditCart
:
!
this
.
data
.
isEditCart
,
checkedAllStatus
:
that
.
isCheckedAll
(),
'
cartTotal.checkedGoodsCount
'
:
that
.
getCheckedGoodsCount
()
});
}
},
},
cutNumber
:
function
(
event
)
{
updateCart
:
function
(
productId
,
goodsId
,
number
,
id
)
{
let
that
=
this
;
let
itemIndex
=
event
.
target
.
dataset
.
itemIndex
;
util
.
request
(
api
.
CartUpdate
,
{
let
cartItem
=
this
.
data
.
cartGoods
[
itemIndex
];
productId
:
productId
,
let
number
=
(
cartItem
.
number
-
1
>
1
)
?
cartItem
.
number
-
1
:
1
;
goodsId
:
goodsId
,
cartItem
.
number
=
number
;
number
:
number
,
this
.
setData
({
id
:
id
cartGoods
:
this
.
data
.
cartGoods
},
'
POST
'
).
then
(
function
(
res
)
{
});
that
.
setData
({
this
.
updateCart
(
cartItem
.
productId
,
cartItem
.
goodsId
,
number
,
cartItem
.
id
);
checkedAllStatus
:
that
.
isCheckedAll
()
},
});
addNumber
:
function
(
event
)
{
});
let
itemIndex
=
event
.
target
.
dataset
.
itemIndex
;
let
cartItem
=
this
.
data
.
cartGoods
[
itemIndex
];
let
number
=
cartItem
.
number
+
1
;
cartItem
.
number
=
number
;
this
.
setData
({
cartGoods
:
this
.
data
.
cartGoods
});
this
.
updateCart
(
cartItem
.
productId
,
cartItem
.
goodsId
,
number
,
cartItem
.
id
);
},
},
checkoutOrder
:
function
()
{
cutNumber
:
function
(
event
)
{
//获取已选择的商品
let
that
=
this
;
var
checkedGoods
=
this
.
data
.
cartGoods
.
filter
(
function
(
element
,
index
,
array
)
{
let
itemIndex
=
event
.
target
.
dataset
.
itemIndex
;
if
(
element
.
checked
==
true
)
{
let
cartItem
=
this
.
data
.
cartGoods
[
itemIndex
];
return
true
;
let
number
=
(
cartItem
.
number
-
1
>
1
)
?
cartItem
.
number
-
1
:
1
;
}
else
{
cartItem
.
number
=
number
;
return
false
;
this
.
setData
({
}
cartGoods
:
this
.
data
.
cartGoods
});
});
this
.
updateCart
(
cartItem
.
productId
,
cartItem
.
goodsId
,
number
,
cartItem
.
id
);
},
addNumber
:
function
(
event
)
{
let
itemIndex
=
event
.
target
.
dataset
.
itemIndex
;
let
cartItem
=
this
.
data
.
cartGoods
[
itemIndex
];
let
number
=
cartItem
.
number
+
1
;
cartItem
.
number
=
number
;
this
.
setData
({
cartGoods
:
this
.
data
.
cartGoods
});
this
.
updateCart
(
cartItem
.
productId
,
cartItem
.
goodsId
,
number
,
cartItem
.
id
);
if
(
checkedGoods
.
length
<=
0
)
{
},
return
false
;
checkoutOrder
:
function
()
{
}
//获取已选择的商品
let
that
=
this
;
// storage中设置了cartId,则是购物车购买
var
checkedGoods
=
this
.
data
.
cartGoods
.
filter
(
function
(
element
,
index
,
array
)
{
try
{
if
(
element
.
checked
==
true
)
{
wx
.
setStorageSync
(
'
cartId
'
,
0
);
return
true
;
wx
.
navigateTo
({
}
else
{
url
:
'
../shopping/checkout/checkout
'
return
false
;
})
}
}
catch
(
e
)
{
});
}
},
if
(
checkedGoods
.
length
<=
0
)
{
deleteCart
:
function
()
{
return
false
;
//获取已选择的商品
}
let
that
=
this
;
let
productIds
=
this
.
data
.
cartGoods
.
filter
(
function
(
element
,
index
,
array
)
{
// storage中设置了cartId,则是购物车购买
if
(
element
.
checked
==
true
)
{
try
{
return
true
;
wx
.
setStorageSync
(
'
cartId
'
,
0
)
;
}
else
{
wx
.
navigateTo
(
{
return
false
;
url
:
'
../shopping/checkout/checkout
'
}
}
)
});
}
catch
(
e
)
{}
if
(
productIds
.
length
<=
0
)
{
},
return
false
;
deleteCart
:
function
()
{
}
//获取已选择的商品
let
that
=
this
;
productIds
=
productIds
.
map
(
function
(
element
,
index
,
array
)
{
let
productIds
=
this
.
data
.
cartGoods
.
filter
(
function
(
element
,
index
,
array
)
{
if
(
element
.
checked
==
true
)
{
if
(
element
.
checked
==
true
)
{
return
element
.
productId
;
return
true
;
}
}
else
{
});
return
false
;
}
});
if
(
productIds
.
length
<=
0
)
{
return
false
;
}
util
.
request
(
api
.
CartDelete
,
{
productIds
=
productIds
.
map
(
function
(
element
,
index
,
array
)
{
productIds
:
productIds
if
(
element
.
checked
==
true
)
{
},
'
POST
'
).
then
(
function
(
res
)
{
return
element
.
productId
;
if
(
res
.
errno
===
0
)
{
}
console
.
log
(
res
.
data
);
});
let
cartList
=
res
.
data
.
cartList
.
map
(
v
=>
{
v
.
checked
=
false
;
return
v
;
});
that
.
setData
({
cartGoods
:
cartList
,
cartTotal
:
res
.
data
.
cartTotal
});
}
that
.
setData
({
util
.
request
(
api
.
CartDelete
,
{
checkedAllStatus
:
that
.
isCheckedAll
()
productIds
:
productIds
});
},
'
POST
'
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
console
.
log
(
res
.
data
);
let
cartList
=
res
.
data
.
cartList
.
map
(
v
=>
{
v
.
checked
=
false
;
return
v
;
});
});
}
that
.
setData
({
cartGoods
:
cartList
,
cartTotal
:
res
.
data
.
cartTotal
});
}
that
.
setData
({
checkedAllStatus
:
that
.
isCheckedAll
()
});
});
}
})
})
\ No newline at end of file
litemall-wx/pages/catalog/catalog.js
View file @
eb158458
...
@@ -2,77 +2,85 @@ var util = require('../../utils/util.js');
...
@@ -2,77 +2,85 @@ var util = require('../../utils/util.js');
var
api
=
require
(
'
../../config/api.js
'
);
var
api
=
require
(
'
../../config/api.js
'
);
Page
({
Page
({
data
:
{
data
:
{
categoryList
:
[],
categoryList
:
[],
currentCategory
:
{},
currentCategory
:
{},
currentSubCategoryList
:
{},
currentSubCategoryList
:
{},
scrollLeft
:
0
,
scrollLeft
:
0
,
scrollTop
:
0
,
scrollTop
:
0
,
goodsCount
:
0
,
goodsCount
:
0
,
scrollHeight
:
0
scrollHeight
:
0
},
},
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
this
.
getCatalog
();
this
.
getCatalog
();
},
},
getCatalog
:
function
()
{
onPullDownRefresh
()
{
//CatalogList
wx
.
showNavigationBarLoading
()
//在标题栏中显示加载
let
that
=
this
;
this
.
getCatalog
();
wx
.
showLoading
({
wx
.
hideNavigationBarLoading
()
//完成停止加载
title
:
'
加载中...
'
,
wx
.
stopPullDownRefresh
()
//停止下拉刷新
},
getCatalog
:
function
()
{
//CatalogList
let
that
=
this
;
wx
.
showLoading
({
title
:
'
加载中...
'
,
});
util
.
request
(
api
.
CatalogList
).
then
(
function
(
res
)
{
that
.
setData
({
categoryList
:
res
.
data
.
categoryList
,
currentCategory
:
res
.
data
.
currentCategory
,
currentSubCategoryList
:
res
.
data
.
currentSubCategory
});
wx
.
hideLoading
();
});
util
.
request
(
api
.
GoodsCount
).
then
(
function
(
res
)
{
that
.
setData
({
goodsCount
:
res
.
data
.
goodsCount
});
});
},
getCurrentCategory
:
function
(
id
)
{
let
that
=
this
;
util
.
request
(
api
.
CatalogCurrent
,
{
id
:
id
})
.
then
(
function
(
res
)
{
that
.
setData
({
currentCategory
:
res
.
data
.
currentCategory
,
currentSubCategoryList
:
res
.
data
.
currentSubCategory
});
});
util
.
request
(
api
.
CatalogList
).
then
(
function
(
res
)
{
});
that
.
setData
({
},
categoryList
:
res
.
data
.
categoryList
,
onReady
:
function
()
{
currentCategory
:
res
.
data
.
currentCategory
,
// 页面渲染完成
currentSubCategoryList
:
res
.
data
.
currentSubCategory
},
});
onShow
:
function
()
{
wx
.
hideLoading
();
// 页面显示
});
},
util
.
request
(
api
.
GoodsCount
).
then
(
function
(
res
)
{
onHide
:
function
()
{
that
.
setData
({
// 页面隐藏
goodsCount
:
res
.
data
.
goodsCount
},
});
onUnload
:
function
()
{
// 页面关闭
},
getList
:
function
()
{
var
that
=
this
;
util
.
request
(
api
.
ApiRootUrl
+
'
api/catalog/
'
+
that
.
data
.
currentCategory
.
catId
)
.
then
(
function
(
res
)
{
that
.
setData
({
categoryList
:
res
.
data
,
});
});
});
},
},
getCurrentCategory
:
function
(
id
)
{
switchCate
:
function
(
event
)
{
let
that
=
this
;
var
that
=
this
;
util
.
request
(
api
.
CatalogCurrent
,
{
id
:
id
})
var
currentTarget
=
event
.
currentTarget
;
.
then
(
function
(
res
)
{
if
(
this
.
data
.
currentCategory
.
id
==
event
.
currentTarget
.
dataset
.
id
)
{
that
.
setData
({
return
false
;
currentCategory
:
res
.
data
.
currentCategory
,
currentSubCategoryList
:
res
.
data
.
currentSubCategory
});
});
},
onReady
:
function
()
{
// 页面渲染完成
},
onShow
:
function
()
{
// 页面显示
},
onHide
:
function
()
{
// 页面隐藏
},
onUnload
:
function
()
{
// 页面关闭
},
getList
:
function
()
{
var
that
=
this
;
util
.
request
(
api
.
ApiRootUrl
+
'
api/catalog/
'
+
that
.
data
.
currentCategory
.
catId
)
.
then
(
function
(
res
)
{
that
.
setData
({
categoryList
:
res
.
data
,
});
});
},
switchCate
:
function
(
event
)
{
var
that
=
this
;
var
currentTarget
=
event
.
currentTarget
;
if
(
this
.
data
.
currentCategory
.
id
==
event
.
currentTarget
.
dataset
.
id
)
{
return
false
;
}
this
.
getCurrentCategory
(
event
.
currentTarget
.
dataset
.
id
);
}
}
this
.
getCurrentCategory
(
event
.
currentTarget
.
dataset
.
id
);
}
})
})
\ No newline at end of file
litemall-wx/pages/goods/goods.js
View file @
eb158458
...
@@ -5,471 +5,479 @@ var api = require('../../config/api.js');
...
@@ -5,471 +5,479 @@ var api = require('../../config/api.js');
var
user
=
require
(
'
../../utils/user.js
'
);
var
user
=
require
(
'
../../utils/user.js
'
);
Page
({
Page
({
data
:
{
data
:
{
id
:
0
,
id
:
0
,
goods
:
{},
goods
:
{},
attribute
:
[],
attribute
:
[],
issueList
:
[],
issueList
:
[],
comment
:
[],
comment
:
[],
brand
:
{},
brand
:
{},
specificationList
:
[],
specificationList
:
[],
productList
:
[],
productList
:
[],
relatedGoods
:
[],
relatedGoods
:
[],
cartGoodsCount
:
0
,
cartGoodsCount
:
0
,
userHasCollect
:
0
,
userHasCollect
:
0
,
number
:
1
,
number
:
1
,
checkedSpecText
:
'
规格数量选择
'
,
checkedSpecText
:
'
规格数量选择
'
,
tmpSpecText
:
'
请选择规格数量
'
,
tmpSpecText
:
'
请选择规格数量
'
,
checkedSpecPrice
:
0
,
checkedSpecPrice
:
0
,
openAttr
:
false
,
openAttr
:
false
,
noCollectImage
:
'
/static/images/icon_collect.png
'
,
noCollectImage
:
'
/static/images/icon_collect.png
'
,
hasCollectImage
:
'
/static/images/icon_collect_checked.png
'
,
hasCollectImage
:
'
/static/images/icon_collect_checked.png
'
,
collectImage
:
'
/static/images/icon_collect.png
'
,
collectImage
:
'
/static/images/icon_collect.png
'
,
soldout
:
false
soldout
:
false
},
},
getGoodsInfo
:
function
()
{
let
that
=
this
;
onPullDownRefresh
()
{
util
.
request
(
api
.
GoodsDetail
,
{
wx
.
showNavigationBarLoading
()
//在标题栏中显示加载
id
:
that
.
data
.
id
this
.
getGoodsInfo
();
}).
then
(
function
(
res
)
{
wx
.
hideNavigationBarLoading
()
//完成停止加载
if
(
res
.
errno
===
0
)
{
wx
.
stopPullDownRefresh
()
//停止下拉刷新
},
let
_specificationList
=
res
.
data
.
specificationList
// 如果仅仅存在一种货品,那么商品页面初始化时默认checked
getGoodsInfo
:
function
()
{
if
(
_specificationList
.
length
==
1
)
{
let
that
=
this
;
if
(
_specificationList
[
0
].
valueList
.
length
==
1
)
{
util
.
request
(
api
.
GoodsDetail
,
{
_specificationList
[
0
].
valueList
[
0
].
checked
=
true
id
:
that
.
data
.
id
}).
then
(
function
(
res
)
{
// 如果仅仅存在一种货品,那么商品价格应该和货品价格一致
if
(
res
.
errno
===
0
)
{
// 这里检测一下
let
_productPrice
=
res
.
data
.
productList
[
0
].
price
;
let
_specificationList
=
res
.
data
.
specificationList
let
_goodsPrice
=
res
.
data
.
info
.
retailPrice
;
// 如果仅仅存在一种货品,那么商品页面初始化时默认checked
if
(
_productPrice
!=
_goodsPrice
)
{
if
(
_specificationList
.
length
==
1
)
{
console
.
error
(
'
商品数量价格和货品不一致
'
);
if
(
_specificationList
[
0
].
valueList
.
length
==
1
)
{
}
_specificationList
[
0
].
valueList
[
0
].
checked
=
true
that
.
setData
({
// 如果仅仅存在一种货品,那么商品价格应该和货品价格一致
checkedSpecText
:
_specificationList
[
0
].
valueList
[
0
].
value
,
// 这里检测一下
tmpSpecText
:
'
已选择:
'
+
_specificationList
[
0
].
valueList
[
0
].
value
,
let
_productPrice
=
res
.
data
.
productList
[
0
].
price
;
});
let
_goodsPrice
=
res
.
data
.
info
.
retailPrice
;
}
if
(
_productPrice
!=
_goodsPrice
)
{
}
console
.
error
(
'
商品数量价格和货品不一致
'
);
that
.
setData
({
goods
:
res
.
data
.
info
,
attribute
:
res
.
data
.
attribute
,
issueList
:
res
.
data
.
issue
,
comment
:
res
.
data
.
comment
,
brand
:
res
.
data
.
brand
,
specificationList
:
res
.
data
.
specificationList
,
productList
:
res
.
data
.
productList
,
userHasCollect
:
res
.
data
.
userHasCollect
,
checkedSpecPrice
:
res
.
data
.
info
.
retailPrice
});
if
(
res
.
data
.
userHasCollect
==
1
)
{
that
.
setData
({
collectImage
:
that
.
data
.
hasCollectImage
});
}
else
{
that
.
setData
({
collectImage
:
that
.
data
.
noCollectImage
});
}
WxParse
.
wxParse
(
'
goodsDetail
'
,
'
html
'
,
res
.
data
.
info
.
desc
,
that
);
that
.
getGoodsRelated
();
}
}
});
},
that
.
setData
({
getGoodsRelated
:
function
()
{
checkedSpecText
:
_specificationList
[
0
].
valueList
[
0
].
value
,
let
that
=
this
;
tmpSpecText
:
'
已选择:
'
+
_specificationList
[
0
].
valueList
[
0
].
value
,
util
.
request
(
api
.
GoodsRelated
,
{
});
id
:
that
.
data
.
id
}
}).
then
(
function
(
res
)
{
}
if
(
res
.
errno
===
0
)
{
that
.
setData
({
that
.
setData
({
relatedGoods
:
res
.
data
.
goodsList
,
goods
:
res
.
data
.
info
,
});
attribute
:
res
.
data
.
attribute
,
}
issueList
:
res
.
data
.
issue
,
comment
:
res
.
data
.
comment
,
brand
:
res
.
data
.
brand
,
specificationList
:
res
.
data
.
specificationList
,
productList
:
res
.
data
.
productList
,
userHasCollect
:
res
.
data
.
userHasCollect
,
checkedSpecPrice
:
res
.
data
.
info
.
retailPrice
});
});
},
if
(
res
.
data
.
userHasCollect
==
1
)
{
clickSkuValue
:
function
(
event
)
{
that
.
setData
({
let
that
=
this
;
collectImage
:
that
.
data
.
hasCollectImage
let
specName
=
event
.
currentTarget
.
dataset
.
name
;
});
let
specValueId
=
event
.
currentTarget
.
dataset
.
valueId
;
}
else
{
that
.
setData
({
//判断是否可以点击
collectImage
:
that
.
data
.
noCollectImage
});
//TODO 性能优化,可在wx:for中添加index,可以直接获取点击的属性名和属性值,不用循环
let
_specificationList
=
this
.
data
.
specificationList
;
for
(
let
i
=
0
;
i
<
_specificationList
.
length
;
i
++
)
{
if
(
_specificationList
[
i
].
name
===
specName
)
{
for
(
let
j
=
0
;
j
<
_specificationList
[
i
].
valueList
.
length
;
j
++
)
{
if
(
_specificationList
[
i
].
valueList
[
j
].
id
==
specValueId
)
{
//如果已经选中,则反选
if
(
_specificationList
[
i
].
valueList
[
j
].
checked
)
{
_specificationList
[
i
].
valueList
[
j
].
checked
=
false
;
}
else
{
_specificationList
[
i
].
valueList
[
j
].
checked
=
true
;
}
}
else
{
_specificationList
[
i
].
valueList
[
j
].
checked
=
false
;
}
}
}
}
}
this
.
setData
({
specificationList
:
_specificationList
,
WxParse
.
wxParse
(
'
goodsDetail
'
,
'
html
'
,
res
.
data
.
info
.
desc
,
that
);
that
.
getGoodsRelated
();
}
});
},
getGoodsRelated
:
function
()
{
let
that
=
this
;
util
.
request
(
api
.
GoodsRelated
,
{
id
:
that
.
data
.
id
}).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
relatedGoods
:
res
.
data
.
goodsList
,
});
});
//重新计算spec改变后的信息
}
this
.
changeSpecInfo
();
});
//重新计算哪些值不可以点击
},
},
clickSkuValue
:
function
(
event
)
{
//获取选中的规格信息
let
that
=
this
;
getCheckedSpecValue
:
function
()
{
let
specName
=
event
.
currentTarget
.
dataset
.
name
;
let
checkedValues
=
[];
let
specValueId
=
event
.
currentTarget
.
dataset
.
valueId
;
let
_specificationList
=
this
.
data
.
specificationList
;
for
(
let
i
=
0
;
i
<
_specificationList
.
length
;
i
++
)
{
//判断是否可以点击
let
_checkedObj
=
{
name
:
_specificationList
[
i
].
name
,
//TODO 性能优化,可在wx:for中添加index,可以直接获取点击的属性名和属性值,不用循环
valueId
:
0
,
let
_specificationList
=
this
.
data
.
specificationList
;
valueText
:
''
for
(
let
i
=
0
;
i
<
_specificationList
.
length
;
i
++
)
{
};
if
(
_specificationList
[
i
].
name
===
specName
)
{
for
(
let
j
=
0
;
j
<
_specificationList
[
i
].
valueList
.
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
_specificationList
[
i
].
valueList
.
length
;
j
++
)
{
if
(
_specificationList
[
i
].
valueList
[
j
].
checked
)
{
if
(
_specificationList
[
i
].
valueList
[
j
].
id
==
specValueId
)
{
_checkedObj
.
valueId
=
_specificationList
[
i
].
valueList
[
j
].
id
;
//如果已经选中,则反选
_checkedObj
.
valueText
=
_specificationList
[
i
].
valueList
[
j
].
value
;
if
(
_specificationList
[
i
].
valueList
[
j
].
checked
)
{
}
_specificationList
[
i
].
valueList
[
j
].
checked
=
false
;
}
else
{
_specificationList
[
i
].
valueList
[
j
].
checked
=
true
;
}
}
checkedValues
.
push
(
_checkedObj
);
}
else
{
_specificationList
[
i
].
valueList
[
j
].
checked
=
false
;
}
}
}
}
}
this
.
setData
({
specificationList
:
_specificationList
,
});
//重新计算spec改变后的信息
this
.
changeSpecInfo
();
//重新计算哪些值不可以点击
},
//获取选中的规格信息
getCheckedSpecValue
:
function
()
{
let
checkedValues
=
[];
let
_specificationList
=
this
.
data
.
specificationList
;
for
(
let
i
=
0
;
i
<
_specificationList
.
length
;
i
++
)
{
let
_checkedObj
=
{
name
:
_specificationList
[
i
].
name
,
valueId
:
0
,
valueText
:
''
};
for
(
let
j
=
0
;
j
<
_specificationList
[
i
].
valueList
.
length
;
j
++
)
{
if
(
_specificationList
[
i
].
valueList
[
j
].
checked
)
{
_checkedObj
.
valueId
=
_specificationList
[
i
].
valueList
[
j
].
id
;
_checkedObj
.
valueText
=
_specificationList
[
i
].
valueList
[
j
].
value
;
}
}
checkedValues
.
push
(
_checkedObj
);
}
return
checkedValues
;
return
checkedValues
;
},
},
//根据已选的值,计算其它值的状态
//根据已选的值,计算其它值的状态
setSpecValueStatus
:
function
()
{
setSpecValueStatus
:
function
()
{
},
},
//判断规格是否选择完整
//判断规格是否选择完整
isCheckedAllSpec
:
function
()
{
isCheckedAllSpec
:
function
()
{
return
!
this
.
getCheckedSpecValue
().
some
(
function
(
v
)
{
return
!
this
.
getCheckedSpecValue
().
some
(
function
(
v
)
{
if
(
v
.
valueId
==
0
)
{
if
(
v
.
valueId
==
0
)
{
return
true
;
return
true
;
}
}
});
},
getCheckedSpecKey
:
function
()
{
let
checkedValue
=
this
.
getCheckedSpecValue
().
map
(
function
(
v
)
{
return
v
.
valueText
;
});
return
checkedValue
;
},
changeSpecInfo
:
function
()
{
let
checkedNameValue
=
this
.
getCheckedSpecValue
();
//设置选择的信息
let
checkedValue
=
checkedNameValue
.
filter
(
function
(
v
)
{
if
(
v
.
valueId
!=
0
)
{
return
true
;
}
else
{
return
false
;
}
}).
map
(
function
(
v
)
{
return
v
.
valueText
;
});
if
(
checkedValue
.
length
>
0
)
{
this
.
setData
({
tmpSpecText
:
checkedValue
.
join
(
'
'
)
});
}
else
{
this
.
setData
({
tmpSpecText
:
'
请选择规格数量
'
});
}
if
(
this
.
isCheckedAllSpec
())
{
this
.
setData
({
checkedSpecText
:
this
.
data
.
tmpSpecText
});
// 规格所对应的货品选择以后
let
checkedProductArray
=
this
.
getCheckedProductItem
(
this
.
getCheckedSpecKey
());
if
(
!
checkedProductArray
||
checkedProductArray
.
length
<=
0
)
{
this
.
setData
({
soldout
:
true
});
});
},
console
.
error
(
'
规格所对应货品不存在
'
);
getCheckedSpecKey
:
function
()
{
return
;
let
checkedValue
=
this
.
getCheckedSpecValue
().
map
(
function
(
v
)
{
}
return
v
.
valueText
;
let
checkedProduct
=
checkedProductArray
[
0
];
if
(
checkedProduct
.
number
>
0
)
{
this
.
setData
({
checkedSpecPrice
:
checkedProduct
.
price
,
soldout
:
false
});
}
else
{
this
.
setData
({
checkedSpecPrice
:
this
.
data
.
goods
.
retailPrice
,
soldout
:
true
});
});
}
return
checkedValue
;
}
else
{
},
this
.
setData
({
changeSpecInfo
:
function
()
{
checkedSpecText
:
'
规格数量选择
'
,
let
checkedNameValue
=
this
.
getCheckedSpecValue
();
checkedSpecPrice
:
this
.
data
.
goods
.
retailPrice
,
soldout
:
false
});
}
//设置选择的信息
},
let
checkedValue
=
checkedNameValue
.
filter
(
function
(
v
)
{
getCheckedProductItem
:
function
(
key
)
{
if
(
v
.
valueId
!=
0
)
{
return
this
.
data
.
productList
.
filter
(
function
(
v
)
{
return
true
;
if
(
v
.
specifications
.
toString
()
==
key
.
toString
())
{
}
else
{
return
true
;
return
false
;
}
else
{
}
return
false
;
}).
map
(
function
(
v
)
{
}
return
v
.
valueText
;
});
},
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
this
.
setData
({
id
:
parseInt
(
options
.
id
)
});
this
.
getGoodsInfo
();
},
onReady
:
function
()
{
// 页面渲染完成
},
onShow
:
function
()
{
// 页面显示
var
that
=
this
;
util
.
request
(
api
.
CartGoodsCount
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
cartGoodsCount
:
res
.
data
});
});
if
(
checkedValue
.
length
>
0
)
{
}
this
.
setData
({
});
tmpSpecText
:
checkedValue
.
join
(
'
'
)
},
onHide
:
function
()
{
// 页面隐藏
},
onUnload
:
function
()
{
// 页面关闭
},
switchAttrPop
:
function
()
{
if
(
this
.
data
.
openAttr
==
false
)
{
this
.
setData
({
openAttr
:
!
this
.
data
.
openAttr
});
}
},
closeAttr
:
function
()
{
this
.
setData
({
openAttr
:
false
,
});
},
addCollectOrNot
:
function
()
{
let
that
=
this
;
//添加或是取消收藏
util
.
request
(
api
.
CollectAddOrDelete
,
{
type
:
0
,
valueId
:
this
.
data
.
id
},
"
POST
"
)
.
then
(
function
(
res
)
{
let
_res
=
res
;
if
(
_res
.
errno
==
0
)
{
if
(
_res
.
data
.
type
==
'
add
'
)
{
that
.
setData
({
collectImage
:
that
.
data
.
hasCollectImage
});
});
}
else
{
}
else
{
th
is
.
setData
({
th
at
.
setData
({
tmpSpecText
:
'
请选择规格数量
'
collectImage
:
that
.
data
.
noCollectImage
});
});
}
}
if
(
this
.
isCheckedAllSpec
())
{
this
.
setData
({
checkedSpecText
:
this
.
data
.
tmpSpecText
});
// 规格所对应的货品选择以后
let
checkedProductArray
=
this
.
getCheckedProductItem
(
this
.
getCheckedSpecKey
());
if
(
!
checkedProductArray
||
checkedProductArray
.
length
<=
0
)
{
this
.
setData
({
soldout
:
true
});
console
.
error
(
'
规格所对应货品不存在
'
);
return
;
}
let
checkedProduct
=
checkedProductArray
[
0
];
if
(
checkedProduct
.
number
>
0
)
{
this
.
setData
({
checkedSpecPrice
:
checkedProduct
.
price
,
soldout
:
false
});
}
else
{
this
.
setData
({
checkedSpecPrice
:
this
.
data
.
goods
.
retailPrice
,
soldout
:
true
});
}
}
else
{
}
else
{
this
.
setData
({
wx
.
showToast
({
checkedSpecText
:
'
规格数量选择
'
,
image
:
'
/static/images/icon_error.png
'
,
checkedSpecPrice
:
this
.
data
.
goods
.
retailPrice
,
title
:
_res
.
errmsg
,
soldout
:
fals
e
mask
:
tru
e
});
});
}
}
},
});
getCheckedProductItem
:
function
(
key
)
{
return
this
.
data
.
productList
.
filter
(
function
(
v
)
{
},
if
(
v
.
specifications
.
toString
()
==
key
.
toString
())
{
openCartPage
:
function
()
{
return
true
;
wx
.
switchTab
({
}
else
{
url
:
'
/pages/cart/cart
'
return
false
;
});
}
},
addFast
:
function
()
{
var
that
=
this
;
if
(
this
.
data
.
openAttr
==
false
)
{
//打开规格选择窗口
this
.
setData
({
openAttr
:
!
this
.
data
.
openAttr
});
}
else
{
//提示选择完整规格
if
(
!
this
.
isCheckedAllSpec
())
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
请选择完整规格
'
});
});
},
return
false
;
onLoad
:
function
(
options
)
{
}
// 页面初始化 options为页面跳转所带来的参数
this
.
setData
({
//根据选中的规格,判断是否有对应的sku信息
id
:
parseInt
(
options
.
id
)
let
checkedProductArray
=
this
.
getCheckedProductItem
(
this
.
getCheckedSpecKey
());
if
(
!
checkedProductArray
||
checkedProductArray
.
length
<=
0
)
{
//找不到对应的product信息,提示没有库存
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
没有库存
'
});
});
this
.
getGoodsInfo
();
return
false
;
},
}
onReady
:
function
()
{
// 页面渲染完成
let
checkedProduct
=
checkedProductArray
[
0
];
//验证库存
},
if
(
checkedProduct
.
number
<=
0
)
{
onShow
:
function
()
{
wx
.
showToast
({
// 页面显示
image
:
'
/static/images/icon_error.png
'
,
var
that
=
this
;
title
:
'
没有库存
'
util
.
request
(
api
.
CartGoodsCount
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
cartGoodsCount
:
res
.
data
});
}
});
});
},
return
false
;
onHide
:
function
()
{
}
// 页面隐藏
//立即购买
},
util
.
request
(
api
.
CartFastAdd
,
{
onUnload
:
function
()
{
goodsId
:
this
.
data
.
goods
.
id
,
// 页面关闭
number
:
this
.
data
.
number
,
productId
:
checkedProduct
.
id
},
},
"
POST
"
)
switchAttrPop
:
function
()
{
.
then
(
function
(
res
)
{
if
(
this
.
data
.
openAttr
==
false
)
{
if
(
res
.
errno
==
0
)
{
this
.
setData
({
openAttr
:
!
this
.
data
.
openAttr
// 如果storage中设置了cartId,则是立即购买,否则是购物车购买
try
{
wx
.
setStorageSync
(
'
cartId
'
,
res
.
data
);
wx
.
navigateTo
({
url
:
'
/pages/checkout/checkout
'
})
}
catch
(
e
)
{}
}
else
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
res
.
errmsg
,
mask
:
true
});
});
}
}
},
closeAttr
:
function
()
{
this
.
setData
({
openAttr
:
false
,
});
});
},
}
addCollectOrNot
:
function
()
{
let
that
=
this
;
//添加或是取消收藏
util
.
request
(
api
.
CollectAddOrDelete
,
{
type
:
0
,
valueId
:
this
.
data
.
id
},
"
POST
"
)
.
then
(
function
(
res
)
{
let
_res
=
res
;
if
(
_res
.
errno
==
0
)
{
if
(
_res
.
data
.
type
==
'
add
'
)
{
that
.
setData
({
collectImage
:
that
.
data
.
hasCollectImage
});
}
else
{
that
.
setData
({
collectImage
:
that
.
data
.
noCollectImage
});
}
}
else
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
_res
.
errmsg
,
mask
:
true
});
}
});
},
},
openCartPage
:
function
()
{
addToCart
:
function
()
{
wx
.
switchTab
({
var
that
=
this
;
url
:
'
/pages/cart/cart
'
if
(
this
.
data
.
openAttr
==
false
)
{
//打开规格选择窗口
this
.
setData
({
openAttr
:
!
this
.
data
.
openAttr
});
}
else
{
//提示选择完整规格
if
(
!
this
.
isCheckedAllSpec
())
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
请选择完整规格
'
});
return
false
;
}
//根据选中的规格,判断是否有对应的sku信息
let
checkedProductArray
=
this
.
getCheckedProductItem
(
this
.
getCheckedSpecKey
());
if
(
!
checkedProductArray
||
checkedProductArray
.
length
<=
0
)
{
//找不到对应的product信息,提示没有库存
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
没有库存
'
});
return
false
;
}
let
checkedProduct
=
checkedProductArray
[
0
];
//验证库存
if
(
checkedProduct
.
number
<=
0
)
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
没有库存
'
});
});
},
return
false
;
addFast
:
function
()
{
}
var
that
=
this
;
if
(
this
.
data
.
openAttr
==
false
)
{
//添加到购物车
//打开规格选择窗口
util
.
request
(
api
.
CartAdd
,
{
this
.
setData
({
goodsId
:
this
.
data
.
goods
.
id
,
openAttr
:
!
this
.
data
.
openAttr
number
:
this
.
data
.
number
,
productId
:
checkedProduct
.
id
},
"
POST
"
)
.
then
(
function
(
res
)
{
let
_res
=
res
;
if
(
_res
.
errno
==
0
)
{
wx
.
showToast
({
title
:
'
添加成功
'
});
});
}
else
{
that
.
setData
({
openAttr
:
!
that
.
data
.
openAttr
,
//提示选择完整规格
cartGoodsCount
:
_res
.
data
if
(
!
this
.
isCheckedAllSpec
())
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
请选择完整规格
'
});
return
false
;
}
//根据选中的规格,判断是否有对应的sku信息
let
checkedProductArray
=
this
.
getCheckedProductItem
(
this
.
getCheckedSpecKey
());
if
(
!
checkedProductArray
||
checkedProductArray
.
length
<=
0
)
{
//找不到对应的product信息,提示没有库存
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
没有库存
'
});
return
false
;
}
let
checkedProduct
=
checkedProductArray
[
0
];
//验证库存
if
(
checkedProduct
.
number
<=
0
)
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
没有库存
'
});
return
false
;
}
//立即购买
util
.
request
(
api
.
CartFastAdd
,
{
goodsId
:
this
.
data
.
goods
.
id
,
number
:
this
.
data
.
number
,
productId
:
checkedProduct
.
id
},
"
POST
"
)
.
then
(
function
(
res
)
{
if
(
res
.
errno
==
0
)
{
// 如果storage中设置了cartId,则是立即购买,否则是购物车购买
try
{
wx
.
setStorageSync
(
'
cartId
'
,
res
.
data
);
wx
.
navigateTo
({
url
:
'
/pages/checkout/checkout
'
})
}
catch
(
e
)
{}
}
else
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
res
.
errmsg
,
mask
:
true
});
}
});
}
},
addToCart
:
function
()
{
var
that
=
this
;
if
(
this
.
data
.
openAttr
==
false
)
{
//打开规格选择窗口
this
.
setData
({
openAttr
:
!
this
.
data
.
openAttr
});
});
}
else
{
if
(
that
.
data
.
userHasCollect
==
1
)
{
that
.
setData
({
//提示选择完整规格
collectImage
:
that
.
data
.
hasCollectImage
if
(
!
this
.
isCheckedAllSpec
())
{
});
wx
.
showToast
({
}
else
{
image
:
'
/static/images/icon_error.png
'
,
that
.
setData
({
title
:
'
请选择完整规格
'
collectImage
:
that
.
data
.
noCollectImage
});
});
return
false
;
}
//根据选中的规格,判断是否有对应的sku信息
let
checkedProductArray
=
this
.
getCheckedProductItem
(
this
.
getCheckedSpecKey
());
if
(
!
checkedProductArray
||
checkedProductArray
.
length
<=
0
)
{
//找不到对应的product信息,提示没有库存
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
没有库存
'
});
return
false
;
}
let
checkedProduct
=
checkedProductArray
[
0
];
//验证库存
if
(
checkedProduct
.
number
<=
0
)
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
'
没有库存
'
});
return
false
;
}
}
}
else
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
_res
.
errmsg
,
mask
:
true
});
}
//添加到购物车
util
.
request
(
api
.
CartAdd
,
{
goodsId
:
this
.
data
.
goods
.
id
,
number
:
this
.
data
.
number
,
productId
:
checkedProduct
.
id
},
"
POST
"
)
.
then
(
function
(
res
)
{
let
_res
=
res
;
if
(
_res
.
errno
==
0
)
{
wx
.
showToast
({
title
:
'
添加成功
'
});
that
.
setData
({
openAttr
:
!
that
.
data
.
openAttr
,
cartGoodsCount
:
_res
.
data
});
if
(
that
.
data
.
userHasCollect
==
1
)
{
that
.
setData
({
collectImage
:
that
.
data
.
hasCollectImage
});
}
else
{
that
.
setData
({
collectImage
:
that
.
data
.
noCollectImage
});
}
}
else
{
wx
.
showToast
({
image
:
'
/static/images/icon_error.png
'
,
title
:
_res
.
errmsg
,
mask
:
true
});
}
});
}
},
cutNumber
:
function
()
{
this
.
setData
({
number
:
(
this
.
data
.
number
-
1
>
1
)
?
this
.
data
.
number
-
1
:
1
});
},
addNumber
:
function
()
{
this
.
setData
({
number
:
this
.
data
.
number
+
1
});
});
}
}
},
cutNumber
:
function
()
{
this
.
setData
({
number
:
(
this
.
data
.
number
-
1
>
1
)
?
this
.
data
.
number
-
1
:
1
});
},
addNumber
:
function
()
{
this
.
setData
({
number
:
this
.
data
.
number
+
1
});
}
})
})
\ No newline at end of file
litemall-wx/pages/index/index.js
View file @
eb158458
...
@@ -14,7 +14,7 @@ Page({
...
@@ -14,7 +14,7 @@ Page({
banner
:
[],
banner
:
[],
channel
:
[]
channel
:
[]
},
},
onShareAppMessage
:
function
()
{
onShareAppMessage
:
function
()
{
return
{
return
{
title
:
'
litemall小程序商场
'
,
title
:
'
litemall小程序商场
'
,
desc
:
'
开源微信小程序商城
'
,
desc
:
'
开源微信小程序商城
'
,
...
@@ -22,9 +22,16 @@ Page({
...
@@ -22,9 +22,16 @@ Page({
}
}
},
},
getIndexData
:
function
()
{
onPullDownRefresh
()
{
wx
.
showNavigationBarLoading
()
//在标题栏中显示加载
this
.
getIndexData
();
wx
.
hideNavigationBarLoading
()
//完成停止加载
wx
.
stopPullDownRefresh
()
//停止下拉刷新
},
getIndexData
:
function
()
{
let
that
=
this
;
let
that
=
this
;
util
.
request
(
api
.
IndexUrl
).
then
(
function
(
res
)
{
util
.
request
(
api
.
IndexUrl
).
then
(
function
(
res
)
{
if
(
res
.
errno
===
0
)
{
if
(
res
.
errno
===
0
)
{
that
.
setData
({
that
.
setData
({
newGoods
:
res
.
data
.
newGoodsList
,
newGoods
:
res
.
data
.
newGoodsList
,
...
@@ -38,19 +45,19 @@ Page({
...
@@ -38,19 +45,19 @@ Page({
}
}
});
});
},
},
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
this
.
getIndexData
();
this
.
getIndexData
();
},
},
onReady
:
function
()
{
onReady
:
function
()
{
// 页面渲染完成
// 页面渲染完成
},
},
onShow
:
function
()
{
onShow
:
function
()
{
// 页面显示
// 页面显示
},
},
onHide
:
function
()
{
onHide
:
function
()
{
// 页面隐藏
// 页面隐藏
},
},
onUnload
:
function
()
{
onUnload
:
function
()
{
// 页面关闭
// 页面关闭
},
},
})
})
\ No newline at end of file
litemall-wx/pages/ucenter/index/index.json
View file @
eb158458
{
{
"backgroundColor"
:
"#f4f4f4"
,
"backgroundColor"
:
"#f4f4f4"
,
"navigationBarTitleText"
:
"个人中心"
"navigationBarTitleText"
:
"个人中心"
,
"enablePullDownRefresh"
:
false
}
}
\ No newline at end of file
litemall-wx/pages/ucenter/order/order.js
View file @
eb158458
...
@@ -2,42 +2,52 @@ var util = require('../../../utils/util.js');
...
@@ -2,42 +2,52 @@ var util = require('../../../utils/util.js');
var
api
=
require
(
'
../../../config/api.js
'
);
var
api
=
require
(
'
../../../config/api.js
'
);
Page
({
Page
({
data
:{
data
:
{
orderList
:
[],
orderList
:
[],
showType
:
0
showType
:
0
},
},
onLoad
:
function
(
options
){
onLoad
:
function
(
options
)
{
// 页面初始化 options为页面跳转所带来的参数
// 页面初始化 options为页面跳转所带来的参数
},
},
getOrderList
(){
let
that
=
this
;
onPullDownRefresh
()
{
util
.
request
(
api
.
OrderList
,
{
showType
:
that
.
data
.
showType
}).
then
(
function
(
res
)
{
wx
.
showNavigationBarLoading
()
//在标题栏中显示加载
if
(
res
.
errno
===
0
)
{
this
.
getOrderList
();
console
.
log
(
res
.
data
);
wx
.
hideNavigationBarLoading
()
//完成停止加载
that
.
setData
({
wx
.
stopPullDownRefresh
()
//停止下拉刷新
orderList
:
res
.
data
.
data
},
});
}
getOrderList
()
{
});
let
that
=
this
;
},
util
.
request
(
api
.
OrderList
,
{
switchTab
:
function
(
event
)
{
showType
:
that
.
data
.
showType
let
showType
=
event
.
currentTarget
.
dataset
.
index
;
}).
then
(
function
(
res
)
{
this
.
setData
({
if
(
res
.
errno
===
0
)
{
showType
:
showType
console
.
log
(
res
.
data
);
that
.
setData
({
orderList
:
res
.
data
.
data
});
});
this
.
getOrderList
();
}
},
});
onReady
:
function
(){
},
// 页面渲染完成
switchTab
:
function
(
event
)
{
},
let
showType
=
event
.
currentTarget
.
dataset
.
index
;
onShow
:
function
(){
this
.
setData
({
// 页面显示
showType
:
showType
this
.
getOrderList
();
});
},
this
.
getOrderList
();
onHide
:
function
(){
},
// 页面隐藏
onReady
:
function
()
{
},
// 页面渲染完成
onUnload
:
function
(){
},
// 页面关闭
onShow
:
function
()
{
}
// 页面显示
this
.
getOrderList
();
},
onHide
:
function
()
{
// 页面隐藏
},
onUnload
:
function
()
{
// 页面关闭
}
})
})
\ No newline at end of file
litemall-wx/project.config.json
View file @
eb158458
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
"list"
:
[]
"list"
:
[]
},
},
"miniprogram"
:
{
"miniprogram"
:
{
"current"
:
3
3
,
"current"
:
3
2
,
"list"
:
[
"list"
:
[
{
{
"id"
:
-1
,
"id"
:
-1
,
...
@@ -219,7 +219,13 @@
...
@@ -219,7 +219,13 @@
{
{
"id"
:
-1
,
"id"
:
-1
,
"name"
:
"关于"
,
"name"
:
"关于"
,
"pathName"
:
"pages/about/about"
"pathName"
:
"pages/about/about"
,
"query"
:
""
},
{
"id"
:
-1
,
"name"
:
"测试更新"
,
"pathName"
:
"pages/index/index"
}
}
]
]
}
}
...
...
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