东风启辰小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7KB

  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. imgUrl: app.globalData.urlStatic,//图片路径
  7. phoneInputShow:false,//是否显示电话输入框
  8. siteSelect: false,//是否显示位置选择框
  9. provinceArr:['广东','上海','河南','河北'],//省
  10. provinceValue: 0,//选中的省下标
  11. storeArr:['百联超市','全家','喜士多'],//店铺
  12. storeValue:0,//选中的店铺下标
  13. swiperCurrent:1,//swiper选中的元素下标
  14. },
  15. onLoad: function () {
  16. this.getUserLocation();//获取用户当前位置
  17. },
  18. provinceChane: function (e) {//选中省
  19. this.setData({
  20. provinceValue: e.detail.value,
  21. })
  22. },
  23. storeChane: function (e) {//选中店铺
  24. this.setData({
  25. storeValue: e.detail.value,
  26. })
  27. },
  28. getUserPhone:function(e){//获取用户手机号
  29. console.log(e);
  30. this.setData({
  31. phoneInputShow: true,
  32. })
  33. if (e.detail.errMsg=='getPhoneNumber:ok'){
  34. console.log('获取到了手机号');
  35. }
  36. },
  37. getUserLocation:function(e){
  38. wx.getLocation({
  39. type: 'gcj02', //wgs84
  40. success(res) {
  41. if (res) {
  42. console.log(res);
  43. // this.setData({
  44. // siteSelect: true,
  45. // })
  46. }
  47. }
  48. })
  49. },
  50. prevImg(){//上一张图片
  51. if (this.data.swiperCurrent>0) {
  52. this.setData({
  53. swiperCurrent: this.data.swiperCurrent-=1,
  54. })
  55. }
  56. },
  57. nextImg() {//下一张图片
  58. if (this.data.swiperCurrent < 3) {
  59. this.setData({
  60. swiperCurrent: this.data.swiperCurrent+=1,
  61. })
  62. }
  63. },
  64. swiperChange(e){//通过鼠标滑动改变swiper时
  65. if (e.detail.source == "touch"){
  66. this.setData({
  67. swiperCurrent: e.detail.current,
  68. })
  69. }
  70. }
  71. })