diff --git a/app.js b/app.js
index 53e31aa..4fa4578 100644
--- a/app.js
+++ b/app.js
@@ -3,59 +3,60 @@ var restAjax = require('utils/restAjax.js');
var dialog = require('utils/dialog.js');
// + 'https://www.xzszwhy.cn/usercenter'
App({
- loginUrl: restAjax.baseUrl,
- usercenterUrl: restAjax.baseUrl,
- newsUrl: restAjax.baseUrl,
- newsContentUrl: restAjax.baseUrl,
- libraryUrl: restAjax.baseUrl,
- venueUrl: restAjax.baseUrl,
- activityUrl: restAjax.baseUrl,
- volunteerUrl: restAjax.baseUrl,
- activityUrl: restAjax.baseUrl,
- volunteerUrl: restAjax.baseUrl,
- liveUrl: restAjax.baseUrl,
- liveRecordUrl: restAjax.baseUrl,
- socialUrl: restAjax.baseUrl,
- shopUrl: restAjax.url + "xzshop",
- restAjax: restAjax,
- shopImgUrl: restAjax.url + "xzshop/route/file/download/true/",
- dialog: dialog,
- onLaunch: function () {
- // 展示本地存储能力
- var logs = wx.getStorageSync('logs') || []
- logs.unshift(Date.now())
- wx.setStorageSync('logs', logs)
+ loginUrl: restAjax.baseUrl,
+ usercenterUrl: restAjax.baseUrl,
+ newsUrl: restAjax.baseUrl,
+ newsContentUrl: restAjax.baseUrl,
+ libraryUrl: restAjax.baseUrl,
+ venueUrl: restAjax.baseUrl,
+ activityUrl: restAjax.baseUrl,
+ volunteerUrl: restAjax.baseUrl,
+ activityUrl: restAjax.baseUrl,
+ volunteerUrl: restAjax.baseUrl,
+ liveUrl: restAjax.baseUrl,
+ liveRecordUrl: restAjax.baseUrl,
+ socialUrl: restAjax.baseUrl,
+ shopUrl: restAjax.url + "xzshop",
+ restAjax: restAjax,
+ shopImgUrl: restAjax.url + "xzshop/route/file/download/true/",
+ dialog: dialog,
+ onLaunch: function () {
+ // 展示本地存储能力
+ var logs = wx.getStorageSync('logs') || []
+ logs.unshift(Date.now())
+ wx.setStorageSync('logs', logs)
- // 登录
- wx.login({
- success: res => {
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
- }
- })
- // 获取用户信息
- wx.getSetting({
- success: res => {
- if (res.authSetting['scope.userInfo']) {
- // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
- wx.getUserInfo({
+ // 登录
+ wx.login({
success: res => {
- // 可以将 res 发送给后台解码出 unionId
- this.globalData.userInfo = res.userInfo
-
- // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
- // 所以此处加入 callback 以防止这种情况
- if (this.userInfoReadyCallback) {
- this.userInfoReadyCallback(res)
- }
+ // 发送 res.code 到后台换取 openId, sessionKey, unionId
}
- })
- }
- }
- })
- },
- globalData: {
- userInfo: null,
- curLat: -1,
- curLng: -1,
- }
+ })
+ // 获取用户信息
+ wx.getSetting({
+ success: res => {
+ if (res.authSetting['scope.userInfo']) {
+ // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
+ wx.getUserInfo({
+ success: res => {
+ // 可以将 res 发送给后台解码出 unionId
+ this.globalData.userInfo = res.userInfo
+
+ // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+ // 所以此处加入 callback 以防止这种情况
+ if (this.userInfoReadyCallback) {
+ this.userInfoReadyCallback(res)
+ }
+ }
+ })
+ }
+ }
+ })
+ },
+ globalData: {
+ userInfo: null,
+ curLat: -1,
+ curLng: -1,
+ carList: []
+ }
})
\ No newline at end of file
diff --git a/app.json b/app.json
index 15169b4..85c4699 100644
--- a/app.json
+++ b/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": [
{
diff --git a/pages/center/center.js b/pages/center/center.js
index 3a818fd..b77a26e 100644
--- a/pages/center/center.js
+++ b/pages/center/center.js
@@ -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',
diff --git a/pages/center/center.wxml b/pages/center/center.wxml
index ed6b883..fd29c68 100644
--- a/pages/center/center.wxml
+++ b/pages/center/center.wxml
@@ -45,6 +45,14 @@
购物车
+
+
+ 收货地址
+
+
+
+ 我的订单
+
+
+
+
+ 省份
+
+
+
+ {{tempProvIndex==-1 ? '请选择省份':tempProvArray[tempProvIndex].areaName}}
+
+
+
+
+
+
+ 市
+
+
+
+ {{cityIndex==-1? '请选择市':cityArray[cityIndex].areaName}}
+
+
+
+
+
+
+ 区、县
+
+
+
+ {{countyIndex==-1? '请选择区县':countyArray[countyIndex].areaName}}
+
+
+
+
+
+
+ 乡镇街道
+
+
+
+ {{villageIndex==-1?'请选择乡镇街道':villageArray[villageIndex].areaName}}
+
+
+
+
+
+
+ 详细地址
+
+
+
+
+
+ 姓名
+
+
+
+
+
+ 联系方式
+
+
+
+
+
+ 邮政编码
+
+
+
+
+保存
\ No newline at end of file
diff --git a/subpages/addshopaddress/addshopaddress.wxss b/subpages/addshopaddress/addshopaddress.wxss
new file mode 100644
index 0000000..27e72fb
--- /dev/null
+++ b/subpages/addshopaddress/addshopaddress.wxss
@@ -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%;
+}
\ No newline at end of file
diff --git a/subpages/editshopaddress/editshopaddress.js b/subpages/editshopaddress/editshopaddress.js
new file mode 100644
index 0000000..a4198b7
--- /dev/null
+++ b/subpages/editshopaddress/editshopaddress.js
@@ -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;
+
+ }
+})
\ No newline at end of file
diff --git a/subpages/editshopaddress/editshopaddress.json b/subpages/editshopaddress/editshopaddress.json
new file mode 100644
index 0000000..8340eab
--- /dev/null
+++ b/subpages/editshopaddress/editshopaddress.json
@@ -0,0 +1,4 @@
+{
+ "usingComponents": {},
+ "navigationBarTitleText": "收货地址修改"
+}
\ No newline at end of file
diff --git a/subpages/editshopaddress/editshopaddress.wxml b/subpages/editshopaddress/editshopaddress.wxml
new file mode 100644
index 0000000..ac1a5cb
--- /dev/null
+++ b/subpages/editshopaddress/editshopaddress.wxml
@@ -0,0 +1,74 @@
+
+
+
+ {{detailBean.areaName}}
+
+
+ 省份
+
+
+
+ {{tempProvIndex==-1 ? '请选择省份':tempProvArray[tempProvIndex].areaName}}
+
+
+
+
+
+
+ 市
+
+
+
+ {{cityIndex==-1? '请选择市':cityArray[cityIndex].areaName}}
+
+
+
+
+
+
+ 区、县
+
+
+
+ {{countyIndex==-1? '请选择区县':countyArray[countyIndex].areaName}}
+
+
+
+
+
+
+ 乡镇街道
+
+
+
+ {{villageIndex==-1?'请选择乡镇街道':villageArray[villageIndex].areaName}}
+
+
+
+
+
+
+ 详细地址
+
+
+
+
+
+ 姓名
+
+
+
+
+
+ 联系方式
+
+
+
+
+
+ 邮政编码
+
+
+
+
+保存
\ No newline at end of file
diff --git a/subpages/editshopaddress/editshopaddress.wxss b/subpages/editshopaddress/editshopaddress.wxss
new file mode 100644
index 0000000..20832cc
--- /dev/null
+++ b/subpages/editshopaddress/editshopaddress.wxss
@@ -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;
+}
\ No newline at end of file
diff --git a/subpages/goodsaddress/goodsaddress.js b/subpages/goodsaddress/goodsaddress.js
new file mode 100644
index 0000000..f2d0581
--- /dev/null
+++ b/subpages/goodsaddress/goodsaddress.js
@@ -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'
+ })
+ },
+})
\ No newline at end of file
diff --git a/subpages/goodsaddress/goodsaddress.json b/subpages/goodsaddress/goodsaddress.json
new file mode 100644
index 0000000..99a8774
--- /dev/null
+++ b/subpages/goodsaddress/goodsaddress.json
@@ -0,0 +1,4 @@
+{
+ "usingComponents": {},
+ "navigationBarTitleText": "收货地址"
+}
\ No newline at end of file
diff --git a/subpages/goodsaddress/goodsaddress.wxml b/subpages/goodsaddress/goodsaddress.wxml
new file mode 100644
index 0000000..ffecd0f
--- /dev/null
+++ b/subpages/goodsaddress/goodsaddress.wxml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ {{item.areaName}}
+ {{item.shopAddressContent}}
+ {{item.shopAddressName}} {{item.shopAddressPhone}}
+
+
+
+
+
+
+
+
+
+ 暂无数据
+
+ 新增收货地址
+
+
\ No newline at end of file
diff --git a/subpages/goodsaddress/goodsaddress.wxss b/subpages/goodsaddress/goodsaddress.wxss
new file mode 100644
index 0000000..b024cc7
--- /dev/null
+++ b/subpages/goodsaddress/goodsaddress.wxss
@@ -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%;
+}
\ No newline at end of file
diff --git a/subpages/goodscar/goodscar.js b/subpages/goodscar/goodscar.js
index 55a6f3a..f0cd204 100644
--- a/subpages/goodscar/goodscar.js
+++ b/subpages/goodscar/goodscar.js
@@ -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
+ })
+ }
})
\ No newline at end of file
diff --git a/subpages/goodscar/goodscar.wxml b/subpages/goodscar/goodscar.wxml
index 187b84c..4095d88 100644
--- a/subpages/goodscar/goodscar.wxml
+++ b/subpages/goodscar/goodscar.wxml
@@ -3,11 +3,27 @@
-
+
-
+
-
+
+ ¥{{item.goodsPrice}}
+ {{item.goodsStandarName}}
+
+
+ 销量{{item.goodsSalesVolume}}
+ {{item.goodsNotFreight ==1 ? '不包邮':'包邮'}}
+
+
+
+
+ {{item.carAmount}}
+
+
+
+
+
@@ -18,4 +34,15 @@
暂无数据
-
\ No newline at end of file
+
+
+
+
+
+
+ ¥
+ {{totalPrice}}
+
+ 去结算
+
+
\ No newline at end of file
diff --git a/subpages/goodscar/goodscar.wxss b/subpages/goodscar/goodscar.wxss
index ecad7d5..d96ddc6 100644
--- a/subpages/goodscar/goodscar.wxss
+++ b/subpages/goodscar/goodscar.wxss
@@ -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 .goods-img{}
-.goods-content{
+.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%;
+
+}
+
+.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;
}
\ No newline at end of file
diff --git a/subpages/goodsdetail/goodsdetail.js b/subpages/goodsdetail/goodsdetail.js
index 311ce03..ca58ec6 100644
--- a/subpages/goodsdetail/goodsdetail.js
+++ b/subpages/goodsdetail/goodsdetail.js
@@ -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('购物车无数据')
}
}
})
\ No newline at end of file
diff --git a/subpages/goodsdetail/goodsdetail.wxml b/subpages/goodsdetail/goodsdetail.wxml
index 6cb7388..b41c699 100644
--- a/subpages/goodsdetail/goodsdetail.wxml
+++ b/subpages/goodsdetail/goodsdetail.wxml
@@ -71,13 +71,13 @@
-
+
- {{carList.length}}
+ {{carNum>99? '99+':carNum}}
购物车
- 添加购物车
+ 加入购物车
\ No newline at end of file
diff --git a/subpages/goodsorder/goodsorder.js b/subpages/goodsorder/goodsorder.js
new file mode 100644
index 0000000..8918d75
--- /dev/null
+++ b/subpages/goodsorder/goodsorder.js
@@ -0,0 +1,66 @@
+// subpages/goodsorder/goodsorder.js
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad(options) {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide() {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload() {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh() {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom() {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage() {
+
+ }
+})
\ No newline at end of file
diff --git a/subpages/goodsorder/goodsorder.json b/subpages/goodsorder/goodsorder.json
new file mode 100644
index 0000000..3928faa
--- /dev/null
+++ b/subpages/goodsorder/goodsorder.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/subpages/goodsorder/goodsorder.wxml b/subpages/goodsorder/goodsorder.wxml
new file mode 100644
index 0000000..d01a740
--- /dev/null
+++ b/subpages/goodsorder/goodsorder.wxml
@@ -0,0 +1,2 @@
+
+subpages/goodsorder/goodsorder.wxml
diff --git a/subpages/goodsorder/goodsorder.wxss b/subpages/goodsorder/goodsorder.wxss
new file mode 100644
index 0000000..1af25b1
--- /dev/null
+++ b/subpages/goodsorder/goodsorder.wxss
@@ -0,0 +1 @@
+/* subpages/goodsorder/goodsorder.wxss */
\ No newline at end of file
diff --git a/subpages/images/ic_add_circle_icon.png b/subpages/images/ic_add_circle_icon.png
new file mode 100644
index 0000000..09f0577
Binary files /dev/null and b/subpages/images/ic_add_circle_icon.png differ
diff --git a/subpages/images/ic_arrow_cir.png b/subpages/images/ic_arrow_cir.png
new file mode 100755
index 0000000..e710ce5
Binary files /dev/null and b/subpages/images/ic_arrow_cir.png differ
diff --git a/subpages/images/ic_cb_checked.png b/subpages/images/ic_cb_checked.png
new file mode 100644
index 0000000..fec766e
Binary files /dev/null and b/subpages/images/ic_cb_checked.png differ
diff --git a/subpages/images/ic_cb_unchecked.png b/subpages/images/ic_cb_unchecked.png
new file mode 100644
index 0000000..dd6618d
Binary files /dev/null and b/subpages/images/ic_cb_unchecked.png differ
diff --git a/subpages/images/ic_del_circle_icon.png b/subpages/images/ic_del_circle_icon.png
new file mode 100644
index 0000000..477058a
Binary files /dev/null and b/subpages/images/ic_del_circle_icon.png differ
diff --git a/subpages/images/ic_edit_icon.png b/subpages/images/ic_edit_icon.png
new file mode 100644
index 0000000..d691718
Binary files /dev/null and b/subpages/images/ic_edit_icon.png differ