index.js 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  1. import tool from "../../../utils/tool.js";
  2. import volunteer from "../../../pages/data/volunteer.js";
  3. import growth from "../../../pages/data/growth.js";
  4. var app = getApp();
  5. var util = require("../../../utils/util.js");
  6. var QQMapWX = require("../../../utils/qqmap-wx-jssdk.js");
  7. var map;
  8. map = new QQMapWX({
  9. key: "RA3BZ-PSGW4-GZUUX-DDAU7-6B54E-KJFQ7", // 必填
  10. });
  11. Page({
  12. /**
  13. * 页面的初始数据
  14. */
  15. data: {
  16. appAssetsUrl: app.appAssetsUrl,
  17. appAssetsUrl2: app.appAssetsUrl2,
  18. appAssetsUrl3: app.appAssetsUrl3,
  19. nodata: util.nodata(),
  20. indicatorData: true,
  21. autoplay: true,
  22. interval: 3000,
  23. circular: true,
  24. autostop: false,
  25. params: {
  26. pageNum: 1,
  27. pageSize: 10,
  28. city: "",
  29. area: "",
  30. type: 1, //1推荐 2最新 3最热
  31. },
  32. total: {
  33. currPage: 0,
  34. totalPage: 0,
  35. },
  36. noMore: false,
  37. statusBarHeightTop: 0,
  38. statusBarHeight: 0,
  39. nameIndex: 0,
  40. nameList: [{
  41. name: "推荐兼职",
  42. },
  43. {
  44. name: "最新兼职",
  45. },
  46. {
  47. name: "最热兼职",
  48. },
  49. ],
  50. classList: [{
  51. // image: app.appAssetsUrl2 + "wjxy/homejianzhi.png",
  52. // image: app.appAssetsUrl2 + "new/job-icon.png",
  53. image: app.appAssetsUrl3 + 'home/icon_1.png',
  54. name: "勤工俭学",
  55. },
  56. {
  57. // image: app.appAssetsUrl2 + "wjxy/homeactive.png",
  58. // image: app.appAssetsUrl2 + "new/activity-icon.png",
  59. image: app.appAssetsUrl3 + 'home/icon_2.png',
  60. name: "热门活动",
  61. },
  62. {
  63. // image: app.appAssetsUrl2 + "wjxy/homeshen.png",
  64. image: app.appAssetsUrl3 + 'home/icon_3.png',
  65. name: "青雲问鼎",
  66. },
  67. // {
  68. // // image: app.appAssetsUrl2 + "wjxy/homevip.png",
  69. // image: app.appAssetsUrl2 + "new/goods-icon.png",
  70. // name: "市集优选",
  71. // },
  72. {
  73. // image: app.appAssetsUrl2 + "wjxy/homevip.png",
  74. // image: app.appAssetsUrl2 + "new/member-icon.png",
  75. image: app.appAssetsUrl3 + 'home/icon_4.png',
  76. name: "联名福利",
  77. },
  78. // {
  79. // image: app.appAssetsUrl2 + "wjxy/homecode.png",
  80. // name: "邀请码",
  81. // },
  82. ],
  83. cityList: [],
  84. cityListPickerData: [],
  85. cityListIndex: [],
  86. listData: [],
  87. imglist: [],
  88. currentCity: {},
  89. current: 0,
  90. maskShow: false,
  91. activeList: [],
  92. jobList: [],
  93. perList: [],
  94. expertList: [],
  95. shopObj: {},
  96. popupImg: "",
  97. latitude: "",
  98. longitude: "",
  99. goodsClassfiyList: [],
  100. goodsList0: [],
  101. goodsList1: [],
  102. shopList: [],
  103. activeTitle: false
  104. },
  105. moreHandler() {
  106. this.experience();
  107. },
  108. selectCity(e) {
  109. wx.navigateTo({
  110. url: "/pages/home/location/index",
  111. });
  112. },
  113. experience(e) {
  114. // console.log(e, 11111111);
  115. if (
  116. e.currentTarget.dataset.index == 4 ||
  117. e.currentTarget.dataset.index == 3
  118. ) {
  119. // if (wx.getStorageSync("USER")) {
  120. const obj = this.data.goodsClassfiyList.find(v => v.name == '联名福利') || '';
  121. // console.log(obj);
  122. wx.setStorageSync('classfiyId', obj ? obj.id : '')
  123. wx.navigateTo({
  124. url: e.currentTarget.dataset.index == 4 ?
  125. "/invitationCode/index" : `/pages/quality/index/index`,
  126. });
  127. // } else {
  128. // wx.navigateTo({
  129. // url: "/pages/login",
  130. // });
  131. // }
  132. } else {
  133. app.params.pePageToIndex =
  134. e === undefined ? 0 : e.currentTarget.dataset.index + 1;
  135. switch (e.currentTarget.dataset.index) {
  136. case 0:
  137. wx.switchTab({
  138. url: "/pages/practicalExperience/practicalExperience",
  139. });
  140. break;
  141. case 1:
  142. wx.navigateTo({
  143. url: "/pages/experience/index/index",
  144. });
  145. break;
  146. case 2:
  147. wx.switchTab({
  148. url: "/pages/dashen/index",
  149. // url: "/pages/quality/index/index",
  150. });
  151. break;
  152. case 3:
  153. wx.navigateTo({
  154. url: "/pages/myMember/myMember",
  155. });
  156. break;
  157. default:
  158. wx.navigateTo({
  159. url: "/invitationCode/index",
  160. });
  161. }
  162. }
  163. },
  164. // 热门活动
  165. hotActive() {
  166. let nowCity = wx.getStorageSync("CHOOSECITY");
  167. let that = this;
  168. app._post_form(
  169. "act/list",
  170. "", {
  171. city: nowCity.cityId,
  172. limit: 10,
  173. page: 1,
  174. isFrontPage: 1,
  175. },
  176. function (res) {
  177. if (res.code == 0) {
  178. res.page.list.map((v) => {
  179. v.startTime = v.startTime.replace(/-/g, ".").split(" ")[0];
  180. v.endTime = v.endTime.replace(/-/g, ".").split(" ")[0];
  181. });
  182. that.setData({
  183. activeList: res.page.list,
  184. });
  185. }
  186. },
  187. function (res) { }
  188. );
  189. },
  190. // 最新兼职
  191. newJob() {
  192. let nowCity = wx.getStorageSync("CHOOSECITY");
  193. console.log(nowCity);
  194. let that = this;
  195. app._post_form(
  196. "home/label",
  197. "", {
  198. city: nowCity.cityId,
  199. pageNum: 1,
  200. isHome: 1,
  201. pageSize: 4,
  202. },
  203. function (res) {
  204. if (res.code == 0) {
  205. that.setData({
  206. jobList: res.page.list,
  207. });
  208. }
  209. },
  210. function (res) { }
  211. );
  212. },
  213. // 校园代理人
  214. schoolPer() {
  215. let that = this;
  216. app._get(
  217. `campusagent/page`, {
  218. page: 1,
  219. limit: 10,
  220. },
  221. (res) => {
  222. if (res.code === 0) {
  223. that.setData({
  224. perList: res.page.list,
  225. });
  226. }
  227. }
  228. );
  229. },
  230. // 推荐行家
  231. getExpert() {
  232. let that = this;
  233. let nowCity = wx.getStorageSync("CHOOSECITY");
  234. app._get(
  235. "expert/greatGodGangPage", {
  236. page: 1,
  237. limit: 10,
  238. city: nowCity.cityId,
  239. },
  240. function (res) {
  241. if (res.code == 0) {
  242. that.setData({
  243. expertList: res.page.list,
  244. });
  245. }
  246. }
  247. );
  248. },
  249. // 门店推荐
  250. getShop() {
  251. let that = this;
  252. let nowCity = wx.getStorageSync("CHOOSECITY");
  253. app._get(
  254. "store/storeRecommendation", {
  255. lon: that.data.longitude,
  256. lat: that.data.latitude,
  257. },
  258. function (res) {
  259. if (res.code == 0 && res.data) {
  260. let val = res.data.calculateNew / 1000;
  261. let formatVal = parseInt(val * 10);
  262. that.setData({
  263. shopObj: res.data,
  264. "shopObj.calculateNew": formatVal / 10,
  265. "shopObj.storePhoto": res.data.storePhoto.split(",")[0],
  266. });
  267. }
  268. }
  269. );
  270. },
  271. // 查看门店详情
  272. goStore(e) {
  273. console.log(e, 111);
  274. let that = this;
  275. wx.navigateTo({
  276. url: "/expert/storedetail/storedetail?id=" +
  277. that.data.shopObj.id +
  278. "&lon=" +
  279. that.data.longitude +
  280. "&lat=" +
  281. that.data.latitude,
  282. });
  283. },
  284. // 查看地图
  285. goLocal() {
  286. let that = this;
  287. let [latitude, longitude] = [
  288. this.data.shopObj.coordinate.split(",")[0],
  289. this.data.shopObj.coordinate.split(",")[1],
  290. ];
  291. console.log(Number(latitude), Number(longitude));
  292. wx.openLocation({
  293. latitude: Number(longitude),
  294. longitude: Number(latitude),
  295. name: that.data.shopObj.name,
  296. address: that.data.shopObj.address,
  297. success: function () {
  298. console.log("success");
  299. },
  300. });
  301. },
  302. callPhone() {
  303. let that = this;
  304. wx.makePhoneCall({
  305. phoneNumber: that.data.shopObj.phone,
  306. });
  307. },
  308. // 开屏弹窗
  309. openPopup() {
  310. app._get("openscreenpopup/openScreenPopup", {}, (res) => {
  311. if (res.code == 0 && res.data) {
  312. let maskShow = false;
  313. if (wx.getStorageSync("popId") != res.data.id) {
  314. wx.setStorageSync("popId", res.data.id);
  315. maskShow = true;
  316. }
  317. this.setData({
  318. popupImg: res.data.popUpPicture,
  319. maskShow: maskShow,
  320. });
  321. }
  322. });
  323. },
  324. // 兼职详情
  325. toPartDetail(e) {
  326. wx.navigateTo({
  327. url: `/pages/home/index/partDetail/partDetail?id=${e.currentTarget.dataset.id}`,
  328. });
  329. },
  330. // 校园代理人详情
  331. perDetail(e) {
  332. // console.log(e)
  333. wx.navigateTo({
  334. url: "/expert/agentdetail/agentdetail?id=" +
  335. e.currentTarget.dataset.id +
  336. "&type=校园代理人",
  337. });
  338. },
  339. // 行家详情
  340. toExpertDetail(e) {
  341. wx.navigateTo({
  342. url: `/expert/detail/detail?id=${e.currentTarget.dataset.id}`,
  343. });
  344. },
  345. onBindFocus: function (e) {
  346. let _this = this;
  347. wx.navigateTo({
  348. url: "/pages/search/index",
  349. });
  350. },
  351. closePopup() {
  352. this.setData({
  353. maskShow: false,
  354. });
  355. },
  356. nameHandler(e) {
  357. this.setData({
  358. nameIndex: e.target.dataset.index,
  359. });
  360. this.loadList(true);
  361. },
  362. growthMore: function (event) {
  363. wx.navigateTo({
  364. url: "/pages/home/index/growth/growthMore/growthMore",
  365. });
  366. },
  367. activitymore: function (event) {
  368. wx.reLaunch({
  369. url: "/pages/experience/index/index?type=1",
  370. });
  371. },
  372. onReady: function () {
  373. this.popup2 = this.selectComponent("#popup2");
  374. // this.setData({
  375. // maskShow: true
  376. // })
  377. },
  378. onLoad: function (options) {
  379. console.log("options", options);
  380. if (!options.cityId) {
  381. this.loadCity();
  382. }
  383. this.height();
  384. if (wx.getStorageSync("USER")) {
  385. this.PushVipInfo();
  386. }
  387. let _this = this;
  388. _this.data.option = options;
  389. setTimeout(function () {
  390. _this.loadDictionary();
  391. }, 100);
  392. _this.addScore();
  393. if (options.cityId) {
  394. let cityData = {
  395. cityName: options.cityName,
  396. cityId: options.cityId
  397. };
  398. wx.setStorageSync("CHOOSECITY", cityData);
  399. this.setData({
  400. currentCity: cityData,
  401. }, () => {
  402. console.log("currentCity", this.data.currentCity)
  403. //设置城市选择数据
  404. this.loadList(true)
  405. _this.hotActive();
  406. _this.newJob();
  407. _this.schoolPer();
  408. _this.getExpert();
  409. _this.getShop();
  410. _this.getGoodsClassfiy();
  411. _this.getShopList();
  412. });
  413. } else {
  414. _this.getLocal();
  415. }
  416. _this.getAgree()
  417. },
  418. toPrivacy() {
  419. wx.openPrivacyContract({
  420. success: () => { }, // 打开成功
  421. fail: () => { }, // 打开失败
  422. complete: () => { }
  423. })
  424. // wx.navigateTo({
  425. // url: "/pages/privacy/privacy",
  426. // });
  427. },
  428. closeAgree() {
  429. this.popup2.hidePopup();
  430. },
  431. handleAgreePrivacyAuthorization() {
  432. this.getLocal();
  433. this.popup2.hidePopup();
  434. },
  435. getAgree() {
  436. wx.getPrivacySetting({
  437. success: res => {
  438. // console.log(res, 3333) // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
  439. if (res.needAuthorization) {
  440. this.popup2.showPopup();
  441. // 需要弹出隐私协议
  442. } else {
  443. // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用已声明过的隐私接口
  444. // wx.getUserProfile()
  445. // wx.chooseMedia()
  446. // wx.getClipboardData()
  447. // wx.startRecord()
  448. }
  449. },
  450. fail: () => { },
  451. complete: () => { }
  452. })
  453. },
  454. onShow() {
  455. this.openPopup();
  456. },
  457. //获取城市信息
  458. getLocal() {
  459. const _this = this;
  460. wx.getFuzzyLocation({
  461. type: "gcj02",
  462. isHighAccuracy: true,
  463. success(res) {
  464. console.log("经纬度", res);
  465. const latitude = res.latitude;
  466. const longitude = res.longitude;
  467. _this.setData({
  468. latitude: res.latitude,
  469. longitude: res.longitude,
  470. });
  471. //通过【小程序定位】获取经纬度,在通过第三方sdk获取的地址信息
  472. _this.pointToAddress(latitude, longitude, function (address) {
  473. if (address) {
  474. wx.setStorageSync("CHOOSECITY", {
  475. cityName: address.city,
  476. areaName: address.district,
  477. });
  478. _this.loadCity();
  479. }
  480. });
  481. console.log("111");
  482. },
  483. fail(e) {
  484. console.log(e);
  485. _this.loadCity();
  486. },
  487. });
  488. },
  489. // 定义 pointToAddress 方法
  490. pointToAddress: function (latitude, longitude, callback) {
  491. var _this = this;
  492. // 调用接口
  493. map.reverseGeocoder({
  494. location: {
  495. latitude: latitude,
  496. longitude: longitude,
  497. },
  498. success: function (res) {
  499. // 解析成功返回地址
  500. callback(res.result.ad_info);
  501. },
  502. fail: function (res) {
  503. // console.log(res);
  504. },
  505. complete: function (res) { },
  506. });
  507. },
  508. //统计积分(每日登录)
  509. addScore: function () {
  510. if (!util.getUserId()) {
  511. return;
  512. }
  513. wx.showLoading({
  514. title: "努力加载中...",
  515. });
  516. app._post_form(
  517. "scoreStu/dailyLogin",
  518. "", {
  519. stuId: util.getUserId(),
  520. },
  521. function (res) {
  522. if (res.code === 0) { }
  523. }
  524. );
  525. },
  526. // 首页banner
  527. loadImg: function () {
  528. let _this = this;
  529. let nowCity = wx.getStorageSync("CHOOSECITY");
  530. let params = {
  531. type: "01",
  532. area: "",
  533. };
  534. app._post_form("img/mylist", "application/json", params, function (res) {
  535. if (res.code == 0) {
  536. _this.setData({
  537. imglist: res.data,
  538. });
  539. }
  540. });
  541. },
  542. //banner跳转
  543. imgJump(v) {
  544. console.log(v);
  545. console.log(v.currentTarget.dataset.item.jumpAddressType);
  546. if (v.currentTarget.dataset.item.jumpAddressType == 0) {
  547. //内部跳转
  548. wx.navigateTo({
  549. url: v.currentTarget.dataset.item.linkUrl,
  550. });
  551. } else if (v.currentTarget.dataset.item.jumpAddressType == 1) {
  552. //公众号跳转 'https://www.kujiale.cn/design/3FO4EQWQJF0M/show'
  553. wx.setStorageSync("gzurl", v.currentTarget.dataset.item.linkUrl);
  554. wx.navigateTo({
  555. url: "./gz/gz",
  556. });
  557. }
  558. },
  559. more(e) {
  560. console.log(e);
  561. if (e.currentTarget.dataset.type == "tab") {
  562. wx.switchTab({
  563. url: e.currentTarget.dataset.url,
  564. });
  565. } else {
  566. wx.navigateTo({
  567. url: e.currentTarget.dataset.url,
  568. });
  569. }
  570. },
  571. popupDetail() {
  572. this.setData({
  573. maskShow: false,
  574. });
  575. wx.navigateTo({
  576. url: "/expert/popupdetail/popupdetail",
  577. });
  578. },
  579. changeSwiper(e) {
  580. let {
  581. current,
  582. source
  583. } = e.detail;
  584. if (source === "autoplay" || source === "touch") {
  585. this.setData({
  586. current: current,
  587. });
  588. }
  589. // this.setData({
  590. // current: e.detail.current
  591. // })
  592. },
  593. loadCity: function () {
  594. let _this = this;
  595. app._post_form("serviceCityList", "", null, function (res) {
  596. if (res.data.length) {
  597. //设置城市选择的数据
  598. let cityData = {
  599. cityName: "",
  600. cityId: "",
  601. // areaName: '',
  602. // areaId: ''
  603. };
  604. // console.log(res.data);
  605. //设置城市下拉框数据
  606. let cityListPickerData = res.data;
  607. let cityListIndex = [];
  608. //nowCity是之前首页的城市选择下拉框的数据
  609. let nowCity = wx.getStorageSync("CHOOSECITY");
  610. if (nowCity) {
  611. a: for (let i = 0; i < res.data.length; i++) {
  612. let cityName = res.data[i].name;
  613. if (nowCity.cityName === cityName) {
  614. cityData.cityName = res.data[i].name;
  615. cityData.cityId = res.data[i].cityId;
  616. cityListIndex.push(i);
  617. }
  618. }
  619. if (cityListIndex.length == 0) {
  620. cityData.cityName = res.data[0].name;
  621. cityData.cityId = res.data[0].cityId;
  622. cityListIndex.push(0);
  623. }
  624. }
  625. else {
  626. cityData.cityName = res.data[0].name;
  627. cityData.cityId = res.data[0].cityId;
  628. cityListIndex = [0, 0];
  629. }
  630. //设置城市选择数据
  631. wx.setStorageSync("CHOOSECITY", cityData);
  632. //设置城市下拉框数据
  633. _this.setData({
  634. cityList: res.data,
  635. cityListPickerData,
  636. cityListIndex,
  637. currentCity: cityData,
  638. });
  639. // console.log(_this.data.cityListPickerData);
  640. setTimeout(function () {
  641. _this.loadImg();
  642. _this.hotActive();
  643. _this.newJob();
  644. _this.schoolPer();
  645. _this.getExpert();
  646. _this.getShop();
  647. _this.getGoodsClassfiy();
  648. _this.getShopList();
  649. // _this.loadList(true);
  650. }, 300);
  651. }
  652. });
  653. },
  654. // 查看活动详情
  655. activeDetail: function (e) {
  656. if (e.currentTarget.dataset.id) {
  657. wx.navigateTo({
  658. url: "/pages/home/index/activityDetail/activityDetail?id=" +
  659. e.currentTarget.dataset.id,
  660. });
  661. }
  662. },
  663. // 自定义高度处理
  664. height() {
  665. const {
  666. platform,
  667. statusBarHeight
  668. } = wx.getSystemInfoSync();
  669. // console.log("statusBarHeight======", statusBarHeight);
  670. let statusBarHeightTop = statusBarHeight;
  671. let height = statusBarHeight + 4; //ios 24px
  672. let mH = statusBarHeight + 4;
  673. if (platform.toLowerCase() == "android") {
  674. height += 4; //android 28px
  675. mH += 4;
  676. }
  677. height = height + 100;
  678. // height = height + 38 + 118;
  679. // 胶囊高度 32px 下边框6px height 状态栏高度
  680. let then = this
  681. this.setData({
  682. statusBarHeightTop: statusBarHeightTop + "px",
  683. statusBarHeight: statusBarHeight + 88 + "px",
  684. statusBarMH: mH + "px",
  685. }, res => {
  686. // console.log("加载完成======", height);
  687. // 创建选择器查询
  688. // const query = wx.createSelectorQuery();
  689. // console.log("query======", query);
  690. // 选择 id 为 diy-top 的节点
  691. wx.createSelectorQuery().in(this).select('#diy-top').boundingClientRect(rect => {
  692. // console.log("rect===", rect) //这 里有值
  693. then.setData({
  694. statusBarHeight: rect.height + "px"
  695. })
  696. }).exec();
  697. });
  698. },
  699. loadDictionary() {
  700. let _this = this;
  701. app._post_form(
  702. "bizcatelog/apiSelectBizcatelog/workUnit",
  703. "",
  704. null,
  705. function (res) {
  706. _this.setData(res);
  707. }
  708. );
  709. },
  710. PushVipInfo() {
  711. let _this = this;
  712. let id = util.getUserId();
  713. let parm = {
  714. id,
  715. };
  716. app._post_form(
  717. "member/apiSelectMeberInfo",
  718. "application/json",
  719. JSON.stringify(parm),
  720. function (res) {
  721. if (res.code === 0) {
  722. wx.setStorageSync("USER", res.member);
  723. } else {
  724. // wx.removeStorageSync("USER");
  725. wx.clearStorage();
  726. // wx.reLaunch({
  727. // url: '/pages/login',
  728. // })
  729. wx.switchTab({
  730. url: "/pages/my/index/index",
  731. });
  732. }
  733. }
  734. );
  735. },
  736. // 获取商品分类
  737. getGoodsClassfiy() {
  738. app._get("goodscategory/select", {}, (res) => {
  739. if (res.code == 0) {
  740. // const arr = res.list.splice(0, 2);
  741. this.setData({
  742. goodsClassfiyList: res.list,
  743. });
  744. if (this.data.goodsClassfiyList[0]) {
  745. // this.getGoodsList0(this.data.goodsClassfiyList[0].id);
  746. }
  747. const obj = res.list.find(v => v.name == '联名福利') || '';
  748. // console.log(obj);
  749. if (!obj) return
  750. this.getGoodsList1(obj.id);
  751. }
  752. });
  753. },
  754. getGoodsList0(categoryId, i) {
  755. app._get(
  756. "goods/page", {
  757. pageSize: 1,
  758. pageNum: 1,
  759. categoryId: categoryId,
  760. },
  761. (res) => {
  762. if (res.code == 0) {
  763. this.setData({
  764. goodsList0: res.page.list || [],
  765. });
  766. }
  767. }
  768. );
  769. },
  770. getGoodsList1(categoryId) {
  771. app._get(
  772. "goods/page", {
  773. pageSize: 3,
  774. pageNum: 1,
  775. categoryId: categoryId,
  776. },
  777. (res) => {
  778. if (res.code == 0) {
  779. this.setData({
  780. goodsList1: res.page.list || [],
  781. });
  782. }
  783. }
  784. );
  785. },
  786. toGoodsList(e) {
  787. let name = e.currentTarget.dataset.name;
  788. const obj = this.data.goodsClassfiyList.find(v => v.name == name) || '';
  789. // console.log(obj);
  790. wx.setStorageSync('classfiyId', obj ? obj.id : '')
  791. wx.navigateTo({
  792. url: `/pages/quality/index/index`,
  793. });
  794. },
  795. goodsDetail(e) {
  796. wx.navigateTo({
  797. url: `/pages/quality/detail/index?id=${e.currentTarget.dataset.id}`,
  798. });
  799. },
  800. getShopList() {
  801. let nowCity = wx.getStorageSync("CHOOSECITY");
  802. app._get(
  803. "store/list", {
  804. lon: this.data.longitude,
  805. lat: this.data.latitude,
  806. limit: 2,
  807. },
  808. (res) => {
  809. if (res.code == 0) {
  810. this.setData({
  811. shopList: res.list || [],
  812. });
  813. }
  814. }
  815. );
  816. },
  817. // tanslateM(value) {
  818. // let val = value > 1000 ? (value / 1000).toFixed(2) + "KM" : value + "M";
  819. // return val;
  820. // },
  821. // 查看地图
  822. goLocalNew(e) {
  823. let that = this;
  824. let [latitude, longitude] = [
  825. this.data.shopObj.coordinate.split(",")[0],
  826. this.data.shopObj.coordinate.split(",")[1],
  827. ];
  828. console.log(Number(latitude), Number(longitude));
  829. wx.openLocation({
  830. latitude: Number(longitude),
  831. longitude: Number(latitude),
  832. name: e.currentTarget.dataset.name,
  833. address: e.currentTarget.dataset.address,
  834. success: function () {
  835. console.log("success");
  836. },
  837. });
  838. },
  839. callPhoneNew(e) {
  840. let that = this;
  841. wx.makePhoneCall({
  842. phoneNumber: e.currentTarget.dataset.phone,
  843. });
  844. },
  845. // 查看门店详情
  846. goShopStore(e) {
  847. let that = this;
  848. wx.navigateTo({
  849. url: "/expert/storedetail/storedetail?id=" +
  850. e.currentTarget.dataset.id +
  851. "&lon=" +
  852. that.data.longitude +
  853. "&lat=" +
  854. that.data.latitude,
  855. });
  856. },
  857. /**
  858. * 页面相关事件处理函数--监听用户下拉动作
  859. */
  860. onPullDownRefresh: function () {
  861. var _this = this;
  862. //强制更新
  863. setTimeout(() => {
  864. _this.getLocal();
  865. }, 200);
  866. // 处理完成后,终止下拉刷新
  867. wx.stopPullDownRefresh();
  868. },
  869. /**
  870. * 页面上拉触底事件的处理函数
  871. */
  872. onReachBottom: function () {
  873. // this.loadList();
  874. },
  875. //重新选择城市
  876. cityPickerChange(e) {
  877. // console.log('e.detail.value===>', e.detail.value);
  878. let cityListIndex = e.detail.value;
  879. let cityData = {
  880. cityName: this.data.cityListPickerData[cityListIndex].name,
  881. cityId: this.data.cityListPickerData[cityListIndex].id,
  882. // areaName: this.data.cityList[cityListIndex[0]].childRegionList[cityListIndex[1]].name,
  883. // areaId: this.data.cityList[cityListIndex[0]].childRegionList[cityListIndex[1]].id,
  884. };
  885. // console.log('cityData===>', cityData);
  886. wx.setStorageSync("CHOOSECITY", cityData);
  887. this.setData({
  888. cityListIndex,
  889. currentCity: cityData,
  890. }, () => {
  891. //设置城市选择数据
  892. // this.loadList(true)
  893. this.hotActive();
  894. this.newJob();
  895. this.schoolPer();
  896. this.getExpert();
  897. this.getShop();
  898. this.getGoodsClassfiy();
  899. this.getShopList();
  900. });
  901. },
  902. cityPickerColumnChange(e) {
  903. if (e.detail.column == 0) {
  904. this.setData({
  905. cityListPickerData: [
  906. this.data.cityList,
  907. this.data.cityList[e.detail.value].childRegionList,
  908. ],
  909. });
  910. }
  911. },
  912. /**
  913. * @param {Object} isRefresh 是否刷新,否则就是下一页
  914. */
  915. loadList(isRefresh) {
  916. let that = this;
  917. if (!isRefresh && this.data.noMore) {
  918. wx.showToast({
  919. title: "没有更多了~",
  920. icon: "none",
  921. });
  922. return false;
  923. }
  924. let nowCity = wx.getStorageSync("CHOOSECITY");
  925. if (!nowCity || !nowCity.cityId) {
  926. return false;
  927. }
  928. this.setData({
  929. listData: isRefresh ? [] : this.data.listData,
  930. params: {
  931. ...this.data.params,
  932. pageNum: isRefresh ? 1 : this.data.params.pageNum + 1,
  933. city: nowCity.cityId,
  934. area: nowCity.areaId,
  935. type: this.data.nameIndex + 1,
  936. },
  937. noMore: isRefresh ? false : this.data.noMore,
  938. });
  939. wx.showLoading({
  940. title: "努力加载中...",
  941. });
  942. app._post_form(
  943. "home/mylist",
  944. "",
  945. this.data.params,
  946. function (res) {
  947. if (res.code == 0) {
  948. if (
  949. res.page.list.length > 0 &&
  950. that.data.listData.length > 0 &&
  951. res.page.list[0].id == that.data.listData[0].id
  952. ) {
  953. return;
  954. }
  955. let listData = that.data.listData;
  956. listData.push(...res.page.list);
  957. that.setData({
  958. listData,
  959. currPage: res.page.currPage,
  960. totalPage: res.page.totalPage,
  961. noMore: res.page.totalPage == res.page.currPage,
  962. });
  963. }
  964. },
  965. function (res) {
  966. wx.hideLoading();
  967. }
  968. );
  969. },
  970. onShareAppMessage: function () { },
  971. onPageScroll: function (e) {
  972. if (
  973. e.scrollTop >= 10 &&
  974. this.data.activeTitle == false
  975. ) {
  976. this.setData({
  977. activeTitle: true,
  978. });
  979. }
  980. if (
  981. e.scrollTop < 10 &&
  982. this.data.activeTitle == true
  983. ) {
  984. this.setData({
  985. activeTitle: false,
  986. });
  987. }
  988. },
  989. });