Commit 7a0b5346 authored by 吴颖's avatar 吴颖

Merge branch 'wuying' into 'master'

Wuying

See merge request !40
parents d62ee252 f5c3d4e9
const app = getApp()
import { Base } from '../../../utils/base.js';
import {
Base
} from '../../../utils/base.js';
const base = new Base()
Page({
......@@ -7,13 +9,15 @@ Page({
* 页面的初始数据
*/
data: {
coach_id: '',
currentArea: [],
city: '',
cityShow: false,
cityList: [],
city_name: '',
cityChecked: '',
show: false,
forIndex: 3,
areaNameList: [],
},
......@@ -21,32 +25,32 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getCitylist()
this.getMyarea()
},
showCitypop(e) {
this.setData({
show: true,
showIndex: e.currentTarget.dataset.index
})
},
onClose() {
this.setData({
show: false
coach_id: app.globalData.coach_id
})
this.getMyarea()
this.getCitylist()
},
getMyarea : function () {
getMyarea: function () {
let params = {
url:'coach/myarea',
data : {
coach_id: app.globalData.coach_id,
url: 'coach/myarea',
data: {
coach_id: this.data.coach_id,
},
callback : (data) => {
console.log(data)
callback: (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({
myarea : data
currentArea: arr
})
console.log(this.data.currentArea)
}
}
base.newRequest(params)
......@@ -55,7 +59,6 @@ Page({
let params = {
url: 'coach/city',
callback: (data) => {
console.log(data)
this.setData({
cityList: data
})
......@@ -74,6 +77,38 @@ Page({
}
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) {
this.setData({
cityShow: true
......@@ -86,7 +121,6 @@ Page({
},
chooseCity(e) {
console.log(e.currentTarget.dataset.item)
let city_name = e.currentTarget.dataset.item.city_name;
let city_id = e.currentTarget.dataset.item.id;
let region_id = e.currentTarget.dataset.item.region_id;
......@@ -100,7 +134,11 @@ Page({
}
},
cityChangeComfirm: function (e) {
const { cityChecked, cityChecked_id, region_id } = this.data;
const {
cityChecked,
cityChecked_id,
region_id
} = this.data;
this.setData({
city: cityChecked,
city_id: cityChecked_id,
......@@ -108,82 +146,40 @@ Page({
})
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) {
const { picker, value, index } = event.detail;
const {showIndex, areaList } = this.data;
let area_id;
for(let i = 0; i<areaList.length;i++){
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)
let index = event.detail.index
let list = this.data.currentArea
list[this.data.showIndex-1].name = this.data.areaList[index].name
list[this.data.showIndex-1].id = this.data.areaList[index].id
this.setData({
currentArea: list,
show: !this.data.show
})
},
onCancel() {
this.setData({
show : !this.data.show
show: !this.data.show
})
},
save : function () {
const {city_id, first_area, second_area, third_area} = this.data;
if(first_area || second_area || third_area){
save: function () {
if (this.data.currentArea[0].id || this.data.currentArea[1].id || this.data.currentArea[2].id) {
let params = {
url : 'coach/save_area',
data : {
// coach_id : 5,
coach_id: app.globalData.coach_id,
city_id,
first_area,
second_area,
third_area
},
type:'POST',
callback : (data) => {
url: 'coach/save_area',
data: {
coach_id : this.data.coach_id,
city_id: this.data.city_id,
first_area: this.data.currentArea[0].id,
second_area: this.data.currentArea[1].id,
third_area: this.data.currentArea[2].id
},
type: 'POST',
callback: (data) => {
base.toast('保存区域成功')
}
}
base.newRequest(params)
}else{
} else {
base.toast('请至少选择一个意向区域')
}
},
......
......@@ -3,13 +3,11 @@
<view>已选城市:{{city}}</view>
</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="one">意向区域{{index+1}}</view>
<view class="two" bindtap="showCitypop" data-index="{{index+1}}">
<text wx:if="{{index == 0}}">{{first_area_name}}</text>
<text wx:if="{{index == 1}}">{{second_area_name}}</text>
<text wx:if="{{index == 2}}">{{third_area_name}}</text>
<text>{{item.name}}</text>
<text class="iconfont icongengduo"></text>
</view>
</view>
......
<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">
<text>账户昵称</text>
<view>
......@@ -14,7 +8,7 @@
<view class="onerow flex-h flex-vc flex-hb">
<text>账户头像</text>
<view class="flex-h" catchtap="changeImg">
<image src="{{headImg}}"></image>
<image src="{{headImg}}" mode="aspectFill"></image>
</view>
</view>
......
......@@ -35,7 +35,7 @@
</view>
<view class="every flex-h flex-vc flex-hb" catchtap="tcHold">
<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 class="row">
......
<view class="box flex-v flex-hc flex-vc">
<image src="/images/course_login.png"></image>
<view>豌豆成长</view>
<view>豌豆教练</view>
</view>
\ No newline at end of file
......@@ -178,6 +178,12 @@
{
"name": "课程瞬间上传",
"pathName": "pages/index/courseInstant/courseInstant",
"query": "",
"scene": null
},
{
"name": "教学区域",
"pathName": "pages/my/teachingArea/teachingArea",
"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