city.js 696 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. var util = require("../../utils/util.js")
  2. const app = getApp()
  3. Page({
  4. data: {
  5. cityObj: []
  6. },
  7. onLoad: function(options) {
  8. let _this = this;
  9. _this.setData({
  10. navH: app.globalData.navHeight
  11. });
  12. this.getCityList();
  13. },
  14. // 获取当前已开通城市
  15. getCityList: function() {
  16. util.getData('/getBranches')
  17. .then(res => {
  18. this.setData({
  19. cityObj: res
  20. })
  21. })
  22. .catch(err => {
  23. console.log(err);
  24. })
  25. },
  26. // 点击城市跳转
  27. clickCity: function(e) {
  28. let code = e.currentTarget.dataset.code;
  29. let name = e.currentTarget.dataset.name;
  30. wx.setStorageSync(
  31. 'branche_code', code
  32. )
  33. wx.setStorageSync(
  34. 'branche_name', name
  35. )
  36. util.goHome();
  37. }
  38. })