123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902 |
- const app = getApp();
- const webSocket = require('../../utils/websocket.js');
- Page({
- data: {
- multiArray: [],
- step: 0,
- multiIndex: [0, 0, 0],
- CityRecord: '',
- areaRecord: '',
- CityRecordid: [],
- UsedRecord: false,
- provincename:'',
- cityname: '',
- areaname: '',
- heightid: 0,
- heightArray: [],
- heightindex: [0, 0],
- Ageid: 0,
- AgeArray: [],
- AgeIndex: [0, 0],
- MarriageArray: [],
- Marriageindex: '',
- EducationArray: [],
- Educationindex: '',
- nickname: '',
- sex: 0,
- age: 0,
- height: 0,
- province: 0,
- city: 0,
- area: 0,
- education: 0,
- marry: 0,
- income:0,
-
-
-
-
- home: [],
-
- page: 1,
- limit: 10,
- morehide: false,
- moreTxt: '',
- },
- onLoad: function (options) {
- webSocket.connectSocket();
- },
- onShow: function (options) {
- var that = this;
- that.setData({
- page: 1,
- })
- getApp().showLoading();
-
-
-
-
-
- var _Selection = app.globalData.Selection
-
- var _income = app.globalData.income
- that.setData({
- UsedRecord: false,
- CityRecord: '',
- areaRecord:'',
- multiIndex: [0, 0, 0],
- step: 0,
- })
- if (app.globalData.income){
- that.setData({
- income: _income,
- })
- } else if (app.globalData.income == 0 && _Selection == 1) {
- that.setData({
- income: _income,
- })
- }
-
-
-
- var _province = app.globalData.province
- var _city = app.globalData.city
- var _area = app.globalData.area
- if (_province && _city && _area) {
- that.setData({
- province: _province,
- city: _city,
- area: _area,
- })
-
-
-
- } else if (_city == 0 && _Selection == 1) {
- that.setData({
- province: _province,
- city: _city,
- area: _area,
- })
- }
- var _provincename = app.globalData.provincename
- var _cityname = app.globalData.cityname
- var _areaname = app.globalData.areaname
-
- if (_provincename && _cityname && _areaname) {
- that.setData({
- provincename: _provincename,
- cityname: _cityname,
- areaname: _areaname,
- step : 0,
- })
-
-
-
- } else if (_cityname == 0 && _Selection == 1) {
- that.setData({
- provincename: _provincename,
- cityname: _cityname,
- areaname: _areaname,
- step: 0,
- })
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- let Age_url = 'public/paramsgather?type=age';
- let Age_data = {};
- if (app.globalData.age){
-
- var _age = app.globalData.age
- var agenewArry = _age.split("-");
- var _age_min = agenewArry[0]
- var _age_max = agenewArry[1]
-
-
- that.setData({
- Ageid: 0,
- age: _age
- })
- } else if (app.globalData.age == 0 && _Selection == 1) {
- var _age = app.globalData.age
- that.setData({
- age: _age,
- Ageid :0,
- AgeIndex: ['', '']
- })
- }
- app.postRequest(Age_url, Age_data, function (res) {
- if (res.code == 201) {
- if (app.globalData.age){
- for (let i = 0; i < res.data.length; i++) {
- if (res.data[i] == _age_min) { var _min = i; }
- if (res.data[i] == _age_max) { var _max = i; }
- that.setData({
- AgeIndex: [_min, _max]
- })
- }
- }
- let dictObject = res.data;
-
- var createArr = []
- for (let i in dictObject) {
- createArr.push(dictObject[i] + "岁");
- }
- that.setData({
- AgeArray: [createArr, createArr],
- })
-
- }
- })
-
-
- let height_url = 'public/paramsgather?type=height';
- let height_data = {
- pid: '0'
- };
- if (app.globalData.height) {
-
- var _height = app.globalData.height
- var heightnewArry = _height.split("-");
- var heightSmall = heightnewArry[0]
- var heightlarge = heightnewArry[1]
-
-
- that.setData({
- height: _height,
- heightid:0
- })
- } else if (app.globalData.height == 0 && _Selection == 1) {
- var _height = app.globalData.height
- that.setData({
- height: _height,
- heightid: 0,
- heightindex: ['', ''],
- })
- }
- app.postRequest(height_url, height_data, function (res) {
- if (res.code == 201) {
- if (app.globalData.height) {
- for (let i = 0; i < res.data.length; i++) {
-
- if (res.data[i] == heightSmall) { var _min = i; }
- if (res.data[i] == heightlarge) { var _max = i; }
- that.setData({
- heightindex: [_min, _max]
- })
- }
- }
- let dictObject = res.data;
-
- var createArr = []
- for (let i in dictObject) {
- createArr.push(dictObject[i] + "cm");
- }
-
- that.setData({
- heightArray: [createArr, createArr],
- })
- }
- })
-
- let Marriage_url = 'public/paramsgather?type=marriage';
- let Marriage_data = {};
- if (app.globalData.marry) {
-
- var _marry = app.globalData.marry
- that.setData({
- marry: _marry
- })
- } else if (app.globalData.marry == 0 && _Selection == 1) {
- var _marry = app.globalData.marry
- that.setData({
- marry: _marry,
- Marriageindex: "",
- })
- }
- app.postRequest(Marriage_url, Marriage_data, function (res) {
- if (res.code == 201) {
- if (app.globalData.marry) {
- for (let i = 0; i < res.data.length; i++) {
- if (i == _marry) {
- that.setData({
- Marriageindex: i,
- })
- }
- }
- }
- that.setData({
- MarriageArray: res.data
- })
- }
- })
-
- let Education_url = 'public/paramsgather?type=xueli';
- let Education_data = {};
- if (app.globalData.education) {
-
- var _education = app.globalData.education
- that.setData({
- education: _education
- })
- } else if (app.globalData.education == 0 && _Selection == 1) {
- var _education = app.globalData.education
- that.setData({
- education: _education,
- Educationindex: "",
- })
- }
- app.postRequest(Education_url, Education_data, function (res) {
- if (res.code == 201) {
- if (app.globalData.education) {
- for (let i = 0; i < res.data.length; i++) {
- if (res.data[i].id == _education) {
- that.setData({
- Educationindex: i,
- })
- }
- }
- }
- that.setData({
- EducationArray: res.data
- })
- }
- })
-
- that.getProvince();
- that.list();
- },
-
- getPhone: function (e) {
- var nickname = e.detail.value;
- console.log(nickname);
- this.setData({
- nickname: nickname
- });
- },
-
- Code: function (e) {
- var that = this;
-
- if (that.data.nickname){
- that.showLoading();
-
- let home_url = 'circle/friend/home';
- let home_data = {
- page: that.data.page,
- limit: that.data.limit,
- number: that.data.nickname,
- };
- app.postRequest(home_url, home_data, function (res) {
- if (res.code == 201) {
-
- that.setData({
- home: res.data,
- })
- that.cancelLoading();
- return;
- }
- that.cancelLoading();
- that.setData({
- home_code: res.code,
- morehide: true,
- moreTxt: '暂无更多数据。'
- })
-
- })
- }else{
- var fail = '请输入会员编号'
- getApp().Tips(fail)
- }
-
- },
- heightEvent: function (e) {
- var that = this;
-
-
-
-
- var heightSmall = this.data.heightArray[0][e.detail.value[0]].substring(0, 3);
- var heightlarge = this.data.heightArray[1][e.detail.value[1]].substring(0, 3);
- var heightdata = heightSmall + '-' + heightlarge;
-
- this.setData({
- heightindex: e.detail.value,
- height: heightdata,
- heightid: 1,
- })
- that.list();
- },
-
- AgeEvent: function (e) {
- var that = this;
-
- var Small = this.data.AgeArray[0][e.detail.value[0]].substring(0, 2);
- var large = this.data.AgeArray[1][e.detail.value[1]].substring(0, 2);
- var Agedata = Small + '-' + large;
-
- this.setData({
- AgeIndex: e.detail.value,
- age: Agedata,
- Ageid: 1,
- page:1,
- })
- that.list();
- },
- MarriageEvent: function (e) {
- var that = this;
-
-
-
-
- this.setData({
- Marriageindex: e.detail.value,
- marry: e.detail.value,
- page: 1,
- })
- that.list();
- },
- EducationEvent: function (e) {
- var that = this;
-
-
-
-
- this.setData({
- Educationindex: e.detail.value,
- education: this.data.EducationArray[e.detail.value].id,
- page: 1,
- })
- that.list();
- },
-
-
-
-
-
-
-
-
-
- getProvince() {
- let _this = this;
- let d_url = 'public/citypid';
- app.postRequest(d_url, { pid: '0' }, function (res) {
- if (res.code == '201') {
- var provinceList = res.data;
- var provinceArr = [];
- provinceArr = _this.mapArray(res.data);
- _this.setData({
- multiArray: [provinceArr, [], []],
- provinceList,
- provinceArr,
- })
-
-
-
-
- if (_this.data.CityRecord) {
-
- var defaultCode = _this.data.CityRecord
- if (defaultCode) {
- _this.setData({
- currnetProvinceKey: defaultCode
- })
- _this.getCity(defaultCode)
- }
- } else {
-
- var defaultCode = provinceList[0]['area_id']
- if (defaultCode) {
- _this.setData({
- currnetProvinceKey: defaultCode
- })
- _this.getCity(defaultCode)
- }
- }
- }
- })
- },
- getCity(codes) {
-
- let _this = this;
- let d_url = 'public/citypid';
- app.postRequest(d_url, { pid: codes }, function (res) {
- var cityList = res.data;
- var cityArr = [];
- if (res.code == '201') {
- cityArr = _this.mapArray(res.data);
- _this.setData({
- multiArray: [_this.data.provinceArr, cityArr, []],
- cityArr,
- cityList
- })
-
- if (_this.data.areaRecord && _this.data.cancelID == false) {
-
- var defaultCode = _this.data.areaRecord
-
- if (defaultCode) {
- _this.setData({
- currnetProvinceKey: defaultCode
- })
- _this.getArea(defaultCode)
- }
- } else {
-
- var defaultCode = cityList[0]['area_id']
-
- if (defaultCode) {
- _this.setData({
- currnetProvinceKey: defaultCode
- })
- _this.getArea(defaultCode)
- }
- }
- }
- })
- },
- getArea(codes) {
-
- let _this = this;
- let d_url = 'public/citypid';
- app.postRequest(d_url, { pid: codes }, function (res) {
- var areaList = res.data;
- var areaArr = [];
- if (res.code == '201') {
- areaArr = _this.mapArray(res.data);
- }
-
-
- _this.setData({
- multiArray: [_this.data.provinceArr, _this.data.cityArr, areaArr],
- areaList,
- areaArr,
- })
- _this.setData({
- cancelID: true,
- })
- })
- },
- mapArray: function (data) {
- let cityArray = []
- if (data) {
- for (let i = 0; i < data.length; i++) {
- if (data[i].area_name) {
- cityArray[i] = data[i].area_name;
- }
- }
- }
- return cityArray;
- },
- columnchange(e) {
- var column = e.detail.column
-
-
-
- var data = {
- multiIndex: this.data.multiIndex,
- multiArray: this.data.multiArray
- }
- data.multiIndex[column] = e.detail.value;
- switch (column) {
- case 0:
- var currentProvinceKey = this.data.provinceList[e.detail.value].area_id
- if (currentProvinceKey != this.data.currnetProvinceKey) {
- this.getCity(currentProvinceKey)
- }
- data.multiIndex[1] = 0
- break;
- case 1:
- var currentCitykey = this.data.cityList[e.detail.value].area_id
- if (currentCitykey != this.data.currnetCityKey) {
- this.getArea(currentCitykey)
- }
- data.multiIndex[2] = 0
- break;
- }
- this.setData(data)
-
- },
- pickchange(e) {
- var that =this;
-
-
-
-
- that.setData({
- step: 1,
- multiIndex: e.detail.value,
- province: that.data.provinceList[e.detail.value[0]].area_id,
- city: that.data.cityList[e.detail.value[1]].area_id,
- area: that.data.areaList[e.detail.value[2]].area_id,
- provincename: that.data.provinceList[e.detail.value[0]].area_name,
- cityname: that.data.cityList[e.detail.value[1]].area_name,
- areaname: that.data.areaList[e.detail.value[2]].area_name,
-
- CityRecord: that.data.provinceList[e.detail.value[0]].area_id,
- areaRecord: that.data.cityList[e.detail.value[1]].area_id,
- CityRecordid: that.data.multiIndex,
- UsedRecord: true,
- })
-
- that.list();
- },
-
- cancel: function (e) {
- var _this = this;
- if (_this.data.UsedRecord == true) {
- _this.setData({
- multiIndex: _this.data.CityRecordid,
- cancelID: false
- })
-
- _this.getProvince();
- }
- },
- onReachBottom() {
- var that = this;
- that.showLoading();
-
- let home_url = 'circle/friend/home';
- let home_data = {
- page: (that.data.page++) + 1,
- limit: that.data.limit,
- height: that.data.height,
- age: that.data.age,
- marry: that.data.marry,
- education: that.data.education,
-
- city: that.data.city,
-
- };
- app.postRequest(home_url, home_data, function (res) {
- if (res.code == 201) {
-
- var home = that.data.home
- var moreTxt = '';
- if (0 < (res.data.length < 10)) {
- moreTxt = '暂无更多数据。'
- console.log('无')
- } else {
- moreTxt = ''
- console.log('有')
- }
-
- for (var i = 0; i < res.data.length; i++) {
- home.push(res.data[i]);
- }
-
- that.setData({
- home: home,
- morehide: true,
- moreTxt: moreTxt,
- })
- that.cancelLoading();
- return;
- }
- that.cancelLoading();
- that.setData({
- home_code: res.code,
- morehide: true,
- moreTxt:"暂无更多数据。"
- })
-
-
- })
- },
- More:function(){
- var that = this;
-
- wx.navigateTo({
- url: '/pages/index_screen/index_screen?age=' + that.data.age + '&height=' + that.data.height + '&marry=' + that.data.marry + '&education=' + that.data.education + '&income=' + that.data.income + '&province=' + that.data.province + '&city=' + that.data.city + '&area=' + that.data.area + '&provincename=' + that.data.provincename + '&cityname=' + that.data.cityname + '&areaname=' + that.data.areaname + ''
- })
- },
- list: function () {
- var that = this;
- that.showLoading();
-
- let home_url = 'circle/friend/home';
- let home_data = {
- page: that.data.page,
- limit: that.data.limit,
- age: that.data.age,
- height: that.data.height,
- marry: that.data.marry,
- education: that.data.education,
- income: that.data.income,
-
- city: that.data.city,
-
-
- };
- app.postRequest(home_url, home_data, function (res) {
- if (res.code == 201) {
- var moreTxt = '';
- if (res.data.length < 10) {
- moreTxt = '暂无更多数据。'
- } else {
- moreTxt = ''
- }
- console.log(res.data);
- that.setData({
- home: res.data,
- moreTxt: moreTxt,
- home_code: res.code,
- })
- that.cancelLoading();
- return;
- }
- that.cancelLoading();
- that.setData({
- home: res.data,
- morehide: true,
- moreTxt: '暂无更多数据。'
- })
-
- })
- },
- showLoading: function () {
- wx.showToast({
- title: '加载中',
- icon: 'loading'
- });
- },
-
- cancelLoading: function () {
- wx.hideToast();
- }
- })
|