index.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. const app = getApp();
  2. const webSocket = require('../../utils/websocket.js');
  3. Page({
  4. data: {
  5. multiArray: [], // 地址-数据
  6. step: 0, // 地址
  7. multiIndex: [0, 0, 0], // 地址-下标
  8. CityRecord: '', //城市记录
  9. areaRecord: '', //区域记录
  10. CityRecordid: [], //下标记录
  11. UsedRecord: false, //是否初次
  12. provincename:'', // 省
  13. cityname: '', // 市
  14. areaname: '', // 区
  15. heightid: 0,
  16. heightArray: [], // 身高-数据
  17. heightindex: [0, 0], // 身高-下标
  18. Ageid: 0,
  19. AgeArray: [], // 年龄-数据
  20. AgeIndex: [0, 0], // 年龄-下标
  21. MarriageArray: [], // 婚史-数据
  22. Marriageindex: '', // 婚史-下标
  23. EducationArray: [], // 学历-数据
  24. Educationindex: '', // 学历-下标
  25. nickname: '',//ID
  26. sex: 0, // 性别
  27. age: 0, // 年龄
  28. height: 0, // 身高
  29. province: 0, // 省
  30. city: 0, // 市
  31. area: 0, // 区
  32. education: 0, // 学历
  33. marry: 0, // 婚史
  34. income:0,
  35. // income: '', // 收入
  36. // occupation: '', // 职业
  37. // home: '', //列表信息
  38. // tab: [true, true, true, true],
  39. home: [], //定义列表信息数组
  40. // tabTxt: ['性别', '年龄', '婚史', '特色'],//tab文案
  41. page: 1,//当前页码
  42. limit: 10,//获取条数
  43. morehide: false, //暂无更多信息显示隐藏
  44. moreTxt:'',
  45. },
  46. onLoad: function (options) {
  47. webSocket.connectSocket();
  48. },
  49. onShow: function (options) {
  50. var that = this;
  51. getApp().showLoading(); //提示加载中
  52. // console.log(app.globalData.height);
  53. // console.log(app.globalData.marry);
  54. // console.log(app.globalData.education);
  55. // console.log(app.globalData.income);
  56. var _Selection = app.globalData.Selection // 是否选中 1选中 0没选中
  57. // console.log(_Selection);
  58. var _income = app.globalData.income // 收入
  59. that.setData({
  60. UsedRecord: false,
  61. CityRecord: '',
  62. areaRecord:'',
  63. multiIndex: [0, 0, 0], // 地址-下标
  64. step: 0,
  65. })
  66. if (app.globalData.income){
  67. that.setData({
  68. income: _income,
  69. })
  70. } else if (app.globalData.income == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  71. that.setData({
  72. income: _income,
  73. })
  74. }
  75. // console.log(that.data.provincename);
  76. // console.log(that.data.cityname);
  77. // console.log(that.data.areaname);
  78. var _province = app.globalData.province // 省
  79. var _city = app.globalData.city // 市
  80. var _area = app.globalData.area // 区
  81. if (_province && _city && _area) {
  82. that.setData({
  83. province: _province,
  84. city: _city,
  85. area: _area,
  86. })
  87. // console.log(_province);
  88. // console.log(_city);
  89. // console.log(_area);
  90. } else if (_city == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  91. that.setData({
  92. province: _province,
  93. city: _city,
  94. area: _area,
  95. })
  96. }
  97. var _provincename = app.globalData.provincename // 省
  98. var _cityname = app.globalData.cityname // 市
  99. var _areaname = app.globalData.areaname // 区
  100. if (_provincename && _cityname && _areaname) {
  101. that.setData({
  102. provincename: _provincename,
  103. cityname: _cityname,
  104. areaname: _areaname,
  105. step : 0,
  106. })
  107. // console.log(_provincename);
  108. // console.log(_cityname);
  109. // console.log(_areaname);
  110. } else if (_cityname == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  111. that.setData({
  112. provincename: _provincename,
  113. cityname: _cityname,
  114. areaname: _areaname,
  115. step: 0,
  116. })
  117. }
  118. // that.setData({
  119. // // nickname: that.options.nickname, //姓名
  120. // age: that.options.age, // 年龄
  121. // height: that.options.height, // 身高
  122. // // province: that.options.province, // 市
  123. // // city: that.options.city, // 市
  124. // // area: that.options.area, // 区
  125. // education: that.options.education, // 学历
  126. // income: that.options.income, // 收入
  127. // });
  128. // 年龄 ajax
  129. let Age_url = 'public/paramsgather?type=age';
  130. let Age_data = {};
  131. if (app.globalData.age){ //判断 是否从筛选页面传来的参数
  132. // console.log(app.globalData.age);
  133. var _age = app.globalData.age // 年龄
  134. var agenewArry = _age.split("-"); //转成数组
  135. var _age_min = agenewArry[0]
  136. var _age_max = agenewArry[1]
  137. // console.log(_age_min)
  138. // console.log(_age_max)
  139. that.setData({
  140. Ageid: 0,
  141. age: _age
  142. })
  143. } else if (app.globalData.age == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  144. var _age = app.globalData.age // 年龄
  145. that.setData({
  146. age: _age,
  147. Ageid :0,
  148. AgeIndex: ['', '']
  149. })
  150. }
  151. app.postRequest(Age_url, Age_data, function (res) { // 年龄 ajax
  152. if (res.code == 201) {
  153. if (app.globalData.age){
  154. for (let i = 0; i < res.data.length; i++) { //已选中的数据处理
  155. if (res.data[i] == _age_min) { var _min = i; }
  156. if (res.data[i] == _age_max) { var _max = i; }
  157. that.setData({
  158. AgeIndex: [_min, _max]
  159. })
  160. }
  161. }
  162. let dictObject = res.data; //对象不能直接使用 以下转成数组
  163. // 对象转成数组
  164. var createArr = []
  165. for (let i in dictObject) {
  166. createArr.push(dictObject[i] + "岁");
  167. }
  168. that.setData({
  169. AgeArray: [createArr, createArr],
  170. })
  171. // console.log(createArr);
  172. }
  173. })
  174. // 身高 ajax
  175. let height_url = 'public/paramsgather?type=height';
  176. let height_data = {
  177. pid: '0'
  178. };
  179. if (app.globalData.height) { //判断 是否从筛选页面传来的参数
  180. // console.log(app.globalData.height);
  181. var _height = app.globalData.height // 身高
  182. var heightnewArry = _height.split("-"); //转成数组
  183. var heightSmall = heightnewArry[0]
  184. var heightlarge = heightnewArry[1]
  185. // console.log(heightSmall)
  186. // console.log(heightlarge)
  187. that.setData({
  188. height: _height,
  189. heightid:0
  190. })
  191. } else if (app.globalData.height == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  192. var _height = app.globalData.height // 身高
  193. that.setData({
  194. height: _height,
  195. heightid: 0,
  196. heightindex: ['', ''], // 身高-下标
  197. })
  198. }
  199. app.postRequest(height_url, height_data, function (res) { // 身高 ajax
  200. if (res.code == 201) {
  201. if (app.globalData.height) {
  202. for (let i = 0; i < res.data.length; i++) { //已选中的数据处理
  203. // console.log(res.data[i])
  204. if (res.data[i] == heightSmall) { var _min = i; }
  205. if (res.data[i] == heightlarge) { var _max = i; }
  206. that.setData({
  207. heightindex: [_min, _max]
  208. })
  209. }
  210. }
  211. let dictObject = res.data; //对象不能直接使用 以下转成数组
  212. // 对象转成数组
  213. var createArr = []
  214. for (let i in dictObject) {
  215. createArr.push(dictObject[i] + "cm");
  216. }
  217. // console.log(createArr);
  218. that.setData({
  219. heightArray: [createArr, createArr],
  220. })
  221. }
  222. })
  223. // 婚史 ajax
  224. let Marriage_url = 'public/paramsgather?type=marriage';
  225. let Marriage_data = {};
  226. if (app.globalData.marry) { //判断 是否从筛选页面传来的参数
  227. // console.log(app.globalData.marry);
  228. var _marry = app.globalData.marry // 婚姻
  229. that.setData({
  230. marry: _marry
  231. })
  232. } else if (app.globalData.marry == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  233. var _marry = app.globalData.marry // 婚姻
  234. that.setData({
  235. marry: _marry,
  236. Marriageindex: "", // 身高-下标
  237. })
  238. }
  239. app.postRequest(Marriage_url, Marriage_data, function (res) { // 婚史 ajax
  240. if (res.code == 201) {
  241. if (app.globalData.marry) {
  242. for (let i = 0; i < res.data.length; i++) { //已选中的数据处理
  243. if (i == _marry) {
  244. that.setData({
  245. Marriageindex: i,
  246. })
  247. }
  248. }
  249. }
  250. that.setData({
  251. MarriageArray: res.data
  252. })
  253. }
  254. })
  255. // 学历 ajax
  256. let Education_url = 'public/paramsgather?type=xueli';
  257. let Education_data = {};
  258. if (app.globalData.education) { //判断 是否从筛选页面传来的参数
  259. // console.log(app.globalData.marry);
  260. var _education = app.globalData.education // 学历
  261. that.setData({
  262. education: _education
  263. })
  264. } else if (app.globalData.education == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  265. var _education = app.globalData.education // 学历
  266. that.setData({
  267. education: _education,
  268. Educationindex: "", // 学历-下标
  269. })
  270. }
  271. app.postRequest(Education_url, Education_data, function (res) { // 学历 ajax
  272. if (res.code == 201) {
  273. if (app.globalData.education) {
  274. for (let i = 0; i < res.data.length; i++) { //已选中的数据处理
  275. if (res.data[i].id == _education) {
  276. that.setData({
  277. Educationindex: i,
  278. })
  279. }
  280. }
  281. }
  282. that.setData({
  283. EducationArray: res.data
  284. })
  285. }
  286. })
  287. that.getProvince(); //地址 ajax
  288. that.list();
  289. },
  290. // 会员编码
  291. getPhone: function (e) {
  292. var nickname = e.detail.value;
  293. console.log(nickname);
  294. this.setData({
  295. nickname: nickname
  296. });
  297. },
  298. // 会员编码查询
  299. Code: function (e) {
  300. var that = this;
  301. // 判断会员编码是否存在
  302. if (that.data.nickname){
  303. that.showLoading(); //提示加载中
  304. // 列表信息
  305. let home_url = 'circle/friend/home';
  306. let home_data = {
  307. page: that.data.page,
  308. limit: that.data.limit,
  309. number: that.data.nickname, // 性别
  310. };
  311. app.postRequest(home_url, home_data, function (res) {
  312. if (res.code == 201) {
  313. // console.log(res.data);
  314. that.setData({
  315. home: res.data,
  316. })
  317. that.cancelLoading(); //数据加载完关闭
  318. return;
  319. }
  320. that.cancelLoading(); //数据加载完关闭
  321. that.setData({
  322. home_code: res.code,
  323. morehide: true,
  324. moreTxt: '暂无更多数据。'
  325. })
  326. })
  327. }else{
  328. var fail = '请输入会员编号' //调用提示框
  329. getApp().Tips(fail)
  330. }
  331. },
  332. heightEvent: function (e) { // 身高
  333. var that = this;
  334. // console.log(this);
  335. // console.log(e);
  336. // console.log(this.data.heightArray[e.detail.value]);
  337. // console.log('picker发送选择改变,携带值为', e.detail.value)
  338. var heightSmall = this.data.heightArray[0][e.detail.value[0]].substring(0, 3);
  339. var heightlarge = this.data.heightArray[1][e.detail.value[1]].substring(0, 3);
  340. var heightdata = heightSmall + '-' + heightlarge;
  341. // console.log(heightdata)
  342. this.setData({
  343. heightindex: e.detail.value,
  344. height: heightdata,
  345. heightid: 1,
  346. })
  347. that.list();
  348. },
  349. // 年龄双选
  350. AgeEvent: function (e) {
  351. var that = this;
  352. // console.log('picker发送选择改变,携带值为', e.detail.value)
  353. var Small = this.data.AgeArray[0][e.detail.value[0]].substring(0, 2);
  354. var large = this.data.AgeArray[1][e.detail.value[1]].substring(0, 2);
  355. var Agedata = Small + '-' + large;
  356. // console.log(Agedata);
  357. this.setData({
  358. AgeIndex: e.detail.value,
  359. age: Agedata,
  360. Ageid: 1,
  361. page:1,
  362. })
  363. that.list(); //调用筛选
  364. },
  365. MarriageEvent: function (e) { // 婚史 单项选择器
  366. var that = this;
  367. // console.log(this);
  368. // console.log(e);
  369. // console.log(this.data.MarriageArray[e.detail.value]);
  370. // console.log('picker发送选择改变,携带值为', e.detail.value)
  371. this.setData({
  372. Marriageindex: e.detail.value,
  373. marry: e.detail.value,
  374. page: 1,
  375. })
  376. that.list(); //调用筛选
  377. },
  378. EducationEvent: function (e) { // 学历 单项选择器
  379. var that = this;
  380. // console.log(this);
  381. // console.log(e);
  382. // console.log(this.data.EducationArray[e.detail.value].id);
  383. // console.log('picker发送选择改变,携带值为', e.detail.value)
  384. this.setData({
  385. Educationindex: e.detail.value,
  386. education: this.data.EducationArray[e.detail.value].id,
  387. page: 1,
  388. })
  389. that.list(); //调用筛选
  390. },
  391. // 列表切换
  392. // filterTab: function (e) {
  393. // var data = [true, true, true, true], qhid = e.currentTarget.dataset.qhid;
  394. // // console.log(e.currentTarget.dataset.qhid);
  395. // data[qhid] = !this.data.tab[qhid];
  396. // // console.log(!this.data.tab[qhid]);
  397. // this.setData({
  398. // tab: data,
  399. // })
  400. // },
  401. getProvince() { // 多项选择器
  402. let _this = this;
  403. let d_url = 'public/citypid';
  404. app.postRequest(d_url, { pid: '0' }, function (res) {
  405. if (res.code == '201') {
  406. var provinceList = res.data;
  407. var provinceArr = [];
  408. provinceArr = _this.mapArray(res.data);
  409. _this.setData({
  410. multiArray: [provinceArr, [], []],
  411. provinceList,
  412. provinceArr,
  413. })
  414. // console.log(provinceList);
  415. // console.log(provinceArr);
  416. // console.log(_this.data.CityRecord)
  417. // 方便取消事件调用 getProvince 判断 如果选择过城市 传选择过的城市
  418. if (_this.data.CityRecord) {
  419. // console.log('有');
  420. var defaultCode = _this.data.CityRecord
  421. if (defaultCode) {
  422. _this.setData({
  423. currnetProvinceKey: defaultCode
  424. })
  425. _this.getCity(defaultCode)
  426. }
  427. } else { //如果没有选择过 , 传第一个城市
  428. // console.log('无');
  429. var defaultCode = provinceList[0]['area_id']
  430. if (defaultCode) {
  431. _this.setData({
  432. currnetProvinceKey: defaultCode
  433. })
  434. _this.getCity(defaultCode)
  435. }
  436. }
  437. }
  438. })
  439. },
  440. getCity(codes) {
  441. // 多项选择
  442. let _this = this;
  443. let d_url = 'public/citypid';
  444. app.postRequest(d_url, { pid: codes }, function (res) {
  445. var cityList = res.data;
  446. var cityArr = [];
  447. if (res.code == '201') {
  448. cityArr = _this.mapArray(res.data);
  449. _this.setData({
  450. multiArray: [_this.data.provinceArr, cityArr, []],
  451. cityArr,
  452. cityList
  453. })
  454. // 方便取消事件调用 getProvince 判断 如果选择过城市 传选择过的城市
  455. if (_this.data.areaRecord && _this.data.cancelID == false) {
  456. // console.log('有');
  457. var defaultCode = _this.data.areaRecord
  458. // console.log(_this.data.areaRecord);
  459. if (defaultCode) {
  460. _this.setData({
  461. currnetProvinceKey: defaultCode
  462. })
  463. _this.getArea(defaultCode)
  464. }
  465. } else { //如果没有选择过 , 传第一个城市
  466. // console.log('无');
  467. var defaultCode = cityList[0]['area_id']
  468. // console.log(defaultCode);
  469. if (defaultCode) {
  470. _this.setData({
  471. currnetProvinceKey: defaultCode
  472. })
  473. _this.getArea(defaultCode)
  474. }
  475. }
  476. }
  477. })
  478. },
  479. getArea(codes) {
  480. // 多项选择
  481. let _this = this;
  482. let d_url = 'public/citypid';
  483. app.postRequest(d_url, { pid: codes }, function (res) {
  484. var areaList = res.data;
  485. var areaArr = [];
  486. if (res.code == '201') {
  487. areaArr = _this.mapArray(res.data);
  488. }
  489. // console.log(areaList);
  490. // console.log(areaArr);
  491. _this.setData({
  492. multiArray: [_this.data.provinceArr, _this.data.cityArr, areaArr],
  493. areaList,
  494. areaArr,
  495. })
  496. _this.setData({
  497. cancelID: true,
  498. })
  499. })
  500. },
  501. mapArray: function (data) {
  502. let cityArray = []
  503. if (data) {
  504. for (let i = 0; i < data.length; i++) {
  505. if (data[i].area_name) {
  506. cityArray[i] = data[i].area_name;
  507. }
  508. }
  509. }
  510. return cityArray;
  511. },
  512. columnchange(e) { // 滚动选择器 触发的事件
  513. var column = e.detail.column // 当前改变的列
  514. // console.log(column);
  515. // console.log(this.data.multiIndex);
  516. // console.log(JSON.parse(JSON.stringify(this.data.multiIndex)));
  517. var data = {
  518. multiIndex: this.data.multiIndex,
  519. multiArray: this.data.multiArray
  520. }
  521. data.multiIndex[column] = e.detail.value; // 第几列改变了就是对应multiIndex的第几个,更新它
  522. switch (column) { // 处理不同的逻辑
  523. case 0: // 第一列更改 就是省级的更改
  524. var currentProvinceKey = this.data.provinceList[e.detail.value].area_id
  525. if (currentProvinceKey != this.data.currnetProvinceKey) { // 判断当前的key是不是真正的更新了
  526. this.getCity(currentProvinceKey) // 获取当前key下面的市级数据
  527. }
  528. data.multiIndex[1] = 0 // 将市默认选择第一个
  529. break;
  530. case 1: // 市发生变化
  531. var currentCitykey = this.data.cityList[e.detail.value].area_id
  532. if (currentCitykey != this.data.currnetCityKey) { // 同样判断
  533. this.getArea(currentCitykey) // 获取门店
  534. }
  535. data.multiIndex[2] = 0
  536. break;
  537. }
  538. this.setData(data) // 更新数据
  539. // console.log(this.data.step)
  540. },
  541. pickchange(e) {
  542. var that =this;
  543. // console.log(that.data.multiIndex);
  544. // console.log(that.data.provinceList[e.detail.value[0]].area_id);
  545. // console.log(that.data.cityList[e.detail.value[1]].area_id);
  546. // console.log(that.data.areaList[e.detail.value[2]].area_id);
  547. that.setData({
  548. step: 1, // 更新,用来选择用户选中的门店
  549. multiIndex: e.detail.value, // 更新下标字段
  550. province: that.data.provinceList[e.detail.value[0]].area_id, // 市
  551. city: that.data.cityList[e.detail.value[1]].area_id, // 市
  552. area: that.data.areaList[e.detail.value[2]].area_id, // 区
  553. provincename: that.data.provinceList[e.detail.value[0]].area_name, // 市
  554. cityname: that.data.cityList[e.detail.value[1]].area_name, // 市
  555. areaname: that.data.areaList[e.detail.value[2]].area_name, // 区
  556. CityRecord: that.data.provinceList[e.detail.value[0]].area_id, // 省
  557. areaRecord: that.data.cityList[e.detail.value[1]].area_id, // 市
  558. CityRecordid: that.data.multiIndex,
  559. UsedRecord: true, //已使用过
  560. })
  561. that.list();
  562. },
  563. // 城市取消
  564. cancel: function (e) {
  565. var _this = this;
  566. if (_this.data.UsedRecord == true) {
  567. _this.setData({
  568. multiIndex: _this.data.CityRecordid,
  569. cancelID: false
  570. })
  571. // console.log(_this.data.CityRecordid);
  572. _this.getProvince(); //地址 ajax
  573. }
  574. },
  575. // 上拉加载更多
  576. onReachBottom() {
  577. var that = this;
  578. that.showLoading(); //提示加载中
  579. // 列表信息
  580. let home_url = 'circle/friend/home';
  581. let home_data = {
  582. page: (that.data.page++) + 1,
  583. limit: that.data.limit,
  584. height: that.data.height, // 身高
  585. age: that.data.age, // 年龄
  586. marry: that.data.marry, // 婚史
  587. education: that.data.education, // 学历
  588. // province: that.data.province, // 市
  589. city: that.data.city, // 市
  590. // area: that.data.area, // 区
  591. };
  592. app.postRequest(home_url, home_data, function (res) {
  593. if (res.code == 201) {
  594. // console.log(res.data);
  595. var home = that.data.home
  596. // 设置数据
  597. for (var i = 0; i < res.data.length; i++) {
  598. home.push(res.data[i]);
  599. }
  600. that.setData({
  601. home: home,
  602. })
  603. that.cancelLoading(); //数据加载完关闭
  604. return;
  605. }
  606. that.cancelLoading(); //数据加载完关闭
  607. that.setData({
  608. home_code: res.code,
  609. morehide: true,
  610. moreTxt :'暂无更多数据。'
  611. })
  612. })
  613. },
  614. More:function(){
  615. var that = this;
  616. // console.log(that.data.age);
  617. wx.navigateTo({
  618. 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 + ''
  619. })
  620. },
  621. list: function () {
  622. var that = this;
  623. that.showLoading(); //提示加载中
  624. // 列表信息
  625. let home_url = 'circle/friend/home';
  626. let home_data = {
  627. page: that.data.page,
  628. limit: that.data.limit,
  629. age: that.data.age, // 年龄
  630. height: that.data.height, // 身高
  631. marry: that.data.marry, // 婚史
  632. education: that.data.education, // 学历
  633. income: that.data.income, //收入
  634. // province: that.data.province , // 市
  635. city: that.data.city, // 市
  636. // area: that.data.area, // 区
  637. };
  638. app.postRequest(home_url, home_data, function (res) {
  639. if (res.code == 201) {
  640. console.log(res.data);
  641. that.setData({
  642. home: res.data,
  643. home_code: res.code,
  644. })
  645. that.cancelLoading(); //数据加载完关闭
  646. return;
  647. }
  648. that.cancelLoading(); //数据加载完关闭
  649. that.setData({
  650. home_code: res.code,
  651. morehide: true,
  652. moreTxt: '暂无更多数据。'
  653. })
  654. })
  655. },
  656. // 加载
  657. showLoading: function () {
  658. wx.showToast({
  659. title: '加载中',
  660. icon: 'loading'
  661. });
  662. },
  663. // 关闭加载
  664. cancelLoading: function () {
  665. wx.hideToast();
  666. }
  667. })