Initial Commit

This commit is contained in:
quantulr
2024-05-06 15:34:15 +08:00
commit e3a0666d5a
307 changed files with 28969 additions and 0 deletions

View 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 () {
},
})

View File

@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "新增地址"
}

View File

@ -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>

View File

@ -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;
}