index.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  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. agezx:0,
  29. height: 0, // 身高
  30. heightzx:0,
  31. province: 0, // 省
  32. city: 0, // 市
  33. area: 0, // 区
  34. education: 0, // 学历
  35. marry: 0, // 婚史
  36. idmarry:0,
  37. income:0,
  38. // income: '', // 收入
  39. // occupation: '', // 职业
  40. // home: '', //列表信息
  41. // tab: [true, true, true, true],
  42. home: [], //定义列表信息数组
  43. // tabTxt: ['性别', '年龄', '婚史', '特色'],//tab文案
  44. page: 1,//当前页码
  45. limit: 10,//获取条数
  46. morehide: false, //暂无更多信息显示隐藏
  47. moreTxt: '',
  48. code:'', //分享ID
  49. },
  50. onLoad: function (options) {
  51. webSocket.connectSocket();
  52. },
  53. onShow: function (options) {
  54. var that = this;
  55. that.setData({
  56. page: 1,//当前页码
  57. })
  58. getApp().showLoading(); //提示加载中
  59. // console.log(app.globalData.height);
  60. // console.log(app.globalData.marry);
  61. // console.log(app.globalData.education);
  62. // console.log(app.globalData.income);
  63. var _Selection = app.globalData.Selection // 是否选中 1选中 0没选中
  64. // console.log(_Selection);
  65. var _income = app.globalData.income // 收入
  66. that.setData({
  67. UsedRecord: false,
  68. CityRecord: '',
  69. areaRecord:'',
  70. multiIndex: [0, 0, 0], // 地址-下标
  71. step: 0,
  72. })
  73. if (app.globalData.income){
  74. that.setData({
  75. income: _income,
  76. })
  77. } else if (app.globalData.income == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  78. that.setData({
  79. income: _income,
  80. })
  81. }
  82. // console.log(that.data.provincename);
  83. // console.log(that.data.cityname);
  84. // console.log(that.data.areaname);
  85. var _province = app.globalData.province // 省
  86. var _city = app.globalData.city // 市
  87. var _area = app.globalData.area // 区
  88. if (_province && _city && _area) {
  89. that.setData({
  90. province: _province,
  91. city: _city,
  92. area: _area,
  93. })
  94. // console.log(_province);
  95. // console.log(_city);
  96. // console.log(_area);
  97. } else if (_city == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  98. that.setData({
  99. province: _province,
  100. city: _city,
  101. area: _area,
  102. })
  103. }
  104. var _provincename = app.globalData.provincename // 省
  105. var _cityname = app.globalData.cityname // 市
  106. var _areaname = app.globalData.areaname // 区
  107. if (_provincename && _cityname && _areaname) {
  108. that.setData({
  109. provincename: _provincename,
  110. cityname: _cityname,
  111. areaname: _areaname,
  112. step : 0,
  113. })
  114. // console.log(_provincename);
  115. // console.log(_cityname);
  116. // console.log(_areaname);
  117. } else if (_cityname == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  118. that.setData({
  119. provincename: _provincename,
  120. cityname: _cityname,
  121. areaname: _areaname,
  122. step: 0,
  123. })
  124. }
  125. // that.setData({
  126. // // nickname: that.options.nickname, //姓名
  127. // age: that.options.age, // 年龄
  128. // height: that.options.height, // 身高
  129. // // province: that.options.province, // 市
  130. // // city: that.options.city, // 市
  131. // // area: that.options.area, // 区
  132. // education: that.options.education, // 学历
  133. // income: that.options.income, // 收入
  134. // });
  135. // 年龄 ajax
  136. let Age_url = 'public/paramsgather?type=age';
  137. let Age_data = {};
  138. if (app.globalData.age){ //判断 是否从筛选页面传来的参数
  139. // console.log(app.globalData.age);
  140. var _age = app.globalData.age // 年龄
  141. var _agezx = app.globalData.agezx // 年龄
  142. if (_agezx == 0) {
  143. var agenewArry = _age.split("-"); //转成数组
  144. var _age_min = agenewArry[0]
  145. var _age_max = agenewArry[1]
  146. } else {
  147. var agenewArry = _agezx.split("-"); //转成数组
  148. var _age_min = agenewArry[0]
  149. var _age_max = agenewArry[1]
  150. }
  151. // console.log(_age_min)
  152. // console.log(_age_max)
  153. that.setData({
  154. Ageid: 0,
  155. age: _age,
  156. agezx: _agezx,
  157. })
  158. } else if (app.globalData.age == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  159. var _age = app.globalData.age // 年龄
  160. that.setData({
  161. age: _age,
  162. Ageid :0,
  163. AgeIndex: ['', '']
  164. })
  165. }
  166. app.postRequest(Age_url, Age_data, function (res) { // 年龄 ajax
  167. if (res.code == 201) {
  168. if (app.globalData.age){
  169. let createArr1 = res.data;
  170. let newarray1 = ['不限'];
  171. createArr1 = newarray1.concat(createArr1);
  172. for (let i = 0; i < createArr1.length; i++) { //已选中的数据处理
  173. if (createArr1[i] == _age_min) { var _min = i; }
  174. if (createArr1[i] == _age_max) { var _max = i; }
  175. that.setData({
  176. AgeIndex: [_min, _max]
  177. })
  178. }
  179. }
  180. let dictObject = res.data; //对象不能直接使用 以下转成数组
  181. // 对象转成数组
  182. var createArr = []
  183. for (let i in dictObject) {
  184. createArr.push(dictObject[i] + "岁");
  185. }
  186. // console.log(createArr);
  187. //使用concat()来把两个数组合拼起来
  188. let newarray = ['不限'];
  189. createArr = newarray.concat(createArr);
  190. // console.log(createArr);
  191. that.setData({
  192. AgeArray: [createArr, createArr],
  193. })
  194. // console.log(createArr);
  195. }
  196. })
  197. // 身高 ajax
  198. let height_url = 'public/paramsgather?type=height';
  199. let height_data = {
  200. pid: '0'
  201. };
  202. if (app.globalData.height) { //判断 是否从筛选页面传来的参数
  203. // console.log(app.globalData.height);
  204. var _height = app.globalData.height // 身高
  205. var _heightzx = app.globalData.heightzx // 年龄
  206. if (_heightzx == 0) {
  207. var heightnewArry = _height.split("-"); //转成数组
  208. var heightSmall = heightnewArry[0]
  209. var heightlarge = heightnewArry[1]
  210. } else {
  211. var heightnewArry = _heightzx.split("-"); //转成数组
  212. var heightSmall = heightnewArry[0]
  213. var heightlarge = heightnewArry[1]
  214. }
  215. // console.log(heightSmall)
  216. // console.log(heightlarge)
  217. that.setData({
  218. height: _height,
  219. heightid:0,
  220. heightzx: _heightzx,
  221. })
  222. } else if (app.globalData.height == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  223. var _height = app.globalData.height // 身高
  224. that.setData({
  225. height: _height,
  226. heightid: 0,
  227. heightindex: ['', ''], // 身高-下标
  228. })
  229. }
  230. app.postRequest(height_url, height_data, function (res) { // 身高 ajax
  231. if (res.code == 201) {
  232. if (app.globalData.height) {
  233. let createArr1 = res.data;
  234. let newarray1 = ['不限'];
  235. createArr1 = newarray1.concat(createArr1);
  236. for (let i = 0; i < createArr1.length; i++) { //已选中的数据处理
  237. // console.log(res.data[i])
  238. if (createArr1[i] == heightSmall) { var _min = i; }
  239. if (createArr1[i] == heightlarge) { var _max = i; }
  240. that.setData({
  241. heightindex: [_min, _max]
  242. })
  243. }
  244. }
  245. let dictObject = res.data; //对象不能直接使用 以下转成数组
  246. // 对象转成数组
  247. var createArr = []
  248. for (let i in dictObject) {
  249. createArr.push(dictObject[i] + "cm");
  250. }
  251. let newarray = ['不限'];
  252. createArr = newarray.concat(createArr);
  253. // console.log(createArr);
  254. that.setData({
  255. heightArray: [createArr, createArr],
  256. })
  257. }
  258. })
  259. // 婚史 ajax
  260. let Marriage_url = 'public/paramsgather?type=marriage';
  261. let Marriage_data = {};
  262. if (app.globalData.marry) { //判断 是否从筛选页面传来的参数
  263. // console.log(app.globalData.marry);
  264. var _marry = app.globalData.marry // 婚姻
  265. that.setData({
  266. marry: _marry
  267. })
  268. } else if (app.globalData.marry == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  269. var _marry = app.globalData.marry // 婚姻
  270. that.setData({
  271. marry: _marry,
  272. Marriageindex: "", // 婚姻-下标
  273. })
  274. }
  275. app.postRequest(Marriage_url, Marriage_data, function (res) { // 婚史 ajax
  276. if (res.code == 201) {
  277. if (app.globalData.marry) {
  278. let createArr1 = res.data;
  279. let newarray1 = ['不限'];
  280. createArr1 = newarray1.concat(createArr1);
  281. for (let i = 0; i < createArr1.length; i++) { //已选中的数据处理
  282. if (i == _marry) {
  283. that.setData({
  284. Marriageindex: i,
  285. })
  286. }
  287. }
  288. }
  289. let createArr = res.data;
  290. let newarray = ['不限'];
  291. createArr = newarray.concat(createArr);
  292. that.setData({
  293. MarriageArray: createArr,
  294. idmarry: that.data.idmarry,
  295. })
  296. }
  297. })
  298. // 学历 ajax
  299. let Education_url = 'public/paramsgather?type=xueli';
  300. let Education_data = {};
  301. if (app.globalData.education) { //判断 是否从筛选页面传来的参数
  302. // console.log(app.globalData.marry);
  303. var _education = app.globalData.education // 学历
  304. that.setData({
  305. education: _education
  306. })
  307. } else if (app.globalData.education == 0 && _Selection == 1) { //判断筛选页面 是否清空数据 同时 是否选中,而不是返回
  308. var _education = app.globalData.education // 学历
  309. that.setData({
  310. education: _education,
  311. Educationindex: "", // 学历-下标
  312. })
  313. }
  314. app.postRequest(Education_url, Education_data, function (res) { // 学历 ajax
  315. if (res.code == 201) {
  316. if (app.globalData.education) {
  317. for (let i = 0; i < res.data.length; i++) { //已选中的数据处理
  318. if (res.data[i].id == _education) {
  319. that.setData({
  320. Educationindex: i,
  321. })
  322. }
  323. }
  324. }
  325. that.setData({
  326. EducationArray: res.data
  327. })
  328. }
  329. })
  330. that.getProvince(); //地址 ajax
  331. that.list();
  332. },
  333. // 会员编码
  334. getPhone: function (e) {
  335. var nickname = e.detail.value;
  336. console.log(nickname);
  337. this.setData({
  338. nickname: nickname
  339. });
  340. },
  341. // 会员编码查询
  342. Code: function (e) {
  343. var that = this;
  344. // 判断会员编码是否存在
  345. if (that.data.nickname){
  346. that.showLoading(); //提示加载中
  347. // 列表信息
  348. let home_url = 'circle/friend/home';
  349. let home_data = {
  350. page: that.data.page,
  351. limit: that.data.limit,
  352. number: that.data.nickname, // 性别
  353. };
  354. app.postRequest(home_url, home_data, function (res) {
  355. if (res.code == 201) {
  356. // console.log(res.data);
  357. that.setData({
  358. home: res.data,
  359. })
  360. that.cancelLoading(); //数据加载完关闭
  361. return;
  362. }
  363. that.cancelLoading(); //数据加载完关闭
  364. that.setData({
  365. home_code: res.code,
  366. morehide: true,
  367. moreTxt: '暂无更多数据。'
  368. })
  369. })
  370. }else{
  371. var fail = '请输入会员编号' //调用提示框
  372. getApp().Tips(fail)
  373. }
  374. },
  375. heightEvent: function (e) { // 身高
  376. var that = this;
  377. // console.log(this);
  378. // console.log(e);
  379. // console.log(this.data.heightArray[e.detail.value]);
  380. // console.log('picker发送选择改变,携带值为', e.detail.value)
  381. var _value = e.detail.value; //发送选择改变,携带值为
  382. var heightSmall = this.data.heightArray[0][e.detail.value[0]].substring(0, 3); //最小值
  383. var heightlarge = this.data.heightArray[1][e.detail.value[1]].substring(0, 3); //最大值
  384. // console.log(heightdata)
  385. if (heightSmall > heightlarge && heightSmall != '不限' && heightlarge != '不限') { //判断 最小值 大于 最大值 数据互换
  386. // console.log('调换')
  387. var heightdata = heightlarge + '-' + heightSmall;
  388. that.Exchange(_value); // 调用数组调换
  389. that.setData({
  390. heightzx: 0,
  391. })
  392. } else if (heightSmall == '不限' && heightlarge != '不限') { //判断 最小值 = 不限 输出 最大的值以下
  393. // console.log('以下')
  394. var heightdata = heightlarge + '以下';
  395. var heightdatazx = '不限' + '-' + heightlarge;
  396. that.setData({
  397. heightzx: heightdatazx,
  398. })
  399. } else if (heightlarge == '不限' && heightSmall != '不限') { //判断 最大值 = 不限 输出 最小的值以上
  400. // console.log('以上')
  401. var heightdata = heightSmall + '以上';
  402. var heightdatazx = heightSmall + '-' + '不限';
  403. that.setData({
  404. heightzx: heightdatazx,
  405. })
  406. } else if (heightSmall == '不限' && heightlarge == '不限') { //判断 大小值 = 不限 输出 不限
  407. // console.log('不限')
  408. var heightdata = '不限';
  409. var heightdatazx = '不限' + '-' + '不限';
  410. that.setData({
  411. heightzx: heightdatazx,
  412. })
  413. } else {
  414. var heightdata = heightSmall + '-' + heightlarge; //否则正常选中
  415. that.setData({
  416. heightzx: 0,
  417. })
  418. }
  419. that.setData({
  420. heightindex: _value,
  421. height: heightdata,
  422. heightid: 1,
  423. })
  424. that.list();
  425. },
  426. // 年龄双选
  427. AgeEvent: function (e) {
  428. var that = this;
  429. // console.log('picker发送选择改变,携带值为', e.detail.value)
  430. var _value = e.detail.value; //发送选择改变,携带值为
  431. var Small = this.data.AgeArray[0][e.detail.value[0]].substring(0, 2); //小
  432. var large = this.data.AgeArray[1][e.detail.value[1]].substring(0, 2); //大
  433. // console.log(Small);
  434. // console.log(large);
  435. if (Small > large && Small != '不限' && large != '不限'){ //判断 最小值 大于 最大值 数据互换
  436. // console.log('调换')
  437. var Agedata = large + '-' + Small;
  438. that.Exchange(_value); // 调用数组调换
  439. that.setData({
  440. agezx: 0,
  441. })
  442. } else if (Small == '不限' && large != '不限') { //判断 最小值 = 不限 输出 最大的值以下
  443. // console.log('以下')
  444. var Agedata = large + '以下';
  445. var Agedataxz = '不限' + '-' + large;
  446. that.setData({
  447. agezx: Agedataxz,
  448. })
  449. } else if (large == '不限' && Small != '不限') { //判断 最大值 = 不限 输出 最小的值以上
  450. // console.log('以上')
  451. var Agedata = Small + '以上';
  452. var Agedataxz = Small + '-' + '不限';
  453. that.setData({
  454. agezx: Agedataxz,
  455. })
  456. } else if (Small == '不限' && large == '不限') { //判断 大小值 = 不限 输出 不限
  457. // console.log('不限')
  458. var Agedata = '不限';
  459. var Agedataxz = '不限' + '-' + '不限';
  460. that.setData({
  461. agezx: Agedataxz,
  462. })
  463. }else {
  464. var Agedata = Small + '-' + large; //否则正常选中
  465. that.setData({
  466. agezx: 0,
  467. })
  468. }
  469. // console.log(_value);
  470. that.setData({
  471. AgeIndex: _value,
  472. age: Agedata,
  473. Ageid: 1,
  474. page:1,
  475. })
  476. that.list(); //调用筛选
  477. },
  478. // 数组数据调换
  479. Exchange: function (data) {
  480. for (var i = 0; i < data.length / 2; i++) {
  481. var data_i = data[i];
  482. data[i] = data[data.length - 1 - i];
  483. data[data.length - 1 - i] = data_i;
  484. }
  485. return;
  486. },
  487. MarriageEvent: function (e) { // 婚史 单项选择器
  488. var that = this;
  489. // console.log(this);
  490. // console.log(e);
  491. // console.log(this.data.MarriageArray[e.detail.value]);
  492. // console.log('picker发送选择改变,携带值为', e.detail.value)
  493. this.setData({
  494. Marriageindex: e.detail.value,
  495. marry: e.detail.value,
  496. page: 1,
  497. idmarry:1,
  498. })
  499. that.list(); //调用筛选
  500. },
  501. EducationEvent: function (e) { // 学历 单项选择器
  502. var that = this;
  503. // console.log(this);
  504. // console.log(e);
  505. // console.log(this.data.EducationArray[e.detail.value].id);
  506. // console.log('picker发送选择改变,携带值为', e.detail.value)
  507. this.setData({
  508. Educationindex: e.detail.value,
  509. education: this.data.EducationArray[e.detail.value].id,
  510. page: 1,
  511. })
  512. that.list(); //调用筛选
  513. },
  514. // 列表切换
  515. // filterTab: function (e) {
  516. // var data = [true, true, true, true], qhid = e.currentTarget.dataset.qhid;
  517. // // console.log(e.currentTarget.dataset.qhid);
  518. // data[qhid] = !this.data.tab[qhid];
  519. // // console.log(!this.data.tab[qhid]);
  520. // this.setData({
  521. // tab: data,
  522. // })
  523. // },
  524. getProvince() { // 多项选择器
  525. let _this = this;
  526. let d_url = 'public/citypid';
  527. app.postRequest(d_url, { pid: '0' }, function (res) {
  528. if (res.code == '201') {
  529. var provinceList = res.data;
  530. var provinceArr = [];
  531. provinceArr = _this.mapArray(res.data);
  532. _this.setData({
  533. multiArray: [provinceArr, [], []],
  534. provinceList,
  535. provinceArr,
  536. })
  537. // console.log(provinceList);
  538. // console.log(provinceArr);
  539. // console.log(_this.data.CityRecord)
  540. // 方便取消事件调用 getProvince 判断 如果选择过城市 传选择过的城市
  541. if (_this.data.CityRecord) {
  542. // console.log('有');
  543. var defaultCode = _this.data.CityRecord
  544. if (defaultCode) {
  545. _this.setData({
  546. currnetProvinceKey: defaultCode
  547. })
  548. _this.getCity(defaultCode)
  549. }
  550. } else { //如果没有选择过 , 传第一个城市
  551. // console.log('无');
  552. var defaultCode = provinceList[0]['area_id']
  553. if (defaultCode) {
  554. _this.setData({
  555. currnetProvinceKey: defaultCode
  556. })
  557. _this.getCity(defaultCode)
  558. }
  559. }
  560. }
  561. })
  562. },
  563. getCity(codes) {
  564. // 多项选择
  565. let _this = this;
  566. let d_url = 'public/citypid';
  567. app.postRequest(d_url, { pid: codes }, function (res) {
  568. var cityList = res.data;
  569. var cityArr = [];
  570. if (res.code == '201') {
  571. cityArr = _this.mapArray(res.data);
  572. _this.setData({
  573. multiArray: [_this.data.provinceArr, cityArr, []],
  574. cityArr,
  575. cityList
  576. })
  577. // 方便取消事件调用 getProvince 判断 如果选择过城市 传选择过的城市
  578. if (_this.data.areaRecord && _this.data.cancelID == false) {
  579. // console.log('有');
  580. var defaultCode = _this.data.areaRecord
  581. // console.log(_this.data.areaRecord);
  582. if (defaultCode) {
  583. _this.setData({
  584. currnetProvinceKey: defaultCode
  585. })
  586. _this.getArea(defaultCode)
  587. }
  588. } else { //如果没有选择过 , 传第一个城市
  589. // console.log('无');
  590. var defaultCode = cityList[0]['area_id']
  591. // console.log(defaultCode);
  592. if (defaultCode) {
  593. _this.setData({
  594. currnetProvinceKey: defaultCode
  595. })
  596. _this.getArea(defaultCode)
  597. }
  598. }
  599. }
  600. })
  601. },
  602. getArea(codes) {
  603. // 多项选择
  604. let _this = this;
  605. let d_url = 'public/citypid';
  606. app.postRequest(d_url, { pid: codes }, function (res) {
  607. var areaList = res.data;
  608. var areaArr = [];
  609. if (res.code == '201') {
  610. areaArr = _this.mapArray(res.data);
  611. }
  612. // console.log(areaList);
  613. // console.log(areaArr);
  614. _this.setData({
  615. multiArray: [_this.data.provinceArr, _this.data.cityArr, areaArr],
  616. areaList,
  617. areaArr,
  618. })
  619. _this.setData({
  620. cancelID: true,
  621. })
  622. })
  623. },
  624. mapArray: function (data) {
  625. let cityArray = []
  626. if (data) {
  627. for (let i = 0; i < data.length; i++) {
  628. if (data[i].area_name) {
  629. cityArray[i] = data[i].area_name;
  630. }
  631. }
  632. }
  633. return cityArray;
  634. },
  635. columnchange(e) { // 滚动选择器 触发的事件
  636. var column = e.detail.column // 当前改变的列
  637. // console.log(column);
  638. // console.log(this.data.multiIndex);
  639. // console.log(JSON.parse(JSON.stringify(this.data.multiIndex)));
  640. var data = {
  641. multiIndex: this.data.multiIndex,
  642. multiArray: this.data.multiArray
  643. }
  644. data.multiIndex[column] = e.detail.value; // 第几列改变了就是对应multiIndex的第几个,更新它
  645. switch (column) { // 处理不同的逻辑
  646. case 0: // 第一列更改 就是省级的更改
  647. var currentProvinceKey = this.data.provinceList[e.detail.value].area_id
  648. if (currentProvinceKey != this.data.currnetProvinceKey) { // 判断当前的key是不是真正的更新了
  649. this.getCity(currentProvinceKey) // 获取当前key下面的市级数据
  650. }
  651. data.multiIndex[1] = 0 // 将市默认选择第一个
  652. break;
  653. case 1: // 市发生变化
  654. var currentCitykey = this.data.cityList[e.detail.value].area_id
  655. if (currentCitykey != this.data.currnetCityKey) { // 同样判断
  656. this.getArea(currentCitykey) // 获取门店
  657. }
  658. data.multiIndex[2] = 0
  659. break;
  660. }
  661. this.setData(data) // 更新数据
  662. // console.log(this.data.step)
  663. },
  664. pickchange(e) {
  665. var that =this;
  666. // console.log(that.data.multiIndex);
  667. // console.log(that.data.provinceList[e.detail.value[0]].area_id);
  668. // console.log(that.data.cityList[e.detail.value[1]].area_id);
  669. // console.log(that.data.areaList[e.detail.value[2]].area_id);
  670. that.setData({
  671. step: 1, // 更新,用来选择用户选中的门店
  672. multiIndex: e.detail.value, // 更新下标字段
  673. province: that.data.provinceList[e.detail.value[0]].area_id, // 市
  674. city: that.data.cityList[e.detail.value[1]].area_id, // 市
  675. area: that.data.areaList[e.detail.value[2]].area_id, // 区
  676. provincename: that.data.provinceList[e.detail.value[0]].area_name, // 市
  677. cityname: that.data.cityList[e.detail.value[1]].area_name, // 市
  678. areaname: that.data.areaList[e.detail.value[2]].area_name, // 区
  679. CityRecord: that.data.provinceList[e.detail.value[0]].area_id, // 省
  680. areaRecord: that.data.cityList[e.detail.value[1]].area_id, // 市
  681. CityRecordid: that.data.multiIndex,
  682. UsedRecord: true, //已使用过
  683. })
  684. that.list();
  685. },
  686. // 城市取消
  687. cancel: function (e) {
  688. var _this = this;
  689. if (_this.data.UsedRecord == true) {
  690. _this.setData({
  691. multiIndex: _this.data.CityRecordid,
  692. cancelID: false
  693. })
  694. // console.log(_this.data.CityRecordid);
  695. _this.getProvince(); //地址 ajax
  696. }
  697. },
  698. // 上拉加载更多
  699. onReachBottom() {
  700. var that = this;
  701. that.showLoading(); //提示加载中
  702. // 列表信息
  703. let home_url = 'circle/friend/home';
  704. let home_data = {
  705. page: (that.data.page++) + 1,
  706. limit: that.data.limit,
  707. height: that.data.height, // 身高
  708. age: that.data.age, // 年龄
  709. marry: that.data.marry, // 婚史
  710. education: that.data.education, // 学历
  711. // province: that.data.province, // 市
  712. city: that.data.city, // 市
  713. // area: that.data.area, // 区
  714. };
  715. app.postRequest(home_url, home_data, function (res) {
  716. if (res.code == 201) {
  717. // console.log(res.data);
  718. var home = that.data.home
  719. var moreTxt = '';
  720. if (0 < (res.data.length < 10)) {
  721. moreTxt = '暂无更多数据。'
  722. console.log('无')
  723. } else {
  724. moreTxt = ''
  725. console.log('有')
  726. }
  727. // 设置数据
  728. for (var i = 0; i < res.data.length; i++) {
  729. home.push(res.data[i]);
  730. }
  731. that.setData({
  732. home: home,
  733. morehide: true,
  734. moreTxt: moreTxt,
  735. })
  736. that.cancelLoading(); //数据加载完关闭
  737. return;
  738. }
  739. that.cancelLoading(); //数据加载完关闭
  740. that.setData({
  741. home_code: res.code,
  742. morehide: true,
  743. moreTxt:"暂无更多数据。"
  744. })
  745. })
  746. },
  747. More:function(){
  748. var that = this;
  749. // console.log(that.data.age);
  750. wx.navigateTo({
  751. url: '/pages/index_screen/index_screen?age=' + that.data.age + '&agezx=' + that.data.agezx + '&heightzx=' + that.data.heightzx + '&height=' + that.data.height + '&marry=' + that.data.marry + '&idmarry=' + that.data.idmarry + '&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 + ''
  752. })
  753. },
  754. list: function () {
  755. var that = this;
  756. that.showLoading(); //提示加载中
  757. // 列表信息
  758. let home_url = 'circle/friend/home';
  759. let home_data = {
  760. page: that.data.page,
  761. limit: that.data.limit,
  762. age: that.data.age, // 年龄
  763. height: that.data.height, // 身高
  764. marry: that.data.marry, // 婚史
  765. education: that.data.education, // 学历
  766. income: that.data.income, //收入
  767. // province: that.data.province , // 市
  768. city: that.data.city, // 市
  769. // area: that.data.area, // 区
  770. };
  771. app.postRequest(home_url, home_data, function (res) {
  772. if (res.code == 201) {
  773. var moreTxt = '';
  774. if (res.data.length < 10) {
  775. moreTxt = '暂无更多数据。'
  776. } else {
  777. moreTxt = ''
  778. }
  779. // console.log(res.data);
  780. that.setData({
  781. home: res.data,
  782. moreTxt: moreTxt,
  783. home_code: res.code,
  784. })
  785. that.cancelLoading(); //数据加载完关闭
  786. return;
  787. }
  788. that.cancelLoading(); //数据加载完关闭
  789. that.setData({
  790. home: res.data,
  791. morehide: true,
  792. moreTxt: '暂无更多数据。'
  793. })
  794. })
  795. },
  796. // 加载
  797. showLoading: function () {
  798. wx.showToast({
  799. title: '加载中',
  800. icon: 'loading'
  801. });
  802. },
  803. // 关闭加载
  804. cancelLoading: function () {
  805. wx.hideToast();
  806. },
  807. // 分享
  808. onShareAppMessage: function (res) {
  809. var that = this;
  810. var code ='';
  811. // getApp().showLoading(); //提示加载中
  812. // 头部信息
  813. let datum_url = 'my/other/share';
  814. let datum_data = {
  815. };
  816. app.postRequest(datum_url, datum_data, function (res) {
  817. if (res.code == 201) {
  818. console.log(res.data.code);
  819. that.setData({
  820. code: res.data.code,
  821. })
  822. }
  823. })
  824. if (res.from === 'button') {
  825. console.log("来自页面内转发按钮");
  826. console.log(res.target);
  827. }
  828. else {
  829. console.log("来自右上角转发菜单")
  830. }
  831. return {
  832. title: '妹子图片',
  833. path: '/pages/share/share?code=' + _that.data.code +'',
  834. success: (res) => {
  835. console.log("转发成功", res);
  836. },
  837. fail: (res) => {
  838. console.log("转发失败", res);
  839. }
  840. }
  841. }
  842. })