index.js 25 KB

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