282 lines
7.7 KiB
JavaScript
282 lines
7.7 KiB
JavaScript
// pages/addaddress/addaddress.js
|
|
import { request } from "../../utils/bin"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
canshu: [],
|
|
no: 0,
|
|
userid:"",
|
|
show: false,
|
|
arealist1:[],
|
|
arealist2:[],
|
|
arealist3:[],
|
|
area:["请选择","请选择","请选择"],
|
|
tagDis:[false,true,true],
|
|
active:0,
|
|
addressCity:"请选择 请选择 请选择",
|
|
countrys:[],
|
|
countryid:44,
|
|
nowcountry:"中国",
|
|
areaid:[]
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
request({
|
|
url: "User/getArea",
|
|
urldata:{
|
|
parent_id:0
|
|
},
|
|
|
|
}).then((res)=>{
|
|
// console.log(res)
|
|
this.setData({
|
|
arealist1:res.data.result
|
|
})
|
|
console.log(this.data.arealist)
|
|
})
|
|
|
|
request({
|
|
url: "User/getCountry",
|
|
}).then((res)=>{
|
|
let country=[]
|
|
console.log(res,10000)
|
|
for(let i=0;i<res.data.result.length;i++){
|
|
country[i]=res.data.result[i].name
|
|
}
|
|
this.setData({
|
|
countrys:country
|
|
})
|
|
})
|
|
|
|
},
|
|
bindPickerChange(e) {
|
|
console.log(e.detail.value)
|
|
let nowcountry=this.data.countrys[e.detail.value]
|
|
this.setData({
|
|
countryid:e.detail.value+1,
|
|
nowcountry:nowcountry
|
|
})
|
|
console.log(nowcountry,"zxc")
|
|
},
|
|
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)
|
|
},
|
|
choose1(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)
|
|
this.setData({
|
|
arealist2:res.data.result,
|
|
active:1
|
|
})
|
|
// this.data.area[type]=e.currentTarget.dataset.name
|
|
this.setData({
|
|
tagDis:[false,false,true]
|
|
})
|
|
// console.log(this.data.area,123)
|
|
this.data.area[0]=e.currentTarget.dataset.name
|
|
this.data.areaid[0]=e.currentTarget.dataset.id
|
|
// for(let i in this.data.area){
|
|
// if(i==type){
|
|
// this.data.area[i]=e.currentTarget.dataset.name
|
|
// }
|
|
// }
|
|
this.setData({
|
|
area:this.data.area
|
|
})
|
|
|
|
// console.log(this.data.area,this.data.arealist)
|
|
})
|
|
},
|
|
choose2(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)=>{
|
|
|
|
this.setData({
|
|
arealist3:res.data.result,
|
|
active:2,
|
|
tagDis:[false,false,false]
|
|
})
|
|
|
|
// this.data.area[type]=e.currentTarget.dataset.name
|
|
|
|
// console.log(this.data.area,123)
|
|
|
|
this.data.area[1]=e.currentTarget.dataset.name
|
|
this.data.areaid[1]=e.currentTarget.dataset.id
|
|
// for(let i in this.data.area){
|
|
// if(i==type){
|
|
// this.data.area[i]=e.currentTarget.dataset.name
|
|
// }
|
|
// }
|
|
|
|
this.setData({
|
|
area:this.data.area
|
|
})
|
|
|
|
// console.log(this.data.area,this.data.arealist)
|
|
console.log(this.data.arealist3+"001",this.data.active+"002",this.data.tagDis+"003")
|
|
})
|
|
|
|
|
|
},
|
|
choose3(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)
|
|
this.setData({
|
|
arealist1:res.data.result,
|
|
tagDis:[false,false,false],
|
|
active:1
|
|
})
|
|
// this.data.area[type]=e.currentTarget.dataset.name
|
|
|
|
// console.log(this.data.area,123)
|
|
|
|
this.data.area[2]=e.currentTarget.dataset.name
|
|
this.data.areaid[2]=e.currentTarget.dataset.id
|
|
// for(let i in this.data.area){
|
|
// if(i==type){
|
|
// this.data.area[i]=e.currentTarget.dataset.name
|
|
// }
|
|
// }}
|
|
console.log(93)
|
|
this.setData({
|
|
area:this.data.area,
|
|
show: false,
|
|
addressCity:this.data.area[0]+this.data.area[1]+this.data.area[2]
|
|
})
|
|
console.log(this.data.active,94)
|
|
// console.log(this.data.area,this.data.arealist)
|
|
})
|
|
},
|
|
save() {
|
|
// wx.navigateTo({
|
|
// url: "/pages/chooseaddr/chooseaddr"
|
|
// })
|
|
console.log(this.data.canshu)
|
|
console.log(this.data.countryid)
|
|
console.log(this.data.area)
|
|
console.log(this.data.areaid)
|
|
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: this.data.canshu[4],
|
|
city: this.data.areaid[1],
|
|
consignee: this.data.canshu[0],
|
|
country: this.data.countryid,
|
|
address: this.data.canshu[4],
|
|
is_default: 0,
|
|
mobile: this.data.canshu[1],
|
|
province: this.data.areaid[0],
|
|
twon: this.data.areaid[2],
|
|
user_id:this.data.userid,
|
|
zipcode: this.data.canshu[5],
|
|
idcard: this.data.canshu[6],
|
|
}
|
|
}).then((res)=>{
|
|
console.log(res)
|
|
})
|
|
})
|
|
|
|
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |