购物车、收货地址管理
This commit is contained in:
parent
4901d6c43f
commit
27f2fce932
6
app.json
6
app.json
@ -40,7 +40,11 @@
|
||||
"pages/serviceActivityDetail/serviceActivityDetail",
|
||||
"pages/shop/shopcategory",
|
||||
"subpages/goodsdetail/goodsdetail",
|
||||
"subpages/goodscar/goodscar"
|
||||
"subpages/goodscar/goodscar",
|
||||
"subpages/goodsaddress/goodsaddress",
|
||||
"subpages/goodsorder/goodsorder",
|
||||
"subpages/addshopaddress/addshopaddress",
|
||||
"subpages/editshopaddress/editshopaddress"
|
||||
],
|
||||
"subPackages": [
|
||||
{
|
||||
|
@ -90,7 +90,19 @@ Page({
|
||||
},
|
||||
})
|
||||
},
|
||||
// 购物车
|
||||
//收货地址
|
||||
toAddressManage() {
|
||||
wx.navigateTo({
|
||||
url: '/subpages/goodsaddress/goodsaddress',
|
||||
})
|
||||
},
|
||||
//我的订单
|
||||
toShopOrder() {
|
||||
wx.navigateTo({
|
||||
url: '/subpages/goodsorder/goodsorder',
|
||||
})
|
||||
},
|
||||
//购物车
|
||||
toShopCar() {
|
||||
wx.navigateTo({
|
||||
url: '/subpages/goodscar/goodscar',
|
||||
|
@ -45,6 +45,14 @@
|
||||
<image src="../../images/share.png"></image>
|
||||
<view class="title">购物车</view>
|
||||
</view>
|
||||
<view class="main-box" bindtap="toAddressManage">
|
||||
<image src="../../images/share.png"></image>
|
||||
<view class="title">收货地址</view>
|
||||
</view>
|
||||
<view class="main-box" bindtap="toShopOrder">
|
||||
<image src="../../images/share.png"></image>
|
||||
<view class="title">我的订单</view>
|
||||
</view>
|
||||
<!-- <view class="main-box">
|
||||
<image src="../../images/setting.png"></image>
|
||||
<view class="title">设置</view>
|
||||
|
@ -37,6 +37,7 @@ Page({
|
||||
wx.login({
|
||||
success(res) {
|
||||
if (res.code) {
|
||||
wx.setStorageSync('token', 'aGh2UkUyWTBMbFh5dlV2WXJRci9pT1VPN1JuNkhEQUc5NDF4NmdsUUUxSE91enFBc2VMTmoyTkJscDdlaEhnYW01dEQ1bDFqN1lXLzk2S2l1S1ZEclhTeEFiMEp1Vzk0a1VJWTBlandZSmV6YXVGbjhnaFMzOFN2MkdVdzZsZFA1V0JWcXBYTFFFWWRrREhUTHp0RUJ1YktFWi82N09xTGdjM1UwcFdVdy9WSTQ3U3VrUVdZVklZK0tRV2VQMTZtTElpYTkvandSNFo1cjMzVlRIaGRTVXlEUnBPQy9VV1NlNWZuYThYUzJVRT0');
|
||||
app.restAjax.post(app.restAjax.path('{url}/wechat-miniapp/sign/default', [app.loginUrl]), {
|
||||
jsCode: res.code
|
||||
}, null, function (code, data) {
|
||||
@ -78,9 +79,9 @@ Page({
|
||||
app.restAjax.get(app.restAjax.path('{venueUrl}/app/venuesinfo/listpagevenuesinforelease', [self.data.venue.venueUrl]), {
|
||||
page: 1,
|
||||
rows: 3,
|
||||
latitude:app.globalData.curLat,
|
||||
longitude:app.globalData.curLng,
|
||||
orderKey:"",
|
||||
latitude: app.globalData.curLat,
|
||||
longitude: app.globalData.curLng,
|
||||
orderKey: "",
|
||||
}, null, function (code, data) {
|
||||
for (var i = 0, item; item = data.rows[i++];) {
|
||||
item.venuePanoramaArray = item.venuePanorama.split(',');
|
||||
@ -233,8 +234,8 @@ Page({
|
||||
// const longitude = res.longitude
|
||||
// const speed = res.speed
|
||||
// const accuracy = res.accuracy
|
||||
app.globalData.curLng=res.longitude
|
||||
app.globalData.curLat=res.latitude
|
||||
app.globalData.curLng = res.longitude
|
||||
app.globalData.curLat = res.latitude
|
||||
}
|
||||
})
|
||||
self.doLogin();
|
||||
|
@ -53,5 +53,10 @@ Page({
|
||||
wx.navigateTo({
|
||||
url: '/subpages/goodslist/goodslist?id=' + id,
|
||||
})
|
||||
},
|
||||
showCar() {
|
||||
wx.navigateTo({
|
||||
url: '/subpages/goodscar/goodscar',
|
||||
})
|
||||
}
|
||||
})
|
@ -23,5 +23,9 @@
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="car-box" bindtap="showCar">
|
||||
<image src="/subpages/images/ic_shop_car_icon.png" mode="scaleToFill"></image>
|
||||
<text>购物车</text>
|
||||
</view>
|
||||
</view>
|
||||
<page-loading wx:else></page-loading>
|
@ -120,3 +120,29 @@ page {
|
||||
width: 96rpx;
|
||||
height: 66rpx;
|
||||
}
|
||||
|
||||
.car-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
bottom: 30rpx;
|
||||
right: 50rpx;
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
background: linear-gradient(to right bottom, rgb(243, 209, 55), rgb(245, 170, 9) 70px);
|
||||
border-radius: 50%;
|
||||
padding: 10rpx;
|
||||
|
||||
}
|
||||
|
||||
.car-box image {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.car-box text {
|
||||
font-size: 25rpx;
|
||||
color: #9f1512;
|
||||
}
|
244
subpages/addshopaddress/addshopaddress.js
Normal file
244
subpages/addshopaddress/addshopaddress.js
Normal file
@ -0,0 +1,244 @@
|
||||
// subpages/addshopaddress/addshopaddress.js
|
||||
var app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
token: '',
|
||||
area1: '',
|
||||
area2: '',
|
||||
area3: '',
|
||||
area4: '',
|
||||
detailContent: '',
|
||||
name: '',
|
||||
phone: '',
|
||||
zipCode: '',
|
||||
|
||||
tempProvIndex: -1,
|
||||
tempProvArray: [],
|
||||
|
||||
cityIndex: -1,
|
||||
cityArray: [],
|
||||
|
||||
countyIndex: -1,
|
||||
countyArray: [],
|
||||
|
||||
villageIndex: -1,
|
||||
villageArray: []
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
var _self = this;
|
||||
_self.getToken().then(result => {
|
||||
|
||||
})
|
||||
_self.getAreaList(0, 1);
|
||||
},
|
||||
getToken() {
|
||||
var self = this;
|
||||
return new Promise(resolve => {
|
||||
wx.getStorage({
|
||||
key: 'token',
|
||||
success(res) {
|
||||
self.setData({
|
||||
token: res.data
|
||||
})
|
||||
return resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
inputZip(e) {
|
||||
this.setData({
|
||||
zipCode: e.detail.value
|
||||
})
|
||||
},
|
||||
inputName(e) {
|
||||
this.setData({
|
||||
name: e.detail.value
|
||||
})
|
||||
},
|
||||
inputPhone(e) {
|
||||
this.setData({
|
||||
phone: e.detail.value
|
||||
})
|
||||
},
|
||||
inputDetail(e) {
|
||||
this.setData({
|
||||
detailContent: e.detail.value
|
||||
})
|
||||
},
|
||||
//获取
|
||||
getAreaList(areaId, type) {
|
||||
var _self = this;
|
||||
app.dialog.loading("加载中...");
|
||||
app.restAjax.get(app.restAjax.path('{shopUrl}/app/area/listbyparentidrelease/{areaParentId}',
|
||||
[app.loginUrl, areaId]),
|
||||
null, null,
|
||||
function (code, data) {
|
||||
switch (type) {
|
||||
case 1: //省份
|
||||
_self.setData({
|
||||
tempProvIndex: -1,
|
||||
tempProvArray: data
|
||||
})
|
||||
break;
|
||||
case 2:
|
||||
_self.setData({
|
||||
cityArray: data
|
||||
})
|
||||
break;
|
||||
case 3:
|
||||
_self.setData({
|
||||
countyArray: data
|
||||
})
|
||||
break;
|
||||
case 4:
|
||||
_self.setData({
|
||||
villageArray: data
|
||||
})
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
function (code, data) {
|
||||
app.dialog.msg(data.msg);
|
||||
},
|
||||
function () {
|
||||
wx.hideLoading();
|
||||
})
|
||||
},
|
||||
//省份选择
|
||||
provChange(e) {
|
||||
var index = e.detail.value
|
||||
this.setData({
|
||||
tempProvIndex: index,
|
||||
cityIndex: -1,
|
||||
cityArray: [],
|
||||
countyIndex: -1,
|
||||
countyArray: [],
|
||||
villageIndex: -1,
|
||||
villageArray: []
|
||||
})
|
||||
this.getAreaList(this.data.tempProvArray[this.data.tempProvIndex].areaId, 2);
|
||||
},
|
||||
//市选择
|
||||
cityChange(e) {
|
||||
var index = e.detail.value
|
||||
this.setData({
|
||||
cityIndex: index,
|
||||
countyIndex: -1,
|
||||
countyArray: [],
|
||||
villageIndex: -1,
|
||||
villageArray: []
|
||||
})
|
||||
this.getAreaList(this.data.cityArray[this.data.cityIndex].areaId, 3);
|
||||
},
|
||||
//区县选择
|
||||
countyChange(e) {
|
||||
var index = e.detail.value
|
||||
this.setData({
|
||||
countyIndex: index,
|
||||
villageIndex: -1,
|
||||
villageArray: []
|
||||
})
|
||||
this.getAreaList(this.data.countyArray[this.data.countyIndex].areaId, 4);
|
||||
},
|
||||
//乡镇选择
|
||||
villageChange(e) {
|
||||
var index = e.detail.value
|
||||
this.setData({
|
||||
villageIndex: index
|
||||
})
|
||||
},
|
||||
doSave() {
|
||||
if (this.checkParams()) {
|
||||
app.dialog.loading("保存中...")
|
||||
var _self = this;
|
||||
var areaName = _self.data.tempProvArray[_self.data.tempProvIndex].areaName + ' ' + _self.data.cityArray[_self.data.cityIndex].areaName + ' ' + _self.data.countyArray[_self.data.countyIndex].areaName + ' ' + _self.data.villageArray[_self.data.villageIndex].areaName
|
||||
var info = {
|
||||
areaCode: _self.data.villageArray[_self.data.villageIndex].areaCode,
|
||||
areaId: _self.data.villageArray[_self.data.villageIndex].areaId,
|
||||
areaName: areaName,
|
||||
shopAddressContent: _self.data.detailContent,
|
||||
shopAddressName: _self.data.name,
|
||||
shopAddressPhone: _self.data.phone,
|
||||
shopAddressZipcode: _self.data.zipCode
|
||||
};
|
||||
app.restAjax.post(app.restAjax.path('{url}/app/shopaddress/save', [app.shopUrl]), info, {
|
||||
headers: {
|
||||
token: _self.data.token
|
||||
}
|
||||
}, function (code, data) {
|
||||
wx.hideLoading()
|
||||
console.log(code)
|
||||
if (code == 200) {
|
||||
app.dialog.msg("添加成功")
|
||||
var pages = getCurrentPages();
|
||||
let prevPage = pages[pages.length - 2];
|
||||
prevPage.doRefresh()
|
||||
wx.navigateBack()
|
||||
}
|
||||
}, function (code, data) {
|
||||
wx.hideLoading()
|
||||
app.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
},
|
||||
checkParams() {
|
||||
if (this.data.tempProvIndex == -1) {
|
||||
wx.showToast({
|
||||
title: '请选择省份',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.cityIndex == -1) {
|
||||
wx.showToast({
|
||||
title: '请选择市',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.countyIndex == -1) {
|
||||
wx.showToast({
|
||||
title: '请选择区县',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.villageIndex == -1) {
|
||||
wx.showToast({
|
||||
title: '请选择乡镇街道',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.detailContent == '') {
|
||||
wx.showToast({
|
||||
title: '请输入详细地址',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.name == '') {
|
||||
wx.showToast({
|
||||
title: '请输入姓名',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.phone == '') {
|
||||
wx.showToast({
|
||||
title: '请输入联系方式',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
})
|
4
subpages/addshopaddress/addshopaddress.json
Normal file
4
subpages/addshopaddress/addshopaddress.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "新增收货地址"
|
||||
}
|
72
subpages/addshopaddress/addshopaddress.wxml
Normal file
72
subpages/addshopaddress/addshopaddress.wxml
Normal file
@ -0,0 +1,72 @@
|
||||
<!--subpages/addshopaddress/addshopaddress.wxml-->
|
||||
<view class="address-content">
|
||||
<!-- 省份 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">省份</view>
|
||||
<view class="line"></view>
|
||||
<picker class="area-content" bindchange="provChange" value="{{tempProvIndex}}" range="{{tempProvArray}}" range-key="areaName">
|
||||
<view>
|
||||
{{tempProvIndex==-1 ? '请选择省份':tempProvArray[tempProvIndex].areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
<image src="/subpages/images/ic_arrow_cir.png" mode="scaleToFill" class="arrow-icon"></image>
|
||||
</view>
|
||||
<!-- 市 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">市</view>
|
||||
<view class="line"></view>
|
||||
<picker class="area-content" bindchange="cityChange" value="{{cityIndex}}" range="{{cityArray}}" range-key="areaName">
|
||||
<view>
|
||||
{{cityIndex==-1? '请选择市':cityArray[cityIndex].areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
<image src="/subpages/images/ic_arrow_cir.png" mode="scaleToFill" class="arrow-icon"></image>
|
||||
</view>
|
||||
<!-- 区县 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">区、县</view>
|
||||
<view class="line"></view>
|
||||
<picker class="area-content" bindchange="countyChange" value="{{countyIndex}}" range="{{countyArray}}" range-key="areaName">
|
||||
<view>
|
||||
{{countyIndex==-1? '请选择区县':countyArray[countyIndex].areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
<image src="/subpages/images/ic_arrow_cir.png" mode="scaleToFill" class="arrow-icon"></image>
|
||||
</view>
|
||||
<!-- 社区街道 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">乡镇街道</view>
|
||||
<view class="line"></view>
|
||||
<picker class="area-content" bindchange="villageChange" value="{{villageIndex}}" range="{{villageArray}}" range-key="areaName">
|
||||
<view>
|
||||
{{villageIndex==-1?'请选择乡镇街道':villageArray[villageIndex].areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
<image src="/subpages/images/ic_arrow_cir.png" mode="scaleToFill" class="arrow-icon"></image>
|
||||
</view>
|
||||
<!-- 详细地址 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">详细地址</view>
|
||||
<view class="line"></view>
|
||||
<input class="area-content" bindinput="inputDetail" placeholder="请输入详细地址"></input>
|
||||
</view>
|
||||
<!-- 收货人姓名 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">姓名</view>
|
||||
<view class="line"></view>
|
||||
<input class="area-content" bindinput="inputName" placeholder="请输入收货人姓名"></input>
|
||||
</view>
|
||||
<!-- 联系方式 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">联系方式</view>
|
||||
<view class="line"></view>
|
||||
<input bindinput="inputPhone" class="area-content" placeholder="请输入联系方式"></input>
|
||||
</view>
|
||||
<!-- 邮政编码 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">邮政编码</view>
|
||||
<view class="line"></view>
|
||||
<input bindinput="inputZip" placeholder="请输入邮政编码" class="area-content"></input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom-btn" bindtap="doSave">保存</view>
|
58
subpages/addshopaddress/addshopaddress.wxss
Normal file
58
subpages/addshopaddress/addshopaddress.wxss
Normal file
@ -0,0 +1,58 @@
|
||||
/* subpages/addshopaddress/addshopaddress.wxss */
|
||||
.address-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.address-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.address-item:nth-of-type(n+2) {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.area-title {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.line {
|
||||
background: #9f1512;
|
||||
width: 5rpx;
|
||||
height: 35rpx;
|
||||
}
|
||||
|
||||
.area-content {
|
||||
flex: 2;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.arrow-icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
|
||||
.bottom-btn {
|
||||
height: 80rpx;
|
||||
background: #9f1512;
|
||||
border-radius: 10rpx;
|
||||
text-align: center;
|
||||
color: white;
|
||||
position: fixed;
|
||||
bottom: 0rpx;
|
||||
left: 0rpx;
|
||||
line-height: 80rpx;
|
||||
margin: 0rpx 20rpx 10rpx 20rpx;
|
||||
width: 95%;
|
||||
}
|
285
subpages/editshopaddress/editshopaddress.js
Normal file
285
subpages/editshopaddress/editshopaddress.js
Normal file
@ -0,0 +1,285 @@
|
||||
// subpages/addshopaddress/addshopaddress.js
|
||||
var app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
id: '',
|
||||
token: '',
|
||||
area1: '',
|
||||
area2: '',
|
||||
area3: '',
|
||||
area4: '',
|
||||
detailContent: '',
|
||||
name: '',
|
||||
phone: '',
|
||||
zipCode: '',
|
||||
|
||||
tempProvIndex: -1,
|
||||
tempProvArray: [],
|
||||
|
||||
cityIndex: -1,
|
||||
cityArray: [],
|
||||
|
||||
countyIndex: -1,
|
||||
countyArray: [],
|
||||
|
||||
villageIndex: -1,
|
||||
villageArray: [],
|
||||
detailBean: {}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
var _self = this;
|
||||
var id = options.id
|
||||
_self.setData({
|
||||
id: id
|
||||
})
|
||||
_self.getToken().then(result => {
|
||||
_self.getAddressDetail();
|
||||
})
|
||||
_self.getAreaList(0, 1);
|
||||
},
|
||||
getToken() {
|
||||
var self = this;
|
||||
return new Promise(resolve => {
|
||||
wx.getStorage({
|
||||
key: 'token',
|
||||
success(res) {
|
||||
self.setData({
|
||||
token: res.data
|
||||
})
|
||||
return resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
getAddressDetail() {
|
||||
var _self = this;
|
||||
app.dialog.loading("加载中...");
|
||||
app.restAjax.get(app.restAjax.path('{baseUrl}/app/shopaddress/get/{shopAddressId}', [app.shopUrl, _self.data.id]), null, {
|
||||
headers: {
|
||||
token: _self.data.token
|
||||
}
|
||||
}, function (code, data) {
|
||||
wx.hideLoading()
|
||||
if (data) {
|
||||
_self.setData({
|
||||
detailBean: data,
|
||||
detailContent: data.shopAddressContent,
|
||||
name: data.shopAddressName,
|
||||
phone: data.shopAddressPhone,
|
||||
zipCode: data.shopAddressZipcode
|
||||
})
|
||||
}
|
||||
}, function (code, data) {
|
||||
wx.hideLoading()
|
||||
})
|
||||
},
|
||||
inputZip(e) {
|
||||
this.setData({
|
||||
zipCode: e.detail.value
|
||||
})
|
||||
},
|
||||
inputName(e) {
|
||||
this.setData({
|
||||
name: e.detail.value
|
||||
})
|
||||
},
|
||||
inputPhone(e) {
|
||||
this.setData({
|
||||
phone: e.detail.value
|
||||
})
|
||||
},
|
||||
inputDetail(e) {
|
||||
this.setData({
|
||||
detailContent: e.detail.value
|
||||
})
|
||||
},
|
||||
//获取
|
||||
getAreaList(areaId, type) {
|
||||
var _self = this;
|
||||
app.dialog.loading("加载中...");
|
||||
app.restAjax.get(app.restAjax.path('{shopUrl}/app/area/listbyparentidrelease/{areaParentId}',
|
||||
[app.loginUrl, areaId]),
|
||||
null, null,
|
||||
function (code, data) {
|
||||
switch (type) {
|
||||
case 1: //省份
|
||||
_self.setData({
|
||||
tempProvIndex: -1,
|
||||
tempProvArray: data
|
||||
})
|
||||
break;
|
||||
case 2:
|
||||
_self.setData({
|
||||
cityArray: data
|
||||
})
|
||||
break;
|
||||
case 3:
|
||||
_self.setData({
|
||||
countyArray: data
|
||||
})
|
||||
break;
|
||||
case 4:
|
||||
_self.setData({
|
||||
villageArray: data
|
||||
})
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
function (code, data) {
|
||||
app.dialog.msg(data.msg);
|
||||
},
|
||||
function () {
|
||||
wx.hideLoading();
|
||||
})
|
||||
},
|
||||
//省份选择
|
||||
provChange(e) {
|
||||
var index = e.detail.value
|
||||
this.setData({
|
||||
tempProvIndex: index,
|
||||
cityIndex: -1,
|
||||
cityArray: [],
|
||||
countyIndex: -1,
|
||||
countyArray: [],
|
||||
villageIndex: -1,
|
||||
villageArray: []
|
||||
})
|
||||
this.getAreaList(this.data.tempProvArray[this.data.tempProvIndex].areaId, 2);
|
||||
},
|
||||
//市选择
|
||||
cityChange(e) {
|
||||
var index = e.detail.value
|
||||
this.setData({
|
||||
cityIndex: index,
|
||||
countyIndex: -1,
|
||||
countyArray: [],
|
||||
villageIndex: -1,
|
||||
villageArray: []
|
||||
})
|
||||
this.getAreaList(this.data.cityArray[this.data.cityIndex].areaId, 3);
|
||||
},
|
||||
//区县选择
|
||||
countyChange(e) {
|
||||
var index = e.detail.value
|
||||
this.setData({
|
||||
countyIndex: index,
|
||||
villageIndex: -1,
|
||||
villageArray: []
|
||||
})
|
||||
this.getAreaList(this.data.countyArray[this.data.countyIndex].areaId, 4);
|
||||
},
|
||||
//乡镇选择
|
||||
villageChange(e) {
|
||||
var index = e.detail.value
|
||||
this.setData({
|
||||
villageIndex: index
|
||||
})
|
||||
},
|
||||
doSave() {
|
||||
if (this.checkParams()) {
|
||||
app.dialog.loading("修改中...")
|
||||
var _self = this;
|
||||
var areaName = '';
|
||||
var areaId = '';
|
||||
var areaCode = '';
|
||||
if (_self.data.tempProvIndex == -1) {
|
||||
areaName = _self.data.detailBean.areaName;
|
||||
areaId = _self.data.detailBean.areaId;
|
||||
areaCode = _self.data.detailBean.areaCode;
|
||||
} else {
|
||||
areaName = _self.data.tempProvArray[_self.data.tempProvIndex].areaName + ' ' + _self.data.cityArray[_self.data.cityIndex].areaName + ' ' + _self.data.countyArray[_self.data.countyIndex].areaName + ' ' + _self.data.villageArray[_self.data.villageIndex].areaName;
|
||||
areaCode = _self.data.villageArray[_self.data.villageIndex].areaCode;
|
||||
areaId = _self.data.villageArray[_self.data.villageIndex].areaId;
|
||||
}
|
||||
var info = {
|
||||
areaCode: areaCode,
|
||||
areaId: areaId,
|
||||
areaName: areaName,
|
||||
shopAddressContent: _self.data.detailContent,
|
||||
shopAddressName: _self.data.name,
|
||||
shopAddressPhone: _self.data.phone,
|
||||
shopAddressZipcode: _self.data.zipCode
|
||||
};
|
||||
app.restAjax.put(app.restAjax.path('{url}/app/shopaddress/update/{shopAddressId}', [app.shopUrl, _self.data.id]), info, {
|
||||
headers: {
|
||||
token: _self.data.token
|
||||
}
|
||||
}, function (code, data) {
|
||||
wx.hideLoading()
|
||||
console.log(code)
|
||||
if (code == 200) {
|
||||
app.dialog.msg("修改成功")
|
||||
var pages = getCurrentPages();
|
||||
let prevPage = pages[pages.length - 2];
|
||||
prevPage.doRefresh()
|
||||
wx.navigateBack()
|
||||
}
|
||||
}, function (code, data) {
|
||||
wx.hideLoading()
|
||||
app.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
},
|
||||
checkParams() {
|
||||
if (this.data.tempProvIndex != -1) {
|
||||
if (this.data.tempProvIndex == -1) {
|
||||
wx.showToast({
|
||||
title: '请选择省份',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.cityIndex == -1) {
|
||||
wx.showToast({
|
||||
title: '请选择市',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.countyIndex == -1) {
|
||||
wx.showToast({
|
||||
title: '请选择区县',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.villageIndex == -1) {
|
||||
wx.showToast({
|
||||
title: '请选择乡镇街道',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (this.data.detailContent == '') {
|
||||
wx.showToast({
|
||||
title: '请输入详细地址',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.name == '') {
|
||||
wx.showToast({
|
||||
title: '请输入姓名',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
if (this.data.phone == '') {
|
||||
wx.showToast({
|
||||
title: '请输入联系方式',
|
||||
})
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
})
|
4
subpages/editshopaddress/editshopaddress.json
Normal file
4
subpages/editshopaddress/editshopaddress.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "收货地址修改"
|
||||
}
|
74
subpages/editshopaddress/editshopaddress.wxml
Normal file
74
subpages/editshopaddress/editshopaddress.wxml
Normal file
@ -0,0 +1,74 @@
|
||||
<!--subpages/addshopaddress/addshopaddress.wxml-->
|
||||
<view class="address-content">
|
||||
<!-- 当前选择的省市县 -->
|
||||
<view class="current-address">{{detailBean.areaName}}</view>
|
||||
<!-- 省份 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">省份</view>
|
||||
<view class="line"></view>
|
||||
<picker class="area-content" bindchange="provChange" value="{{tempProvIndex}}" range="{{tempProvArray}}" range-key="areaName">
|
||||
<view>
|
||||
{{tempProvIndex==-1 ? '请选择省份':tempProvArray[tempProvIndex].areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
<image src="/subpages/images/ic_arrow_cir.png" mode="scaleToFill" class="arrow-icon"></image>
|
||||
</view>
|
||||
<!-- 市 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">市</view>
|
||||
<view class="line"></view>
|
||||
<picker class="area-content" bindchange="cityChange" value="{{cityIndex}}" range="{{cityArray}}" range-key="areaName">
|
||||
<view>
|
||||
{{cityIndex==-1? '请选择市':cityArray[cityIndex].areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
<image src="/subpages/images/ic_arrow_cir.png" mode="scaleToFill" class="arrow-icon"></image>
|
||||
</view>
|
||||
<!-- 区县 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">区、县</view>
|
||||
<view class="line"></view>
|
||||
<picker class="area-content" bindchange="countyChange" value="{{countyIndex}}" range="{{countyArray}}" range-key="areaName">
|
||||
<view>
|
||||
{{countyIndex==-1? '请选择区县':countyArray[countyIndex].areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
<image src="/subpages/images/ic_arrow_cir.png" mode="scaleToFill" class="arrow-icon"></image>
|
||||
</view>
|
||||
<!-- 社区街道 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">乡镇街道</view>
|
||||
<view class="line"></view>
|
||||
<picker class="area-content" bindchange="villageChange" value="{{villageIndex}}" range="{{villageArray}}" range-key="areaName">
|
||||
<view>
|
||||
{{villageIndex==-1?'请选择乡镇街道':villageArray[villageIndex].areaName}}
|
||||
</view>
|
||||
</picker>
|
||||
<image src="/subpages/images/ic_arrow_cir.png" mode="scaleToFill" class="arrow-icon"></image>
|
||||
</view>
|
||||
<!-- 详细地址 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">详细地址</view>
|
||||
<view class="line"></view>
|
||||
<input class="area-content" bindinput="inputDetail" placeholder="请输入详细地址" value="{{detailContent}}"></input>
|
||||
</view>
|
||||
<!-- 收货人姓名 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">姓名</view>
|
||||
<view class="line"></view>
|
||||
<input class="area-content" bindinput="inputName" placeholder="请输入收货人姓名" value="{{name}}"></input>
|
||||
</view>
|
||||
<!-- 联系方式 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">联系方式</view>
|
||||
<view class="line"></view>
|
||||
<input bindinput="inputPhone" class="area-content" placeholder="请输入联系方式" value="{{phone}}"></input>
|
||||
</view>
|
||||
<!-- 邮政编码 -->
|
||||
<view class="address-item">
|
||||
<view class="area-title">邮政编码</view>
|
||||
<view class="line"></view>
|
||||
<input bindinput="inputZip" placeholder="请输入邮政编码" class="area-content" value="{{zipCode}}"></input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bottom-btn" bindtap="doSave">保存</view>
|
64
subpages/editshopaddress/editshopaddress.wxss
Normal file
64
subpages/editshopaddress/editshopaddress.wxss
Normal file
@ -0,0 +1,64 @@
|
||||
/* subpages/addshopaddress/addshopaddress.wxss */
|
||||
.address-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.address-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.address-item:nth-of-type(n+2) {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.area-title {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.line {
|
||||
background: #9f1512;
|
||||
width: 5rpx;
|
||||
height: 35rpx;
|
||||
}
|
||||
|
||||
.area-content {
|
||||
flex: 2;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.arrow-icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
|
||||
.bottom-btn {
|
||||
height: 80rpx;
|
||||
background: #9f1512;
|
||||
border-radius: 10rpx;
|
||||
text-align: center;
|
||||
color: white;
|
||||
position: fixed;
|
||||
bottom: 0rpx;
|
||||
left: 0rpx;
|
||||
line-height: 80rpx;
|
||||
margin: 0rpx 20rpx 10rpx 20rpx;
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.current-address {
|
||||
font-size: 36rpx;
|
||||
padding: 20rpx 0rpx;
|
||||
font-weight: bold;
|
||||
}
|
132
subpages/goodsaddress/goodsaddress.js
Normal file
132
subpages/goodsaddress/goodsaddress.js
Normal file
@ -0,0 +1,132 @@
|
||||
// subpages/goodsaddress/goodsaddress.js
|
||||
var app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
token: '',
|
||||
list: [],
|
||||
hidePageLoading: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
var _self = this;
|
||||
_self.getToken().then(result => {
|
||||
_self.getList();
|
||||
})
|
||||
},
|
||||
getToken() {
|
||||
var self = this;
|
||||
return new Promise(resolve => {
|
||||
wx.getStorage({
|
||||
key: 'token',
|
||||
success(res) {
|
||||
self.setData({
|
||||
token: res.data
|
||||
})
|
||||
return resolve();
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
//获取列表
|
||||
getList() {
|
||||
var _self = this
|
||||
var header = {
|
||||
headers: {
|
||||
token: _self.data.token
|
||||
}
|
||||
};
|
||||
|
||||
app.restAjax.get(app.restAjax.path('{shopUrl}/app/shopaddress/list', [app.shopUrl]), null, header, function (code, data) {
|
||||
console.log(data);
|
||||
_self.setData({
|
||||
list: data,
|
||||
hidePageLoading: true
|
||||
})
|
||||
}, function (code, data) {
|
||||
app.dialog.msg(data.msg);
|
||||
_self.setData({
|
||||
hidePageLoading: true
|
||||
})
|
||||
}, function () {
|
||||
wx.hideLoading();
|
||||
_self.setData({
|
||||
hideLoading: true
|
||||
})
|
||||
})
|
||||
},
|
||||
doRefresh() {
|
||||
this.setData({
|
||||
list: []
|
||||
})
|
||||
this.getList();
|
||||
},
|
||||
doEdit(e) {
|
||||
var id = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: '/subpages/editshopaddress/editshopaddress?id=' + id,
|
||||
})
|
||||
},
|
||||
doDel(e) {
|
||||
var id = e.currentTarget.dataset.id;
|
||||
var _self = this;
|
||||
wx.showModal({
|
||||
title: '警告',
|
||||
content: '确定要删除该收货地址吗?',
|
||||
complete: (res) => {
|
||||
if (res.confirm) {
|
||||
app.dialog.loading("删除中...")
|
||||
app.restAjax.delete(app.restAjax.path('{shopUrl}/app/shopaddress/remove/{ids}', [app.shopUrl, id]), null, {
|
||||
headers: {
|
||||
token: _self.data.token
|
||||
}
|
||||
}, function (code, data) {
|
||||
wx.hideLoading()
|
||||
if (code == 200) {
|
||||
app.dialog.msg("删除成功")
|
||||
_self.getList()
|
||||
}
|
||||
}, function (code, data) {
|
||||
app.dialog.msg(data.msg)
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
doSetDefault(e) {
|
||||
var _self = this;
|
||||
app.dialog.loading('设置中')
|
||||
var id = e.currentTarget.dataset.id
|
||||
var index = e.currentTarget.dataset.index
|
||||
app.restAjax.put(app.restAjax.path('{shopUrl}/app/shopaddress/updatedefault/{shopAddressId}', [app.shopUrl, id]), null, {
|
||||
headers: {
|
||||
token: _self.data.token
|
||||
}
|
||||
}, function (code, data) {
|
||||
wx.hideLoading();
|
||||
if (code == 200) {
|
||||
app.dialog.msg('设置成功')
|
||||
}
|
||||
_self.setData({
|
||||
list: []
|
||||
})
|
||||
_self.getList();
|
||||
}, function (code, data) {
|
||||
console.log(data)
|
||||
wx.hideLoading();
|
||||
app.dialog.msg(data.msg)
|
||||
})
|
||||
|
||||
},
|
||||
addAddress() {
|
||||
wx.navigateTo({
|
||||
url: '/subpages/addshopaddress/addshopaddress'
|
||||
})
|
||||
},
|
||||
})
|
4
subpages/goodsaddress/goodsaddress.json
Normal file
4
subpages/goodsaddress/goodsaddress.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "收货地址"
|
||||
}
|
23
subpages/goodsaddress/goodsaddress.wxml
Normal file
23
subpages/goodsaddress/goodsaddress.wxml
Normal file
@ -0,0 +1,23 @@
|
||||
<!--subpages/goodsaddress/goodsaddress.wxml-->
|
||||
<scroll-view wx:if="{{hidePageLoading}}" style="min-height: 600rpx;" scroll-y="true">
|
||||
<view wx:if="{{list.length>0}}" class="content-box">
|
||||
<view class="address-item" wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="index">
|
||||
<image class="check" src="/subpages/images/ic_cb_checked.png" mode="scaleToFill" wx:if="{{item.shopAddressDefault=='1'}}"></image>
|
||||
<view class="address-content" bindtap="doSetDefault" data-id="{{item.shopAddressId}}" data-index="{{index}}">
|
||||
<view class="address-area">{{item.areaName}}</view>
|
||||
<view class="address-name">{{item.shopAddressContent}}</view>
|
||||
<view class="address-phone">{{item.shopAddressName}} {{item.shopAddressPhone}}</view>
|
||||
</view>
|
||||
<view class="address-control-box">
|
||||
<image src="/subpages/images/ic_edit_icon.png" mode="scaleToFill" class="edit-icon" bindtap="doEdit" data-id="{{item.shopAddressId}}"></image>
|
||||
<image src="/images/delete.png" mode="scaleToFill" class="del-icon" bindtap="doDel" data-id="{{item.shopAddressId}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else class="empty-box">
|
||||
<image src="/images/ic_empty_data.png"></image>
|
||||
<text>暂无数据</text>
|
||||
</view>
|
||||
<view class="bottom-btn" bindtap="addAddress">新增收货地址</view>
|
||||
</scroll-view>
|
||||
<page-loading wx:else></page-loading>
|
106
subpages/goodsaddress/goodsaddress.wxss
Normal file
106
subpages/goodsaddress/goodsaddress.wxss
Normal file
@ -0,0 +1,106 @@
|
||||
/* subpages/goodsaddress/goodsaddress.wxss */
|
||||
.empty-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%)translateY(-50%);
|
||||
}
|
||||
|
||||
.empty-box image {
|
||||
width: 140rpx;
|
||||
height: 100rpx;
|
||||
}
|
||||
|
||||
.empty-box text {
|
||||
margin-top: 20rpx;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.content-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 95%;
|
||||
padding: 20rpx;
|
||||
border-radius: 10rpx;
|
||||
box-shadow: 5rpx 5rpx 20rpx #f2f2f2;
|
||||
margin: 20rpx 20rpx 100rpx 0rpx;
|
||||
}
|
||||
|
||||
.address-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
padding: 10rpx;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.address-item .check {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
|
||||
}
|
||||
|
||||
.address-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.address-area {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.address-name {
|
||||
font-size: 40rpx;
|
||||
margin: 10rpx 0rpx;
|
||||
}
|
||||
|
||||
.address-phone {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.address-control-box {
|
||||
display: flex;
|
||||
width: 80rpx;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.edit-icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.del-icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.bottom-btn {
|
||||
height: 80rpx;
|
||||
background: #9f1512;
|
||||
border-radius: 10rpx;
|
||||
text-align: center;
|
||||
color: white;
|
||||
position: fixed;
|
||||
bottom: 0rpx;
|
||||
left: 0rpx;
|
||||
line-height: 80rpx;
|
||||
margin: 0rpx 20rpx 10rpx 20rpx;
|
||||
width: 95%;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
// subpages/goodscar/goodscar.js
|
||||
var app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
@ -7,6 +8,8 @@ Page({
|
||||
data: {
|
||||
carList: [],
|
||||
isHidePageloading: false,
|
||||
imgUrl: app.shopImgUrl,
|
||||
totalPrice: 0.0
|
||||
},
|
||||
|
||||
/**
|
||||
@ -22,6 +25,7 @@ Page({
|
||||
carList: value,
|
||||
isHidePageloading: true
|
||||
})
|
||||
_self.countPrice()
|
||||
} else {
|
||||
_self.setData({
|
||||
isHidePageloading: true
|
||||
@ -31,5 +35,69 @@ Page({
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
delGoods(e) {
|
||||
var _self = this;
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该商品吗?',
|
||||
complete: (res) => {
|
||||
if (res.confirm) {
|
||||
var index = e.currentTarget.dataset.index
|
||||
console.log(index)
|
||||
_self.data.carList.splice(index, 1)
|
||||
_self.setData({
|
||||
carList: _self.data.carList
|
||||
})
|
||||
wx.setStorageSync('carlist', _self.data.carList);
|
||||
_self.countPrice();
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
delCount(e) {
|
||||
var _self = this;
|
||||
var index = e.currentTarget.dataset.index
|
||||
if (this.data.carList[index].carAmount == 1) {
|
||||
return;
|
||||
}
|
||||
this.data.carList[index].carAmount -= 1;
|
||||
this.setData({
|
||||
carList: this.data.carList
|
||||
})
|
||||
wx.setStorageSync('carlist', _self.data.carList);
|
||||
_self.countPrice();
|
||||
},
|
||||
addCount(e) {
|
||||
var _self = this;
|
||||
var index = e.currentTarget.dataset.index
|
||||
this.data.carList[index].carAmount += 1;
|
||||
this.setData({
|
||||
carList: this.data.carList
|
||||
})
|
||||
wx.setStorageSync('carlist', _self.data.carList);
|
||||
_self.countPrice();
|
||||
},
|
||||
selSelect(e) {
|
||||
var _self = this;
|
||||
var index = e.currentTarget.dataset.index;
|
||||
_self.data.carList[index].isCheck = !_self.data.carList[index].isCheck;
|
||||
_self.setData({
|
||||
carList: _self.data.carList
|
||||
})
|
||||
wx.setStorageSync('carlist', _self.data.carList);
|
||||
_self.countPrice();
|
||||
},
|
||||
countPrice() {
|
||||
var _self = this;
|
||||
var tempCount = 0;
|
||||
for (let i = 0; i < _self.data.carList.length; i++) {
|
||||
const item = _self.data.carList[i];
|
||||
if (item.isCheck) {
|
||||
tempCount = item.goodsPrice * item.carAmount + tempCount;
|
||||
}
|
||||
}
|
||||
_self.setData({
|
||||
totalPrice: tempCount
|
||||
})
|
||||
}
|
||||
})
|
@ -3,11 +3,27 @@
|
||||
<view wx:if="{{carList.length>0}}">
|
||||
<block wx:for="{{carList}}" wx:for-item="item" wx:for-index="index" wx:key="index">
|
||||
<view class="goods-item">
|
||||
<image class="check" src="/subpages/images/ic_shop_car_icon.png" mode="aspectFill"></image>
|
||||
<image class="check" src="{{item.isCheck? '/subpages/images/ic_cb_checked.png':'/subpages/images/ic_cb_unchecked.png'}}" mode="scaleToFill"></image>
|
||||
<view class="goods">
|
||||
<image class="goods-img"></image>
|
||||
<image class="goods-img" src="{{item.goodsIcon=='' ? '/images/address.png' : imgUrl+item.goodsIcon}}" mode="scaleToFill" bindtap="selSelect" data-index="{{index}}"></image>
|
||||
<view class="goods-content">
|
||||
|
||||
<rich-text class="goods-name" nodes="{{item.goodsName}}" bindtap="selSelect" data-index="{{index}}"></rich-text>
|
||||
<view class="goods-price" bindtap="selSelect" data-index="{{index}}">¥{{item.goodsPrice}}</view>
|
||||
<view class="goods-standard" bindtap="selSelect" data-index="{{index}}">{{item.goodsStandarName}}</view>
|
||||
<view class="goods-type-box">
|
||||
<view class="type-box" bindtap="selSelect" data-index="{{index}}">
|
||||
<view class="goods-type">销量{{item.goodsSalesVolume}}</view>
|
||||
<view class="goods-type">{{item.goodsNotFreight ==1 ? '不包邮':'包邮'}}</view>
|
||||
</view>
|
||||
<view class="control-box">
|
||||
<view class="add-del-box">
|
||||
<image bindtap="delCount" data-index="{{index}}" src="/subpages/images/ic_del_circle_icon.png" mode="scaleToFill" class="del"></image>
|
||||
<text class="txt">{{item.carAmount}}</text>
|
||||
<image bindtap="addCount" data-index="{{index}}" src="/subpages/images/ic_add_circle_icon.png" mode="scaleToFill" class="add"></image>
|
||||
</view>
|
||||
<image src="/images/delete.png" mode="scaleToFill" bindtap="delGoods" data-index="{{index}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -19,3 +35,14 @@
|
||||
</view>
|
||||
</scroll-view>
|
||||
<page-loading wx:else></page-loading>
|
||||
|
||||
|
||||
<view class="bottom-box">
|
||||
<view class="bottom-content">
|
||||
<view class="bottom-price">
|
||||
<view class="price-icon">¥</view>
|
||||
<view class="price-content">{{totalPrice}}</view>
|
||||
</view>
|
||||
<view class="car-add" bindtap="toConfirmOrder">去结算</view>
|
||||
</view>
|
||||
</view>
|
@ -24,20 +24,211 @@
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.goods-item {}
|
||||
.goods-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding: 10rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.check {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
min-width: 48rpx;
|
||||
min-height: 48rpx;
|
||||
max-height: 48rpx;
|
||||
max-width: 48rpx;
|
||||
}
|
||||
|
||||
.goods {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.goods-img {
|
||||
width: 180rpx;
|
||||
height: 160rpx;
|
||||
}
|
||||
|
||||
|
||||
.goods-content {
|
||||
margin: 0rpx 10rpx;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.goods-name {
|
||||
font-size: 32rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.goods-unit-price {
|
||||
font-size: 40rpx;
|
||||
color: #9f1512;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.goods-standard {
|
||||
margin-top: 10rpx;
|
||||
font-size: 32rpx;
|
||||
border: 1rpx solid #9f1512;
|
||||
border-radius: 3rpx;
|
||||
color: #9f1512;
|
||||
width: fit-content;
|
||||
max-width: fit-content;
|
||||
padding: 0rpx 10rpx;
|
||||
}
|
||||
|
||||
.goods-type-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.goods-type-box image {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.goods-type {
|
||||
color: #9f1512;
|
||||
font-size: 25rpx;
|
||||
border: 1rpx solid #9f1512;
|
||||
padding: 0rpx 10rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.goods-type:last-child {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.type-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 50%;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.add-del-box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.add-del-box .txt {
|
||||
font-size: 35rpx;
|
||||
padding: 0rpx 15rpx;
|
||||
}
|
||||
|
||||
.control-box {
|
||||
width: 50%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.bottom-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: white;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
.goods .goods-img{}
|
||||
.goods-content{
|
||||
|
||||
.bottom-content {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 25rpx;
|
||||
}
|
||||
|
||||
.bottom-price {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: baseline;
|
||||
color: #e70606;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.price-icon {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.price-content {
|
||||
font-size: 55rpx;
|
||||
}
|
||||
|
||||
|
||||
.icon-btn {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.car-icon {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.car-icon image {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
align-items: center;
|
||||
align-self: center;
|
||||
margin-left: 25rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.car {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.car-num {
|
||||
position: relative;
|
||||
right: 10rpx;
|
||||
top: -10rpx;
|
||||
background: #e70606;
|
||||
color: white;
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 50%;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 25rpx;
|
||||
}
|
||||
|
||||
.car-add {
|
||||
background: linear-gradient(to right bottom, rgb(245, 74, 74), rgb(221, 5, 5) 70px);
|
||||
color: white;
|
||||
padding: 15rpx;
|
||||
border-radius: 10rpx;
|
||||
margin-left: 20rpx;
|
||||
font-size: 32rpx;
|
||||
}
|
@ -14,6 +14,7 @@ Page({
|
||||
curStandardIndex: 0,
|
||||
imgUrl: app.shopImgUrl,
|
||||
carList: [],
|
||||
carNum: 0,
|
||||
},
|
||||
|
||||
/**
|
||||
@ -26,6 +27,33 @@ Page({
|
||||
this.getGoodsDetail();
|
||||
|
||||
},
|
||||
onShow() {
|
||||
try {
|
||||
var value = wx.getStorageSync('carlist');
|
||||
if (value) {
|
||||
this.setData({
|
||||
carList: value
|
||||
})
|
||||
this.parseCarList();
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
},
|
||||
parseCarList() {
|
||||
var _self = this;
|
||||
var count = 0;
|
||||
for (let i = 0; i < _self.data.carList.length; i++) {
|
||||
const item = _self.data.carList[i];
|
||||
count = item.carAmount + count;
|
||||
}
|
||||
console.log(count)
|
||||
if (count > 0) {
|
||||
_self.setData({
|
||||
carNum: count
|
||||
})
|
||||
}
|
||||
},
|
||||
//获取商品详情
|
||||
getGoodsDetail() {
|
||||
var _self = this
|
||||
@ -121,9 +149,33 @@ Page({
|
||||
addToCar() {
|
||||
//判断购物车中是否存在该商品
|
||||
var _self = this;
|
||||
var pos = -1;
|
||||
for (let i = 0; i < _self.data.carList.length; i++) {
|
||||
var item = _self.data.carList[i];
|
||||
|
||||
if (_self.data.detailBean.goodsId == item.goodsId && _self.data.detailBean.goodsStandarId == item.goodsStandarId) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pos != -1) {
|
||||
_self.data.carList[pos].carAmount = _self.data.carList[pos].carAmount + 1;
|
||||
} else {
|
||||
_self.data.detailBean.carAmount = 1;
|
||||
_self.data.carList.push(_self.data.detailBean);
|
||||
}
|
||||
_self.setData({
|
||||
carList: _self.data.carList
|
||||
})
|
||||
_self.parseCarList();
|
||||
wx.setStorageSync('carlist', _self.data.carList)
|
||||
},
|
||||
openCar() {
|
||||
if (this.data.carNum > 0) {
|
||||
wx.navigateTo({
|
||||
url: '/subpages/goodscar/goodscar',
|
||||
})
|
||||
} else {
|
||||
app.dialog.msg('购物车无数据')
|
||||
}
|
||||
}
|
||||
})
|
@ -71,13 +71,13 @@
|
||||
</view>
|
||||
<view class="icon-btn">
|
||||
<view class="car-icon">
|
||||
<view class="car">
|
||||
<view class="car" bindtap="openCar">
|
||||
<image src="/subpages/images/ic_shop_car_icon.png" mode="aspectFill"></image>
|
||||
<view class="car-num ">{{carList.length}}</view>
|
||||
<view class="car-num" wx:if="{{carNum >0}}">{{carNum>99? '99+':carNum}}</view>
|
||||
</view>
|
||||
<view>购物车</view>
|
||||
</view>
|
||||
<view class="car-add">添加购物车</view>
|
||||
<view class="car-add" bindtap="addToCar">加入购物车</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
66
subpages/goodsorder/goodsorder.js
Normal file
66
subpages/goodsorder/goodsorder.js
Normal file
@ -0,0 +1,66 @@
|
||||
// subpages/goodsorder/goodsorder.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
3
subpages/goodsorder/goodsorder.json
Normal file
3
subpages/goodsorder/goodsorder.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
2
subpages/goodsorder/goodsorder.wxml
Normal file
2
subpages/goodsorder/goodsorder.wxml
Normal file
@ -0,0 +1,2 @@
|
||||
<!--subpages/goodsorder/goodsorder.wxml-->
|
||||
<text>subpages/goodsorder/goodsorder.wxml</text>
|
1
subpages/goodsorder/goodsorder.wxss
Normal file
1
subpages/goodsorder/goodsorder.wxss
Normal file
@ -0,0 +1 @@
|
||||
/* subpages/goodsorder/goodsorder.wxss */
|
BIN
subpages/images/ic_add_circle_icon.png
Normal file
BIN
subpages/images/ic_add_circle_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 809 B |
BIN
subpages/images/ic_arrow_cir.png
Executable file
BIN
subpages/images/ic_arrow_cir.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 416 B |
BIN
subpages/images/ic_cb_checked.png
Normal file
BIN
subpages/images/ic_cb_checked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 869 B |
BIN
subpages/images/ic_cb_unchecked.png
Normal file
BIN
subpages/images/ic_cb_unchecked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 900 B |
BIN
subpages/images/ic_del_circle_icon.png
Normal file
BIN
subpages/images/ic_del_circle_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 696 B |
BIN
subpages/images/ic_edit_icon.png
Normal file
BIN
subpages/images/ic_edit_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 425 B |
Loading…
Reference in New Issue
Block a user