index.js 25 KB

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