2019-12-14 11:53:14 +08:00
|
|
|
// pages/addaddress/addaddress.js
|
2019-12-20 14:03:59 +08:00
|
|
|
import { request } from "../../utils/bin"
|
2019-12-14 11:53:14 +08:00
|
|
|
Page({
|
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
2019-12-20 14:03:59 +08:00
|
|
|
canshu: [],
|
|
|
|
no: 0,
|
|
|
|
userid:"",
|
|
|
|
show: false,
|
2019-12-23 14:13:27 +08:00
|
|
|
arealist1:[],
|
|
|
|
arealist2:[],
|
|
|
|
arealist3:[],
|
|
|
|
area:["请选择","请选择","请选择"],
|
|
|
|
tagDis:[false,true,true],
|
|
|
|
active:0,
|
|
|
|
addressCity:"北京市 北京市 北京市"
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
2019-12-20 14:03:59 +08:00
|
|
|
onLoad: function (options) {
|
|
|
|
request({
|
|
|
|
url: "User/getArea",
|
|
|
|
urldata:{
|
|
|
|
parent_id:0
|
|
|
|
},
|
2019-12-23 14:13:27 +08:00
|
|
|
|
2019-12-20 14:03:59 +08:00
|
|
|
}).then((res)=>{
|
2019-12-23 14:13:27 +08:00
|
|
|
// console.log(res)
|
2019-12-20 14:03:59 +08:00
|
|
|
this.setData({
|
2019-12-23 14:13:27 +08:00
|
|
|
arealist1:res.data.result
|
2019-12-20 14:03:59 +08:00
|
|
|
})
|
|
|
|
console.log(this.data.arealist)
|
|
|
|
})
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
2019-12-20 14:03:59 +08:00
|
|
|
bindPickerChange(e) {
|
2019-12-23 14:13:27 +08:00
|
|
|
// console.log(e)
|
2019-12-20 14:03:59 +08:00
|
|
|
},
|
|
|
|
showPopup() {
|
|
|
|
this.setData({ show: true });
|
|
|
|
},
|
|
|
|
|
|
|
|
onClose() {
|
|
|
|
this.setData({ show: false });
|
|
|
|
},
|
|
|
|
onMyEvent(e) {
|
2019-12-23 14:13:27 +08:00
|
|
|
// console.log(e)
|
2019-12-20 14:03:59 +08:00
|
|
|
for (let i = 0; i < 8; i++) {
|
|
|
|
if (i == e.currentTarget.dataset.no) {
|
|
|
|
this.data.canshu[i] = e.detail
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-12-23 14:13:27 +08:00
|
|
|
// console.log(this.data.canshu)
|
2019-12-20 14:03:59 +08:00
|
|
|
},
|
2019-12-23 14:13:27 +08:00
|
|
|
choose1(e){
|
|
|
|
// console.log(e.currentTarget.dataset.id,e.currentTarget.dataset.name,e.currentTarget.dataset)
|
2019-12-20 14:03:59 +08:00
|
|
|
let type=parseInt(e.currentTarget.dataset.type)
|
|
|
|
request({
|
|
|
|
url: "User/getArea",
|
|
|
|
urldata:{
|
|
|
|
parent_id:e.currentTarget.dataset.id
|
|
|
|
},
|
|
|
|
}).then((res)=>{
|
2019-12-23 14:13:27 +08:00
|
|
|
// console.log(res)
|
2019-12-20 14:03:59 +08:00
|
|
|
this.setData({
|
2019-12-23 14:13:27 +08:00
|
|
|
arealist2:res.data.result,
|
|
|
|
active:1
|
2019-12-20 14:03:59 +08:00
|
|
|
})
|
|
|
|
// this.data.area[type]=e.currentTarget.dataset.name
|
2019-12-23 14:13:27 +08:00
|
|
|
this.setData({
|
|
|
|
tagDis:[false,false,true]
|
|
|
|
})
|
|
|
|
// console.log(this.data.area,123)
|
|
|
|
this.data.area[0]=e.currentTarget.dataset.name
|
|
|
|
// 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)
|
2019-12-20 14:03:59 +08:00
|
|
|
|
2019-12-23 14:13:27 +08:00
|
|
|
this.data.area[1]=e.currentTarget.dataset.name
|
2019-12-20 14:03:59 +08:00
|
|
|
// for(let i in this.data.area){
|
|
|
|
// if(i==type){
|
|
|
|
// this.data.area[i]=e.currentTarget.dataset.name
|
|
|
|
// }
|
|
|
|
// }
|
2019-12-23 14:13:27 +08:00
|
|
|
|
|
|
|
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")
|
|
|
|
})
|
2019-12-20 14:03:59 +08:00
|
|
|
|
2019-12-23 14:13:27 +08:00
|
|
|
|
|
|
|
},
|
|
|
|
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
|
|
|
|
// 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)
|
2019-12-20 14:03:59 +08:00
|
|
|
})
|
|
|
|
},
|
2019-12-16 18:26:28 +08:00
|
|
|
save() {
|
2019-12-20 14:03:59 +08:00
|
|
|
// wx.navigateTo({
|
|
|
|
// url: "/pages/chooseaddr/chooseaddr"
|
|
|
|
// })
|
|
|
|
request({
|
|
|
|
url: "User/validateOpenid",
|
|
|
|
}).then((res)=>{
|
2019-12-23 14:13:27 +08:00
|
|
|
// console.log(res,1452)
|
2019-12-20 14:03:59 +08:00
|
|
|
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)=>{
|
2019-12-23 14:13:27 +08:00
|
|
|
// console.log(res)
|
2019-12-20 14:03:59 +08:00
|
|
|
})
|
2019-12-16 18:26:28 +08:00
|
|
|
})
|
2019-12-20 14:03:59 +08:00
|
|
|
|
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
2019-12-20 14:03:59 +08:00
|
|
|
onReady: function () {
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
2019-12-20 14:03:59 +08:00
|
|
|
onShow: function () {
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
2019-12-20 14:03:59 +08:00
|
|
|
onHide: function () {
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
2019-12-20 14:03:59 +08:00
|
|
|
onUnload: function () {
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
2019-12-20 14:03:59 +08:00
|
|
|
onPullDownRefresh: function () {
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
2019-12-20 14:03:59 +08:00
|
|
|
onReachBottom: function () {
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
},
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
2019-12-20 14:03:59 +08:00
|
|
|
onShareAppMessage: function () {
|
2019-12-14 11:53:14 +08:00
|
|
|
|
2019-12-16 18:26:28 +08:00
|
|
|
}
|
2019-12-14 11:53:14 +08:00
|
|
|
})
|