index.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  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.getLocation({
  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. let statusBarHeightTop = statusBarHeight;
  647. let height = statusBarHeight + 4; //ios 24px
  648. let mH = statusBarHeight + 4;
  649. if (platform.toLowerCase() == "android") {
  650. height += 4; //android 28px
  651. mH += 4;
  652. }
  653. height = height + 100;
  654. // height = height + 38 + 118;
  655. // 胶囊高度 32px 下边框6px height 状态栏高度
  656. this.setData({
  657. statusBarHeightTop: statusBarHeightTop + "px",
  658. statusBarHeight: height - 12 + "px",
  659. statusBarMH: mH + "px",
  660. });
  661. },
  662. loadDictionary() {
  663. let _this = this;
  664. app._post_form(
  665. "bizcatelog/apiSelectBizcatelog/workUnit",
  666. "",
  667. null,
  668. function (res) {
  669. _this.setData(res);
  670. }
  671. );
  672. },
  673. PushVipInfo() {
  674. let _this = this;
  675. let id = util.getUserId();
  676. let parm = {
  677. id,
  678. };
  679. app._post_form(
  680. "member/apiSelectMeberInfo",
  681. "application/json",
  682. JSON.stringify(parm),
  683. function (res) {
  684. if (res.code === 0) {
  685. wx.setStorageSync("USER", res.member);
  686. } else {
  687. // wx.removeStorageSync("USER");
  688. wx.clearStorage();
  689. // wx.reLaunch({
  690. // url: '/pages/login',
  691. // })
  692. wx.switchTab({
  693. url: "/pages/my/index/index",
  694. });
  695. }
  696. }
  697. );
  698. },
  699. // 获取商品分类
  700. getGoodsClassfiy() {
  701. app._get("goodscategory/select", {}, (res) => {
  702. if (res.code == 0) {
  703. // const arr = res.list.splice(0, 2);
  704. this.setData({
  705. goodsClassfiyList: res.list,
  706. });
  707. if (this.data.goodsClassfiyList[0]) {
  708. // this.getGoodsList0(this.data.goodsClassfiyList[0].id);
  709. }
  710. const obj = res.list.find(v => v.name == '联名福利') || '';
  711. console.log(obj);
  712. if(!obj) return
  713. this.getGoodsList1(obj.id);
  714. }
  715. });
  716. },
  717. getGoodsList0(categoryId, i) {
  718. app._get(
  719. "goods/page", {
  720. pageSize: 1,
  721. pageNum: 1,
  722. categoryId: categoryId,
  723. },
  724. (res) => {
  725. if (res.code == 0) {
  726. this.setData({
  727. goodsList0: res.page.list || [],
  728. });
  729. }
  730. }
  731. );
  732. },
  733. getGoodsList1(categoryId) {
  734. app._get(
  735. "goods/page", {
  736. pageSize: 3,
  737. pageNum: 1,
  738. categoryId: categoryId,
  739. },
  740. (res) => {
  741. if (res.code == 0) {
  742. this.setData({
  743. goodsList1: res.page.list || [],
  744. });
  745. }
  746. }
  747. );
  748. },
  749. toGoodsList(e) {
  750. let name = e.currentTarget.dataset.name;
  751. const obj = this.data.goodsClassfiyList.find(v => v.name == name) || '';
  752. // console.log(obj);
  753. wx.setStorageSync('classfiyId', obj ? obj.id : '')
  754. wx.navigateTo({
  755. url: `/pages/quality/index/index`,
  756. });
  757. },
  758. goodsDetail(e) {
  759. wx.navigateTo({
  760. url: `/pages/quality/detail/index?id=${e.currentTarget.dataset.id}`,
  761. });
  762. },
  763. getShopList() {
  764. let nowCity = wx.getStorageSync("CHOOSECITY");
  765. app._get(
  766. "store/list", {
  767. lon: this.data.longitude,
  768. lat: this.data.latitude,
  769. limit: 2,
  770. },
  771. (res) => {
  772. if (res.code == 0) {
  773. this.setData({
  774. shopList: res.list || [],
  775. });
  776. }
  777. }
  778. );
  779. },
  780. // tanslateM(value) {
  781. // let val = value > 1000 ? (value / 1000).toFixed(2) + "KM" : value + "M";
  782. // return val;
  783. // },
  784. // 查看地图
  785. goLocalNew(e) {
  786. let that = this;
  787. let [latitude, longitude] = [
  788. this.data.shopObj.coordinate.split(",")[0],
  789. this.data.shopObj.coordinate.split(",")[1],
  790. ];
  791. console.log(Number(latitude), Number(longitude));
  792. wx.openLocation({
  793. latitude: Number(longitude),
  794. longitude: Number(latitude),
  795. name: e.currentTarget.dataset.name,
  796. address: e.currentTarget.dataset.address,
  797. success: function () {
  798. console.log("success");
  799. },
  800. });
  801. },
  802. callPhoneNew(e) {
  803. let that = this;
  804. wx.makePhoneCall({
  805. phoneNumber: e.currentTarget.dataset.phone,
  806. });
  807. },
  808. // 查看门店详情
  809. goShopStore(e) {
  810. let that = this;
  811. wx.navigateTo({
  812. url: "/expert/storedetail/storedetail?id=" +
  813. e.currentTarget.dataset.id +
  814. "&lon=" +
  815. that.data.longitude +
  816. "&lat=" +
  817. that.data.latitude,
  818. });
  819. },
  820. /**
  821. * 页面相关事件处理函数--监听用户下拉动作
  822. */
  823. onPullDownRefresh: function () {
  824. var _this = this;
  825. //强制更新
  826. setTimeout(() => {
  827. _this.getLocal();
  828. }, 200);
  829. // 处理完成后,终止下拉刷新
  830. wx.stopPullDownRefresh();
  831. },
  832. /**
  833. * 页面上拉触底事件的处理函数
  834. */
  835. onReachBottom: function () {
  836. // this.loadList();
  837. },
  838. //重新选择城市
  839. cityPickerChange(e) {
  840. let cityListIndex = e.detail.value;
  841. let cityData = {
  842. cityName: this.data.cityListPickerData[cityListIndex].name,
  843. cityId: this.data.cityListPickerData[cityListIndex].id,
  844. // areaName: this.data.cityList[cityListIndex[0]].childRegionList[cityListIndex[1]].name,
  845. // areaId: this.data.cityList[cityListIndex[0]].childRegionList[cityListIndex[1]].id,
  846. };
  847. this.setData({
  848. cityListIndex,
  849. currentCity: cityData,
  850. });
  851. //设置城市选择数据
  852. wx.setStorageSync("CHOOSECITY", cityData);
  853. // this.loadList(true)
  854. this.hotActive();
  855. this.newJob();
  856. this.schoolPer();
  857. this.getExpert();
  858. this.getShop();
  859. this.getGoodsClassfiy();
  860. this.getShopList();
  861. console.log(e);
  862. },
  863. cityPickerColumnChange(e) {
  864. if (e.detail.column == 0) {
  865. this.setData({
  866. cityListPickerData: [
  867. this.data.cityList,
  868. this.data.cityList[e.detail.value].childRegionList,
  869. ],
  870. });
  871. }
  872. },
  873. /**
  874. * @param {Object} isRefresh 是否刷新,否则就是下一页
  875. */
  876. loadList(isRefresh) {
  877. let that = this;
  878. if (!isRefresh && this.data.noMore) {
  879. wx.showToast({
  880. title: "没有更多了~",
  881. icon: "none",
  882. });
  883. return false;
  884. }
  885. let nowCity = wx.getStorageSync("CHOOSECITY");
  886. if (!nowCity || !nowCity.cityId) {
  887. return false;
  888. }
  889. this.setData({
  890. listData: isRefresh ? [] : this.data.listData,
  891. params: {
  892. ...this.data.params,
  893. pageNum: isRefresh ? 1 : this.data.params.pageNum + 1,
  894. city: nowCity.cityId,
  895. area: nowCity.areaId,
  896. type: this.data.nameIndex + 1,
  897. },
  898. noMore: isRefresh ? false : this.data.noMore,
  899. });
  900. wx.showLoading({
  901. title: "努力加载中...",
  902. });
  903. app._post_form(
  904. "home/mylist",
  905. "",
  906. this.data.params,
  907. function (res) {
  908. if (res.code == 0) {
  909. if (
  910. res.page.list.length > 0 &&
  911. that.data.listData.length > 0 &&
  912. res.page.list[0].id == that.data.listData[0].id
  913. ) {
  914. return;
  915. }
  916. let listData = that.data.listData;
  917. listData.push(...res.page.list);
  918. that.setData({
  919. listData,
  920. currPage: res.page.currPage,
  921. totalPage: res.page.totalPage,
  922. noMore: res.page.totalPage == res.page.currPage,
  923. });
  924. }
  925. },
  926. function (res) {
  927. wx.hideLoading();
  928. }
  929. );
  930. },
  931. onShareAppMessage: function () { },
  932. onPageScroll: function (e) {
  933. if (
  934. e.scrollTop >= 10 &&
  935. this.data.activeTitle == false
  936. ) {
  937. this.setData({
  938. activeTitle: true,
  939. });
  940. }
  941. if (
  942. e.scrollTop < 10 &&
  943. this.data.activeTitle == true
  944. ) {
  945. this.setData({
  946. activeTitle: false,
  947. });
  948. }
  949. },
  950. showRewardedVideoAd: function (e) {
  951. this.selectComponent('.uni-rewarded-video-ad').show();
  952. },
  953. onadload: function (e) {
  954. console.log('广告加载成功:', e)
  955. },
  956. onadclose: function (e) {
  957. const detail = e.detail
  958. // 用户点击了【关闭广告】按钮
  959. if (detail && detail.isEnded) {
  960. // 正常播放结束
  961. console.log("onClose-正常播放结束:" + detail.isEnded);
  962. } else {
  963. // 播放中途退出
  964. console.log("onClose-播放中途退出:" + detail.isEnded);
  965. }
  966. },
  967. onaderror: function (e) {
  968. // 广告加载失败
  969. console.log('广告加载失败:', e.detail)
  970. }
  971. });