Commit 64f04a10 authored by Junling Bu's avatar Junling Bu
Browse files

chore[litemall-core]: 调整代码

parent 3759c910
# 阿里云对象存储配置信息
# 阿里云对象存储配置信息
aliyun.os.ENDPOINT=oss-cn-shenzhen.aliyuncs.com
aliyun.os.ACCESS_KEY_ID=
aliyun.os.ACCESS_KEY_SECRET=
......
......@@ -13,7 +13,7 @@
"pages/ucenter/coupon/coupon",
"pages/ucenter/collect/collect",
"pages/auth/login/login",
"pages/auth/accountLogin/accountLogin",
"pages/auth/accountLogin/accountLogin",
"pages/auth/register/register",
"pages/auth/reset/reset",
"pages/payResult/payResult",
......@@ -32,7 +32,7 @@
"pages/shopping/address/address",
"pages/shopping/addressAdd/addressAdd",
"pages/goods/goods",
"pages/about/index"
"pages/about/about"
],
"window": {
"navigationBarTitleText": "litemall小程序商城",
......
// index.js
// about.js
var app = getApp()
var util = require("../../utils/util.js");
......@@ -14,9 +14,9 @@ Page({
shopInfo: {
name: 'litemall',
address: 'https://github.com/linlinjava/litemall',
latitude: 22.60,
longitude: 116.87,
linkPhone: '0755-xxxx-xxxx',
latitude: 31.201900,
longitude: 121.587839,
linkPhone: '021-xxxx-xxxx',
qqNumber: '738696120'
},
},
......
......@@ -24,12 +24,14 @@ Page({
openAttr: false,
noCollectImage: '/static/images/icon_collect.png',
hasCollectImage: '/static/images/icon_collect_checked.png',
collectBackImage: '/static/images/icon_collect.png',
collectImage: '/static/images/icon_collect.png',
soldout: false
},
getGoodsInfo: function () {
getGoodsInfo: function() {
let that = this;
util.request(api.GoodsDetail, { id: that.data.id }).then(function (res) {
util.request(api.GoodsDetail, {
id: that.data.id
}).then(function(res) {
if (res.errno === 0) {
let _specificationList = res.data.specificationList
......@@ -67,11 +69,11 @@ Page({
if (res.data.userHasCollect == 1) {
that.setData({
collectBackImage: that.data.hasCollectImage
collectImage: that.data.hasCollectImage
});
} else {
that.setData({
collectBackImage: that.data.noCollectImage
collectImage: that.data.noCollectImage
});
}
......@@ -82,9 +84,11 @@ Page({
});
},
getGoodsRelated: function () {
getGoodsRelated: function() {
let that = this;
util.request(api.GoodsRelated, { id: that.data.id }).then(function (res) {
util.request(api.GoodsRelated, {
id: that.data.id
}).then(function(res) {
if (res.errno === 0) {
that.setData({
relatedGoods: res.data.goodsList,
......@@ -93,7 +97,7 @@ Page({
});
},
clickSkuValue: function (event) {
clickSkuValue: function(event) {
let that = this;
let specName = event.currentTarget.dataset.name;
let specValueId = event.currentTarget.dataset.valueId;
......@@ -127,7 +131,7 @@ Page({
//重新计算哪些值不可以点击
},
//获取选中的规格信息
getCheckedSpecValue: function () {
getCheckedSpecValue: function() {
let checkedValues = [];
let _specificationList = this.data.specificationList;
for (let i = 0; i < _specificationList.length; i++) {
......@@ -148,35 +152,35 @@ Page({
return checkedValues;
},
//根据已选的值,计算其它值的状态
setSpecValueStatus: function () {
setSpecValueStatus: function() {
},
//判断规格是否选择完整
isCheckedAllSpec: function () {
return !this.getCheckedSpecValue().some(function (v) {
isCheckedAllSpec: function() {
return !this.getCheckedSpecValue().some(function(v) {
if (v.valueId == 0) {
return true;
}
});
},
getCheckedSpecKey: function () {
let checkedValue = this.getCheckedSpecValue().map(function (v) {
getCheckedSpecKey: function() {
let checkedValue = this.getCheckedSpecValue().map(function(v) {
return v.valueText;
});
return checkedValue;
},
changeSpecInfo: function () {
changeSpecInfo: function() {
let checkedNameValue = this.getCheckedSpecValue();
//设置选择的信息
let checkedValue = checkedNameValue.filter(function (v) {
let checkedValue = checkedNameValue.filter(function(v) {
if (v.valueId != 0) {
return true;
} else {
return false;
}
}).map(function (v) {
}).map(function(v) {
return v.valueText;
});
if (checkedValue.length > 0) {
......@@ -211,16 +215,14 @@ Page({
checkedSpecPrice: checkedProduct.price,
soldout: false
});
}
else {
} else {
this.setData({
checkedSpecPrice: this.data.goods.retailPrice,
soldout: true
});
}
}
else {
} else {
this.setData({
checkedSpecText: '规格数量选择',
checkedSpecPrice: this.data.goods.retailPrice,
......@@ -229,8 +231,8 @@ Page({
}
},
getCheckedProductItem: function (key) {
return this.data.productList.filter(function (v) {
getCheckedProductItem: function(key) {
return this.data.productList.filter(function(v) {
if (v.specifications.toString() == key.toString()) {
return true;
} else {
......@@ -238,21 +240,21 @@ Page({
}
});
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
this.setData({
id: parseInt(options.id)
});
this.getGoodsInfo();
},
onReady: function () {
onReady: function() {
// 页面渲染完成
},
onShow: function () {
onShow: function() {
// 页面显示
var that = this;
util.request(api.CartGoodsCount).then(function (res) {
util.request(api.CartGoodsCount).then(function(res) {
if (res.errno === 0) {
that.setData({
cartGoodsCount: res.data
......@@ -260,79 +262,68 @@ Page({
}
});
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
switchAttrPop: function () {
switchAttrPop: function() {
if (this.data.openAttr == false) {
this.setData({
openAttr: !this.data.openAttr,
collectBackImage: '/static/images/detail_back.png'
openAttr: !this.data.openAttr
});
}
},
closeAttr: function () {
closeAttr: function() {
this.setData({
openAttr: false,
});
},
addCollectOrNot: function () {
addCollectOrNot: function() {
let that = this;
// if (this.data.openAttr) {
// this.setData({
// openAttr: false,
// });
// if (that.data.userHasCollect == 1) {
// that.setData({
// collectBackImage: that.data.hasCollectImage
// });
// } else {
// that.setData({
// collectBackImage: that.data.noCollectImage
// });
// }
// } else {
//添加或是取消收藏
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({
collectBackImage: that.data.hasCollectImage
});
} else {
that.setData({
collectBackImage: that.data.noCollectImage
});
}
//添加或是取消收藏
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 {
wx.showToast({
image: '/static/images/icon_error.png',
title: _res.errmsg,
mask: true
that.setData({
collectImage: that.data.noCollectImage
});
}
});
} else {
wx.showToast({
image: '/static/images/icon_error.png',
title: _res.errmsg,
mask: true
});
}
});
},
openCartPage: function () {
wx.switchTab({ url: '/pages/cart/cart' });
openCartPage: function() {
wx.switchTab({
url: '/pages/cart/cart'
});
},
addFast: function () {
addFast: function() {
var that = this;
if (this.data.openAttr == false) {
//打开规格选择窗口
this.setData({
openAttr: !this.data.openAttr,
collectBackImage: '/static/images/detail_back.png'
openAttr: !this.data.openAttr
});
} else {
......@@ -367,8 +358,12 @@ Page({
}
//立即购买
util.request(api.CartFastAdd, { goodsId: this.data.goods.id, number: this.data.number, productId: checkedProduct.id }, "POST")
.then(function (res) {
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,则是立即购买,否则是购物车购买
......@@ -377,8 +372,7 @@ Page({
wx.navigateTo({
url: '/pages/shopping/checkout/checkout'
})
} catch (e) {
}
} catch (e) {}
} else {
wx.showToast({
......@@ -392,13 +386,12 @@ Page({
},
addToCart: function () {
addToCart: function() {
var that = this;
if (this.data.openAttr == false) {
//打开规格选择窗口
this.setData({
openAttr: !this.data.openAttr,
// collectBackImage: '/static/images/detail_back.png'
openAttr: !this.data.openAttr
});
} else {
......@@ -433,8 +426,12 @@ Page({
}
//添加到购物车
util.request(api.CartAdd, { goodsId: this.data.goods.id, number: this.data.number, productId: checkedProduct.id }, "POST")
.then(function (res) {
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({
......@@ -446,11 +443,11 @@ Page({
});
if (that.data.userHasCollect == 1) {
that.setData({
collectBackImage: that.data.hasCollectImage
collectImage: that.data.hasCollectImage
});
} else {
that.setData({
collectBackImage: that.data.noCollectImage
collectImage: that.data.noCollectImage
});
}
} else {
......@@ -465,12 +462,12 @@ Page({
}
},
cutNumber: function () {
cutNumber: function() {
this.setData({
number: (this.data.number - 1 > 1) ? this.data.number - 1 : 1
});
},
addNumber: function () {
addNumber: function() {
this.setData({
number: this.data.number + 1
});
......
......@@ -111,7 +111,7 @@
<view class="info">
<view class="c">
<view class="p">价格:¥{{checkedSpecPrice}}</view>
<view class="a" wx:if="{{productList.length>0}}">已选择:{{checkedSpecText}}</view>
<view class="a">{{tmpSpecText}}</view>
</view>
</view>
</view>
......@@ -119,7 +119,7 @@
<view class="spec-item" wx:for="{{specificationList}}" wx:key="name">
<view class="name">{{item.name}}</view>
<view class="values">
<view class="value {{vitem.checked ? 'selected' : ''}}" bindtap="clickSkuValue" wx:for="{{item.valueList}}" wx:for-item="vitem" wx:key="{{vitem.id}}" data-value-id="{{vitem.id}}" data-name-id="{{vitem.specification}}">{{vitem.value}}</view>
<view class="value {{vitem.checked ? 'selected' : ''}}" bindtap="clickSkuValue" wx:for="{{item.valueList}}" wx:for-item="vitem" wx:key="{{vitem.id}}" data-value-id="{{vitem.id}}" data-name="{{vitem.specification}}">{{vitem.value}}</view>
</view>
</view>
......@@ -140,7 +140,7 @@
</view>
<view class="bottom-btn">
<view class="l l-collect" bindtap="addCollectOrNot">
<image class="icon" src="{{ collectBackImage }}"></image>
<image class="icon" src="{{ collectImage }}"></image>
</view>
<view class="l l-cart">
<view class="box">
......
......@@ -524,9 +524,10 @@
text-align: center;
width: 90rpx;
}
.bottom-btn .l.l-kefu {
position: relative;
height:54rpx;
height: 54rpx;
width: 63rpx;
}
......@@ -534,7 +535,6 @@
position: relative;
height: 60rpx;
width: 60rpx;
}
.bottom-btn .l.l-cart .cart-count {
......@@ -572,7 +572,8 @@
line-height: 28rpx;
border-radius: 50%;
}
.bottom-btn .l.l-kefu .icon{
.bottom-btn .l.l-kefu .icon {
position: absolute;
top: 10rpx;
left: 0;
......@@ -584,36 +585,34 @@
width: 44rpx;
}
.bottom-btn .c{
float: left;
background: #f48f18;
height: 100rpx;
line-height: 96rpx;
flex: 1;
text-align: center;
color: #fff;
/* border-top: 2px solid #f4f4f4; */
/* border-bottom: 2px solid #f4f4f4; */
.bottom-btn .c {
float: left;
background: #f48f18;
height: 100rpx;
line-height: 96rpx;
flex: 1;
text-align: center;
color: #fff;
/* border-top: 2px solid #f4f4f4; *//* border-bottom: 2px solid #f4f4f4; */
}
.bottom-btn .r{
border:1px solid #b4282d;
background: #b4282d;
float: left;
height: 100rpx;
line-height: 96rpx;
flex: 1;
text-align: center;
color: #fff;
.bottom-btn .r {
border: 1px solid #b4282d;
background: #b4282d;
float: left;
height: 100rpx;
line-height: 96rpx;
flex: 1;
text-align: center;
color: #fff;
}
@import "../../lib/wxParse/wxParse.wxss";
.attr-pop-box {
width: 100%;
height: 100%;
position: fixed;
background: rgba(0, 0, 0, .5);
background: rgba(0, 0, 0, 0.5);
z-index: 8;
bottom: 0;
/* display: none; */
......@@ -754,48 +753,32 @@
line-height: 65rpx;
}
.contact{
height: 100rpx;
width: 100rpx;
background-color: #008000;
border-radius: 100%;
position: fixed;
bottom: 150rpx;
right: 20rpx;
display: flex;
align-items: center;
justify-content: center;
z-index: 9;
.contact {
height: 100rpx;
width: 100rpx;
background-color: #008000;
border-radius: 100%;
position: fixed;
bottom: 150rpx;
right: 20rpx;
display: flex;
align-items: center;
justify-content: center;
z-index: 9;
flex-direction: column;
/*line-height: 100rpx;
text-align: center;
padding-top: 26rpx;*/
font-size: 20rpx;
color: #008000;
box-sizing: border-box;
background: url("https://litemall.oss-cn-shenzhen.aliyuncs.com/kefu.png") no-repeat center 21rpx;
background: url("https://litemall.oss-cn-shenzhen.aliyuncs.com/kefu.png") no-repeat center 21rpx;
background-size: 55rpx auto;
}
.contact .name{
font-size: 32rpx;
max-width: 80rpx;
color: #fff;
text-align: center;
.contact .name {
font-size: 32rpx;
max-width: 80rpx;
color: #fff;
text-align: center;
}
......@@ -16,8 +16,8 @@ Page({
},
onShareAppMessage: function () {
return {
title: 'litemall小商场',
desc: '仿网易严选微信小程序商城',
title: 'litemall小程序商场',
desc: '开源微信小程序商城',
path: '/pages/index/index'
}
},
......
......@@ -10,16 +10,16 @@ Page({
avatarUrl: 'http://yanxuan.nosdn.127.net/8945ae63d940cc42406c3f67019c5cb6.png'
}
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
},
onReady: function () {
onReady: function() {
},
onShow: function () {
onShow: function() {
//获取用户的登录信息
if (app.globalData.hasLogin){
if (app.globalData.hasLogin) {
let userInfo = wx.getStorageSync('userInfo');
this.setData({
userInfo: userInfo,
......@@ -27,82 +27,87 @@ Page({
}
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
goLogin(){
goLogin() {
if (!app.globalData.hasLogin) {
wx.navigateTo({ url: "/pages/auth/login/login" });
wx.navigateTo({
url: "/pages/auth/login/login"
});
}
},
goOrder() {
if (app.globalData.hasLogin) {
wx.navigateTo({ url: "/pages/ucenter/order/order" });
}
else {
wx.navigateTo({ url: "/pages/auth/login/login" });
wx.navigateTo({
url: "/pages/ucenter/order/order"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
}
},
goCoupon() {
if (app.globalData.hasLogin) {
wx.navigateTo({ url: "/pages/ucenter/coupon/coupon" });
}
else {
wx.navigateTo({ url: "/pages/auth/login/login" });
wx.navigateTo({
url: "/pages/ucenter/coupon/coupon"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
goCollect() {
if (app.globalData.hasLogin) {
wx.navigateTo({ url: "/pages/ucenter/collect/collect" });
}
else {
wx.navigateTo({ url: "/pages/auth/login/login" });
wx.navigateTo({
url: "/pages/ucenter/collect/collect"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
goFootprint() {
if (app.globalData.hasLogin) {
wx.navigateTo({ url: "/pages/ucenter/footprint/footprint" });
}
else {
wx.navigateTo({ url: "/pages/auth/login/login" });
wx.navigateTo({
url: "/pages/ucenter/footprint/footprint"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
goAddress() {
if (app.globalData.hasLogin) {
wx.navigateTo({ url: "/pages/ucenter/address/address" });
}
else {
wx.navigateTo({ url: "/pages/auth/login/login" });
wx.navigateTo({
url: "/pages/ucenter/address/address"
});
} else {
wx.navigateTo({
url: "/pages/auth/login/login"
});
};
},
aboutUs: function () {
// wx.navigateTo({
// url: '/page/about/index',
// })
aboutUs: function() {
wx.navigateTo({
url: '../../about/index',//页面跳转相对路径要写清楚且准确
success: function (res) {
console.log('跳转到news页面成功')// success
},
fail: function () {
console.log('跳转到news页面失败') // fail
},
complete: function () {
console.log('跳转到news页面完成') // complete
}
})
url: '/pages/about/about'
});
},
exitLogin: function () {
exitLogin: function() {
wx.showModal({
title: '',
confirmColor: '#b4282d',
content: '退出登录?',
success: function (res) {
success: function(res) {
if (res.confirm) {
wx.removeStorageSync('token');
wx.removeStorageSync('userInfo');
......
......@@ -28,7 +28,7 @@
"list": []
},
"miniprogram": {
"current": 32,
"current": 33,
"list": [
{
"id": -1,
......@@ -210,12 +210,12 @@
"pathName": "pages/auth/login/login",
"query": ""
},
{
"id": -1,
"name": "账号登录",
"pathName": "pages/auth/accountLogin/accountLogin",
"query": ""
},
{
"id": -1,
"name": "账号登录",
"pathName": "pages/auth/accountLogin/accountLogin",
"query": ""
},
{
"id": -1,
"name": "注册",
......@@ -227,6 +227,11 @@
"name": "找回密码",
"pathName": "pages/auth/reset/reset",
"query": ""
},
{
"id": -1,
"name": "关于",
"pathName": "pages/about/about"
}
]
}
......
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