购物车、收货地址管理
This commit is contained in:
parent
4901d6c43f
commit
27f2fce932
105
app.js
105
app.js
@ -3,59 +3,60 @@ var restAjax = require('utils/restAjax.js');
|
|||||||
var dialog = require('utils/dialog.js');
|
var dialog = require('utils/dialog.js');
|
||||||
// + 'https://www.xzszwhy.cn/usercenter'
|
// + 'https://www.xzszwhy.cn/usercenter'
|
||||||
App({
|
App({
|
||||||
loginUrl: restAjax.baseUrl,
|
loginUrl: restAjax.baseUrl,
|
||||||
usercenterUrl: restAjax.baseUrl,
|
usercenterUrl: restAjax.baseUrl,
|
||||||
newsUrl: restAjax.baseUrl,
|
newsUrl: restAjax.baseUrl,
|
||||||
newsContentUrl: restAjax.baseUrl,
|
newsContentUrl: restAjax.baseUrl,
|
||||||
libraryUrl: restAjax.baseUrl,
|
libraryUrl: restAjax.baseUrl,
|
||||||
venueUrl: restAjax.baseUrl,
|
venueUrl: restAjax.baseUrl,
|
||||||
activityUrl: restAjax.baseUrl,
|
activityUrl: restAjax.baseUrl,
|
||||||
volunteerUrl: restAjax.baseUrl,
|
volunteerUrl: restAjax.baseUrl,
|
||||||
activityUrl: restAjax.baseUrl,
|
activityUrl: restAjax.baseUrl,
|
||||||
volunteerUrl: restAjax.baseUrl,
|
volunteerUrl: restAjax.baseUrl,
|
||||||
liveUrl: restAjax.baseUrl,
|
liveUrl: restAjax.baseUrl,
|
||||||
liveRecordUrl: restAjax.baseUrl,
|
liveRecordUrl: restAjax.baseUrl,
|
||||||
socialUrl: restAjax.baseUrl,
|
socialUrl: restAjax.baseUrl,
|
||||||
shopUrl: restAjax.url + "xzshop",
|
shopUrl: restAjax.url + "xzshop",
|
||||||
restAjax: restAjax,
|
restAjax: restAjax,
|
||||||
shopImgUrl: restAjax.url + "xzshop/route/file/download/true/",
|
shopImgUrl: restAjax.url + "xzshop/route/file/download/true/",
|
||||||
dialog: dialog,
|
dialog: dialog,
|
||||||
onLaunch: function () {
|
onLaunch: function () {
|
||||||
// 展示本地存储能力
|
// 展示本地存储能力
|
||||||
var logs = wx.getStorageSync('logs') || []
|
var logs = wx.getStorageSync('logs') || []
|
||||||
logs.unshift(Date.now())
|
logs.unshift(Date.now())
|
||||||
wx.setStorageSync('logs', logs)
|
wx.setStorageSync('logs', logs)
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
wx.login({
|
wx.login({
|
||||||
success: res => {
|
|
||||||
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 获取用户信息
|
|
||||||
wx.getSetting({
|
|
||||||
success: res => {
|
|
||||||
if (res.authSetting['scope.userInfo']) {
|
|
||||||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
|
||||||
wx.getUserInfo({
|
|
||||||
success: res => {
|
success: res => {
|
||||||
// 可以将 res 发送给后台解码出 unionId
|
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
||||||
this.globalData.userInfo = res.userInfo
|
|
||||||
|
|
||||||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
||||||
// 所以此处加入 callback 以防止这种情况
|
|
||||||
if (this.userInfoReadyCallback) {
|
|
||||||
this.userInfoReadyCallback(res)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
// 获取用户信息
|
||||||
}
|
wx.getSetting({
|
||||||
})
|
success: res => {
|
||||||
},
|
if (res.authSetting['scope.userInfo']) {
|
||||||
globalData: {
|
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
||||||
userInfo: null,
|
wx.getUserInfo({
|
||||||
curLat: -1,
|
success: res => {
|
||||||
curLng: -1,
|
// 可以将 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: []
|
||||||
|
}
|
||||||
})
|
})
|
6
app.json
6
app.json
@ -40,7 +40,11 @@
|
|||||||
"pages/serviceActivityDetail/serviceActivityDetail",
|
"pages/serviceActivityDetail/serviceActivityDetail",
|
||||||
"pages/shop/shopcategory",
|
"pages/shop/shopcategory",
|
||||||
"subpages/goodsdetail/goodsdetail",
|
"subpages/goodsdetail/goodsdetail",
|
||||||
"subpages/goodscar/goodscar"
|
"subpages/goodscar/goodscar",
|
||||||
|
"subpages/goodsaddress/goodsaddress",
|
||||||
|
"subpages/goodsorder/goodsorder",
|
||||||
|
"subpages/addshopaddress/addshopaddress",
|
||||||
|
"subpages/editshopaddress/editshopaddress"
|
||||||
],
|
],
|
||||||
"subPackages": [
|
"subPackages": [
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,19 @@ Page({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 购物车
|
//收货地址
|
||||||
|
toAddressManage() {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/subpages/goodsaddress/goodsaddress',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//我的订单
|
||||||
|
toShopOrder() {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/subpages/goodsorder/goodsorder',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
//购物车
|
||||||
toShopCar() {
|
toShopCar() {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/subpages/goodscar/goodscar',
|
url: '/subpages/goodscar/goodscar',
|
||||||
|
@ -45,6 +45,14 @@
|
|||||||
<image src="../../images/share.png"></image>
|
<image src="../../images/share.png"></image>
|
||||||
<view class="title">购物车</view>
|
<view class="title">购物车</view>
|
||||||
</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">
|
<!-- <view class="main-box">
|
||||||
<image src="../../images/setting.png"></image>
|
<image src="../../images/setting.png"></image>
|
||||||
<view class="title">设置</view>
|
<view class="title">设置</view>
|
||||||
|
@ -1,296 +1,297 @@
|
|||||||
var app = getApp();
|
var app = getApp();
|
||||||
Page({
|
Page({
|
||||||
/**
|
/**
|
||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
randomName: true,
|
randomName: true,
|
||||||
showPhone: true,
|
showPhone: true,
|
||||||
gotCode: false,
|
gotCode: false,
|
||||||
restTime: 120,
|
restTime: 120,
|
||||||
timer: '',
|
timer: '',
|
||||||
indicatorDots: true,
|
indicatorDots: true,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
token: '',
|
token: '',
|
||||||
news: {
|
news: {
|
||||||
newsUrl: app.newsUrl,
|
newsUrl: app.newsUrl,
|
||||||
bannerList: [],
|
bannerList: [],
|
||||||
newsList: []
|
newsList: []
|
||||||
|
},
|
||||||
|
venue: {
|
||||||
|
venueUrl: app.venueUrl,
|
||||||
|
venueList: []
|
||||||
|
},
|
||||||
|
activity: {
|
||||||
|
activityUrl: app.activityUrl,
|
||||||
|
activityList: []
|
||||||
|
},
|
||||||
|
live: {
|
||||||
|
liveUrl: app.liveUrl,
|
||||||
|
liveList: []
|
||||||
|
},
|
||||||
|
usercenterUrl: app.usercenterUrl,
|
||||||
|
isConfirm: false
|
||||||
},
|
},
|
||||||
venue: {
|
doLogin: function () {
|
||||||
venueUrl: app.venueUrl,
|
var self = this;
|
||||||
venueList: []
|
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) {
|
||||||
|
console.log(data)
|
||||||
|
var tokenArray = data.data.split('_');
|
||||||
|
var token = tokenArray[0];
|
||||||
|
var isRandomUsername = tokenArray[1];
|
||||||
|
self.setData({
|
||||||
|
token: token
|
||||||
|
})
|
||||||
|
wx.setStorageSync('token', token);
|
||||||
|
wx.setStorageSync('isRandomUsername', isRandomUsername)
|
||||||
|
}, function (code, data) {
|
||||||
|
app.dialog.msg(data.msg);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(res)
|
||||||
|
app.dialog.msg('登录失败!' + res.errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
activity: {
|
doGetBanner: function () {
|
||||||
activityUrl: app.activityUrl,
|
var self = this;
|
||||||
activityList: []
|
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), {
|
||||||
},
|
newsDirectoriesId: 'eab0ca3c-d35d-4c02-9397-ace2bdd10fc1',
|
||||||
live: {
|
page: 1,
|
||||||
liveUrl: app.liveUrl,
|
rows: 5
|
||||||
liveList: []
|
}, null, function (code, data) {
|
||||||
},
|
|
||||||
usercenterUrl: app.usercenterUrl,
|
|
||||||
isConfirm: false
|
|
||||||
},
|
|
||||||
doLogin: function () {
|
|
||||||
var self = this;
|
|
||||||
wx.login({
|
|
||||||
success(res) {
|
|
||||||
if (res.code) {
|
|
||||||
app.restAjax.post(app.restAjax.path('{url}/wechat-miniapp/sign/default', [app.loginUrl]), {
|
|
||||||
jsCode: res.code
|
|
||||||
}, null, function (code, data) {
|
|
||||||
console.log(data)
|
|
||||||
var tokenArray = data.data.split('_');
|
|
||||||
var token = tokenArray[0];
|
|
||||||
var isRandomUsername = tokenArray[1];
|
|
||||||
self.setData({
|
self.setData({
|
||||||
token: token
|
'news.bannerList': data.rows
|
||||||
})
|
})
|
||||||
wx.setStorageSync('token', token);
|
}, function (code, data) {
|
||||||
wx.setStorageSync('isRandomUsername', isRandomUsername)
|
|
||||||
}, function (code, data) {
|
|
||||||
app.dialog.msg(data.msg);
|
app.dialog.msg(data.msg);
|
||||||
});
|
});
|
||||||
} else {
|
},
|
||||||
console.log(res)
|
doGetVenueList: function () {
|
||||||
app.dialog.msg('登录失败!' + res.errMsg);
|
var self = this;
|
||||||
}
|
app.restAjax.get(app.restAjax.path('{venueUrl}/app/venuesinfo/listpagevenuesinforelease', [self.data.venue.venueUrl]), {
|
||||||
}
|
page: 1,
|
||||||
})
|
rows: 3,
|
||||||
},
|
latitude: app.globalData.curLat,
|
||||||
doGetBanner: function () {
|
longitude: app.globalData.curLng,
|
||||||
var self = this;
|
orderKey: "",
|
||||||
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), {
|
}, null, function (code, data) {
|
||||||
newsDirectoriesId: 'eab0ca3c-d35d-4c02-9397-ace2bdd10fc1',
|
for (var i = 0, item; item = data.rows[i++];) {
|
||||||
page: 1,
|
item.venuePanoramaArray = item.venuePanorama.split(',');
|
||||||
rows: 5
|
}
|
||||||
}, null, function (code, data) {
|
self.setData({
|
||||||
self.setData({
|
'venue.venueList': data.rows
|
||||||
'news.bannerList': data.rows
|
});
|
||||||
})
|
}, function (code, data) {
|
||||||
}, function (code, data) {
|
app.dialog.msg(data.msg);
|
||||||
app.dialog.msg(data.msg);
|
});
|
||||||
});
|
},
|
||||||
},
|
doGetActivityList: function () {
|
||||||
doGetVenueList: function () {
|
var self = this;
|
||||||
var self = this;
|
app.restAjax.get(app.restAjax.path('{activityUrl}/app/activitylibrary/listpageactivitylibraryrelease', [self.data.activity.activityUrl]), {
|
||||||
app.restAjax.get(app.restAjax.path('{venueUrl}/app/venuesinfo/listpagevenuesinforelease', [self.data.venue.venueUrl]), {
|
page: 1,
|
||||||
page: 1,
|
rows: 3
|
||||||
rows: 3,
|
}, null, function (code, data) {
|
||||||
latitude:app.globalData.curLat,
|
console.log(data);
|
||||||
longitude:app.globalData.curLng,
|
for (var i = 0, item; item = data.rows[i++];) {
|
||||||
orderKey:"",
|
item.activityImageArray = item.activityImage.split(',');
|
||||||
}, null, function (code, data) {
|
}
|
||||||
for (var i = 0, item; item = data.rows[i++];) {
|
self.setData({
|
||||||
item.venuePanoramaArray = item.venuePanorama.split(',');
|
'activity.activityList': data.rows
|
||||||
}
|
});
|
||||||
self.setData({
|
}, function (code, data) {
|
||||||
'venue.venueList': data.rows
|
app.dialog.msg(data.msg);
|
||||||
});
|
});
|
||||||
}, function (code, data) {
|
},
|
||||||
app.dialog.msg(data.msg);
|
doGetNewsList: function () {
|
||||||
});
|
var self = this;
|
||||||
},
|
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), {
|
||||||
doGetActivityList: function () {
|
newsDirectoriesParentId: 'f497904b-7727-4832-891c-604c36ae4167',
|
||||||
var self = this;
|
page: 1,
|
||||||
app.restAjax.get(app.restAjax.path('{activityUrl}/app/activitylibrary/listpageactivitylibraryrelease', [self.data.activity.activityUrl]), {
|
rows: 5
|
||||||
page: 1,
|
}, null, function (code, data) {
|
||||||
rows: 3
|
self.setData({
|
||||||
}, null, function (code, data) {
|
'news.newsList': data.rows
|
||||||
console.log(data);
|
})
|
||||||
for (var i = 0, item; item = data.rows[i++];) {
|
}, function (code, data) {
|
||||||
item.activityImageArray = item.activityImage.split(',');
|
app.dialog.msg(data.msg);
|
||||||
}
|
});
|
||||||
self.setData({
|
},
|
||||||
'activity.activityList': data.rows
|
doGetLiveList: function () {
|
||||||
});
|
var self = this;
|
||||||
}, function (code, data) {
|
app.restAjax.get(app.restAjax.path('{liveUrl}/app/liveplan/listpageliveplanrelease', [self.data.live.liveUrl]), {
|
||||||
app.dialog.msg(data.msg);
|
page: 1,
|
||||||
});
|
rows: 4
|
||||||
},
|
}, null, function (code, data) {
|
||||||
doGetNewsList: function () {
|
self.setData({
|
||||||
var self = this;
|
'live.liveList': data.rows
|
||||||
app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [self.data.news.newsUrl]), {
|
})
|
||||||
newsDirectoriesParentId: 'f497904b-7727-4832-891c-604c36ae4167',
|
}, function (code, data) {
|
||||||
page: 1,
|
app.dialog.msg(data.msg);
|
||||||
rows: 5
|
});
|
||||||
}, null, function (code, data) {
|
},
|
||||||
self.setData({
|
goNewsDetail: function (event) {
|
||||||
'news.newsList': data.rows
|
wx.navigateTo({
|
||||||
})
|
url: '../newsDetail/newsDetail?templateRecordUrl=' + event.currentTarget.dataset.templateRecordUrl,
|
||||||
}, function (code, data) {
|
})
|
||||||
app.dialog.msg(data.msg);
|
},
|
||||||
});
|
goNewsList: function (event) {
|
||||||
},
|
wx.navigateTo({
|
||||||
doGetLiveList: function () {
|
url: '../newsList/newsList?type=' + event.currentTarget.dataset.type,
|
||||||
var self = this;
|
})
|
||||||
app.restAjax.get(app.restAjax.path('{liveUrl}/app/liveplan/listpageliveplanrelease', [self.data.live.liveUrl]), {
|
},
|
||||||
page: 1,
|
goVolunteer: function () {
|
||||||
rows: 4
|
wx.navigateTo({
|
||||||
}, null, function (code, data) {
|
url: '../volunteer/volunteer',
|
||||||
self.setData({
|
})
|
||||||
'live.liveList': data.rows
|
},
|
||||||
})
|
goBroadcast: function () {
|
||||||
}, function (code, data) {
|
wx.navigateTo({
|
||||||
app.dialog.msg(data.msg);
|
url: '../broadcast/broadcast',
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
goNewsDetail: function (event) {
|
goVenue: function () {
|
||||||
wx.navigateTo({
|
wx.switchTab({
|
||||||
url: '../newsDetail/newsDetail?templateRecordUrl=' + event.currentTarget.dataset.templateRecordUrl,
|
url: '../venue/venue',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goNewsList: function (event) {
|
goVenueDetail: function (event) {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '../newsList/newsList?type=' + event.currentTarget.dataset.type,
|
url: '../venueDetail/venueDetail?venuesInfoId=' + event.currentTarget.dataset.venuesInfoId,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goVolunteer: function () {
|
goBroadcastDetail: function (event) {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '../volunteer/volunteer',
|
url: '../broadcastDetail/broadcastDetail?livePlanId=' + event.currentTarget.dataset.livePlanId,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goBroadcast: function () {
|
goActivity: function () {
|
||||||
wx.navigateTo({
|
wx.switchTab({
|
||||||
url: '../broadcast/broadcast',
|
url: '../activity/activity',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goVenue: function () {
|
goActivityDetail: function (event) {
|
||||||
wx.switchTab({
|
wx.navigateTo({
|
||||||
url: '../venue/venue',
|
url: '../activityDetail/activityDetail?id=' + event.currentTarget.dataset.activityLibraryId
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goVenueDetail: function (event) {
|
goHeritage: function () {
|
||||||
wx.navigateTo({
|
wx.switchTab({
|
||||||
url: '../venueDetail/venueDetail?venuesInfoId=' + event.currentTarget.dataset.venuesInfoId,
|
url: '../heritage/heritage',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goBroadcastDetail: function (event) {
|
goCultureDetail: function (event) {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '../broadcastDetail/broadcastDetail?livePlanId=' + event.currentTarget.dataset.livePlanId,
|
url: '../cultureDetail/cultureDetail?libraryId=' + event.currentTarget.dataset.libraryId,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goActivity: function () {
|
// 获取用户信息
|
||||||
wx.switchTab({
|
getUserInfo: function () {
|
||||||
url: '../activity/activity',
|
var self = this
|
||||||
})
|
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/user/getappuser', [app.usercenterUrl]), {}, {
|
||||||
},
|
headers: {
|
||||||
goActivityDetail: function (event) {
|
token: self.data.token
|
||||||
wx.navigateTo({
|
}
|
||||||
url: '../activityDetail/activityDetail?id=' + event.currentTarget.dataset.activityLibraryId
|
}, function (code, data) {
|
||||||
})
|
self.setData({
|
||||||
},
|
userInfo: data
|
||||||
goHeritage: function () {
|
})
|
||||||
wx.switchTab({
|
}, function (code, data) {
|
||||||
url: '../heritage/heritage',
|
app.dialog.msg(data.msg);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goCultureDetail: function (event) {
|
goTrain: function () {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '../cultureDetail/cultureDetail?libraryId=' + event.currentTarget.dataset.libraryId,
|
url: '../train/train',
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 获取用户信息
|
goTravel: function () {
|
||||||
getUserInfo: function () {
|
wx.navigateTo({
|
||||||
var self = this
|
url: '../travel/travel',
|
||||||
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/user/getappuser', [app.usercenterUrl]), {}, {
|
})
|
||||||
headers: {
|
},
|
||||||
token: self.data.token
|
goResource: function () {
|
||||||
}
|
wx.navigateTo({
|
||||||
}, function (code, data) {
|
url: '../resource/resource',
|
||||||
self.setData({
|
})
|
||||||
userInfo: data
|
},
|
||||||
})
|
/**
|
||||||
}, function (code, data) {
|
* 生命周期函数--监听页面加载
|
||||||
app.dialog.msg(data.msg);
|
*/
|
||||||
})
|
onLoad: function (options) {
|
||||||
},
|
var self = this;
|
||||||
goTrain: function () {
|
wx.getLocation({
|
||||||
wx.navigateTo({
|
type: 'gcj02',
|
||||||
url: '../train/train',
|
success(res) {
|
||||||
})
|
// const latitude = res.latitude
|
||||||
},
|
// const longitude = res.longitude
|
||||||
goTravel: function () {
|
// const speed = res.speed
|
||||||
wx.navigateTo({
|
// const accuracy = res.accuracy
|
||||||
url: '../travel/travel',
|
app.globalData.curLng = res.longitude
|
||||||
})
|
app.globalData.curLat = res.latitude
|
||||||
},
|
}
|
||||||
goResource: function () {
|
})
|
||||||
wx.navigateTo({
|
self.doLogin();
|
||||||
url: '../resource/resource',
|
self.doGetBanner();
|
||||||
})
|
self.doGetNewsList();
|
||||||
},
|
self.doGetLiveList();
|
||||||
/**
|
self.doGetVenueList();
|
||||||
* 生命周期函数--监听页面加载
|
self.doGetActivityList();
|
||||||
*/
|
},
|
||||||
onLoad: function (options) {
|
|
||||||
var self = this;
|
|
||||||
wx.getLocation({
|
|
||||||
type: 'gcj02',
|
|
||||||
success(res) {
|
|
||||||
// const latitude = res.latitude
|
|
||||||
// const longitude = res.longitude
|
|
||||||
// const speed = res.speed
|
|
||||||
// const accuracy = res.accuracy
|
|
||||||
app.globalData.curLng=res.longitude
|
|
||||||
app.globalData.curLat=res.latitude
|
|
||||||
}
|
|
||||||
})
|
|
||||||
self.doLogin();
|
|
||||||
self.doGetBanner();
|
|
||||||
self.doGetNewsList();
|
|
||||||
self.doGetLiveList();
|
|
||||||
self.doGetVenueList();
|
|
||||||
self.doGetActivityList();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面初次渲染完成
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
*/
|
*/
|
||||||
onReady: function () {
|
onReady: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面显示
|
* 生命周期函数--监听页面显示
|
||||||
*/
|
*/
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面隐藏
|
* 生命周期函数--监听页面隐藏
|
||||||
*/
|
*/
|
||||||
onHide: function () {
|
onHide: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面卸载
|
* 生命周期函数--监听页面卸载
|
||||||
*/
|
*/
|
||||||
onUnload: function () {
|
onUnload: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面相关事件处理函数--监听用户下拉动作
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
*/
|
*/
|
||||||
onPullDownRefresh: function () {
|
onPullDownRefresh: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面上拉触底事件的处理函数
|
* 页面上拉触底事件的处理函数
|
||||||
*/
|
*/
|
||||||
onReachBottom: function () {
|
onReachBottom: function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户点击右上角分享
|
* 用户点击右上角分享
|
||||||
*/
|
*/
|
||||||
onShareAppMessage: function () {
|
onShareAppMessage: function () {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
@ -2,56 +2,61 @@
|
|||||||
var app = getApp();
|
var app = getApp();
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面的初始数据
|
* 页面的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
categoryOneList: [],
|
categoryOneList: [],
|
||||||
categorySeconList: [],
|
categorySeconList: [],
|
||||||
currentIndex: 0,
|
currentIndex: 0,
|
||||||
isHidePageLoading: false
|
isHidePageLoading: false
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.getCategroyList();
|
this.getCategroyList();
|
||||||
},
|
},
|
||||||
getCategroyList() {
|
getCategroyList() {
|
||||||
var _self = this
|
var _self = this
|
||||||
app.restAjax.get(app.restAjax.path('{shopUrl}/app/category/listztreerelease', [app.shopUrl]), null, null, function (code, data) {
|
app.restAjax.get(app.restAjax.path('{shopUrl}/app/category/listztreerelease', [app.shopUrl]), null, null, function (code, data) {
|
||||||
if (data.length == 0) {
|
if (data.length == 0) {
|
||||||
app.dialog.msg('暂无数据');
|
app.dialog.msg('暂无数据');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(data)
|
console.log(data)
|
||||||
_self.setData({
|
_self.setData({
|
||||||
categoryOneList: data,
|
categoryOneList: data,
|
||||||
categorySeconList: data[0].subList,
|
categorySeconList: data[0].subList,
|
||||||
isHidePageLoading: true
|
isHidePageLoading: true
|
||||||
})
|
})
|
||||||
}, function (code, data) {
|
}, function (code, data) {
|
||||||
app.dialog.msg(data.msg);
|
app.dialog.msg(data.msg);
|
||||||
_self.setData({
|
_self.setData({
|
||||||
isHidePageLoading: true
|
isHidePageLoading: true
|
||||||
})
|
})
|
||||||
}, function () {
|
}, function () {
|
||||||
wx.hideLoading();
|
wx.hideLoading();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
chooseOne(event) {
|
chooseOne(event) {
|
||||||
var index = event.currentTarget.dataset.index
|
var index = event.currentTarget.dataset.index
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this.setData({
|
this.setData({
|
||||||
currentIndex: index,
|
currentIndex: index,
|
||||||
categorySeconList: _self.data.categoryOneList[index].subList
|
categorySeconList: _self.data.categoryOneList[index].subList
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goList(e) {
|
goList(e) {
|
||||||
var id = e.currentTarget.dataset.id
|
var id = e.currentTarget.dataset.id
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '/subpages/goodslist/goodslist?id=' + id,
|
url: '/subpages/goodslist/goodslist?id=' + id,
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
showCar() {
|
||||||
|
wx.navigateTo({
|
||||||
|
url: '/subpages/goodscar/goodscar',
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
@ -23,5 +23,9 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-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>
|
</view>
|
||||||
<page-loading wx:else></page-loading>
|
<page-loading wx:else></page-loading>
|
@ -119,4 +119,30 @@ page {
|
|||||||
.category-empty image {
|
.category-empty image {
|
||||||
width: 96rpx;
|
width: 96rpx;
|
||||||
height: 66rpx;
|
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
|
// subpages/goodscar/goodscar.js
|
||||||
|
var app = getApp();
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -7,6 +8,8 @@ Page({
|
|||||||
data: {
|
data: {
|
||||||
carList: [],
|
carList: [],
|
||||||
isHidePageloading: false,
|
isHidePageloading: false,
|
||||||
|
imgUrl: app.shopImgUrl,
|
||||||
|
totalPrice: 0.0
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,6 +25,7 @@ Page({
|
|||||||
carList: value,
|
carList: value,
|
||||||
isHidePageloading: true
|
isHidePageloading: true
|
||||||
})
|
})
|
||||||
|
_self.countPrice()
|
||||||
} else {
|
} else {
|
||||||
_self.setData({
|
_self.setData({
|
||||||
isHidePageloading: true
|
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}}">
|
<view wx:if="{{carList.length>0}}">
|
||||||
<block wx:for="{{carList}}" wx:for-item="item" wx:for-index="index" wx:key="index">
|
<block wx:for="{{carList}}" wx:for-item="item" wx:for-index="index" wx:key="index">
|
||||||
<view class="goods-item">
|
<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">
|
<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">
|
<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>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -18,4 +34,15 @@
|
|||||||
<text class="hint">暂无数据</text>
|
<text class="hint">暂无数据</text>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
<page-loading wx:else></page-loading>
|
<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;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.goods-item {}
|
.goods-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
padding: 10rpx;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.check {
|
.check {
|
||||||
width: 48rpx;
|
width: 48rpx;
|
||||||
height: 48rpx;
|
height: 48rpx;
|
||||||
|
min-width: 48rpx;
|
||||||
|
min-height: 48rpx;
|
||||||
|
max-height: 48rpx;
|
||||||
|
max-width: 48rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.goods {
|
.goods {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: flex-start;
|
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;
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ Page({
|
|||||||
curStandardIndex: 0,
|
curStandardIndex: 0,
|
||||||
imgUrl: app.shopImgUrl,
|
imgUrl: app.shopImgUrl,
|
||||||
carList: [],
|
carList: [],
|
||||||
|
carNum: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,6 +27,33 @@ Page({
|
|||||||
this.getGoodsDetail();
|
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() {
|
getGoodsDetail() {
|
||||||
var _self = this
|
var _self = this
|
||||||
@ -121,9 +149,33 @@ Page({
|
|||||||
addToCar() {
|
addToCar() {
|
||||||
//判断购物车中是否存在该商品
|
//判断购物车中是否存在该商品
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
var pos = -1;
|
||||||
for (let i = 0; i < _self.data.carList.length; i++) {
|
for (let i = 0; i < _self.data.carList.length; i++) {
|
||||||
var item = _self.data.carList[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>
|
||||||
<view class="icon-btn">
|
<view class="icon-btn">
|
||||||
<view class="car-icon">
|
<view class="car-icon">
|
||||||
<view class="car">
|
<view class="car" bindtap="openCar">
|
||||||
<image src="/subpages/images/ic_shop_car_icon.png" mode="aspectFill"></image>
|
<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>购物车</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="car-add">添加购物车</view>
|
<view class="car-add" bindtap="addToCar">加入购物车</view>
|
||||||
</view>
|
</view>
|
||||||
</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