作者 wumengyu

发布添加搜索地区,优化个人资料性别,优化详情页,优化获取用户信息,

... ... @@ -10,9 +10,9 @@ App({
// console.log('授权过到首页');
// self.globalData.isLogin = true;
// wx.setStorageSync('isLogin', true)
// // wx.redirectTo({
// // url: '/pages/index/index', //跳转到首页
// // });
// wx.redirectTo({
// url: '/pages/index/index', //跳转到首页
// });
// } else {
// console.log('授权失效到授权页');
// self.globalData.isLogin = false;
... ... @@ -32,6 +32,17 @@ App({
// 获取用户信息
this.getUserInfo()
},
getUserInfo() {
const self = this;
wx.getUserInfo({
success: function (user) {
// console.log('获取用户信息', user);// gender:性别 0:未知、1:男、2:女
// console.log('user.userInfo',user.userInfo);
self.globalData.userInfo = user.userInfo;
}
});
},
getLogin() {
const self = this;
... ... @@ -57,7 +68,9 @@ App({
}, {}).then((ret) => {
// console.log('获取token', ret);
wx.setStorageSync('token', ret.data.token);
// console.log('user.userInfo',user.userInfo);
self.globalData.userInfo = user.userInfo;
resolve(ret.data);
// setTimeout(function () {
// wx.navigateBack({delta: 1})
... ...
... ... @@ -22,6 +22,7 @@ Page({
address_position:'',
over_time:'',
is_showRelease_modal:false,
is_select:false
},
//查看我的发布
goMyRelease() {
... ... @@ -62,6 +63,41 @@ Page({
this.setData({max_num:''});
}
},
//输入搜索内容
inputKey(e){
this.setData({search_text:e.detail.value})
},
//点击搜索
search() {
let self = this;
let url = '/portal/Send/select';
let header = {
"XX-Token": wx.getStorageSync('token')
};
let params = {
// token: wx.getStorageSync('token'),
keyword:self.data.search_text,
};
self.setData({is_select:false});
app.post(url, params, header).then((res) => {
console.log('搜索结果', res);
// wx.hideLoading();
if(+res.code === 1) {
self.setData({search_text:'',});
if(res.data.addr.length === 0) {
wx.showToast({title:'暂无此地区',icon:'none'})
}else {
self.setData({
// city_picker_list: arr,
// cityList:res.data,
city:res.data.addr[0].title,
city_id:res.data.addr[0].id,
});
}
}
})
},
//输入地点
inputAddress(e) {
this.setData({address:e.detail.value})
... ... @@ -133,6 +169,10 @@ Page({
},
//确定发布
confirmRelease(e) {
var current_city = this.data.current_city;
var city_list = this.data.city_list;
var city = this.data.city;
var is_select = this.data.is_select;//是否是通过下拉框选择城市
// else if(this.data.address_position === '') {
// wx.showToast({title:'请定位地址',icon:'none'})
// }
... ... @@ -149,8 +189,8 @@ Page({
wx.showToast({title:'请填写最高人数',icon:'none'})
}else if(this.data.current_type === undefined) {
wx.showToast({title:'请选择类别',icon:'none'})
}else if(this.data.current_city === undefined) {
wx.showToast({title:'请选择城市',icon:'none'})
}else if(current_city === undefined && city === undefined) {
wx.showToast({title:'请选择地区',icon:'none'})
}else if(this.data.date === '') {
wx.showToast({title:'请选择日期',icon:'none'})
}else if(this.data.time === '') {
... ... @@ -182,12 +222,13 @@ Page({
select_id: this.data.type_id,//类别
time: this.data.date + ' ' + this.data.time,
addr: this.data.address,
address: this.data.address_position,
// address: this.data.address_position,
address: this.data.address1,
latng: '',
over_time:this.data.over_time,// 报名截止时间
formId: e.detail.formId,
choose_addr: this.data.city_list[this.data.current_city].title,
choose_addr_id:this.data.city_list[this.data.current_city].id,
choose_addr: is_select?city_list[current_city].title:city,
choose_addr_id:is_select?city_list[current_city].id:this.data.city_id,
};
app.post(url, params, {}).then((res) => {
// console.log('确定发布', res);
... ... @@ -315,7 +356,8 @@ Page({
},
//选择城市
bindCityChange(e) {
this.setData({current_city: +e.detail.value})
this.setData({current_city: +e.detail.value,is_select:true})
},
//选择时间
bindTimeChange(e) {
... ...
... ... @@ -24,6 +24,17 @@
<view class="set-box">
<view class="min-num num-box">
<text class="title type-title">地区</text>
<picker bindchange="bindCityChange" value="{{current_city}}" range="{{city_picker_list}}" class="picker">
<view class="input">
<text class="variety-text">{{is_select?city_picker_list[current_city]:city}}</text>
</view>
</picker>
<text class="iconfont icon-xiangxia min-icon"></text>
<input type="text" bindinput="inputKey" class="input search-box" bindconfirm="search"/>
<text bindtap="search">搜索</text><text class="tips">* 可搜索地区</text>
</view>
<view class="min-num num-box">
<text class="title">最低人数</text>
<input type="number" bindinput="inputMinNum" class="input"/>
<text class="iconfont icon-xiangxia min-icon icon-min"></text>
... ... @@ -47,15 +58,6 @@
</picker>
<text class="iconfont icon-xiangxia min-icon"></text>
</view>
<view class="min-num">
<text class="title type-title">城市</text>
<picker bindchange="bindCityChange" value="{{current_city}}" range="{{city_picker_list}}" class="picker">
<view class="input">
<text class="variety-text">{{city_picker_list[current_city]}}</text>
</view>
</picker>
<text class="iconfont icon-xiangxia min-icon"></text>
</view>
<view class="time-box">
<text class="time-title">时间</text>
<picker mode='date' bindchange="bindDateChange" value='{{date}}' start="{{start_date}}"
... ... @@ -93,12 +95,14 @@
<text class="address-title">地点</text>
<input type="text" bindinput="inputAddress" class="input"/>
</view>
<view class="address-box">
<text class="address-title">地址</text>
<input type="text" value="" class="input" bindinput="inputAddr"/>
<!--<view class="address-box">-->
<!--手动填地址-->
<!--<text class="address-title">地址</text>-->
<!--<input type="text" value="" class="input" bindinput="inputAddr"/>-->
<!--打开地图选地址-->
<!--<text class="input">{{address_position}}</text>-->
<!--<text class="iconfont icon-location"></text>-->
</view>
<!--</view>-->
<view class="time-limit">
<text class="limit-title">活动前</text>
<input type="number" bindinput="inputOverTime" value="{{over_time}}"/>
... ...
... ... @@ -116,7 +116,7 @@
.min-num .min-icon {
font-size: 24rpx;
position: absolute;
right:86rpx;
left:245rpx;
top:50%;
transform: translate(0,-50%);
}
... ... @@ -133,6 +133,10 @@
color: #999999;
margin-left: 10rpx;
}
.search-box {
margin-left: 18rpx;
margin-right: 18rpx;
}
.time-box, .address-box {
display: flex;
align-items: center;
... ...
... ... @@ -95,14 +95,15 @@
<!--详细时间-->
<view class="detail-box">
<text>地区:{{detail.choose_addr}}</text>
<text>类别:{{detail.selectName}}</text>
<text>时间:{{end_time}}</text>
<text>地点:{{detail.name}}</text>
<!--<view class="position" bindtap="getNavigate">-->
<view class="position" wx:if="{{detail.address !== ''}}">
<text class="address">地址:{{detail.address}}</text>
<!--<view class="position" wx:if="{{detail.address !== ''}}">-->
<!--<text class="address">地址:{{detail.address}}</text>-->
<!--<text class="iconfont icon-location"></text>-->
</view>
<!--</view>-->
</view>
<!--已加入人员-->
... ...
... ... @@ -41,7 +41,7 @@ Page({
const arr = [];
res.data.forEach((item)=> {
arr.push(item.title)
})
});
self.setData({
city_picker_list: arr,
cityList:res.data,
... ...
{
"navigationBarTitleText": "选择国家或城市",
"navigationBarTitleText": "选择国家或地区",
"usingComponents": {}
}
\ No newline at end of file
... ...
... ... @@ -5,8 +5,8 @@
<view class="tab_item {{current==1?'active':''}}" data-current='{{1}}' bindtap='chargeTab'>境外/港澳台</view>
</view>
<view class="right" wx:if="{{current===1}}">
<input class="input" type="text" placeholder="搜索国家" bindinput="inputKey" bindfocus="inputFocus" value="{{searchValue}}" bindconfirm="startSearch" />
<text class="search-btn">搜索</text>
<input class="input" type="text" placeholder="搜索地区" bindinput="inputKey" bindfocus="inputFocus" value="{{searchValue}}" bindconfirm="startSearch" />
<text class="search-btn" bindtap="startSearch">搜索</text>
<!--<image src="../../../images/search@2x.png" class="search-icon" bindtap="startSearch"></image>-->
<!--<view class="iconfont icon-arrow-down"></view>-->
</view>
... ...
... ... @@ -235,7 +235,7 @@ Page({
"token": wx.getStorageSync('token')
};
app.post(url, params, {}).then((res) => {
// console.log('获取详情', res);
console.log('获取详情', res);
if (+res.code === 1) {
self.setData({
detail: res.data.active,
... ...
... ... @@ -91,13 +91,14 @@
<!--详细时间-->
<view class="detail-box">
<text>地区:{{detail.choose_addr}}</text>
<text>时间:{{end_time}}</text>
<text>餐厅:{{detail.name}}</text><!--餐厅-->
<!--<view class="position" bindtap="getNavigate">-->
<view class="position" wx:if="{{detail.address !== ''}}">
<text class="address">地址:{{detail.address}}</text>
<!--<view class="position" wx:if="{{detail.address !== ''}}">-->
<!--<text class="address">地址:{{detail.address}}</text>-->
<!--<text class="iconfont icon-location"></text>-->
</view>
<!--</view>-->
<text>菜系:{{detail.selectName}}</text>
</view>
... ...
... ... @@ -23,6 +23,7 @@ Page({
address_position:'',
over_time:'',
is_showRelease_modal:false,
is_select:false,
},
//查看我的发布
goMyRelease() {
... ... @@ -68,6 +69,39 @@ Page({
inputAddr(e) {
this.setData({address1:e.detail.value})
},
//输入搜索内容
inputKey(e){
this.setData({search_text:e.detail.value})
},
//点击搜索
search() {
let self = this;
let url = '/portal/Send/select';
let header = {
"XX-Token": wx.getStorageSync('token')
};
let params = {
// token: wx.getStorageSync('token'),
keyword:self.data.search_text,
};
self.setData({is_select:false});
app.post(url, params, header).then((res) => {
console.log('搜索结果', res);
// wx.hideLoading();
if(+res.code === 1) {
self.setData({search_text:'',});
if(res.data.addr.length === 0) {
wx.showToast({title:'暂无此地区',icon:'none'});
}else {
self.setData({
city:res.data.addr[0].title,
city_id:res.data.addr[0].id,
});
}
}
})
},
//获取地址
// choosePosition() {
// //选择当前地址,经纬度
... ... @@ -111,7 +145,11 @@ Page({
},
//确定发布
confirmRelease(e) {
// else if(this.data.address_position === '') {
var current_city = this.data.current_city;
var city_list = this.data.city_list;
var city = this.data.city;
var is_select = this.data.is_select;//是否是通过下拉框选择城市
// else if(this.data.address_position === '') {
// wx.showToast({title:'请定位地址',icon:'none'})
// }
if(this.data.title === '') {
... ... @@ -126,8 +164,8 @@ Page({
wx.showToast({title:'请填写最高人数',icon:'none'})
}else if(this.data.current_type === undefined) {
wx.showToast({title:'请选择类别',icon:'none'})
}else if(this.data.current_city === undefined) {
wx.showToast({title:'请选择城市',icon:'none'})
}else if(current_city === undefined && city === undefined) {
wx.showToast({title:'请选择地区',icon:'none'})
}else if(this.data.date === '') {
wx.showToast({title:'请选择日期',icon:'none'})
}else if(this.data.time === '') {
... ... @@ -159,13 +197,14 @@ Page({
max_number:this.data.max_num,
select_id: this.data.type_id,//类别
time: this.data.date + ' ' + this.data.time,
name: this.data.address,
address: this.data.address_position,
name: this.data.address,//餐厅
// address: this.data.address_position,
address: this.data.address1,
latng: '',
over_time:this.data.over_time,// 报名截止时间
formId: e.detail.formId,
choose_addr: this.data.city_list[this.data.current_city].title,
choose_addr_id:this.data.city_list[this.data.current_city].id,
choose_addr: is_select?city_list[current_city].title:city,
choose_addr_id:is_select?city_list[current_city].id:this.data.city_id,
};
var list = [];
app.post(url, params, {}).then((res) => {
... ... @@ -289,7 +328,7 @@ Page({
},
//选择城市
bindCityChange(e) {
this.setData({current_city: +e.detail.value})
this.setData({current_city: +e.detail.value,is_select:true});
},
//选择时间
bindTimeChange(e) {
... ...
... ... @@ -30,6 +30,17 @@
<!--<text class="tips">注:最低拼单人数</text>-->
<!--</view>-->
<view class="min-num num-box">
<text class="title type-title">地区</text>
<picker bindchange="bindCityChange" value="{{current_city}}" range="{{city_picker_list}}" class="picker">
<view class="input">
<text class="variety-text">{{is_select?city_picker_list[current_city]:city}}</text>
</view>
</picker>
<text class="iconfont icon-xiangxia min-icon"></text>
<input type="text" bindinput="inputKey" class="input search-box" bindconfirm="search" value="{{search_text}}"/>
<text bindtap="search">搜索</text><text class="tips">* 可搜索地区</text>
</view>
<view class="min-num num-box">
<text class="title">最低人数</text>
<input type="number" bindinput="inputMinNum" class="input"/>
<text class="iconfont icon-xiangxia min-icon icon-min"></text>
... ... @@ -57,15 +68,6 @@
</picker>
<text class="iconfont icon-xiangxia min-icon"></text>
</view>
<view class="min-num">
<text class="title type-title">城市</text>
<picker bindchange="bindCityChange" value="{{current_city}}" range="{{city_picker_list}}" class="picker">
<view class="input">
<text class="variety-text">{{city_picker_list[current_city]}}</text>
</view>
</picker>
<text class="iconfont icon-xiangxia min-icon"></text>
</view>
<view class="time-box">
<text class="time-title">时间</text>
<picker mode='date' bindchange="bindDateChange" value='{{date}}' end='2021-12-31' start="{{start_date}}">
... ... @@ -102,12 +104,14 @@
<text class="address-title">餐厅</text>
<input type="text" bindinput="inputAddress" class="input"/>
</view>
<view class="address-box">
<text class="address-title">地址</text>
<input type="text" value="" class="input" bindinput="inputAddr"/>
<!--<text class="input">{{address_position}}</text>-->
<!--<view class="address-box">-->
<!--手动填地址-->
<!--<text class="address-title">地址</text>-->
<!--<input type="text" value="" class="input" bindinput="inputAddr"/>-->
<!--打开地图选地址-->
<!--<text class="input">{{address_position}}</text>-->
<!--<text class="iconfont icon-location"></text>-->
</view>
<!--</view>-->
<view class="time-limit">
<text class="limit-title">开餐前</text>
<input type="number" bindinput="inputOverTime" value="{{over_time}}"/>
... ...
... ... @@ -32,25 +32,28 @@ Page({
inputPhone(e) {
this.setData({
phone_number: e.detail.value,
is_choose_phone:true
// is_choose_phone:true,
});
if(this.data.phone_number.length>=11) {
if(!(/^1[0-9]{10}$/.test(this.data.phone_number))){
wx.showToast({title:'手机号格式错误',icon:'none'});
this.setData({is_wrong_phone:true,phone_number_params:''});
// console.log('params', this.data.phone_number_params);
}else {
this.setData({
phone_number_params: this.data.phone_number,
'user.tel':this.data.phone_number,
is_wrong_phone:false,
});
// console.log('params', this.data.phone_number_params);
}
}
console.log('phone_number', this.data.phone_number);
// if(this.data.phone_number.length>=11) {
// if(!(/^1[0-9]{10}$/.test(this.data.phone_number))){
// wx.showToast({title:'手机号格式错误',icon:'none'});
// this.setData({is_wrong_phone:true,phone_number_params:''});
// // console.log('params', this.data.phone_number_params);
// }else {
// this.setData({
// phone_number_params: this.data.phone_number,
// 'user.tel':this.data.phone_number,
// is_wrong_phone:false,
// });
// // console.log('params', this.data.phone_number_params);
// }
// }
if(e.detail.value === '') {
// console.log('手机号为空',this.data.is_wrong_phone,this.data.phone_number_params,this.data.is_choose_phone);
this.setData({is_change:false});//按钮置灰
}else {
this.setData({is_change:true});
}
if((this.data.is_choose_phone&&this.data.phone_number_params !== '') &&
this.data.user.country !== null &&
... ... @@ -64,11 +67,11 @@ Page({
//失去焦点
blur() {
// if(this.data.phone_number.length>=11) {
if(!(/^1[0-9]{10}$/.test(this.data.phone_number))){
wx.showToast({title:'手机号格式错误',icon:'none'});
this.setData({is_wrong_phone:true,phone_number_params:''});
// console.log('params', this.data.phone_number_params);
}
// if(!(/^1[0-9]{10}$/.test(this.data.phone_number))){
// wx.showToast({title:'手机号格式错误',icon:'none'});
// this.setData({is_wrong_phone:true,phone_number_params:''});
// // console.log('params', this.data.phone_number_params);
// }
// }
},
//自动获取手机号
... ... @@ -187,6 +190,10 @@ Page({
},
//保存
submit() {
console.log('phone_number',this.data.phone_number);
// else if(this.data.is_wrong_phone){
// wx.showToast({title:'手机号格式错误',icon:'none'})
// }
// console.log('this.data.phone_number.length', this.data.phone_number.length,this.data.is_sex_change);
if(this.data.userInfo.gender == '未知' && this.data.is_sex_change === undefined) {
wx.showToast({title:'请选择性别',icon:'none'})
... ... @@ -196,14 +203,16 @@ Page({
wx.showToast({title:'请填写城市',icon:'none'})
}else if (this.data.user.tel === null && this.data.phone_number === '') {
wx.showToast({title:'请获取手机号',icon:'none'})
}else if(this.data.is_wrong_phone){
wx.showToast({title:'手机号格式错误',icon:'none'})
}else if(this.data.wx_num === '' && this.data.user.wx === null) {
wx.showToast({title:'请填写微信号',icon:'none'})
}else if(this.data.introduce === '' && this.data.user.introduce === null) {
wx.showToast({title:'请填写简介',icon:'none'})
}else {
const choose_sex = this.data.is_sex_change&&this.data.sexList[this.data.current_sex] === '男'?1:2;
var choose_sex = null;
if(this.data.is_sex_change&&this.data.sexList[this.data.current_sex] === '男') {
choose_sex = 1
}
// console.log('choose_sex', choose_sex);
let url = '/portal/Member/detail';
let sex = this.data.userInfo.gender;
let params = {
... ... @@ -212,7 +221,7 @@ Page({
country:this.data.is_choose_country?this.data.country:this.data.user.country,
city:this.data.is_choose_city?this.data.city:this.data.user.city,
// tel:(this.data.is_choose_phone&&this.data.phone_number !== '')?this.data.phone_number:this.data.user.tel,
tel:this.data.user.tel,
tel:this.data.user.tel === null?this.data.phone_number:this.data.phone_number!==''?this.data.phone_number:this.data.user.tel,
wx: this.data.is_choose_wx?this.data.wx_num:this.data.user.wx,
introduce:this.data.is_choose_introduce?this.data.introduce:this.data.user.introduce
};
... ... @@ -259,6 +268,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(app.globalData.userInfo);
this.setData({userInfo:app.globalData.userInfo});
if(this.data.userInfo.tel !== null) {
this.setData({is_wrong_phone:false})
... ...
... ... @@ -29,7 +29,8 @@
<view class="title">手机号:</view>
<view class="phone-box">
<!--<text>{{user.tel!==null?user.tel:''}}</text>-->
<input type="number" bindinput="inputPhone" bindblur="blur" value="{{user.tel!==null?user.tel:is_choose_phone&&!is_wrong_phone?phone_number:''}}"/>
<!--value="{{user.tel!==null?user.tel:is_choose_phone&&!is_wrong_phone?phone_number:''}}"-->
<input type="number" bindinput="inputPhone" bindblur="blur" value="{{user.tel}}"/>
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="phone-btn">自动填写</button>
</view>
</view>
... ...
... ... @@ -6,7 +6,8 @@
<!-- // (0全部,2待拼成,3人数不足未拼成,4已拼成,5已取消,6已完成,7已评价,8已拼成(活动未结束),9删除-->
<view class="state1">
<view class="circle change"></view>
<text>已拍下</text>
<text wx:if="{{order_detail.sonType === 1}}">已发布</text>
<text wx:if="{{order_detail.sonType === 2}}">已加入</text>
</view>
<view class="state2">
<!--{{detail.status === 4 ||detail.status === 5 || detail.status === 6||detail.status === 8?'change':''}}-->
... ...