Commit 6e3c1bdf authored by 吴颖's avatar 吴颖

'修改意向区域选择'

parent 1fae4902
const app = getApp() const app = getApp()
import { Base } from '../../../utils/base.js'; import {
Base
} from '../../../utils/base.js';
const base = new Base() const base = new Base()
Page({ Page({
...@@ -7,13 +9,15 @@ Page({ ...@@ -7,13 +9,15 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
coach_id: '',
currentArea: [],
city: '', city: '',
cityShow: false, cityShow: false,
cityList: [], cityList: [],
city_name: '', city_name: '',
cityChecked: '', cityChecked: '',
show: false, show: false,
forIndex: 3,
areaNameList: [], areaNameList: [],
}, },
...@@ -21,32 +25,32 @@ Page({ ...@@ -21,32 +25,32 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.getCitylist()
this.getMyarea()
},
showCitypop(e) {
this.setData({ this.setData({
show: true, coach_id: app.globalData.coach_id
showIndex: e.currentTarget.dataset.index
})
},
onClose() {
this.setData({
show: false
}) })
this.getMyarea()
this.getCitylist()
}, },
getMyarea : function () { getMyarea: function () {
let params = { let params = {
url:'coach/myarea', url: 'coach/myarea',
data : { data: {
coach_id: app.globalData.coach_id, coach_id: this.data.coach_id,
}, },
callback : (data) => { callback: (data) => {
console.log(data) var arr = []
for(var i in data.area){
let option = {
id: data.area[i] !=null && data.area[i].id ? data.area[i].id: '',
name: data.area[i] !=null && data.area[i].name ? data.area[i].name: '',
}
arr.push(option)
}
this.setData({ this.setData({
myarea : data currentArea: arr
}) })
console.log(this.data.currentArea)
} }
} }
base.newRequest(params) base.newRequest(params)
...@@ -55,7 +59,6 @@ Page({ ...@@ -55,7 +59,6 @@ Page({
let params = { let params = {
url: 'coach/city', url: 'coach/city',
callback: (data) => { callback: (data) => {
console.log(data)
this.setData({ this.setData({
cityList: data cityList: data
}) })
...@@ -74,6 +77,38 @@ Page({ ...@@ -74,6 +77,38 @@ Page({
} }
base.newRequest(params) base.newRequest(params)
}, },
getArealist: function (region_id) {
let params = {
url: 'coach/area',
data: {
region_id: region_id
},
callback: (data) => {
var areaNameList = []
for (let i in data) {
areaNameList.push(data[i].name); //属性
}
this.setData({
areaNameList: areaNameList,
areaList: data
})
}
}
base.newRequest(params)
},
showCitypop(e) {
this.setData({
show: true,
showIndex: e.currentTarget.dataset.index
})
},
onClose() {
this.setData({
show: false
})
},
changeCity: function (e) { changeCity: function (e) {
this.setData({ this.setData({
cityShow: true cityShow: true
...@@ -86,7 +121,6 @@ Page({ ...@@ -86,7 +121,6 @@ Page({
}, },
chooseCity(e) { chooseCity(e) {
console.log(e.currentTarget.dataset.item)
let city_name = e.currentTarget.dataset.item.city_name; let city_name = e.currentTarget.dataset.item.city_name;
let city_id = e.currentTarget.dataset.item.id; let city_id = e.currentTarget.dataset.item.id;
let region_id = e.currentTarget.dataset.item.region_id; let region_id = e.currentTarget.dataset.item.region_id;
...@@ -100,7 +134,11 @@ Page({ ...@@ -100,7 +134,11 @@ Page({
} }
}, },
cityChangeComfirm: function (e) { cityChangeComfirm: function (e) {
const { cityChecked, cityChecked_id, region_id } = this.data; const {
cityChecked,
cityChecked_id,
region_id
} = this.data;
this.setData({ this.setData({
city: cityChecked, city: cityChecked,
city_id: cityChecked_id, city_id: cityChecked_id,
...@@ -108,82 +146,40 @@ Page({ ...@@ -108,82 +146,40 @@ Page({
}) })
this.getArealist(region_id) this.getArealist(region_id)
}, },
getArealist: function (region_id) {
let params = {
url: 'coach/area',
data: {
region_id: region_id
},
callback: (data) => {
console.log(data)
var areaNameList = []
for (let i in data) {
areaNameList.push(data[i].name); //属性
}
console.log(areaNameList)
this.setData({
areaNameList: areaNameList,
areaList: data
})
}
}
base.newRequest(params)
},
onConfirm(event) { onConfirm(event) {
const { picker, value, index } = event.detail; let index = event.detail.index
const {showIndex, areaList } = this.data; let list = this.data.currentArea
let area_id; list[this.data.showIndex-1].name = this.data.areaList[index].name
for(let i = 0; i<areaList.length;i++){ list[this.data.showIndex-1].id = this.data.areaList[index].id
if(areaList[i].name == value){
area_id = areaList[i].id;
}
}
if(showIndex == 1){
this.setData({
first_area_name: value,
first_area: area_id
})
}else if(showIndex == 2){
this.setData({
second_area_name: value,
second_area: area_id
})
}else if(showIndex == 3){
this.setData({
third_area_name: value,
third_area: area_id
})
}
console.log(area_id)
this.setData({ this.setData({
currentArea: list,
show: !this.data.show show: !this.data.show
}) })
}, },
onCancel() { onCancel() {
this.setData({ this.setData({
show : !this.data.show show: !this.data.show
}) })
}, },
save : function () { save: function () {
const {city_id, first_area, second_area, third_area} = this.data; if (this.data.currentArea[0].id || this.data.currentArea[1].id || this.data.currentArea[2].id) {
if(first_area || second_area || third_area){
let params = { let params = {
url : 'coach/save_area', url: 'coach/save_area',
data : { data: {
// coach_id : 5, coach_id : this.data.coach_id,
coach_id: app.globalData.coach_id, city_id: this.data.city_id,
city_id, first_area: this.data.currentArea[0].id,
first_area, second_area: this.data.currentArea[1].id,
second_area, third_area: this.data.currentArea[2].id
third_area },
}, type: 'POST',
type:'POST', callback: (data) => {
callback : (data) => {
base.toast('保存区域成功') base.toast('保存区域成功')
} }
} }
base.newRequest(params) base.newRequest(params)
}else{ } else {
base.toast('请至少选择一个意向区域') base.toast('请至少选择一个意向区域')
} }
}, },
......
...@@ -3,13 +3,11 @@ ...@@ -3,13 +3,11 @@
<view>已选城市:{{city}}</view> <view>已选城市:{{city}}</view>
</view> </view>
<view class="select">选择意向区域</view> <view class="select">选择意向区域</view>
<view class="item" wx:for="{{forIndex}}" wx:key="index"> <view class="item" wx:for="{{currentArea}}" wx:key="index">
<view class="every flex-h flex-vc"> <view class="every flex-h flex-vc">
<view class="one">意向区域{{index+1}}</view> <view class="one">意向区域{{index+1}}</view>
<view class="two" bindtap="showCitypop" data-index="{{index+1}}"> <view class="two" bindtap="showCitypop" data-index="{{index+1}}">
<text wx:if="{{index == 0}}">{{first_area_name}}</text> <text>{{item.name}}</text>
<text wx:if="{{index == 1}}">{{second_area_name}}</text>
<text wx:if="{{index == 2}}">{{third_area_name}}</text>
<text class="iconfont icongengduo"></text> <text class="iconfont icongengduo"></text>
</view> </view>
</view> </view>
......
<view class="info"> <view class="info">
<!-- <view class="onerow flex-h flex-vc flex-hb">
<text>手机号码</text>
<view>
<input type="number" max-length='11' value="{{telphone}}" bindinput="changeTel"/>
</view>
</view> -->
<view class="onerow flex-h flex-vc flex-hb"> <view class="onerow flex-h flex-vc flex-hb">
<text>账户昵称</text> <text>账户昵称</text>
<view> <view>
...@@ -14,7 +8,7 @@ ...@@ -14,7 +8,7 @@
<view class="onerow flex-h flex-vc flex-hb"> <view class="onerow flex-h flex-vc flex-hb">
<text>账户头像</text> <text>账户头像</text>
<view class="flex-h" catchtap="changeImg"> <view class="flex-h" catchtap="changeImg">
<image src="{{headImg}}"></image> <image src="{{headImg}}" mode="aspectFill"></image>
</view> </view>
</view> </view>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</view> </view>
<view class="every flex-h flex-vc flex-hb" catchtap="tcHold"> <view class="every flex-h flex-vc flex-hb" catchtap="tcHold">
<view class="row title"> <view class="row title">
<image src="../../../images/my/per_icon_03.png"></image> <image mode="aspectFill" src="../../../images/my/per_icon_03.png"></image>
<view>教学科目</view> <view>教学科目</view>
</view> </view>
<view class="row"> <view class="row">
......
<view class="box flex-v flex-hc flex-vc"> <view class="box flex-v flex-hc flex-vc">
<image src="/images/course_login.png"></image> <image src="/images/course_login.png"></image>
<view>豌豆成长</view> <view>豌豆教练</view>
</view> </view>
\ No newline at end of file
...@@ -178,6 +178,12 @@ ...@@ -178,6 +178,12 @@
{ {
"name": "课程瞬间上传", "name": "课程瞬间上传",
"pathName": "pages/index/courseInstant/courseInstant", "pathName": "pages/index/courseInstant/courseInstant",
"query": "",
"scene": null
},
{
"name": "教学区域",
"pathName": "pages/my/teachingArea/teachingArea",
"scene": null "scene": null
} }
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment