|
|
@ -1,6 +1,7 @@ |
|
|
// pages/order/components/contact/index.js
|
|
|
// pages/order/components/contact/index.js
|
|
|
import userApi from "../../../../utils/https/user" |
|
|
import userApi from "../../../../utils/https/user" |
|
|
import commonApi from "../../../../utils/https/common" |
|
|
import commonApi from "../../../../utils/https/common" |
|
|
|
|
|
import util from "../../../../utils/util.js" |
|
|
let app = getApp() |
|
|
let app = getApp() |
|
|
Component({ |
|
|
Component({ |
|
|
/** |
|
|
/** |
|
|
@ -18,6 +19,26 @@ Component({ |
|
|
type:{ |
|
|
type:{ |
|
|
type:String, |
|
|
type:String, |
|
|
value:"" |
|
|
value:"" |
|
|
|
|
|
}, |
|
|
|
|
|
productNum:{ |
|
|
|
|
|
type:Number, |
|
|
|
|
|
value:1, |
|
|
|
|
|
observer(nv, ov, path) { |
|
|
|
|
|
if (nv) { |
|
|
|
|
|
let num = nv-this.data.selectLinkman.length |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
showNum:num |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
is_authentication:{// 是否实名,0否1是,默认实名
|
|
|
|
|
|
type:String, |
|
|
|
|
|
value:'' |
|
|
|
|
|
}, |
|
|
|
|
|
is_real_name:{// 是否是一证一票,0否1是,
|
|
|
|
|
|
type:String, |
|
|
|
|
|
value:'' |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -29,11 +50,39 @@ Component({ |
|
|
linkmanList:[], |
|
|
linkmanList:[], |
|
|
showMask:false, |
|
|
showMask:false, |
|
|
editId:null, |
|
|
editId:null, |
|
|
isGroup:null |
|
|
isGroup:null, |
|
|
|
|
|
showManList:[], |
|
|
|
|
|
showNum:0, |
|
|
|
|
|
showAdd:false, |
|
|
|
|
|
formData:{}, |
|
|
|
|
|
types:[], |
|
|
|
|
|
selectIndex:0, |
|
|
|
|
|
person:{}, |
|
|
|
|
|
personId:null, |
|
|
|
|
|
r:[], |
|
|
|
|
|
phone:'',//非实名时需要传的电话
|
|
|
}, |
|
|
}, |
|
|
lifetimes: { |
|
|
lifetimes: { |
|
|
attached: function() { |
|
|
attached: function() { |
|
|
// 在组件实例进入页面节点树时执行
|
|
|
// 在组件实例进入页面节点树时执行
|
|
|
|
|
|
console.log(this.properties.productNum); |
|
|
|
|
|
console.log(this.properties.is_real_name); |
|
|
|
|
|
// if (this.properties.is_real_name == '1') {
|
|
|
|
|
|
this.setData({ |
|
|
|
|
|
showNum:this.properties.productNum |
|
|
|
|
|
}) |
|
|
|
|
|
// }
|
|
|
|
|
|
// 不实名时直接获取手机号
|
|
|
|
|
|
if (this.properties.is_authentication) { |
|
|
|
|
|
commonApi.user_post("uservice/user/getMyInfo",{}).then(res=>{ |
|
|
|
|
|
if(res.code==1){ |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
phone:res.data.mobile |
|
|
|
|
|
}) |
|
|
|
|
|
this.triggerEvent("setLinkman",{phone:this.data.phone}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
// 获取默认联系人
|
|
|
// 获取默认联系人
|
|
|
commonApi.user_post("token/check").then(res=>{ |
|
|
commonApi.user_post("token/check").then(res=>{ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
@ -44,8 +93,11 @@ Component({ |
|
|
contactType:"CONTACT" |
|
|
contactType:"CONTACT" |
|
|
}).then(res=>{ |
|
|
}).then(res=>{ |
|
|
if(res.data){ |
|
|
if(res.data){ |
|
|
|
|
|
let length =[res.data].length |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
selectLinkman:[res.data] |
|
|
selectLinkman:[res.data], |
|
|
|
|
|
showNum:this.data.showNum-length, |
|
|
|
|
|
showManList:[res.data] |
|
|
}) |
|
|
}) |
|
|
this.triggerEvent("setLinkman",[res.data]) |
|
|
this.triggerEvent("setLinkman",[res.data]) |
|
|
} |
|
|
} |
|
|
@ -53,6 +105,18 @@ Component({ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
// 获取证件列表
|
|
|
|
|
|
userApi.user_post("user/getCardTypeList", {}).then(r => { |
|
|
|
|
|
console.log(r) |
|
|
|
|
|
let data = []; |
|
|
|
|
|
r.data.map(item=>{ |
|
|
|
|
|
data.push(item.title) |
|
|
|
|
|
}) |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
types: r.data, |
|
|
|
|
|
typeList:data |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
detached: function() { |
|
|
detached: function() { |
|
|
// 在组件实例被从页面节点树移除时执行
|
|
|
// 在组件实例被从页面节点树移除时执行
|
|
|
@ -61,7 +125,6 @@ Component({ |
|
|
pageLifetimes: { |
|
|
pageLifetimes: { |
|
|
show: function() { |
|
|
show: function() { |
|
|
// 页面被展示
|
|
|
// 页面被展示
|
|
|
|
|
|
|
|
|
if(this.data.editId){ |
|
|
if(this.data.editId){ |
|
|
let editId = this.data.editId; |
|
|
let editId = this.data.editId; |
|
|
userApi.user_post("user/getContactInfoById",{ |
|
|
userApi.user_post("user/getContactInfoById",{ |
|
|
@ -117,16 +180,60 @@ Component({ |
|
|
* 组件的方法列表 |
|
|
* 组件的方法列表 |
|
|
*/ |
|
|
*/ |
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
// getPhoneNumber:function(e) {
|
|
|
|
|
|
// console.log(e);
|
|
|
|
|
|
// const code = e.detail.code
|
|
|
|
|
|
// wx.request({
|
|
|
|
|
|
// url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${app.globalData.appId}&secret=${app.globalData.secret}`,
|
|
|
|
|
|
// method: 'GET',
|
|
|
|
|
|
// success:res=>{
|
|
|
|
|
|
// if(res.statusCode!==200) return
|
|
|
|
|
|
// const access_token = res.data.access_token
|
|
|
|
|
|
// wx.request({
|
|
|
|
|
|
// url: `https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=${access_token}`,
|
|
|
|
|
|
// method: 'POST',
|
|
|
|
|
|
// data: {
|
|
|
|
|
|
// code
|
|
|
|
|
|
// },
|
|
|
|
|
|
// success:data=>{
|
|
|
|
|
|
// if(data.statusCode!==200) return
|
|
|
|
|
|
// console.log(data.data.phone_info);
|
|
|
|
|
|
// debugger
|
|
|
|
|
|
// const { phoneNumber } = data.data.phone_info // 这里就是获取到的手机号
|
|
|
|
|
|
// }
|
|
|
|
|
|
// })
|
|
|
|
|
|
// }
|
|
|
|
|
|
// })
|
|
|
|
|
|
// },
|
|
|
gotoEdit:function(e){ |
|
|
gotoEdit:function(e){ |
|
|
|
|
|
userApi.user_post("user/getContactInfoById", { id: e.currentTarget.dataset.item.id }).then(res => { |
|
|
|
|
|
console.log(res); |
|
|
|
|
|
res.data.isDefault = res.data.is_default == '1' ? true : false; |
|
|
|
|
|
res.data.username = res.data.name; |
|
|
|
|
|
res.data.mobile = res.data.tel; |
|
|
|
|
|
res.data.idNumber = res.data.id_number; |
|
|
|
|
|
console.log(res.data); |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
editId:e.currentTarget.dataset.item.id |
|
|
showMask:!this.data.showMask, |
|
|
|
|
|
formData: res.data, |
|
|
|
|
|
idTypeId: res.data.idcard_type, |
|
|
|
|
|
editId:e.currentTarget.dataset.item.id, |
|
|
|
|
|
selectIndex:this.data.types.findIndex(item=>item.type == res.data.idcard_type && item.code == res.data.document_type) |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
this.showAddMask() |
|
|
}, |
|
|
}, |
|
|
showLinkman:function(){ |
|
|
showLinkman:function(){ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
showMask:!this.data.showMask |
|
|
showMask:!this.data.showMask |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
showAddMask:function(){ |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
showAdd:!this.data.showAdd, |
|
|
|
|
|
showMask:!this.data.showMask |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
cancel:function(){ |
|
|
cancel:function(){ |
|
|
let selectLinkman = this.data.selectLinkman,linkmanList = this.data.linkmanList; |
|
|
let selectLinkman = this.data.selectLinkman,linkmanList = this.data.linkmanList; |
|
|
linkmanList.map(linkman=>{ |
|
|
linkmanList.map(linkman=>{ |
|
|
@ -141,6 +248,116 @@ Component({ |
|
|
linkmanList:linkmanList |
|
|
linkmanList:linkmanList |
|
|
}) |
|
|
}) |
|
|
this.showLinkman() |
|
|
this.showLinkman() |
|
|
|
|
|
}, |
|
|
|
|
|
selectType:function(e){ |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
selectIndex:e.detail.value |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 保存
|
|
|
|
|
|
save:function(){ |
|
|
|
|
|
if (!this.data.formData.username){ |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '请输入姓名!', |
|
|
|
|
|
icon:"none" |
|
|
|
|
|
}) |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
if (!this.data.formData.mobile) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '请输入手机号码!', |
|
|
|
|
|
icon: "none" |
|
|
|
|
|
}) |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
if (!util.isTel(this.data.formData.mobile)) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '请输入正确的手机号码!', |
|
|
|
|
|
icon: "none" |
|
|
|
|
|
}) |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
// if (!this.data.idTypeId) {
|
|
|
|
|
|
// wx.showToast({
|
|
|
|
|
|
// title: '请选择证件类型!',
|
|
|
|
|
|
// icon: "none"
|
|
|
|
|
|
// })
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (!this.data.formData.idNumber) {
|
|
|
|
|
|
// wx.showToast({
|
|
|
|
|
|
// title: '请输入证件号!',
|
|
|
|
|
|
// icon: "none"
|
|
|
|
|
|
// })
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
// }
|
|
|
|
|
|
let data = this.data.formData; |
|
|
|
|
|
data.idcard_type = this.data.types[this.data.selectIndex].type; |
|
|
|
|
|
data.is_default = data.isDefault?'1':'0'; |
|
|
|
|
|
data.document_type = this.data.types[this.data.selectIndex].code; |
|
|
|
|
|
data.id_number = this.data.formData.idNumber; |
|
|
|
|
|
let service ="addNewContact"; |
|
|
|
|
|
if(this.data.editId){ |
|
|
|
|
|
data.contactId = this.data.editId; |
|
|
|
|
|
service = "editContactById"; |
|
|
|
|
|
} |
|
|
|
|
|
userApi.user_post("user/"+service,data).then(res=>{ |
|
|
|
|
|
if(res.code==1){ |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: '保存成功!', |
|
|
|
|
|
icon:"success", |
|
|
|
|
|
success:function(){ |
|
|
|
|
|
// util.back();
|
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
showAdd:!this.data.showAdd |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
//取消添加出行人
|
|
|
|
|
|
del:function(){ |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
formData:{}, |
|
|
|
|
|
showAdd:!this.data.showAdd |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 输入监听 不是双向绑定啊 绝望
|
|
|
|
|
|
nameInput:function(e){ |
|
|
|
|
|
var formData = this.data.formData; |
|
|
|
|
|
formData.username = e.detail.value; |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
formData: formData |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
idNumberInput:function(e){ |
|
|
|
|
|
var formData = this.data.formData; |
|
|
|
|
|
formData.idNumber = e.detail.value; |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
formData: formData |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
telInput:function(e){ |
|
|
|
|
|
var formData = this.data.formData; |
|
|
|
|
|
formData.mobile = e.detail.value; |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
formData: formData |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
phoneInput:function(e){ |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
phone: e.detail.value |
|
|
|
|
|
}) |
|
|
|
|
|
this.triggerEvent("setLinkman",{phone:this.data.phone}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 设为默认
|
|
|
|
|
|
setAddDefault:function(e){ |
|
|
|
|
|
var formData = this.data.formData; |
|
|
|
|
|
formData.isDefault = e.detail.value; |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
formData: formData |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
confirm:function(){ |
|
|
confirm:function(){ |
|
|
let linkmanList = this.data.linkmanList,selectLinkman = []; |
|
|
let linkmanList = this.data.linkmanList,selectLinkman = []; |
|
|
@ -149,15 +366,23 @@ Component({ |
|
|
selectLinkman.push(linkman); |
|
|
selectLinkman.push(linkman); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
if(this.properties.maxNum!=-1 && selectLinkman.length>Number(this.properties.maxNum)){ |
|
|
// 需要 改成 根据父组件的购买数量
|
|
|
wx.showToast({ |
|
|
let showNum = this.properties.productNum |
|
|
title: '最多只能选择'+this.properties.maxNum+"个出行人", |
|
|
// let showNum = this.data.showNum
|
|
|
icon:'none' |
|
|
showNum = showNum-selectLinkman.length |
|
|
}) |
|
|
let showManList = this.data.showManList |
|
|
return; |
|
|
showManList = [...selectLinkman] |
|
|
} |
|
|
// if(this.properties.maxNum!=-1 && selectLinkman.length>Number(this.properties.maxNum)){
|
|
|
|
|
|
// wx.showToast({
|
|
|
|
|
|
// title: '最多只能选择'+this.properties.maxNum+"个出行人",
|
|
|
|
|
|
// icon:'none'
|
|
|
|
|
|
// })
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
selectLinkman:selectLinkman |
|
|
selectLinkman:selectLinkman, |
|
|
|
|
|
showManList:showManList, |
|
|
|
|
|
showNum:showNum |
|
|
}) |
|
|
}) |
|
|
this.triggerEvent("setLinkman",selectLinkman) |
|
|
this.triggerEvent("setLinkman",selectLinkman) |
|
|
this.showLinkman() |
|
|
this.showLinkman() |
|
|
@ -210,17 +435,55 @@ Component({ |
|
|
wx.showLoading({ |
|
|
wx.showLoading({ |
|
|
title: '加载中', |
|
|
title: '加载中', |
|
|
}) |
|
|
}) |
|
|
let index = e.currentTarget.dataset.index,selectLinkman = this.data.selectLinkman; |
|
|
let index = e.currentTarget.dataset.index,selectLinkman = this.data.selectLinkman,showManList = this.data.showManList; |
|
|
selectLinkman.splice(index,1); |
|
|
selectLinkman.splice(index,1); |
|
|
|
|
|
showManList.splice(index,1); |
|
|
this.triggerEvent("setLinkman",selectLinkman) |
|
|
this.triggerEvent("setLinkman",selectLinkman) |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
selectLinkman:selectLinkman |
|
|
selectLinkman:selectLinkman, |
|
|
|
|
|
showManList:showManList, |
|
|
|
|
|
showNum:selectLinkman.length>0?this.data.showNum+1:1 |
|
|
}) |
|
|
}) |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
}, |
|
|
}, |
|
|
|
|
|
select:function(e) { |
|
|
|
|
|
console.log(e); |
|
|
|
|
|
let item = e.target.dataset.item |
|
|
|
|
|
if (this.properties.is_real_name == '1') { // 一证一票
|
|
|
|
|
|
this.selectIt(item) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.selectOne(item) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// 一证一票不让他多选
|
|
|
|
|
|
selectOne:function(e) { |
|
|
|
|
|
console.log(e); |
|
|
|
|
|
let item = e,linkmanList = this.data.linkmanList,num = 0 |
|
|
|
|
|
linkmanList.map(linkman=>{ |
|
|
|
|
|
if(linkman.selected==1){ |
|
|
|
|
|
num++; |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
console.log(num); |
|
|
|
|
|
linkmanList.map(linkman=>{ |
|
|
|
|
|
if(item.id==linkman.id){ |
|
|
|
|
|
// linkman.selected = linkman.selected==1?0:1;
|
|
|
|
|
|
linkman.selected = 1 |
|
|
|
|
|
}else { |
|
|
|
|
|
linkman.selected = 0 |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
console.log(linkmanList); |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
linkmanList |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 可多选
|
|
|
selectIt:function(e){ |
|
|
selectIt:function(e){ |
|
|
console.log(e,app.globalData.product) |
|
|
console.log(e,app.globalData.product) |
|
|
let item = e.currentTarget.dataset.item,linkmanList = this.data.linkmanList,num = 0,traveller_limit_num = this.properties.maxNum!=-1?this.properties.maxNum:(app.globalData.product.sku.sku_model && app.globalData.product.sku.sku_model.limit_type!=0?app.globalData.product.sku.sku_model.traveller_limit_num:-1); |
|
|
console.log(e); |
|
|
|
|
|
// let item = e.currentTarget.dataset.item,linkmanList = this.data.linkmanList,num = 0,traveller_limit_num = this.properties.maxNum!=-1?this.properties.maxNum:(app.globalData.product.sku.sku_model && app.globalData.product.sku.sku_model.limit_type!=0?app.globalData.product.sku.sku_model.traveller_limit_num:-1);
|
|
|
|
|
|
let item = e,linkmanList = this.data.linkmanList,num = 0,traveller_limit_num = this.properties.maxNum!=-1?this.properties.maxNum:(app.globalData.product.sku.sku_model && app.globalData.product.sku.sku_model.limit_type!=0?app.globalData.product.sku.sku_model.traveller_limit_num:-1); |
|
|
// 先计算出全部选中的出行人
|
|
|
// 先计算出全部选中的出行人
|
|
|
console.log(111) |
|
|
console.log(111) |
|
|
linkmanList.map(linkman=>{ |
|
|
linkmanList.map(linkman=>{ |
|
|
|