appointOrder.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. //获取应用实例
  2. var util = require('../../../utils/util.js');
  3. var api = require('../../../config/api.js');
  4. var check = require('../../../utils/check.js');
  5. var app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. gender: '2',
  12. address: {
  13. id: 0,
  14. areaCode: 0,
  15. address: '',
  16. name: '',
  17. tel: '',
  18. isDefault: 0,
  19. province: '',
  20. city: '',
  21. county: '',
  22. latitude: '',
  23. longitude: '',
  24. addressDetail: '',
  25. detail: '',
  26. addressname: '',
  27. },
  28. addressIdSave: '', //新增地址保存
  29. orderInfo: {
  30. },
  31. addressId: '',
  32. checkedAddress: {
  33. },
  34. addressList: [],
  35. addressShow: false,
  36. remark: '',
  37. remarkPopupShow: false,
  38. remarkList: [
  39. '上门前提前电话联系',
  40. '请准时到达',
  41. '请自带打扫工具',
  42. '主要打扫厨房&卫生间',
  43. '家里有宠物'
  44. ],
  45. remarkActive: '',
  46. serviceId: '',
  47. message: '',
  48. remarkShow: false,
  49. addressId: '',
  50. addressName: '',
  51. noAppoint: '',
  52. aftersaleStatus: '',
  53. orderId: '',
  54. order: '',
  55. bookId: '',
  56. bookCount: 0,
  57. orderStatusText: '订单服务中',
  58. activeTab: 1,
  59. orderBook: {
  60. status: ''
  61. },
  62. orderChannel: 0,
  63. jzOrderBookDetails: [],
  64. unusedSerList: [],
  65. usedSerList: [],
  66. serList: [],
  67. choosePopup: false,
  68. timeList: [],
  69. // dateList: util.getDateList(new Date(new Date().getTime() + 60 * 60 * 1000 * 24 * 0), 1, 30),
  70. dateList:[],
  71. timeIndex: '',
  72. //选中的时间段
  73. dateIndex: 0, //选中的日期
  74. appointDate: '', //显示信息
  75. isHide: false,
  76. product: {
  77. serviceTimes: '',
  78. price: ''
  79. },
  80. noonType: 1,
  81. selectTimeValue: '',
  82. goodsTip:{
  83. remark:null
  84. }
  85. },
  86. /**
  87. * 生命周期函数--监听页面加载
  88. */
  89. onLoad: function (options) {
  90. console.log(options);
  91. if (options.serviceId) {
  92. this.setData({
  93. serviceId: options.serviceId
  94. });
  95. }
  96. if (options.orderId) {
  97. this.setData({
  98. orderId: options.orderId
  99. });
  100. }
  101. app.globalData.mapSelectFinish = false;
  102. },
  103. getOrderDetail: function () {
  104. wx.showLoading({
  105. title: '加载中'
  106. });
  107. setTimeout(function () {
  108. wx.hideLoading();
  109. }, 2000);
  110. util.request(api.OrderDetail, {
  111. orderId: this.data.orderId
  112. }).then(res => {
  113. if (res.errno === 0) {
  114. wx.hideLoading();
  115. console.log(res.data);
  116. this.setData({
  117. orderInfo: res.data,
  118. goodsTip:res.data.goodsTip,
  119. addressId: res.data.addressId,
  120. dyDetails: res.data.dyDetails,
  121. afterSale: res.data.afterSale,
  122. payOverTime: res.data.payOverTime,
  123. remainTimes: res.data.serviceTimes - res.data.servedTimes,
  124. // orderGoods: res.data.orderGoods,
  125. // handleOption: res.data.orderInfo.handleOption,
  126. // expressInfo: res.data.expressInfo
  127. });
  128. if (res.data.addressId) {
  129. this.getAddressList();
  130. }
  131. }
  132. });
  133. },
  134. getAddressList() {
  135. util.request(api.AddressList).then(res => {
  136. if (res.errno === 0) {
  137. this.setData({
  138. addressList: res.data.list,
  139. });
  140. let current = this.data.addressList.filter(item => {
  141. return item.id == this.data.addressId
  142. });
  143. if (current.length > 0) {
  144. this.setData({
  145. checkedAddress: current[0]
  146. });
  147. }
  148. }
  149. });
  150. },
  151. onShow: function () {
  152. this.getOrderDetail();
  153. if (app.globalData.mapSelectFinish) {
  154. let poi = app.globalData.mapSelectPoi;
  155. let location = poi.location;
  156. let address = this.data.address;
  157. address.lng = location.split(',')[0];
  158. address.lat = location.split(',')[1];
  159. address.addressname = poi.address;
  160. this.setData({
  161. address: address,
  162. // selectAddress:poi.address
  163. });
  164. console.log(this.data.address);
  165. this.getAreaCode();
  166. }
  167. },
  168. getServiceDetail: function () {
  169. let that =this;
  170. if(that.data.orderId ==null ||that.data.orderId===undefined){
  171. util.showErrorToast('页面已过期,请刷新页面重新查看');
  172. return ;
  173. }
  174. util.request(api.ServiceDetail, {
  175. order_id: this.data.orderId
  176. }).then(res => {
  177. if (res.errno === 0) {
  178. let jzOrderBookDetails = res.data.jzOrderBookDetails;
  179. let unusedSerList = jzOrderBookDetails.filter(item => {
  180. return item.status === 0 || item.status == 1;
  181. });
  182. let usedSerList = jzOrderBookDetails.filter(item => {
  183. return item.status == 3 || item.status == 4;
  184. });
  185. this.setData({
  186. aftersaleStatus: res.data.order ? res.data.order.aftersaleStatus : '',
  187. noAppoint: res.data.noAppoint,
  188. goods: res.data.goods,
  189. orderBook: res.data.orderBook,
  190. jzOrderBookDetails: jzOrderBookDetails,
  191. activeTab: 1,
  192. unusedSerList: unusedSerList,
  193. usedSerList: usedSerList,
  194. serList: unusedSerList,
  195. orderChannel: res.data.orderChannel,
  196. addressId: res.data.order.addressId,
  197. addressName: res.data.order.address,
  198. mobile: res.data.order.mobile,
  199. product: res.data.product
  200. });
  201. }
  202. });
  203. },
  204. showAppoint(e) {
  205. // let status = e.currentTarget.dataset.status;
  206. // if (status == 1) {
  207. // let time = e.currentTarget.dataset.time;
  208. // let str = time.substr(0, 16).replace(/-/g, '/');
  209. // let isNear = new Date(str).getTime() - new Date().getTime() - 2 * 60 * 60 * 1000;
  210. // console.log(isNear);
  211. // if (isNear < 0) {
  212. // wx.showToast({
  213. // title: '服务时间小于2小时,不能修改预约',
  214. // icon: 'none',
  215. // duration: 2000
  216. // });
  217. // return false;
  218. // }
  219. // }
  220. // if (this.data.order.aftersaleStatus == 1 || this.data.order.aftersaleStatus == 2) {
  221. // util.showErrorToast("退款中,无法预约");
  222. // return;
  223. // }
  224. // console.info(this.data.addressName)
  225. // if (this.data.addressId == 0||this.data.addressName==null||this.data.addressName=='') {
  226. // util.showErrorToast("请输入服务地址");
  227. // return;
  228. // }
  229. if(this.data.appointDate!=''){
  230. this.setData({
  231. choosePopup: true,
  232. });
  233. return false;
  234. }else{
  235. this.setData({
  236. choosePopup: true,
  237. noonType:1,
  238. timeIndex: 0
  239. });
  240. let params = {
  241. days:30,
  242. // orderBookId:this.data.bookId,
  243. bookId:this.data.serviceId,
  244. productId: this.data.orderInfo.productId,
  245. serviceDuration: this.data.orderInfo.serviceDuration
  246. }
  247. this.getDayTime(params);
  248. }
  249. },
  250. getTimeList() {
  251. let timeList = util.getBeginTimeList(this.data.orderInfo.serviceDuration, this.data.noonType, this.data.dateList[this.data.dateIndex].name);
  252. this.setData({
  253. timeList: timeList,
  254. selectTimeValue: timeList.length == 0 ? '' : timeList[0].value
  255. });
  256. if(this.data.timeList.length==0){
  257. this.setData({
  258. timeIndex:''
  259. });
  260. }
  261. },
  262. getDayStock() {
  263. if (this.data.dateIndex < 0) {
  264. return false;
  265. }
  266. let params = {
  267. day: this.data.dateList[this.data.dateIndex].date,
  268. goodsId: this.data.orderInfo.goodsId,
  269. addressId: this.data.addressId == 0 ? this.data.addressIdSave : this.data.checkedAddress.id,
  270. productId: this.data.orderInfo.productId,
  271. orderId: this.data.orderInfo.id,
  272. serviceDuration: this.data.orderInfo.serviceDuration
  273. };
  274. wx.showLoading({
  275. title: '加载中'
  276. });
  277. util.request(api.EveryDayStock, params, "GET").then(res => {
  278. wx.hideLoading();
  279. if (res.errno == 0) {
  280. this.setData({
  281. timeList: res.data
  282. });
  283. let validList = this.data.timeList.filter(item => {
  284. return item.stock > 0;
  285. });
  286. if (validList.length > 0) {
  287. this.setData({
  288. timeIndex: validList[0].id - 1
  289. });
  290. } else {
  291. this.setData({
  292. timeIndex: ''
  293. });
  294. }
  295. } else {
  296. wx.showToast({
  297. title: res.errmsg,
  298. icon: 'none',
  299. duration: 2000
  300. });
  301. this.setData({
  302. timeList: [],
  303. timeIndex: ''
  304. });
  305. }
  306. }).catch(err=> {
  307. console.log(err);
  308. wx.hideLoading();
  309. wx.showToast({
  310. title: err.errMsg,
  311. icon: 'none'
  312. });
  313. this.setData({
  314. timeList: [],
  315. timeIndex: ''
  316. });
  317. });
  318. },
  319. onClose() {
  320. this.setData({
  321. choosePopup: false
  322. });
  323. },
  324. getDayTime(params) {
  325. wx.showLoading({
  326. title: '加载中',
  327. });
  328. util.request(api.everyDayTime, params, "GET")
  329. .then(res => {
  330. wx.hideLoading();
  331. if (res.errno == 0) {
  332. this.setData({
  333. dateList: res.data,
  334. dateIndex:0,
  335. timeIndex: -1,
  336. noonType:1
  337. });
  338. let period=res.data[0].period;
  339. let list=period.filter(item=>{
  340. return item.ofTime=='上午';
  341. });
  342. this.setData({
  343. timeList:list
  344. });
  345. } else {
  346. wx.showToast({
  347. title: res.errmsg,
  348. icon: 'none',
  349. duration: 2000
  350. });
  351. this.setData({
  352. timeList: [],
  353. timeIndex: ''
  354. });
  355. }
  356. }).catch(err=> {
  357. console.log(err);
  358. wx.hideLoading();
  359. wx.showToast({
  360. title: err.errMsg,
  361. icon: 'none'
  362. });
  363. this.setData({
  364. timeList: [],
  365. timeIndex: ''
  366. });
  367. });
  368. },
  369. dateCheck(e) {
  370. let index = e.currentTarget.dataset.index;
  371. let date = e.currentTarget.dataset.date;
  372. let week = e.currentTarget.dataset.week;
  373. let isbook = e.currentTarget.dataset.isbook;
  374. this.setData({
  375. dateIndex: index
  376. });
  377. let period=this.data.dateList[this.data.dateIndex].period;
  378. let current=(this.data.noonType==1?'上午':'下午');
  379. let list=period.filter(item=>{
  380. return item.ofTime==current;
  381. });
  382. this.setData({
  383. timeList:list
  384. });
  385. let isNoTime=list.every(item=>{
  386. return item.timeMsg&&item.timeMsg!=null;
  387. });
  388. if(isNoTime){
  389. this.setData({
  390. timeIndex:-1,
  391. selectTimeValue:''
  392. });
  393. }
  394. // let dateName = this.data.dateList[this.data.dateIndex].name;
  395. // this.setData({
  396. // dateIndex: index
  397. // });
  398. // let curDateName = this.data.dateList[this.data.dateIndex].name;
  399. // if ((curDateName == '今天') || ((new Date()).getHours() >18&&curDateName == "明天")) {
  400. // this.setData({
  401. // noonType: 2
  402. // })
  403. // }
  404. // this.getTimeList();
  405. },
  406. timeCheck(e) {
  407. let index = e.currentTarget.dataset.index;
  408. // if (e.currentTarget.dataset.stock == 0) {
  409. // wx.showToast({
  410. // title: '所选时间无库存,请选择其他时间',
  411. // icon: 'none',
  412. // duration: 2000
  413. // });
  414. // return;
  415. // }
  416. let msg=e.currentTarget.dataset.msg;
  417. if (msg==null||msg=='') {
  418. let time= (this.data.timeList[index].begin).split(':')[0];
  419. this.setData({
  420. timeIndex: index,
  421. selectTimeValue: Number(time)
  422. });
  423. }
  424. // this.setData({
  425. // timeIndex: index,
  426. // selectTimeValue: this.data.timeList[index].value
  427. // });
  428. },
  429. submitBook() { //提交预约
  430. if (this.data.addressId == '' && this.data.addressIdSave == '') {
  431. util.showErrorToast("请输入服务地址");
  432. return;
  433. }
  434. if (this.data.timeIndex === ''||this.data.timeIndex<0) {
  435. util.showErrorToast("请选择服务时间");
  436. return false;
  437. }
  438. // if (this.data.mobile == null || this.data.mobile.length != 11) {
  439. // util.showErrorToast("请填写手机号码");
  440. // return;
  441. // }
  442. let date = this.data.dateList[this.data.dateIndex].bookdate;
  443. let week = this.data.dateList[this.data.dateIndex].weekOfDay;
  444. let time = this.data.timeList[this.data.timeIndex].begin+'-'+this.data.timeList[this.data.timeIndex].end;
  445. console.log(date, week, time);
  446. let params = {
  447. detail_id: (this.data.serviceId==null||this.data.serviceId=='undefined'||this.data.serviceId=='') ? this.data.orderId : this.data.serviceId,
  448. // bookId: this.data.bookId,
  449. date: date,
  450. startTime: time.split('-')[0],
  451. endTime: time.split('-')[1],
  452. addressId: (this.data.addressId == 0||this.data.addressId == null) ? this.data.addressIdSave : this.data.checkedAddress.id,
  453. // orderId: this.data.orderId,
  454. remark: this.data.remark + this.data.message
  455. };
  456. console.info(params);
  457. wx.showLoading({
  458. title: '加载中...'
  459. });
  460. util.request(api.ServiceOrderBookV2, params, "GET").then(res => {
  461. if (res.errno == 0) {
  462. wx.hideLoading();
  463. this.setData({
  464. isHide: true
  465. });
  466. wx.showToast({
  467. title: '预约成功',
  468. icon: 'none',
  469. duration: 2000
  470. });
  471. setTimeout(() => {
  472. wx.navigateTo({
  473. url: "/pages/ucenter/orderDetail/orderDetail?id=" + this.data.orderId
  474. });
  475. }, 2000);
  476. } else {
  477. wx.showToast({
  478. title: res.errmsg,
  479. icon: 'none'
  480. });
  481. // util.showErrorToast(res.errmsg);
  482. }
  483. });
  484. },
  485. confirmTime() {
  486. if (this.data.timeIndex === ''||this.data.timeIndex<0) {
  487. util.showErrorToast('请选择服务时间');
  488. return false;
  489. }
  490. let date = this.data.dateList[this.data.dateIndex].bookdate;
  491. let week = this.data.dateList[this.data.dateIndex].weekOfDay;
  492. let time = this.data.timeList[this.data.timeIndex].begin+'-'+this.data.timeList[this.data.timeIndex].end;
  493. this.setData({
  494. choosePopup: false,
  495. appointDate: date + ' ' + week + ' ' + time
  496. });
  497. },
  498. selectAddress() {
  499. //已经输入过地址的订单 不允许再次选择地址
  500. if (this.data.order.addressId > 0) return;
  501. wx.navigateTo({
  502. url: '/pages/ucenter/address/address'
  503. });
  504. },
  505. showRemark() {
  506. this.setData({
  507. remarkShow: true
  508. });
  509. },
  510. onRemarkClose() {
  511. this.setData({
  512. remarkShow: false
  513. });
  514. },
  515. confirmRemark() {
  516. this.setData({
  517. remarkShow: false
  518. });
  519. },
  520. bindMessageInput: function (e) {
  521. this.setData({
  522. message: e.detail.value
  523. });
  524. },
  525. bindPhone(e) {
  526. this.setData({
  527. mobile: e.detail.value
  528. })
  529. },
  530. copyOrder() {
  531. wx.setClipboardData({
  532. data: this.data.orderInfo.orderSn,
  533. success: function (res) {
  534. wx.getClipboardData({
  535. success: function (res) {
  536. wx.showToast({
  537. title: '订单编号复制成功',
  538. icon: 'success',
  539. duration: 2000
  540. });
  541. }
  542. });
  543. }
  544. });
  545. },
  546. onAddressClose() {
  547. this.setData({
  548. addressShow: false
  549. })
  550. },
  551. onAddressClick() {
  552. //阻止事件冒泡,不要删
  553. },
  554. addressConfirm(e) {
  555. let address = e.currentTarget.dataset.address;
  556. this.setData({
  557. checkedAddress: address,
  558. addressShow: false
  559. });
  560. },
  561. addressSelect() {
  562. this.setData({
  563. addressShow: true
  564. });
  565. },
  566. showRemarkSelect() {
  567. this.setData({
  568. remarkPopupShow: true
  569. });
  570. },
  571. onRemarkPopupClose() {
  572. this.setData({
  573. remarkPopupShow: false
  574. })
  575. },
  576. onRemarkClick() {
  577. //阻止事件冒泡,不要删
  578. },
  579. remarkItemSelect(e) {
  580. let remark = e.currentTarget.dataset.remark;
  581. this.setData({
  582. remark: remark,
  583. remarkActive: remark,
  584. });
  585. },
  586. remarkItemConfirm() {
  587. if (this.data.remarkActive === '') {
  588. util.showErrorToast("请选择备注");
  589. return false;
  590. }
  591. this.setData({
  592. remarkPopupShow: false
  593. });
  594. },
  595. bindinputMobile(event) {
  596. let address = this.data.address;
  597. address.tel = event.detail.value;
  598. this.setData({
  599. address: address
  600. });
  601. },
  602. bindinputName(event) {
  603. let address = this.data.address;
  604. address.name = event.detail.value;
  605. this.setData({
  606. address: address
  607. });
  608. },
  609. bindinputAddress(event) {
  610. let address = this.data.address;
  611. address.detail = event.detail.value.replace(/[,,]/g, '');
  612. this.setData({
  613. address: address
  614. });
  615. // return value.replace(/[,,]/g,'');
  616. },
  617. bindAddressDetail(event) {
  618. let address = this.data.address;
  619. address.addressname = event.detail.value.replace(/[,,]/g, '');
  620. this.setData({
  621. address: address
  622. });
  623. },
  624. submitAll() {
  625. if ((this.data.addressId == ''||this.data.addressId == null) && this.data.addressIdSave == '') {
  626. this.saveAddress();
  627. } else {
  628. this.submitBook();
  629. }
  630. },
  631. async saveAddress() {
  632. console.log(this.data.address);
  633. let address = this.data.address;
  634. // if (address.addressname == 0) {
  635. // util.showErrorToast('请选择服务地址');
  636. // return false;
  637. // }
  638. if (address.addressname == '') {
  639. util.showErrorToast('请选择服务地址');
  640. return false;
  641. }
  642. if (address.name == '') {
  643. util.showErrorToast('请输入姓名');
  644. return false;
  645. }
  646. if (address.detail == '') {
  647. util.showErrorToast('请输入门牌号');
  648. return false;
  649. }
  650. if (this.data.gender == null || this.data.gender == '') {
  651. util.showErrorToast('请选择性别');
  652. return false;
  653. }
  654. if (address.tel == '') {
  655. util.showErrorToast('请输入手机号码');
  656. return false;
  657. }
  658. if (!check.isValidPhone(address.tel)) {
  659. util.showErrorToast('手机号不正确');
  660. return false;
  661. }
  662. let that = this;
  663. let addressString = address.detail == '' ? address.addressname : address.addressname + ',' + address.detail;
  664. wx.showLoading({
  665. title: '加载中...'
  666. });
  667. let res = await util.request(api.AddressSave, {
  668. gender: this.data.gender,
  669. id: address.id,
  670. name: address.name,
  671. tel: address.tel,
  672. province: address.province,
  673. city: address.city,
  674. county: address.county,
  675. areaCode: address.areaCode,
  676. addressDetail: addressString,
  677. isDefault: address.isDefault,
  678. lat: Number(address.lat).toFixed(5),
  679. lng: Number(address.lng).toFixed(5),
  680. }, 'POST');
  681. wx.hideLoading();
  682. if (res.errno === 0) {
  683. that.setData({
  684. addressIdSave: res.data.id
  685. })
  686. that.submitBook();
  687. } else {
  688. wx.showModal({
  689. title: '提醒',
  690. showCancel: false,
  691. content: res.errmsg
  692. });
  693. }
  694. },
  695. goMap() {
  696. // const key = "JA2BZ-XGOEU-UNZVD-46G64-S6MYJ-6BBF4";
  697. //使用在腾讯位置服务申请的key
  698. // const key = '6TRBZ-XXC6F-BWWJB-N75ME-BQNOF-YKFQY';
  699. // const referer = '鲸致生活LifePlus';
  700. // const category = '小区,生活服务,娱乐休闲';
  701. // wx.navigateTo({
  702. // url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer + '&category=' + category
  703. // });
  704. let that = this;
  705. // wx.authorize({
  706. // scope: "scope.userLocation",
  707. // success: (res) => {
  708. // console.log("authorize", res);
  709. wx.chooseLocation({
  710. success: (location) => {
  711. console.log("chooseLocation success: ", location);
  712. console.log(`经度${location.longitude},维度${location.latitude}`);
  713. console.log(location);
  714. if (location != null) {
  715. let address = that.data.address;
  716. address.lat = location.latitude;
  717. address.lng = location.longitude;
  718. address.addressname = location.address;
  719. that.setData({
  720. address: address,
  721. // selectAddress:location.address
  722. });
  723. console.log(that.data.address);
  724. that.getAreaCode();
  725. }
  726. },
  727. fail: (err) => {
  728. console.log("chooseLocation fail: " + err.errMsg);
  729. },
  730. });
  731. // },
  732. // fail: () => {
  733. // wx.openSetting({});
  734. // },
  735. // });
  736. },
  737. goMap() {
  738. console.log('gomap');
  739. app.globalData.mapSelectFinish = false;
  740. // wx.navigateTo({
  741. // url: '/pages/map/mapContent/mapContent',
  742. // });
  743. if (this.data.address.lng && this.data.address.lat) {
  744. let city = (this.data.address.city == '市辖区' ? this.data.address.province : this.data.address.city)
  745. wx.navigateTo({
  746. url: '/pages/map/mapContent/mapContent?lng=' + this.data.address.lng + '&lat=' + this.data.address.lat + '&addressname=' + this.data.address.addressname + '&city=' + city,
  747. });
  748. } else {
  749. wx.navigateTo({
  750. url: '/pages/map/mapContent/mapContent',
  751. });
  752. }
  753. },
  754. maleSelect() {
  755. this.setData({
  756. gender: 1
  757. });
  758. },
  759. femaleSelect() {
  760. this.setData({
  761. gender: 2
  762. });
  763. },
  764. getAreaCode() {
  765. let param ={
  766. location: this.data.address.lng + ',' + this.data.address.lat,
  767. extensions: 'all',
  768. key: api.gdKey,
  769. radius: 3000,
  770. };
  771. wx.request({
  772. url: api.gdUrl,
  773. data: param,
  774. method: 'GET',
  775. header: {
  776. 'Content-Type': 'application/json'
  777. },
  778. success: res => {
  779. console.log(res);
  780. if (res.data.infocode == "10000") {
  781. if (res.data.info == "OK") {
  782. // let ad_info = res.data.result.ad_info;
  783. // let areaCode = res.data.result.ad_info.adcode;
  784. let regeocode = res.data.regeocode.addressComponent;
  785. let cityName=(regeocode.city==null||regeocode.city.length==0)?regeocode.province:regeocode.city;
  786. let district= (regeocode.district==null||regeocode.district.length==0)?'':regeocode.district;
  787. this.setData({
  788. ['address.areaCode']: regeocode.adcode,
  789. ['address.province']:regeocode.province,
  790. ['address.city']: cityName,
  791. ['address.county']:district,
  792. // ['address.addressname']:res.data.result.address
  793. });
  794. } else {
  795. wx.showToast({
  796. title: '获取地区码失败',
  797. icon: 'none',
  798. duration: 3000
  799. });
  800. }
  801. } else {
  802. wx.showToast({
  803. title: '获取地区码失败',
  804. icon: 'none',
  805. duration: 3000
  806. });
  807. }
  808. },
  809. fail: function (err) {
  810. reject(err);
  811. }
  812. });
  813. },
  814. goAddAddress() {
  815. wx.navigateTo({
  816. url: '/pages/ucenter/addressAdd/addressAdd?id=' + 0
  817. });
  818. },
  819. noonTab(e) {
  820. let noon=e.currentTarget.dataset.noon;
  821. this.setData({
  822. timeIndex: -1,
  823. noonType: noon,
  824. selectTimeValue:'',
  825. });
  826. let period=this.data.dateList[this.data.dateIndex].period;
  827. let current=(this.data.noonType==1?'上午':'下午');
  828. let list=period.filter(item=>{
  829. return item.ofTime==current;
  830. });
  831. this.setData({
  832. timeList:list
  833. });
  834. }
  835. });