This commit is contained in:
pplokijuhyg 2019-12-20 14:16:22 +08:00
commit c890ad64a2
14 changed files with 356 additions and 52 deletions

View File

@ -6,7 +6,7 @@ Component({
properties: {
left: String,
right: String,
ifarrow: Boolean
ifarrow: Boolean,
},
/**
@ -20,6 +20,12 @@ Component({
* 组件的方法列表
*/
methods: {
get(e){
// console.log(e)
this.triggerEvent('myevent', e.detail.value)
},
choose(e){
}
}
})

View File

@ -1,11 +1,11 @@
<view class="shuru">
<view class="left">{{left}}</view>
<view class="right"wx:if="{{ifarrow}}">
<view class="right"wx:if="{{ifarrow}}" bindtap="choose">
<text class="shurupla">{{right}}</text>
<view class="arrow"></view>
</view>
<view class="right" wx:else>
<input type="text" placeholder-class="shurupla" class="shuru1" placeholder="{{right}}" value=""/>
<input type="text" placeholder-class="shurupla" class="shuru1" placeholder="{{right}}" value="" bindinput="get" no="0" data-left="{{left}}"/>
</view>
</view>

View File

@ -4,6 +4,12 @@ Component({
* 组件的属性列表
*/
properties: {
username:String,
tel:String,
address:String,
isdefault:String,
youzheng:String,
addressid:String
},
@ -18,6 +24,12 @@ Component({
* 组件的方法列表
*/
methods: {
del(){
// console.log("del")
this.triggerEvent('delete')
},
setdefault(){
this.triggerEvent('default',this.data.addressid)
}
}
})

View File

@ -7,15 +7,27 @@
padding-bottom: 27rpx;
;
.left {
width: 551rpx;
width: 576rpx;
height: 119rpx;
.userinfo {
color: #333333;
font-size: 26rpx;
text-indent: 30rpx;
text-indent: 16xrpx;
margin-top: 41rpx;
display: flex;
justify-content: space-between;
.username{
display: flex;
flex-wrap: nowrap;
.username1{
width: 140rpx;
overflow: hidden;
}
.tel{
margin-right: 6rpx;
}
}
}
.addr {
color: #999999;
@ -32,6 +44,8 @@
border-radius: 50%;
background-color: #EAEAEA;
float: left;
margin-right: -14rpx;
}
.selected {
background-color: #47C877;
@ -45,7 +59,7 @@
}
.path {
// float: left;
line-height: 39rpx;
line-height: 25rpx;
}
}
}

View File

@ -1,16 +1,30 @@
<view class="address">
<view class="left">
<view class="userinfo">
<text class="username">于于宇 15698857895</text>
<text>邮政编码677467</text>
<view class="username">
<view class="username1">{{username}}</view>
<view class="tel">{{tel}}</view>
</view>
<view class="addr">
<view class="select selected"></view>
<view>邮政编码:{{youzheng}}</view>
</view>
<view class="addr" wx:if="{{isdefault=='1'}}">
<view class="select selected" bindtap="setdefault"></view>
<!-- <view class="default"></view> -->
<view class="path">默认
中国大陆 山东省 青岛市 即墨区 纯阳路 某某某小区</view>
<view class="path">
<text>默认</text>
{{address}}
</view>
</view>
<view class="addr" wx:else>
<view class="select" bindtap="setdefault"></view>
<!-- <view class="default"></view> -->
<view class="path">
<text>设为默认</text>
{{address}}
</view>
</view>
</view>
<view class="line"></view>
<view class="right">删除</view>
<view class="right" bindtap="del">删除</view>
</view>

View File

@ -8,19 +8,33 @@
}
.address .left {
width: 551rpx;
width: 576rpx;
height: 119rpx;
}
.address .left .userinfo {
color: #333333;
font-size: 26rpx;
text-indent: 30rpx;
text-indent: 16xrpx;
margin-top: 41rpx;
display: flex;
justify-content: space-between;
}
.address .left .userinfo .username {
display: flex;
flex-wrap: nowrap;
}
.address .left .userinfo .username .username1 {
width: 140rpx;
overflow: hidden;
}
.address .left .userinfo .username .tel {
margin-right: 6rpx;
}
.address .left .addr {
color: #999999;
font-size: 24rpx;
@ -37,6 +51,7 @@
border-radius: 50%;
background-color: #EAEAEA;
float: left;
margin-right: -14rpx;
}
.address .left .addr .selected {
@ -51,7 +66,7 @@
}
.address .left .addr .path {
line-height: 39rpx;
line-height: 25rpx;
}
.address .line {

View File

@ -1,70 +1,170 @@
// pages/addaddress/addaddress.js
import { request } from "../../utils/bin"
Page({
/**
* 页面的初始数据
*/
data: {
canshu: [],
no: 0,
userid:"",
show: false,
arealist:[],
area:["请选择","请选择","请选择"]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
onLoad: function (options) {
request({
url: "User/getArea",
urldata:{
parent_id:0
},
}).then((res)=>{
console.log(res)
this.setData({
arealist:res.data.result
})
console.log(this.data.arealist)
})
},
save() {
wx.navigateTo({
url: "/pages/chooseaddr/chooseaddr"
bindPickerChange(e) {
console.log(e)
},
showPopup() {
this.setData({ show: true });
},
onClose() {
this.setData({ show: false });
},
onMyEvent(e) {
console.log(e)
for (let i = 0; i < 8; i++) {
if (i == e.currentTarget.dataset.no) {
this.data.canshu[i] = e.detail
}
}
console.log(this.data.canshu)
},
choose(e){
console.log(e.currentTarget.dataset.id,e.currentTarget.dataset.name,e.currentTarget.dataset)
let type=parseInt(e.currentTarget.dataset.type)
request({
url: "User/getArea",
urldata:{
parent_id:e.currentTarget.dataset.id
},
}).then((res)=>{
console.log(res)
if(res.data.result.length){
this.setData({
arealist1:res.data.result
})
// this.data.area[type]=e.currentTarget.dataset.name
console.log(this.data.area,123)
}
// for(let i in this.data.area){
// if(i==type){
// this.data.area[i]=e.currentTarget.dataset.name
// }
// }
this.data.area[0]=e.currentTarget.dataset.name
console.log(this.data.area,this.data.arealist)
})
},
save() {
// wx.navigateTo({
// url: "/pages/chooseaddr/chooseaddr"
// })
request({
url: "User/validateOpenid",
}).then((res)=>{
console.log(res,1452)
this.setData({
userid:res.data.data.user_id
})
request({
url: "User/addAddress",
urldata:{
user_id:this.data.userid
},
method:"POST",
data: {
address: "Wesrdtfyguhijkl",
city: "339",
consignee: "srdtfyguhijokl",
country: 1,
district: "361",
is_default: 0,
mobile: "19953879035",
province: "338",
twon: 0,
user_id: "9",
zipcode: "271103",
}
}).then((res)=>{
console.log(res)
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
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 () {
}
})

View File

@ -1,6 +1,9 @@
{
"usingComponents": {
"shuru": "/components/addaddress/shuru/shuru",
"addradd": "/components/chooseaddr/addradd/addradd"
"addradd": "/components/chooseaddr/addradd/addradd",
"van-popup": "../utils/dist/popup/index",
"van-tab": "../utils/dist/tab/index",
"van-tabs": "../utils/dist/tabs/index"
}
}

View File

@ -5,4 +5,13 @@
bottom: 102rpx;
left: 50rpx;
}
.choose{
width:100%;
height: 500rpx;
.item{
text-indent: 15rpx;
line-height: 70rpx;
}
}
}

View File

@ -1,10 +1,42 @@
<view class="addaddress">
<shuru left="收件人" right="姓名需和身份证一致"></shuru>
<shuru left="手机号" right="请填入常用的手机号码"></shuru>
<shuru left="国家" right="CN中国大陆" ifarrow="{{true}}"></shuru>
<shuru left="城市信息" right="北京市 北京市 东城区" ifarrow="{{true}}"></shuru>
<shuru left="街道地址" right="街道地址"></shuru>
<shuru left="邮政编码" right="邮政编码"></shuru>
<shuru left="身份证号" right="可为空,部分商品需要"></shuru>
<addradd text="保存地址" class="btn1" bindtap="save"></addradd>
<shuru left="收件人" right="姓名需和身份证一致" bindmyevent="onMyEvent" data-no="0"></shuru>
<shuru left="手机号" right="请填入常用的手机号码" bindmyevent="onMyEvent" data-no="1"></shuru>
<picker bindchange="bindPickerChange" value="{{item.item_id?item.item_id:0}}" range="{{info.goods.goods_spec_list?info.goods.goods_spec_list:['默认规格']}}">
<shuru left="国家" right="CN中国大陆" ifarrow="{{true}}" data-no="2"></shuru>
</picker>
<!-- <picker bindchange="bindPickerChange" value="{{item.item_id?item.item_id:0}}" range="{{info.goods.goods_spec_list?info.goods.goods_spec_list:['默认规格']}}">
<shuru left="城市信息" right="北京市 北京市 东城区" ifarrow="{{true}}" data-no="3"></shuru>
</picker> -->
<view bindtap="showPopup">
<shuru left="城市信息" right="北京市 北京市 东城区" ifarrow="{{true}}" data-no="3"></shuru>
</view>
<van-popup show="{{ show }}" position="bottom" bind:close="onClose">
<van-tabs class="tab" swipe-threshold="5">
<van-tab title="{{area[0]}}">
<view class="choose">
<view class="item" wx:for="{{arealist}}" bindtap="choose" data-type="0" data-id="{{item.id}}" data-name="{{item.name}}">
{{item.name}}
</view>
</view>
</van-tab>
<van-tab title="{{area[1]}}">
<view class="choose">
<view class="item" wx:for="{{arealist1}}" data-type="1" data-id="{{item.id}}" data-name="{{item.name}}">
{{item.name}}
</view>
</view>
</van-tab>
<van-tab title="{{area[2]}}">
<view class="choose">
<view class="item" wx:for="{{arealist2}}" data-type="2" data-id="{{item.id}}" data-name="{{item.name}}">
{{item.name}}
</view>
</view>
</van-tab>
</van-tabs>
</van-popup>
<shuru left="街道地址" right="街道地址" bindmyevent="onMyEvent" data-no="4"></shuru>
<shuru left="邮政编码" right="邮政编码" bindmyevent="onMyEvent" data-no="5"></shuru>
<shuru left="身份证号" right="可为空,部分商品需要" bindmyevent="onMyEvent" data-no="6"></shuru>
<addradd text="保存地址" class="btn1" bindtap="save"></addradd>
</view>

View File

@ -7,3 +7,13 @@
bottom: 102rpx;
left: 50rpx;
}
.addaddress .choose {
width: 100%;
height: 500rpx;
}
.addaddress .choose .item {
text-indent: 15rpx;
line-height: 70rpx;
}

View File

@ -1,10 +1,13 @@
// pages/chooseaddr/chooseaddr.js
import { request } from "../../utils/bin"
Page({
/**
* 页面的初始数据
*/
data: {
addresslist:[],
userid:""
},
@ -12,6 +15,24 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
request({
url: "User/validateOpenid",
}).then((res)=>{
this.setData({
userid:res.data.data.user_id
})
request({
url: "User/getAddressList",
urldata:{
user_id:this.data.userid
},
}).then((res)=>{
console.log(res)
this.setData({
addresslist:res.data.result
})
})
})
},
add() {
@ -19,6 +40,74 @@ Page({
url: "/pages/addaddress/addaddress"
})
},
// user_id/8/id/215
delete(e){
let t=this
wx.showModal({
title: '确认',
content: '要删除这个地址吗?',
success(){
console.log(e.currentTarget.dataset.id)
request({
url: "User/validateOpenid",
}).then((res)=>{
t.setData({
userid:res.data.data.user_id
})
request({
url: "User/del_address",
urldata:{
user_id:res.data.data.user_id,
id:e.currentTarget.dataset.id
},
}).then((res)=>{
console.log(res)
request({
url: "User/getAddressList",
urldata:{
user_id:t.data.userid
},
}).then((res)=>{
console.log(res)
t.setData({
addresslist:res.data.result
})
})
})
})
}
})
},
setdefault(e){
console.log(e.currentTarget.dataset.id)
request({
url: "User/setDefaultAddress",
urldata:{
user_id:this.data.userid,
address_id:e.currentTarget.dataset.id
},
}).then((res)=>{
console.log(res)
request({
url: "User/getAddressList",
urldata:{
user_id:this.data.userid
},
}).then((res)=>{
console.log(res)
this.setData({
addresslist:res.data.result
})
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -1,13 +1,13 @@
<view class="chooseaddress">
<view class="addr">
<view class="addr" wx:for="{{addresslist}}">
<address binddelete="delete" binddefault="setdefault"data-id="{{item.address_id}}" username="{{item.consignee}}" address="{{item.address}}" tel="{{item.mobile}}" youzheng="{{item.zipcode}}" isdefault="{{item.is_default}}"></address>
</view>
<!-- <view class="addr">
<address></address>
</view>
<view class="addr">
<address></address>
</view>
<view class="addr">
<address></address>
</view>
</view> -->
<view class="btn1" bindtap="add">
<addradd text="添加地址"></addradd>
</view>

View File

@ -23,12 +23,12 @@ let request = function (obj){
}
}
url+=text
if(method == "POST" || method == "post"){
if(header == undefined){
header ={}
}
header['content-type'] = "application/x-www-form-urlencoded"
}
// if(method == "POST" || method == "post"){
// if(header == undefined){
// header ={}
// }
// header['content-type'] = "application/x-www-form-urlencoded"
// }
if(data == undefined){
data = {}
}