index.js 25 KB

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