You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
3.8 KiB
187 lines
3.8 KiB
// pages/order/joinOrder/index.js
|
|
import commonApi from "../../../utils/https/common"
|
|
import util from "../../../utils/util"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
team_id:null,
|
|
info:{},
|
|
mobile:"",
|
|
detail:{},
|
|
oid:null
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if(!options.id){
|
|
util.back()
|
|
return;
|
|
}
|
|
this.setData({
|
|
team_id:options.id,
|
|
info:{
|
|
team_id:options.id
|
|
}
|
|
})
|
|
commonApi.user_post("uservice/user/getMyInfo",{}).then(res=>{
|
|
if(res.code==1){
|
|
this.setData({
|
|
mobile:res.data.mobile
|
|
})
|
|
// if(options.uid && res.data.id && options.uid==res.data.id && !options.mid){
|
|
// // 是发起人的话 直接取团购订单详情页
|
|
// wx.redirectTo({
|
|
// url: '/pages/info/groupOrderInfo/index?id='+options.oid,
|
|
// })
|
|
// }
|
|
}
|
|
})
|
|
if(options.oid){
|
|
this.setData({
|
|
oid:options.oid
|
|
})
|
|
// 如果是编辑来的
|
|
commonApi.user_post("team_order/get_team_detail",{
|
|
order_id:options.oid
|
|
}).then(res=>{
|
|
if(res.code==1){
|
|
if(options.mid){
|
|
let item = res.data.list.members.find(i=>i.id==options.mid);
|
|
let info = {
|
|
team_id:options.id,
|
|
member_id:options.mid,
|
|
name:item.name,
|
|
id_number:item.id_number,
|
|
mobile:item.mobile
|
|
}
|
|
this.setData({
|
|
info:info
|
|
})
|
|
}
|
|
res.data.list.order_info = res.data.list.order_info?JSON.parse(res.data.list.order_info):null
|
|
this.setData({
|
|
detail:res.data
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
changeName:function(e){
|
|
let info = this.data.info
|
|
info.name=e.detail.value
|
|
this.setData({
|
|
info:info
|
|
})
|
|
},
|
|
changeId:function(e){
|
|
let info = this.data.info
|
|
info.id_number=e.detail.value
|
|
this.setData({
|
|
info:info
|
|
})
|
|
},
|
|
submit:function(e){
|
|
let info = this.data.info;
|
|
// wx.redirectTo({
|
|
// url: '/pages/order/joinOrder/success/index?id='+this.data.team_id+'&oid='+this.data.oid
|
|
// })
|
|
// return;
|
|
if(!info.name){
|
|
wx.showToast({
|
|
title: '请输入姓名',
|
|
icon:'none'
|
|
})
|
|
return;
|
|
}
|
|
if(info.id_number.length!=18){
|
|
wx.showToast({
|
|
title: '请输入正确的身份证号码',
|
|
icon:'none'
|
|
})
|
|
return;
|
|
}
|
|
let service="team_order/appoint"
|
|
if(info.member_id){
|
|
// 编辑的
|
|
service="team_order/update"
|
|
}
|
|
else {
|
|
info.type=2
|
|
info.mobile = this.data.mobile
|
|
}
|
|
commonApi.user_post(service,info).then(res=>{
|
|
if(res.code==1){
|
|
wx.showToast({
|
|
title: '操作成功',
|
|
icon:'success'
|
|
})
|
|
setTimeout(()=>{
|
|
if(info.member_id){
|
|
// 如果是编辑来的 直接返回
|
|
util.back()
|
|
}
|
|
else {
|
|
// 如果是添加的话 去添加成功页
|
|
wx.redirectTo({
|
|
url: 'success/index&id='+this.data.team_id+'&oid='+this.data.oid
|
|
})
|
|
}
|
|
},500)
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|