Commit 20b97ec8 authored by Junling Bu's avatar Junling Bu
Browse files

chore[litemall-wx]: 使用微信开发者工具的格式化代码

parent 822d5075
...@@ -3,13 +3,13 @@ var api = require('./config/api.js'); ...@@ -3,13 +3,13 @@ var api = require('./config/api.js');
var user = require('./utils/user.js'); var user = require('./utils/user.js');
App({ App({
onLaunch: function () { onLaunch: function() {
const updateManager = wx.getUpdateManager(); const updateManager = wx.getUpdateManager();
wx.getUpdateManager().onUpdateReady(function () { wx.getUpdateManager().onUpdateReady(function() {
wx.showModal({ wx.showModal({
title: '更新提示', title: '更新提示',
content: '新版本已经准备好,是否重启应用?', content: '新版本已经准备好,是否重启应用?',
success: function (res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate() updateManager.applyUpdate()
...@@ -18,7 +18,7 @@ App({ ...@@ -18,7 +18,7 @@ App({
}) })
}) })
}, },
onShow: function (options) { onShow: function(options) {
user.checkLogin().then(res => { user.checkLogin().then(res => {
this.globalData.hasLogin = true; this.globalData.hasLogin = true;
}).catch(() => { }).catch(() => {
......
{ {
"pages": [ "pages": [
"pages/index/index", "pages/index/index",
"pages/catalog/catalog", "pages/catalog/catalog",
"pages/newGoods/newGoods", "pages/newGoods/newGoods",
"pages/hotGoods/hotGoods", "pages/hotGoods/hotGoods",
"pages/ucenter/index/index", "pages/ucenter/index/index",
"pages/ucenter/address/address", "pages/ucenter/address/address",
"pages/ucenter/addressAdd/addressAdd", "pages/ucenter/addressAdd/addressAdd",
"pages/ucenter/feedback/feedback", "pages/ucenter/feedback/feedback",
"pages/ucenter/footprint/footprint", "pages/ucenter/footprint/footprint",
"pages/ucenter/order/order", "pages/ucenter/order/order",
"pages/ucenter/orderDetail/orderDetail", "pages/ucenter/orderDetail/orderDetail",
"pages/ucenter/coupon/coupon", "pages/ucenter/coupon/coupon",
"pages/ucenter/collect/collect", "pages/ucenter/collect/collect",
"pages/auth/login/login", "pages/auth/login/login",
"pages/auth/accountLogin/accountLogin", "pages/auth/accountLogin/accountLogin",
"pages/auth/register/register", "pages/auth/register/register",
"pages/auth/reset/reset", "pages/auth/reset/reset",
"pages/payResult/payResult", "pages/payResult/payResult",
"pages/comment/comment", "pages/comment/comment",
"pages/commentPost/commentPost", "pages/commentPost/commentPost",
"pages/topic/topic", "pages/topic/topic",
"pages/topicComment/topicComment", "pages/topicComment/topicComment",
"pages/topicDetail/topicDetail", "pages/topicDetail/topicDetail",
"pages/topicCommentPost/topicCommentPost", "pages/topicCommentPost/topicCommentPost",
"pages/brand/brand", "pages/brand/brand",
"pages/brandDetail/brandDetail", "pages/brandDetail/brandDetail",
"pages/search/search", "pages/search/search",
"pages/category/category", "pages/category/category",
"pages/cart/cart", "pages/cart/cart",
"pages/checkout/checkout", "pages/checkout/checkout",
"pages/goods/goods", "pages/goods/goods",
"pages/about/about", "pages/about/about",
"pages/groupon/myGroupon/myGroupon", "pages/groupon/myGroupon/myGroupon",
"pages/groupon/grouponDetail/grouponDetail", "pages/groupon/grouponDetail/grouponDetail",
"pages/groupon/grouponList/grouponList" "pages/groupon/grouponList/grouponList"
], ],
"window": { "window": {
"navigationBarBackgroundColor": "#FFFFFF", "navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTitleText": "litemall小程序商城", "navigationBarTitleText": "litemall小程序商城",
"enablePullDownRefresh": true, "enablePullDownRefresh": true,
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"backgroundColor": "#FFFFFF", "backgroundColor": "#FFFFFF",
"backgroundTextStyle": "dark" "backgroundTextStyle": "dark"
}, },
"tabBar": { "tabBar": {
"backgroundColor": "#fafafa", "backgroundColor": "#fafafa",
"borderStyle": "white", "borderStyle": "white",
"selectedColor": "#AB956D", "selectedColor": "#AB956D",
"color": "#666", "color": "#666",
"list": [ "list": [
{ {
"pagePath": "pages/index/index", "pagePath": "pages/index/index",
"iconPath": "static/images/home.png", "iconPath": "static/images/home.png",
"selectedIconPath": "static/images/home@selected.png", "selectedIconPath": "static/images/home@selected.png",
"text": "首页" "text": "首页"
}, },
{ {
"pagePath": "pages/catalog/catalog", "pagePath": "pages/catalog/catalog",
"iconPath": "static/images/category.png", "iconPath": "static/images/category.png",
"selectedIconPath": "static/images/category@selected.png", "selectedIconPath": "static/images/category@selected.png",
"text": "分类" "text": "分类"
}, },
{ {
"pagePath": "pages/cart/cart", "pagePath": "pages/cart/cart",
"iconPath": "static/images/cart.png", "iconPath": "static/images/cart.png",
"selectedIconPath": "static/images/cart@selected.png", "selectedIconPath": "static/images/cart@selected.png",
"text": "购物车" "text": "购物车"
}, },
{ {
"pagePath": "pages/ucenter/index/index", "pagePath": "pages/ucenter/index/index",
"iconPath": "static/images/my.png", "iconPath": "static/images/my.png",
"selectedIconPath": "static/images/my@selected.png", "selectedIconPath": "static/images/my@selected.png",
"text": "个人" "text": "个人"
} }
] ]
}, },
"networkTimeout": { "networkTimeout": {
"request": 10000, "request": 10000,
"connectSocket": 10000, "connectSocket": 10000,
"uploadFile": 10000, "uploadFile": 10000,
"downloadFile": 10000 "downloadFile": 10000
}, },
"debug": true "debug": true
} }
\ No newline at end of file
/**app.wxss**/ /**app.wxss**/
.container { .container {
box-sizing: border-box; box-sizing: border-box;
background-color: #f4f4f4; background-color: #f4f4f4;
font-family: PingFangSC-Light,helvetica,'Heiti SC'; font-family: PingFangSC-Light, helvetica, 'Heiti SC';
} }
view,image,text,navigator{ view, image, text, navigator {
box-sizing: border-box; box-sizing: border-box;
padding:0; padding: 0;
margin:0; margin: 0;
} }
view,text{ view, text {
font-family: PingFangSC-Light,helvetica,'Heiti SC'; font-family: PingFangSC-Light, helvetica, 'Heiti SC';
font-size: 29rpx; font-size: 29rpx;
color: #333; color: #333;
} }
\ No newline at end of file
// 以下是业务服务器API地址 // 以下是业务服务器API地址
// 本机开发时使用 // 本机开发时使用
var WxApiRoot = 'http://localhost:8080/wx/'; var WxApiRoot = 'http://localhost:8080/wx/';
// 局域网测试使用 // 局域网测试使用
// var WxApiRoot = 'http://192.168.0.101:8080/wx/'; // var WxApiRoot = 'http://192.168.0.101:8080/wx/';
// 云平台部署时使用 // 云平台部署时使用
...@@ -9,87 +9,87 @@ ...@@ -9,87 +9,87 @@
// var WxApiRoot = 'https://www.menethil.com.cn/wx/'; // var WxApiRoot = 'https://www.menethil.com.cn/wx/';
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', //账号登录
AuthLogout: WxApiRoot + 'auth/logout', //账号登出 AuthLogout: WxApiRoot + 'auth/logout', //账号登出
AuthRegister: WxApiRoot + 'auth/register', //账号注册 AuthRegister: WxApiRoot + 'auth/register', //账号注册
AuthReset: WxApiRoot + 'auth/reset', //账号密码重置 AuthReset: WxApiRoot + 'auth/reset', //账号密码重置
AuthRegisterCaptcha: WxApiRoot + 'auth/regCaptcha', //验证码 AuthRegisterCaptcha: WxApiRoot + 'auth/regCaptcha', //验证码
AuthBindPhone: WxApiRoot + 'auth/bindPhone', //绑定微信手机号 AuthBindPhone: WxApiRoot + 'auth/bindPhone', //绑定微信手机号
GoodsCount: WxApiRoot + 'goods/count', //统计商品总数 GoodsCount: WxApiRoot + 'goods/count', //统计商品总数
GoodsList: WxApiRoot + 'goods/list', //获得商品列表 GoodsList: WxApiRoot + 'goods/list', //获得商品列表
GoodsCategory: WxApiRoot + 'goods/category', //获得分类数据 GoodsCategory: WxApiRoot + 'goods/category', //获得分类数据
GoodsDetail: WxApiRoot + 'goods/detail', //获得商品的详情 GoodsDetail: WxApiRoot + 'goods/detail', //获得商品的详情
GoodsNew: WxApiRoot + 'goods/new', //新品 GoodsNew: WxApiRoot + 'goods/new', //新品
GoodsHot: WxApiRoot + 'goods/hot', //热门 GoodsHot: WxApiRoot + 'goods/hot', //热门
GoodsRelated: WxApiRoot + 'goods/related', //商品详情页的关联商品(大家都在看) GoodsRelated: WxApiRoot + 'goods/related', //商品详情页的关联商品(大家都在看)
BrandList: WxApiRoot + 'brand/list', //品牌列表 BrandList: WxApiRoot + 'brand/list', //品牌列表
BrandDetail: WxApiRoot + 'brand/detail', //品牌详情 BrandDetail: WxApiRoot + 'brand/detail', //品牌详情
CartList: WxApiRoot + 'cart/index', //获取购物车的数据 CartList: WxApiRoot + 'cart/index', //获取购物车的数据
CartAdd: WxApiRoot + 'cart/add', // 添加商品到购物车 CartAdd: WxApiRoot + 'cart/add', // 添加商品到购物车
CartFastAdd: WxApiRoot + 'cart/fastadd', // 立即购买商品 CartFastAdd: WxApiRoot + 'cart/fastadd', // 立即购买商品
CartUpdate: WxApiRoot + 'cart/update', // 更新购物车的商品 CartUpdate: WxApiRoot + 'cart/update', // 更新购物车的商品
CartDelete: WxApiRoot + 'cart/delete', // 删除购物车的商品 CartDelete: WxApiRoot + 'cart/delete', // 删除购物车的商品
CartChecked: WxApiRoot + 'cart/checked', // 选择或取消选择商品 CartChecked: WxApiRoot + 'cart/checked', // 选择或取消选择商品
CartGoodsCount: WxApiRoot + 'cart/goodscount', // 获取购物车商品件数 CartGoodsCount: WxApiRoot + 'cart/goodscount', // 获取购物车商品件数
CartCheckout: WxApiRoot + 'cart/checkout', // 下单前信息确认 CartCheckout: WxApiRoot + 'cart/checkout', // 下单前信息确认
CollectList: WxApiRoot + 'collect/list', //收藏列表 CollectList: WxApiRoot + 'collect/list', //收藏列表
CollectAddOrDelete: WxApiRoot + 'collect/addordelete', //添加或取消收藏 CollectAddOrDelete: WxApiRoot + 'collect/addordelete', //添加或取消收藏
CommentList: WxApiRoot + 'comment/list', //评论列表 CommentList: WxApiRoot + 'comment/list', //评论列表
CommentCount: WxApiRoot + 'comment/count', //评论总数 CommentCount: WxApiRoot + 'comment/count', //评论总数
CommentPost: WxApiRoot + 'comment/post', //发表评论 CommentPost: WxApiRoot + 'comment/post', //发表评论
TopicList: WxApiRoot + 'topic/list', //专题列表 TopicList: WxApiRoot + 'topic/list', //专题列表
TopicDetail: WxApiRoot + 'topic/detail', //专题详情 TopicDetail: WxApiRoot + 'topic/detail', //专题详情
TopicRelated: WxApiRoot + 'topic/related', //相关专题 TopicRelated: WxApiRoot + 'topic/related', //相关专题
SearchIndex: WxApiRoot + 'search/index', //搜索关键字 SearchIndex: WxApiRoot + 'search/index', //搜索关键字
SearchResult: WxApiRoot + 'search/result', //搜索结果 SearchResult: WxApiRoot + 'search/result', //搜索结果
SearchHelper: WxApiRoot + 'search/helper', //搜索帮助 SearchHelper: WxApiRoot + 'search/helper', //搜索帮助
SearchClearHistory: WxApiRoot + 'search/clearhistory', //搜索历史清楚 SearchClearHistory: WxApiRoot + 'search/clearhistory', //搜索历史清楚
AddressList: WxApiRoot + 'address/list', //收货地址列表 AddressList: WxApiRoot + 'address/list', //收货地址列表
AddressDetail: WxApiRoot + 'address/detail', //收货地址详情 AddressDetail: WxApiRoot + 'address/detail', //收货地址详情
AddressSave: WxApiRoot + 'address/save', //保存收货地址 AddressSave: WxApiRoot + 'address/save', //保存收货地址
AddressDelete: WxApiRoot + 'address/delete', //保存收货地址 AddressDelete: WxApiRoot + 'address/delete', //保存收货地址
ExpressQuery: WxApiRoot + 'express/query', //物流查询 ExpressQuery: WxApiRoot + 'express/query', //物流查询
RegionList: WxApiRoot + 'region/list', //获取区域列表 RegionList: WxApiRoot + 'region/list', //获取区域列表
OrderSubmit: WxApiRoot + 'order/submit', // 提交订单 OrderSubmit: WxApiRoot + 'order/submit', // 提交订单
OrderPrepay: WxApiRoot + 'order/prepay', // 订单的预支付会话 OrderPrepay: WxApiRoot + 'order/prepay', // 订单的预支付会话
OrderList: WxApiRoot + 'order/list', //订单列表 OrderList: WxApiRoot + 'order/list', //订单列表
OrderDetail: WxApiRoot + 'order/detail', //订单详情 OrderDetail: WxApiRoot + 'order/detail', //订单详情
OrderCancel: WxApiRoot + 'order/cancel', //取消订单 OrderCancel: WxApiRoot + 'order/cancel', //取消订单
OrderRefund: WxApiRoot + 'order/refund', //退款取消订单 OrderRefund: WxApiRoot + 'order/refund', //退款取消订单
OrderDelete: WxApiRoot + 'order/delete', //删除订单 OrderDelete: WxApiRoot + 'order/delete', //删除订单
OrderConfirm: WxApiRoot + 'order/confirm', //确认收货 OrderConfirm: WxApiRoot + 'order/confirm', //确认收货
OrderGoods: WxApiRoot + 'order/goods', // 代评价商品信息 OrderGoods: WxApiRoot + 'order/goods', // 代评价商品信息
OrderComment: WxApiRoot + 'order/comment', // 评价订单商品信息 OrderComment: WxApiRoot + 'order/comment', // 评价订单商品信息
FeedbackAdd: WxApiRoot + 'feedback/submit', //添加反馈 FeedbackAdd: WxApiRoot + 'feedback/submit', //添加反馈
FootprintList: WxApiRoot + 'footprint/list', //足迹列表 FootprintList: WxApiRoot + 'footprint/list', //足迹列表
FootprintDelete: WxApiRoot + 'footprint/delete', //删除足迹 FootprintDelete: WxApiRoot + 'footprint/delete', //删除足迹
UserFormIdCreate: WxApiRoot + 'formid/create', //用户FromId,用于发送模版消息 UserFormIdCreate: WxApiRoot + 'formid/create', //用户FromId,用于发送模版消息
GroupOnList: WxApiRoot + 'groupon/list', //团购列表 GroupOnList: WxApiRoot + 'groupon/list', //团购列表
GroupOn: WxApiRoot + 'groupon/query', //团购API-查询 GroupOn: WxApiRoot + 'groupon/query', //团购API-查询
GroupOnMy: WxApiRoot + 'groupon/my', //团购API-我的团购 GroupOnMy: WxApiRoot + 'groupon/my', //团购API-我的团购
GroupOnDetail: WxApiRoot + 'groupon/detail', //团购API-详情 GroupOnDetail: WxApiRoot + 'groupon/detail', //团购API-详情
GroupOnJoin: WxApiRoot + 'groupon/join', //团购API-详情 GroupOnJoin: WxApiRoot + 'groupon/join', //团购API-详情
StorageUpload: WxApiRoot + 'storage/upload', //图片上传, StorageUpload: WxApiRoot + 'storage/upload', //图片上传,
UserIndex: WxApiRoot + 'user/index', //个人页面用户相关信息 UserIndex: WxApiRoot + 'user/index', //个人页面用户相关信息
}; };
\ No newline at end of file
...@@ -10,26 +10,26 @@ Page({ ...@@ -10,26 +10,26 @@ Page({
code: '', code: '',
loginErrorCount: 0 loginErrorCount: 0
}, },
onLoad: function (options) { onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数 // 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成 // 页面渲染完成
}, },
onReady: function () { onReady: function() {
}, },
onShow: function () { onShow: function() {
// 页面显示 // 页面显示
}, },
onHide: function () { onHide: function() {
// 页面隐藏 // 页面隐藏
}, },
onUnload: function () { onUnload: function() {
// 页面关闭 // 页面关闭
}, },
accountLogin: function () { accountLogin: function() {
var that = this; var that = this;
if (this.data.password.length < 1 || this.data.username.length < 1) { if (this.data.password.length < 1 || this.data.username.length < 1) {
...@@ -51,24 +51,23 @@ Page({ ...@@ -51,24 +51,23 @@ Page({
header: { header: {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
success: function (res) { success: function(res) {
if (res.data.errno == 0){ if (res.data.errno == 0) {
that.setData({ that.setData({
loginErrorCount: 0 loginErrorCount: 0
}); });
app.globalData.hasLogin = true; app.globalData.hasLogin = true;
wx.setStorageSync('userInfo', res.data.data.userInfo); wx.setStorageSync('userInfo', res.data.data.userInfo);
wx.setStorage({ wx.setStorage({
key:"token", key: "token",
data: res.data.data.token, data: res.data.data.token,
success: function(){ success: function() {
wx.switchTab({ wx.switchTab({
url: '/pages/ucenter/index/index' url: '/pages/ucenter/index/index'
}); });
} }
}); });
} } else {
else{
that.setData({ that.setData({
loginErrorCount: that.data.loginErrorCount + 1 loginErrorCount: that.data.loginErrorCount + 1
}); });
...@@ -78,25 +77,25 @@ Page({ ...@@ -78,25 +77,25 @@ Page({
} }
}); });
}, },
bindUsernameInput: function (e) { bindUsernameInput: function(e) {
this.setData({ this.setData({
username: e.detail.value username: e.detail.value
}); });
}, },
bindPasswordInput: function (e) { bindPasswordInput: function(e) {
this.setData({ this.setData({
password: e.detail.value password: e.detail.value
}); });
}, },
bindCodeInput: function (e) { bindCodeInput: function(e) {
this.setData({ this.setData({
code: e.detail.value code: e.detail.value
}); });
}, },
clearInput: function (e) { clearInput: function(e) {
switch (e.currentTarget.id) { switch (e.currentTarget.id) {
case 'clear-username': case 'clear-username':
this.setData({ this.setData({
......
...@@ -4,27 +4,27 @@ var user = require('../../../utils/user.js'); ...@@ -4,27 +4,27 @@ var user = require('../../../utils/user.js');
var app = getApp(); var app = getApp();
Page({ Page({
onLoad: function (options) { onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数 // 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成 // 页面渲染完成
}, },
onReady: function () { onReady: function() {
}, },
onShow: function () { onShow: function() {
// 页面显示 // 页面显示
}, },
onHide: function () { onHide: function() {
// 页面隐藏 // 页面隐藏
}, },
onUnload: function () { onUnload: function() {
// 页面关闭 // 页面关闭
}, },
wxLogin: function (e) { wxLogin: function(e) {
if (e.detail.userInfo == undefined){ if (e.detail.userInfo == undefined) {
app.globalData.hasLogin = false; app.globalData.hasLogin = false;
util.showErrorToast('微信登录失败'); util.showErrorToast('微信登录失败');
return; return;
...@@ -45,7 +45,9 @@ Page({ ...@@ -45,7 +45,9 @@ Page({
}); });
}, },
accountLogin: function () { accountLogin: function() {
wx.navigateTo({ url: "/pages/auth/accountLogin/accountLogin" }); wx.navigateTo({
url: "/pages/auth/accountLogin/accountLogin"
});
} }
}) })
\ No newline at end of file
<view class="container"> <view class="container">
<view class="login-box"> <view class="login-box">
<button type="primary" open-type="getUserInfo" class="wx-login-btn" bindgetuserinfo="wxLogin">微信直接登录</button> <button type="primary" open-type="getUserInfo" class="wx-login-btn" bindgetuserinfo="wxLogin">微信直接登录</button>
<button type="primary" class="account-login-btn" bindtap="accountLogin">账号登录</button> <button type="primary" class="account-login-btn" bindtap="accountLogin">账号登录</button>
</view> </view>
</view> </view>
\ No newline at end of file
var api = require('../../../config/api.js'); var api = require('../../../config/api.js');
var check = require('../../../utils/check.js'); var check = require('../../../utils/check.js');
...@@ -11,27 +10,27 @@ Page({ ...@@ -11,27 +10,27 @@ Page({
mobile: '', mobile: '',
code: '' code: ''
}, },
onLoad: function (options) { onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数 // 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成 // 页面渲染完成
}, },
onReady: function () { onReady: function() {
}, },
onShow: function () { onShow: function() {
// 页面显示 // 页面显示
}, },
onHide: function () { onHide: function() {
// 页面隐藏 // 页面隐藏
}, },
onUnload: function () { onUnload: function() {
// 页面关闭 // 页面关闭
}, },
sendCode: function () { sendCode: function() {
let that = this; let that = this;
if (this.data.mobile.length == 0) { if (this.data.mobile.length == 0) {
...@@ -61,15 +60,14 @@ Page({ ...@@ -61,15 +60,14 @@ Page({
header: { header: {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
success: function (res) { success: function(res) {
if (res.data.errno == 0) { if (res.data.errno == 0) {
wx.showModal({ wx.showModal({
title: '发送成功', title: '发送成功',
content: '验证码已发送', content: '验证码已发送',
showCancel: false showCancel: false
}); });
} } else {
else {
wx.showModal({ wx.showModal({
title: '错误信息', title: '错误信息',
content: res.data.errmsg, content: res.data.errmsg,
...@@ -79,7 +77,7 @@ Page({ ...@@ -79,7 +77,7 @@ Page({
} }
}); });
}, },
requestRegister: function (wxCode) { requestRegister: function(wxCode) {
let that = this; let that = this;
wx.request({ wx.request({
url: api.AuthRegister, url: api.AuthRegister,
...@@ -94,21 +92,20 @@ Page({ ...@@ -94,21 +92,20 @@ Page({
header: { header: {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
success: function (res) { success: function(res) {
if (res.data.errno == 0) { if (res.data.errno == 0) {
app.globalData.hasLogin = true; app.globalData.hasLogin = true;
wx.setStorageSync('userInfo', res.data.data.userInfo); wx.setStorageSync('userInfo', res.data.data.userInfo);
wx.setStorage({ wx.setStorage({
key: "token", key: "token",
data: res.data.data.token, data: res.data.data.token,
success: function () { success: function() {
wx.switchTab({ wx.switchTab({
url: '/pages/ucenter/index/index' url: '/pages/ucenter/index/index'
}); });
} }
}); });
} } else {
else {
wx.showModal({ wx.showModal({
title: '错误信息', title: '错误信息',
content: res.data.errmsg, content: res.data.errmsg,
...@@ -118,7 +115,7 @@ Page({ ...@@ -118,7 +115,7 @@ Page({
} }
}); });
}, },
startRegister: function () { startRegister: function() {
var that = this; var that = this;
if (this.data.password.length < 6 || this.data.username.length < 6) { if (this.data.password.length < 6 || this.data.username.length < 6) {
...@@ -156,9 +153,9 @@ Page({ ...@@ -156,9 +153,9 @@ Page({
}); });
return false; return false;
} }
wx.login({ wx.login({
success: function (res) { success: function(res) {
if (!res.code) { if (!res.code) {
wx.showModal({ wx.showModal({
title: '错误信息', title: '错误信息',
...@@ -171,37 +168,37 @@ Page({ ...@@ -171,37 +168,37 @@ Page({
} }
}); });
}, },
bindUsernameInput: function (e) { bindUsernameInput: function(e) {
this.setData({ this.setData({
username: e.detail.value username: e.detail.value
}); });
}, },
bindPasswordInput: function (e) { bindPasswordInput: function(e) {
this.setData({ this.setData({
password: e.detail.value password: e.detail.value
}); });
}, },
bindConfirmPasswordInput: function (e) { bindConfirmPasswordInput: function(e) {
this.setData({ this.setData({
confirmPassword: e.detail.value confirmPassword: e.detail.value
}); });
}, },
bindMobileInput: function (e) { bindMobileInput: function(e) {
this.setData({ this.setData({
mobile: e.detail.value mobile: e.detail.value
}); });
}, },
bindCodeInput: function (e) { bindCodeInput: function(e) {
this.setData({ this.setData({
code: e.detail.value code: e.detail.value
}); });
}, },
clearInput: function (e) { clearInput: function(e) {
switch (e.currentTarget.id) { switch (e.currentTarget.id) {
case 'clear-username': case 'clear-username':
this.setData({ this.setData({
...@@ -222,7 +219,7 @@ Page({ ...@@ -222,7 +219,7 @@ Page({
this.setData({ this.setData({
mobile: '' mobile: ''
}); });
break; break;
case 'clear-code': case 'clear-code':
this.setData({ this.setData({
code: '' code: ''
......
<view class="container"> <view class="container">
<view class="form-box"> <view class="form-box">
<view class="form-item"> <view class="form-item">
<input class="username" value="{{username}}" bindinput="bindUsernameInput" placeholder="用户名" auto-focus/> <input class="username" value="{{username}}" bindinput="bindUsernameInput" placeholder="用户名" auto-focus/>
<image wx:if="{{ username.length > 0 }}" id="clear-username" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image> <image wx:if="{{ username.length > 0 }}" id="clear-username" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="password" value="{{password}}" password bindinput="bindPasswordInput" placeholder="密码"/> <input class="password" value="{{password}}" password bindinput="bindPasswordInput" placeholder="密码" />
<image class="clear" id="clear-password" wx:if="{{ password.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image> <image class="clear" id="clear-password" wx:if="{{ password.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="password" value="{{confirmPassword}}" password bindinput="bindConfirmPasswordInput" placeholder="确认密码"/> <input class="password" value="{{confirmPassword}}" password bindinput="bindConfirmPasswordInput" placeholder="确认密码" />
<image class="clear" id="clear-confirm-password" wx:if="{{ confirmPassword.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image> <image class="clear" id="clear-confirm-password" wx:if="{{ confirmPassword.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view> </view>
<view class="form-item"> <view class="form-item">
<input class="mobile" value="{{mobile}}" bindinput="bindMobileInput" placeholder="手机号" /> <input class="mobile" value="{{mobile}}" bindinput="bindMobileInput" placeholder="手机号" />
<image wx:if="{{ mobile.length > 0 }}" id="clear-mobile" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image> <image wx:if="{{ mobile.length > 0 }}" id="clear-mobile" class="clear" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view> </view>
<view class="form-item-code" >
<view class="form-item code-item">
<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码"/>
<image class="clear" id="clear-code" wx:if="{{ code.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
<view class="code-btn" bindtap="sendCode">获取验证码</view>
</view>
<button type="primary" class="register-btn" bindtap="startRegister">注册</button>
<view class="form-item-code">
<view class="form-item code-item">
<input class="code" value="{{code}}" bindinput="bindCodeInput" placeholder="验证码" />
<image class="clear" id="clear-code" wx:if="{{ code.length > 0 }}" src="/static/images/clear_input.png" catchtap="clearInput"></image>
</view>
<view class="code-btn" bindtap="sendCode">获取验证码</view>
</view> </view>
<button type="primary" class="register-btn" bindtap="startRegister">注册</button>
</view>
</view> </view>
\ No newline at end of file
.form-box{ .form-box {
width: 100%; width: 100%;
height: auto; height: auto;
overflow: hidden; overflow: hidden;
padding: 0 40rpx; padding: 0 40rpx;
margin-top: 96rpx; margin-top: 96rpx;
background: #fff; background: #fff;
} }
.form-item{ .form-item {
position: relative; position: relative;
background: #fff; background: #fff;
height: 96rpx; height: 96rpx;
border-bottom: 1px solid #d9d9d9; border-bottom: 1px solid #d9d9d9;
} }
.form-item .username, .form-item .password, .form-item .mobile, .form-item .code{ .form-item .username, .form-item .password, .form-item .mobile, .form-item .code {
position: absolute; position: absolute;
top: 26rpx; top: 26rpx;
left: 0; left: 0;
display: block; display: block;
width: 100%; width: 100%;
height: 44rpx; height: 44rpx;
background: #fff; background: #fff;
color: #333; color: #333;
font-size: 30rpx; font-size: 30rpx;
} }
.form-item-code{ .form-item-code {
margin-top:32rpx; margin-top: 32rpx;
height: auto; height: auto;
overflow: hidden; overflow: hidden;
width: 100%; width: 100%;
} }
.form-item-code .form-item{ .form-item-code .form-item {
float: left; float: left;
width: 350rpx; width: 350rpx;
} }
.form-item-code .code-btn{ .form-item-code .code-btn {
float: right; float: right;
padding: 20rpx 40rpx; padding: 20rpx 40rpx;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
border-radius: 10rpx; border-radius: 10rpx;
color: #fff; color: #fff;
background: green; background: green;
} }
.form-item .clear{ .form-item .clear {
position: absolute; position: absolute;
top: 26rpx; top: 26rpx;
right: 18rpx; right: 18rpx;
z-index: 2; z-index: 2;
display: block; display: block;
background: #fff; background: #fff;
height: 44rpx; height: 44rpx;
width: 44rpx; width: 44rpx;
} }
.register-btn{ .register-btn {
margin: 60rpx 0 40rpx 0; margin: 60rpx 0 40rpx 0;
height: 96rpx; height: 96rpx;
line-height: 96rpx; line-height: 96rpx;
color: #fff; color: #fff;
font-size: 30rpx; font-size: 30rpx;
width: 100%; width: 100%;
border-radius: 6rpx; border-radius: 6rpx;
} }
\ No newline at end of file
...@@ -9,28 +9,28 @@ Page({ ...@@ -9,28 +9,28 @@ Page({
password: '', password: '',
confirmPassword: '' confirmPassword: ''
}, },
onLoad: function (options) { onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数 // 页面初始化 options为页面跳转所带来的参数
// 页面渲染完成 // 页面渲染完成
}, },
onReady: function () { onReady: function() {
}, },
onShow: function () { onShow: function() {
// 页面显示 // 页面显示
}, },
onHide: function () { onHide: function() {
// 页面隐藏 // 页面隐藏
}, },
onUnload: function () { onUnload: function() {
// 页面关闭 // 页面关闭
}, },
sendCode: function () { sendCode: function() {
let that = this; let that = this;
wx.request({ wx.request({
url: api.AuthRegisterCaptcha, url: api.AuthRegisterCaptcha,
...@@ -41,15 +41,14 @@ Page({ ...@@ -41,15 +41,14 @@ Page({
header: { header: {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
success: function (res) { success: function(res) {
if (res.data.errno == 0) { if (res.data.errno == 0) {
wx.showModal({ wx.showModal({
title: '发送成功', title: '发送成功',
content: '验证码已发送', content: '验证码已发送',
showCancel: false showCancel: false
}); });
} } else {
else {
wx.showModal({ wx.showModal({
title: '错误信息', title: '错误信息',
content: res.data.errmsg, content: res.data.errmsg,
...@@ -59,7 +58,7 @@ Page({ ...@@ -59,7 +58,7 @@ Page({
} }
}); });
}, },
startReset: function(){ startReset: function() {
var that = this; var that = this;
if (this.data.mobile.length == 0 || this.data.code.length == 0) { if (this.data.mobile.length == 0 || this.data.code.length == 0) {
...@@ -109,11 +108,10 @@ Page({ ...@@ -109,11 +108,10 @@ Page({
header: { header: {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
success: function (res) { success: function(res) {
if (res.data.errno == 0) { if (res.data.errno == 0) {
wx.navigateBack(); wx.navigateBack();
} } else {
else{
wx.showModal({ wx.showModal({
title: '密码重置失败', title: '密码重置失败',
content: res.data.errmsg, content: res.data.errmsg,
...@@ -123,32 +121,32 @@ Page({ ...@@ -123,32 +121,32 @@ Page({
} }
}); });
}, },
bindPasswordInput: function (e) { bindPasswordInput: function(e) {
this.setData({ this.setData({
password: e.detail.value password: e.detail.value
}); });
}, },
bindConfirmPasswordInput: function (e) { bindConfirmPasswordInput: function(e) {
this.setData({ this.setData({
confirmPassword: e.detail.value confirmPassword: e.detail.value
}); });
}, },
bindMobileInput: function (e) { bindMobileInput: function(e) {
this.setData({ this.setData({
mobile: e.detail.value mobile: e.detail.value
}); });
}, },
bindCodeInput: function(e){ bindCodeInput: function(e) {
this.setData({ this.setData({
code: e.detail.value code: e.detail.value
}); });
}, },
clearInput: function(e){ clearInput: function(e) {
switch (e.currentTarget.id){ switch (e.currentTarget.id) {
case 'clear-password': case 'clear-password':
this.setData({ this.setData({
password: '' password: ''
......
.form-box{ .form-box {
width: 100%; width: 100%;
height: auto; height: auto;
overflow: hidden; overflow: hidden;
padding: 0 40rpx; padding: 0 40rpx;
margin-top: 96rpx; margin-top: 96rpx;
background: #fff; background: #fff;
} }
.form-item{ .form-item {
position: relative; position: relative;
background: #fff; background: #fff;
height: 96rpx; height: 96rpx;
border-bottom: 1px solid #d9d9d9; border-bottom: 1px solid #d9d9d9;
} }
.form-item .mobile, .form-item .password, .form-item .code{ .form-item .mobile, .form-item .password, .form-item .code {
position: absolute; position: absolute;
top: 26rpx; top: 26rpx;
left: 0; left: 0;
display: block; display: block;
width: 100%; width: 100%;
height: 44rpx; height: 44rpx;
background: #fff; background: #fff;
color: #333; color: #333;
font-size: 30rpx; font-size: 30rpx;
} }
.form-item-code{ .form-item-code {
margin-top:32rpx; margin-top: 32rpx;
height: auto; height: auto;
overflow: hidden; overflow: hidden;
width: 100%; width: 100%;
} }
.form-item-code .form-item{ .form-item-code .form-item {
float: left; float: left;
width: 350rpx; width: 350rpx;
} }
.form-item-code .code-btn{ .form-item-code .code-btn {
float: right; float: right;
padding: 20rpx 40rpx; padding: 20rpx 40rpx;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
border-radius: 10rpx; border-radius: 10rpx;
} }
.form-item .clear{ .form-item .clear {
position: absolute; position: absolute;
top: 26rpx; top: 26rpx;
right: 18rpx; right: 18rpx;
z-index: 2; z-index: 2;
display: block; display: block;
background: #fff; background: #fff;
height: 44rpx; height: 44rpx;
width: 44rpx; width: 44rpx;
} }
.reset-btn{ .reset-btn {
margin: 60rpx 0 40rpx 0; margin: 60rpx 0 40rpx 0;
height: 96rpx; height: 96rpx;
line-height: 96rpx; line-height: 96rpx;
color: #fff; color: #fff;
font-size: 30rpx; font-size: 30rpx;
width: 100%; width: 100%;
background: #b4282d; background: #b4282d;
border-radius: 6rpx; border-radius: 6rpx;
} }
\ No newline at end of file
...@@ -8,16 +8,19 @@ Page({ ...@@ -8,16 +8,19 @@ Page({
size: 10, size: 10,
totalPages: 1 totalPages: 1
}, },
onLoad: function (options) { onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数 // 页面初始化 options为页面跳转所带来的参数
this.getBrandList(); this.getBrandList();
}, },
getBrandList: function () { getBrandList: function() {
wx.showLoading({ wx.showLoading({
title: '加载中...', title: '加载中...',
}); });
let that = this; let that = this;
util.request(api.BrandList, { page: that.data.page, size: that.data.size }).then(function (res) { util.request(api.BrandList, {
page: that.data.page,
size: that.data.size
}).then(function(res) {
if (res.errno === 0) { if (res.errno === 0) {
that.setData({ that.setData({
brandList: that.data.brandList.concat(res.data.brandList), brandList: that.data.brandList.concat(res.data.brandList),
...@@ -27,7 +30,7 @@ Page({ ...@@ -27,7 +30,7 @@ Page({
wx.hideLoading(); wx.hideLoading();
}); });
}, },
onReachBottom (){ onReachBottom() {
if (this.data.totalPages > this.data.page) { if (this.data.totalPages > this.data.page) {
this.setData({ this.setData({
page: this.data.page + 1 page: this.data.page + 1
...@@ -38,18 +41,18 @@ Page({ ...@@ -38,18 +41,18 @@ Page({
this.getBrandList(); this.getBrandList();
}, },
onReady: function () { onReady: function() {
}, },
onShow: function () { onShow: function() {
// 页面显示 // 页面显示
}, },
onHide: function () { onHide: function() {
// 页面隐藏 // 页面隐藏
}, },
onUnload: function () { onUnload: function() {
// 页面关闭 // 页面关闭
} }
......
<view class="container"> <view class="container">
<view class="brand-list" > <view class="brand-list">
<navigator url="../brandDetail/brandDetail?id={{item.id}}" class="item" wx:for="{{brandList}}" wx:key="id"> <navigator url="../brandDetail/brandDetail?id={{item.id}}" class="item" wx:for="{{brandList}}" wx:key="id">
<view class="img-bg"> <view class="img-bg">
<image src="{{item.picUrl}}" background-size="cover"></image> <image src="{{item.picUrl}}" background-size="cover"></image>
</view> </view>
<view class="txt-box"> <view class="txt-box">
<view class="line"> <view class="line">
<text class="name" >{{item.name}}</text> <text class="name">{{item.name}}</text>
<text class="s">|</text> <text class="s">|</text>
<text class="price">{{item.floorPrice}}元起</text> <text class="price">{{item.floorPrice}}元起</text>
</view> </view>
</view> </view>
</navigator > </navigator>
</view> </view>
</view> </view>
\ No newline at end of file
.brand-list .item{ .brand-list .item {
display: block; display: block;
width: 750rpx; width: 750rpx;
height: 416rpx; height: 416rpx;
position: relative; position: relative;
margin-bottom: 4rpx; margin-bottom: 4rpx;
} }
.brand-list .item .img-bg{ .brand-list .item .img-bg {
position: absolute; position: absolute;
left:0; left: 0;
top:0; top: 0;
z-index: 0; z-index: 0;
width: 750rpx; width: 750rpx;
height: 417rpx; height: 417rpx;
overflow: hidden; overflow: hidden;
} }
.brand-list .item .img-bg image{ .brand-list .item .img-bg image {
width: 750rpx; width: 750rpx;
height: 416rpx; height: 416rpx;
} }
.brand-list .item .txt-box{ .brand-list .item .txt-box {
position: absolute; position: absolute;
left:0; left: 0;
top:0; top: 0;
display: table; display: table;
z-index: 0; z-index: 0;
width: 750rpx; width: 750rpx;
height: 417rpx; height: 417rpx;
} }
.brand-list .item .line{ .brand-list .item .line {
display: table-cell; display: table-cell;
vertical-align: middle; vertical-align: middle;
text-align: center; text-align: center;
height: 63rpx; height: 63rpx;
line-height: 63rpx; line-height: 63rpx;
} }
.brand-list .item .line text{ .brand-list .item .line text {
font-size: 35rpx; font-size: 35rpx;
font-weight: 700; font-weight: 700;
text-shadow: 1rpx 1rpx rgba(0,0,0,.32); text-shadow: 1rpx 1rpx rgba(0, 0, 0, 0.32);
color: #fff; color: #fff;
} }
.brand-list .item .line .s{ .brand-list .item .line .s {
padding: 0 10rpx; padding: 0 10rpx;
font-size: 40rpx; font-size: 40rpx;
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ Page({ ...@@ -12,7 +12,7 @@ Page({
page: 1, page: 1,
size: 100 size: 100
}, },
onLoad: function (options) { onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数 // 页面初始化 options为页面跳转所带来的参数
var that = this; var that = this;
that.setData({ that.setData({
...@@ -20,9 +20,11 @@ Page({ ...@@ -20,9 +20,11 @@ Page({
}); });
this.getBrand(); this.getBrand();
}, },
getBrand: function () { getBrand: function() {
let that = this; let that = this;
util.request(api.BrandDetail, { id: that.data.id }).then(function (res) { util.request(api.BrandDetail, {
id: that.data.id
}).then(function(res) {
if (res.errno === 0) { if (res.errno === 0) {
that.setData({ that.setData({
brand: res.data.brand brand: res.data.brand
...@@ -35,8 +37,12 @@ Page({ ...@@ -35,8 +37,12 @@ Page({
getGoodsList() { getGoodsList() {
var that = this; var that = this;
util.request(api.GoodsList, { brandId: that.data.id, page: that.data.page, size: that.data.size}) util.request(api.GoodsList, {
.then(function (res) { brandId: that.data.id,
page: that.data.page,
size: that.data.size
})
.then(function(res) {
if (res.errno === 0) { if (res.errno === 0) {
that.setData({ that.setData({
goodsList: res.data.goodsList goodsList: res.data.goodsList
...@@ -44,19 +50,19 @@ Page({ ...@@ -44,19 +50,19 @@ Page({
} }
}); });
}, },
onReady: function () { onReady: function() {
// 页面渲染完成 // 页面渲染完成
}, },
onShow: function () { onShow: function() {
// 页面显示 // 页面显示
}, },
onHide: function () { onHide: function() {
// 页面隐藏 // 页面隐藏
}, },
onUnload: function () { onUnload: function() {
// 页面关闭 // 页面关闭
} }
......
<view class="container"> <view class="container">
<view class="brand-info"> <view class="brand-info">
<view class="name"> <view class="name">
<image class="img" src="{{brand.picUrl}}" background-size="cover"></image> <image class="img" src="{{brand.picUrl}}" background-size="cover"></image>
<view class="info-box"> <view class="info-box">
<view class="info"> <view class="info">
<text class="txt">{{brand.name}}</text> <text class="txt">{{brand.name}}</text>
<text class="line"></text> <text class="line"></text>
</view>
</view>
</view>
<view class="desc">
{{brand.desc}}
</view> </view>
</view>
</view>
<view class="desc">
{{brand.desc}}
</view> </view>
</view>
<view class="cate-item"> <view class="cate-item">
<view class="b"> <view class="b">
<block wx:for="{{goodsList}}" wx:key="id" wx:for-index="iindex" wx:for-item="iitem"> <block wx:for="{{goodsList}}" wx:key="id" wx:for-index="iindex" wx:for-item="iitem">
<navigator class="item {{iindex % 2 == 0 ? 'item-b' : ''}}" url="../goods/goods?id={{iitem.id}}"> <navigator class="item {{iindex % 2 == 0 ? 'item-b' : ''}}" url="../goods/goods?id={{iitem.id}}">
<image class="img" src="{{iitem.picUrl}}" background-size="cover"></image> <image class="img" src="{{iitem.picUrl}}" background-size="cover"></image>
<text class="name">{{iitem.name}}</text> <text class="name">{{iitem.name}}</text>
<text class="price">¥{{iitem.retailPrice}}</text> <text class="price">¥{{iitem.retailPrice}}</text>
</navigator> </navigator>
</block> </block>
</view>
</view> </view>
</view>
</view> </view>
\ No newline at end of file
page{ page {
background: #f4f4f4; background: #f4f4f4;
} }
.brand-info .name{
width: 100%; .brand-info .name {
height: 290rpx; width: 100%;
position: relative; height: 290rpx;
position: relative;
} }
.brand-info .img{ .brand-info .img {
position: absolute; position: absolute;
top:0; top: 0;
left:0; left: 0;
width: 100%; width: 100%;
height: 290rpx; height: 290rpx;
} }
.brand-info .info-box{ .brand-info .info-box {
position: absolute; position: absolute;
top:0; top: 0;
left:0; left: 0;
width: 100%; width: 100%;
height: 290rpx; height: 290rpx;
text-align: center; text-align: center;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.brand-info .info{ .brand-info .info {
display: block; display: block;
} }
.brand-info .txt{ .brand-info .txt {
display: block; display: block;
height: 37.5rpx; height: 37.5rpx;
font-size: 37.5rpx; font-size: 37.5rpx;
color: #fff; color: #fff;
} }
.brand-info .line{ .brand-info .line {
margin: 0 auto; margin: 0 auto;
margin-top: 16rpx; margin-top: 16rpx;
display: block; display: block;
height: 2rpx; height: 2rpx;
width: 145rpx; width: 145rpx;
background: #fff; background: #fff;
} }
.brand-info .desc{ .brand-info .desc {
background: #fff; background: #fff;
width: 100%; width: 100%;
height: auto; height: auto;
overflow: hidden; overflow: hidden;
padding: 41.5rpx 31.25rpx; padding: 41.5rpx 31.25rpx;
font-size: 30rpx; font-size: 30rpx;
color: #666; color: #666;
line-height: 41.5rpx; line-height: 41.5rpx;
text-align: center; text-align: center;
} }
.cate-item .b{ .cate-item .b {
width: 750rpx; width: 750rpx;
height: auto; height: auto;
overflow: hidden; overflow: hidden;
...@@ -67,7 +68,7 @@ page{ ...@@ -67,7 +68,7 @@ page{
margin-top: 20rpx; margin-top: 20rpx;
} }
.cate-item .b .item{ .cate-item .b .item {
float: left; float: left;
background: #fff; background: #fff;
width: 375rpx; width: 375rpx;
...@@ -78,17 +79,17 @@ page{ ...@@ -78,17 +79,17 @@ page{
text-align: center; text-align: center;
} }
.cate-item .b .item-b{ .cate-item .b .item-b {
border-right: 1rpx solid #f4f4f4; border-right: 1rpx solid #f4f4f4;
} }
.cate-item .item .img{ .cate-item .item .img {
margin-top: 10rpx; margin-top: 10rpx;
width: 302rpx; width: 302rpx;
height: 302rpx; height: 302rpx;
} }
.cate-item .item .name{ .cate-item .item .name {
display: block; display: block;
width: 365.625rpx; width: 365.625rpx;
height: 35rpx; height: 35rpx;
...@@ -100,11 +101,11 @@ page{ ...@@ -100,11 +101,11 @@ page{
color: #333; color: #333;
} }
.cate-item .item .price{ .cate-item .item .price {
display: block; display: block;
width: 365.625rpx; width: 365.625rpx;
height: 30rpx; height: 30rpx;
text-align: center; text-align: center;
font-size: 30rpx; font-size: 30rpx;
color: #b4282d; color: #b4282d;
} }
\ No newline at end of file
...@@ -5,299 +5,299 @@ var user = require('../../utils/user.js'); ...@@ -5,299 +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
}, },
isEditCart: false, onLoad: function(options) {
checkedAllStatus: true, // 页面初始化 options为页面跳转所带来的参数
editCartList: [], },
hasLogin: false onReady: function() {
}, // 页面渲染完成
onLoad: function(options) { },
// 页面初始化 options为页面跳转所带来的参数 onPullDownRefresh() {
}, wx.showNavigationBarLoading() //在标题栏中显示加载
onReady: function() { this.getCartList();
// 页面渲染完成 wx.hideNavigationBarLoading() //完成停止加载
}, wx.stopPullDownRefresh() //停止下拉刷新
onPullDownRefresh() { },
wx.showNavigationBarLoading() //在标题栏中显示加载 onShow: function() {
this.getCartList(); // 页面显示
wx.hideNavigationBarLoading() //完成停止加载 if (app.globalData.hasLogin) {
wx.stopPullDownRefresh() //停止下拉刷新 this.getCartList();
}, }
onShow: function() {
// 页面显示
if (app.globalData.hasLogin) {
this.getCartList();
}
this.setData({
hasLogin: app.globalData.hasLogin
});
}, 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() {
// 页面关闭
},
goLogin() {
wx.navigateTo({
url: "/pages/auth/login/login"
}); });
} },
}); getCartList: function() {
}, let that = this;
isCheckedAll: function() { util.request(api.CartList).then(function(res) {
//判断购物车商品已全选 if (res.errno === 0) {
return this.data.cartGoods.every(function(element, index, array) { that.setData({
if (element.checked == true) { cartGoods: res.data.cartList,
return true; cartTotal: res.data.cartTotal
} else { });
return false;
}
});
},
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 = [];
productIds.push(that.data.cartGoods[itemIndex].productId);
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,
cartTotal: res.data.cartTotal
});
}
that.setData({ that.setData({
checkedAllStatus: that.isCheckedAll() checkedAllStatus: that.isCheckedAll()
});
}
}); });
}); },
} else { isCheckedAll: function() {
//编辑状态 //判断购物车商品已全选
let tmpCartData = this.data.cartGoods.map(function(element, index, array) { return this.data.cartGoods.every(function(element, index, array) {
if (index == itemIndex) { if (element.checked == true) {
element.checked = !element.checked; return true;
} } else {
return false;
}
});
},
doCheckedAll: function() {
let checkedAll = this.isCheckedAll()
this.setData({
checkedAllStatus: this.isCheckedAll()
});
},
checkedItem: function(event) {
let itemIndex = event.target.dataset.itemIndex;
let that = this;
return element; let productIds = [];
}); productIds.push(that.data.cartGoods[itemIndex].productId);
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,
cartTotal: res.data.cartTotal
});
}
that.setData({ that.setData({
cartGoods: tmpCartData, checkedAllStatus: that.isCheckedAll()
checkedAllStatus: that.isCheckedAll(), });
'cartTotal.checkedGoodsCount': that.getCheckedGoodsCount() });
}); } else {
} //编辑状态
}, let tmpCartData = this.data.cartGoods.map(function(element, index, array) {
getCheckedGoodsCount: function() { if (index == itemIndex) {
let checkedGoodsCount = 0; element.checked = !element.checked;
this.data.cartGoods.forEach(function(v) { }
if (v.checked === true) {
checkedGoodsCount += v.number;
}
});
console.log(checkedGoodsCount);
return checkedGoodsCount;
},
checkedAll: function() {
let that = this;
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()
});
}
},
getCheckedGoodsCount: function() {
let checkedGoodsCount = 0;
this.data.cartGoods.forEach(function(v) {
if (v.checked === true) {
checkedGoodsCount += v.number;
}
}); });
}); console.log(checkedGoodsCount);
} else { return checkedGoodsCount;
//编辑状态 },
let checkedAllStatus = that.isCheckedAll(); checkedAll: function() {
let tmpCartData = this.data.cartGoods.map(function(v) { let that = this;
v.checked = !checkedAllStatus;
return v;
});
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: '/pages/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: '/pages/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
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<view class="c"> <view class="c">
<image src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/noCart-a8fe3f12e5.png" /> <image src="http://nos.netease.com/mailpub/hxm/yanxuan-wap/p/20150730/style/img/icon-normal/noCart-a8fe3f12e5.png" />
<text>还没有登录</text> <text>还没有登录</text>
<button style="background-color:#A9A9A9" bindtap="goLogin">去登录</button> <button style="background-color:#A9A9A9" bindtap="goLogin">去登录</button>
</view> </view>
</view> </view>
<view class='login' wx:else> <view class='login' wx:else>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment