Initial Commit
This commit is contained in:
195
pages/my/my_address/my_address.js
Normal file
195
pages/my/my_address/my_address.js
Normal file
@ -0,0 +1,195 @@
|
||||
// pages/my/my_address/my_address.js
|
||||
const app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
select: false,
|
||||
dataList: [],
|
||||
orderAddress: false,
|
||||
addressIdXz: '',
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
})
|
||||
wx.request({
|
||||
url: app.globalData.ip + '/wisdommining/api/user/getUserAddress',
|
||||
method: 'GET',
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
userId: app.globalData.userId
|
||||
},
|
||||
success: res => {
|
||||
console.log(res)
|
||||
wx.hideLoading()
|
||||
if (res.data.code == 1) {
|
||||
let dataList = res.data.value;
|
||||
for (let i = 0; i < dataList.length; i++) {
|
||||
dataList[i].select = false;
|
||||
if (dataList[i].id == this.data.addressIdXz) {
|
||||
dataList[i].select = true;
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
dataList: dataList
|
||||
})
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '提示!',
|
||||
content: res.data.message,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
if (options.orderAddress) {
|
||||
this.setData({
|
||||
orderAddress: options.orderAddress,
|
||||
addressIdXz: options.addressId
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
//选择地址
|
||||
select: function (e) {
|
||||
console.log("aaaaaaaaaaa")
|
||||
let index = e.currentTarget.dataset.index;
|
||||
let dataList = this.data.dataList;
|
||||
for (let i = 0; i < dataList.length; i++) {
|
||||
dataList[i].select = false;
|
||||
}
|
||||
this.setData({
|
||||
dataList: dataList
|
||||
})
|
||||
const pages = getCurrentPages()
|
||||
const prevPage = pages[pages.length - 2] // 上一页
|
||||
|
||||
// 调用上一个页面的setData 方法,将数据存储
|
||||
if(this.data.dataList.length>0){
|
||||
prevPage.setData({
|
||||
address: dataList[index].addressProvince + dataList[index].addressCity + dataList[index].addressArea + dataList[index].addressDetailed,
|
||||
addressId: dataList[index].id,
|
||||
province: dataList[index].addressProvince,
|
||||
orderPick:2,
|
||||
})
|
||||
}else{
|
||||
prevPage.setData({
|
||||
address: '选择收货方式',
|
||||
addressId: '',
|
||||
province: '',
|
||||
orderPick:2,
|
||||
})
|
||||
}
|
||||
|
||||
wx.navigateBack();
|
||||
},
|
||||
//编辑
|
||||
edit: function (e) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/my/my_address/my_address_details/my_address_details?id=' + e.currentTarget.dataset.id,
|
||||
})
|
||||
},
|
||||
|
||||
//新增
|
||||
add: function (e) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/my/my_address/my_address_details/my_address_details',
|
||||
})
|
||||
},
|
||||
//删除
|
||||
del: function (e) {
|
||||
var id = e.currentTarget.dataset.id
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确认要删除此地址吗?',
|
||||
success: suc => {
|
||||
if (suc.confirm) {
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
})
|
||||
wx.request({
|
||||
url: app.globalData.ip + '/wisdommining/api/user/delUserAddress',
|
||||
method: 'DELETE',
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
id: id,
|
||||
},
|
||||
success: res => {
|
||||
console.log(res)
|
||||
wx.hideLoading()
|
||||
if (res.data.code == 1) {
|
||||
wx.showToast({
|
||||
title: '删除成功~',
|
||||
icon: 'none',
|
||||
success: s => {
|
||||
this.onShow()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '提示!',
|
||||
content: res.data.message,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
})
|
4
pages/my/my_address/my_address.json
Normal file
4
pages/my/my_address/my_address.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "收货地址"
|
||||
}
|
32
pages/my/my_address/my_address.wxml
Normal file
32
pages/my/my_address/my_address.wxml
Normal file
@ -0,0 +1,32 @@
|
||||
<view class='contAll' wx:for='{{dataList}}' wx:key="index">
|
||||
<view class="title">收货人信息</view>
|
||||
<view class="cont display_J_B" catchtap="{{orderAddress?'select':''}}" data-index='{{index}}'>
|
||||
<view class="contL">
|
||||
<view class="details ">{{item.addressDetailed}}
|
||||
<view class="default" wx:if="{{item.addressDefault==1}}">默认</view>
|
||||
</view>
|
||||
<view class="phone">{{item.addressProvince}} {{item.addressCity}} {{item.addressArea}}</view>
|
||||
<view class="phone"><text style="margin-right:30rpx;">姓名:{{item.addressName}}</text>手机号码:{{item.addressPhone}}</view>
|
||||
</view>
|
||||
<view class="contR display_A_C" wx:if="{{orderAddress}}">
|
||||
<view class="select">
|
||||
<image src="{{item.select?'/icon/checked.png':'/icon/check.png'}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="btnAll display_J_B" wx:if="{{!orderAddress}}">
|
||||
<view class="btn" catchtap="edit" data-id="{{item.id}}">编 辑</view>
|
||||
<view class="btn" catchtap="del" data-id="{{item.id}}">删 除</view>
|
||||
<view class="btnX"></view>
|
||||
</view>
|
||||
<view class="btnAll display_J_B" wx:if="{{orderAddress}}">
|
||||
<view class="btn" style="width:100%;" catchtap="edit" data-id="{{item.id}}">编 辑</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="empty" wx:if="{{dataList.length==0}}">
|
||||
<image src="/icon/adress_empty.png"></image>
|
||||
<view>暂无收货地址请添加~</view>
|
||||
</view>
|
||||
<view class="height100"></view>
|
||||
<view class="height100"></view>
|
||||
<view class="add" catchtap="add">+新建收货地址</view>
|
121
pages/my/my_address/my_address.wxss
Normal file
121
pages/my/my_address/my_address.wxss
Normal file
@ -0,0 +1,121 @@
|
||||
page{
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.contAll {
|
||||
width: 750rpx;
|
||||
background-color: #ffffff;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 720rpx;
|
||||
height: 80rpx;
|
||||
background-color: #ffffff;
|
||||
line-height: 80rpx;
|
||||
font-size: 32rpx;
|
||||
color: #333333;
|
||||
padding-left: 30rpx;
|
||||
border-bottom: 2rpx solid #f9f9f9;
|
||||
}
|
||||
|
||||
.cont {
|
||||
width: 690rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.contL {
|
||||
width: 590rpx;
|
||||
}
|
||||
|
||||
.details {
|
||||
max-width: 460rpx;
|
||||
position: relative;
|
||||
font-size: 28rpx;
|
||||
color: #444444;
|
||||
line-height: 40rpx;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.default {
|
||||
width: 80rpx;
|
||||
height: 40rpx;
|
||||
background-color: #ee7b1e;
|
||||
border-radius: 20rpx;
|
||||
line-height: 40rpx;
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
color: #ffffff;
|
||||
position: absolute;
|
||||
right: -130rpx;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.phone {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
line-height: 40rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.select {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
}
|
||||
|
||||
.select image {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
}
|
||||
|
||||
.btnAll {
|
||||
width: 750rpx;
|
||||
height: 80rpx;
|
||||
background-color: #ffffff;
|
||||
border-top: 1rpx #eeeeee solid;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.btnAll .btn {
|
||||
width: 50%;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
|
||||
.btnX {
|
||||
width: 2rpx;
|
||||
height: 56rpx;
|
||||
background-color: #eeeeee;
|
||||
position: absolute;
|
||||
top: 12rpx;
|
||||
left: 374rpx;
|
||||
}
|
||||
|
||||
.add {
|
||||
width: 690rpx;
|
||||
height: 80rpx;
|
||||
background-color: #ee7b1e;
|
||||
border-radius: 40rpx;
|
||||
font-size: 34rpx;
|
||||
line-height: 80rpx;
|
||||
text-align: center;
|
||||
color: #f0f0f0;
|
||||
position: fixed;
|
||||
bottom: 80rpx;
|
||||
left: 30rpx;
|
||||
}
|
||||
|
||||
.empty {
|
||||
width: 344rpx;
|
||||
margin: 300rpx auto;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty image {
|
||||
width: 344rpx;
|
||||
height: 198rpx;
|
||||
margin-bottom: 50rpx;
|
||||
}
|
206
pages/my/my_address/my_address_details/my_address_details.js
Normal file
206
pages/my/my_address/my_address_details/my_address_details.js
Normal file
@ -0,0 +1,206 @@
|
||||
// pages/my/my_address/my_address_details/my_address_details.js
|
||||
const app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
region: ['', '', ''],
|
||||
default: true,
|
||||
name: '',
|
||||
phone: '',
|
||||
addr: '',
|
||||
id: '',
|
||||
version: 0,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
if (options.id) {
|
||||
wx.setNavigationBarTitle({
|
||||
title: '编辑地址',
|
||||
})
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
})
|
||||
wx.request({
|
||||
url: app.globalData.ip + '/wisdommining/api/user/getUserAddressDetail',
|
||||
method: 'GET',
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
id: options.id,
|
||||
},
|
||||
success: res => {
|
||||
console.log(res)
|
||||
wx.hideLoading()
|
||||
if (res.data.code == 1) {
|
||||
var data = res.data.value;
|
||||
this.setData({
|
||||
id: options.id,
|
||||
name: data.addressName,
|
||||
addr: data.addressDetailed,
|
||||
phone: data.addressPhone,
|
||||
region: [data.addressProvince, data.addressCity, data.addressArea],
|
||||
default: data.addressDefault == 1 ? true : false,
|
||||
})
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '提示!',
|
||||
content: res.data.message,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
//默认
|
||||
default: function (e) {
|
||||
this.setData({
|
||||
default: !this.data.default
|
||||
})
|
||||
},
|
||||
//选择地址
|
||||
bindRegionChange: function (e) {
|
||||
console.log('picker发送选择改变,携带值为', e.detail.value)
|
||||
this.setData({
|
||||
region: e.detail.value
|
||||
})
|
||||
},
|
||||
//新增 保存
|
||||
add: function (e) {
|
||||
var phone = this.data.phone;
|
||||
var name = this.data.name;
|
||||
var addr = this.data.addr;
|
||||
var region = this.data.region;
|
||||
if (phone == '' || phone.length != 11) {
|
||||
wx.showToast({
|
||||
title: '请输入正确的手机号~',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (name == '') {
|
||||
wx.showToast({
|
||||
title: '请输入姓名~',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (region[0] == '') {
|
||||
wx.showToast({
|
||||
title: '请选择地址~',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (addr == '') {
|
||||
wx.showToast({
|
||||
title: '请输入街道地址~',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
})
|
||||
wx.request({
|
||||
url: app.globalData.ip + '/wisdommining/api/user/addUserAddress',
|
||||
method: 'POST',
|
||||
data: {
|
||||
id:parseInt(this.data.id),
|
||||
addressName: name,
|
||||
addressPhone: phone,
|
||||
addressProvince: region[0],
|
||||
addressCity: region[1],
|
||||
addressArea: region[2],
|
||||
addressDetailed: addr,
|
||||
addressDefault: this.data.default ? 1 : 0,
|
||||
wxuserId:app.globalData.userId,
|
||||
},
|
||||
success: res => {
|
||||
console.log(res)
|
||||
wx.hideLoading()
|
||||
if (res.data.code == 1) {
|
||||
wx.showToast({
|
||||
title: this.data.id == '' ? '添加成功~' : '修改成功~',
|
||||
icon: 'none',
|
||||
success: s => {
|
||||
setTimeout((t) => {
|
||||
wx.navigateBack()
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
}else {
|
||||
wx.showModal({
|
||||
title: '提示!',
|
||||
content: res.data.message,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
name: function (e) {
|
||||
this.setData({
|
||||
name: e.detail.value
|
||||
})
|
||||
},
|
||||
phone: function (e) {
|
||||
this.setData({
|
||||
phone: e.detail.value
|
||||
})
|
||||
},
|
||||
addr: function (e) {
|
||||
this.setData({
|
||||
addr: e.detail.value
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
})
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "新增地址"
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<view class="cont">
|
||||
<view class="data display_J_S display_A_C">
|
||||
<view class="title">收货人姓名</view>
|
||||
<view class="ipt">
|
||||
<input type="text" value="{{name}}" bindinput="name" placeholder="请输入姓名" placeholder-style="color: #999999;"></input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="data display_J_S display_A_C">
|
||||
<view class="title">手机号码</view>
|
||||
<view class="ipt">
|
||||
<input type="number" value="{{phone}}" bindinput="phone" placeholder="请输入手机号码" placeholder-style="color: #999999;"></input>
|
||||
</view>
|
||||
</view>
|
||||
<picker mode="region" bindchange="bindRegionChange" value="{{region}}">
|
||||
<view class="data display_J_S display_A_C">
|
||||
<view class="title">所在地区</view>
|
||||
<view class="ipt">
|
||||
|
||||
<view class="picker GStitleOne" wx:if="{{region[0]!=''}}">
|
||||
{{region[0]}} {{region[1]}} {{region[2]}}
|
||||
</view>
|
||||
<view class="picker" style="color: #999999;" wx:if="{{region[0]==''}}">请选择地址</view>
|
||||
|
||||
</view>
|
||||
<view class="down display_A_C">
|
||||
<image src="/icon/address-down.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</picker>
|
||||
<view class="data display_J_S display_A_C" style="border:none;">
|
||||
<view class="title">街道地址</view>
|
||||
<view class="ipt">
|
||||
<input type="text" value="{{addr}}" bindinput="addr" placeholder="请输入街道地址" placeholder-style="color: #999999;"></input>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="default display_J_S display_A_C" catchtap="default">
|
||||
<image src="{{default?'/icon/checked.png':'/icon/check.png'}}" catchtap="default"></image>
|
||||
<view>默认地址</view>
|
||||
</view>
|
||||
<view class="btn" catchtap="add">保存</view>
|
@ -0,0 +1,78 @@
|
||||
.cont {
|
||||
width: 690rpx;
|
||||
padding: 0 30rpx;
|
||||
margin: 20rpx auto;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.data {
|
||||
width: 100%;
|
||||
height: 110rpx;
|
||||
line-height: 110rpx;
|
||||
border-bottom: 1rpx solid #e5e5e5;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
width: 190rpx;
|
||||
}
|
||||
|
||||
.ipt input {
|
||||
width: 500rpx;
|
||||
height: 110rpx;
|
||||
line-height: 110rpx;
|
||||
border: none;
|
||||
font-size: 28rpx;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 690rpx;
|
||||
height: 80rpx;
|
||||
background-color: #ee7b1e;
|
||||
border-radius: 40rpx;
|
||||
font-size: 32rpx;
|
||||
line-height: 80rpx;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
margin: 400rpx auto 40rpx;
|
||||
}
|
||||
|
||||
.ipt .picker {
|
||||
width: 450rpx;
|
||||
height: 110rpx;
|
||||
line-height: 110rpx;
|
||||
border: none;
|
||||
font-size: 28rpx;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.down {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 34rpx;
|
||||
}
|
||||
|
||||
.down image {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
.default {
|
||||
width: 690rpx;
|
||||
padding: 0 30rpx;
|
||||
height: 110rpx;
|
||||
background-color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.default image {
|
||||
width: 42rpx;
|
||||
height: 42rpx;
|
||||
margin-right: 50rpx;
|
||||
}
|
Reference in New Issue
Block a user