index.js 23 KB

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