index.js 25 KB

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