index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. const app = getApp()
  2. var util = require("../../utils/util.js")
  3. Page({
  4. data: {
  5. duration: 500,
  6. latitude: undefined,
  7. longitude: undefined,
  8. name: undefined,
  9. address: undefined,
  10. arr: [],
  11. mktarr: [],
  12. booking_setp: ['学龄前', '小学一年级', '小学一年级', '小学二年级','小学三年级','小学四年级','小学五年级','小学六年级','初中一年级','初中二年级','初中三年级','高中一年级','高中二年级','高中三年级'],
  13. mktList_m: [
  14. "https://api.zhumi.tech/MiniProgram/mkt/m1.jpg",
  15. "https://api.zhumi.tech/MiniProgram/mkt/m2.jpg",
  16. "https://api.zhumi.tech/MiniProgram/mkt/m3.jpg",
  17. "https://api.zhumi.tech/MiniProgram/mkt/m4.jpg",
  18. "https://api.zhumi.tech/MiniProgram/mkt/m5.jpg",
  19. "https://api.zhumi.tech/MiniProgram/mkt/m6.jpg",
  20. "https://api.zhumi.tech/MiniProgram/mkt/m7.jpg",
  21. "https://api.zhumi.tech/MiniProgram/mkt/m8.jpg",
  22. "https://api.zhumi.tech/MiniProgram/mkt/m9.jpg"
  23. ],
  24. mktList_l: [
  25. "https://api.zhumi.tech/MiniProgram/mkt/l1.jpg",
  26. "https://api.zhumi.tech/MiniProgram/mkt/l2.jpg",
  27. "https://api.zhumi.tech/MiniProgram/mkt/l3.jpg",
  28. "https://api.zhumi.tech/MiniProgram/mkt/l4.jpg",
  29. "https://api.zhumi.tech/MiniProgram/mkt/l5.jpg",
  30. "https://api.zhumi.tech/MiniProgram/mkt/l6.jpg",
  31. "https://api.zhumi.tech/MiniProgram/mkt/l7.jpg",
  32. "https://api.zhumi.tech/MiniProgram/mkt/l8.jpg",
  33. "https://api.zhumi.tech/MiniProgram/mkt/l9.jpg"
  34. ],
  35. mktImgage: "https://api.zhumi.tech/MiniProgram/mkt/l1.jpg",
  36. bookingShow: false,
  37. index_setp: 1,
  38. mask: false,
  39. booking: false,
  40. bookingreturn: false
  41. },
  42. onLoad: function(options) {
  43. this.init(options)
  44. },
  45. init(options) {
  46. var that = this
  47. util.getData('/getBanners')
  48. .then(res => {
  49. that.setData({
  50. arr: res
  51. })
  52. })
  53. that.setData({
  54. navH: app.globalData.navHeight
  55. })
  56. util.getData('/getMktInfos',{
  57. mi_branche_code: 110000
  58. }).then(res => {
  59. that.setData({
  60. mktarr: res
  61. })
  62. })
  63. that.setData({
  64. navH: app.globalData.navHeight
  65. })
  66. },
  67. mktImageChange: function(e) {
  68. this.setData({
  69. mktImgage: e.currentTarget.dataset.path
  70. })
  71. },
  72. //点击轮播图
  73. BhrefPm: function(e) {
  74. var index = e.currentTarget.dataset.index;
  75. if (index != null) {
  76. if (e.currentTarget.dataset.type == 1) {
  77. wx.navigateTo({
  78. url: '/pages/promotion/promotionhref?para=' + index
  79. })
  80. }
  81. if (e.currentTarget.dataset.type == 2) {
  82. wx.navigateTo({
  83. url: index
  84. })
  85. }
  86. }
  87. },
  88. onShareAppMessage: function() {
  89. return {
  90. title: '科技强国梦 编程向未来',
  91. path: '/pages/index/index?id=888'
  92. }
  93. },
  94. // map
  95. markertap: function(e) {
  96. wx.getLocation({
  97. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  98. success: function(res) {
  99. var latitude = e.currentTarget.dataset.latitude
  100. var longitude = e.currentTarget.dataset.longitude
  101. wx.openLocation({ //出发wx.openLocation API
  102. latitude: Number(latitude), //坐标纬度(从地图获取坐标)
  103. longitude: Number(longitude), //坐标经度(从地图获取坐标)
  104. name: e.currentTarget.dataset.name, //打开后显示的地址名称
  105. address: e.currentTarget.dataset.address, //打开后显示的地址汉字
  106. scale: 17
  107. })
  108. }
  109. })
  110. },
  111. hrefoBooking () {
  112. this.setData({
  113. mask: true,
  114. booking: true,
  115. bookingreturn: false
  116. })
  117. },
  118. hideAllBox() {
  119. this.setData({
  120. //遮罩层隐藏
  121. mask: false,
  122. booking: false,
  123. bookingreturn: false
  124. })
  125. },
  126. bindPickerChange: function(e) {
  127. this.setData({
  128. index_setp: e.detail.value
  129. })
  130. },
  131. submitForm: function(data) {
  132. let obj = {
  133. ...data.detail.value,
  134. }
  135. if (obj.phone.length < 11) {
  136. wx.showToast({
  137. title: '手机号填写不完整',
  138. icon: 'none',
  139. duration: 2000
  140. })
  141. return
  142. }
  143. if (obj.name == null || obj.name == '' ) {
  144. wx.showToast({
  145. title: '请填写孩子姓名',
  146. icon: 'none',
  147. duration: 2000
  148. })
  149. return
  150. }
  151. obj.college_code = this.data.booking_setp[obj.step]
  152. util.postData('/college/addCollegeBooking', obj)
  153. .then(res => {
  154. if (res == 1) {
  155. this.setData({
  156. booking: false,
  157. bookingreturn: true
  158. })
  159. }
  160. })
  161. }
  162. })