index.js 23 KB

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