index.js 23 KB

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