index.js 23 KB

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