index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. console.log(res)
  60. that.setData({
  61. mktarr: res
  62. })
  63. })
  64. that.setData({
  65. navH: app.globalData.navHeight
  66. })
  67. },
  68. mktImageChange: function(e) {
  69. this.setData({
  70. mktImgage: e.currentTarget.dataset.path
  71. })
  72. },
  73. //点击轮播图
  74. BhrefPm: function(e) {
  75. var index = e.currentTarget.dataset.index;
  76. if (index != null) {
  77. if (e.currentTarget.dataset.type == 1) {
  78. wx.navigateTo({
  79. url: '/pages/promotion/promotionhref?para=' + index
  80. })
  81. }
  82. if (e.currentTarget.dataset.type == 2) {
  83. wx.navigateTo({
  84. url: index
  85. })
  86. }
  87. }
  88. },
  89. onShareAppMessage: function() {
  90. return {
  91. title: '科技强国梦 编程向未来',
  92. path: '/pages/index/index?id=888'
  93. }
  94. },
  95. // map
  96. markertap: function(e) {
  97. wx.getLocation({
  98. type: 'gcj02', //返回可以用于wx.openLocation的经纬度
  99. success: function(res) {
  100. var latitude = e.currentTarget.dataset.latitude
  101. var longitude = e.currentTarget.dataset.longitude
  102. wx.openLocation({ //出发wx.openLocation API
  103. latitude: Number(latitude), //坐标纬度(从地图获取坐标)
  104. longitude: Number(longitude), //坐标经度(从地图获取坐标)
  105. name: e.currentTarget.dataset.name, //打开后显示的地址名称
  106. address: e.currentTarget.dataset.address, //打开后显示的地址汉字
  107. scale: 17
  108. })
  109. }
  110. })
  111. },
  112. hrefoBooking () {
  113. this.setData({
  114. mask: true,
  115. booking: true,
  116. bookingreturn: false
  117. })
  118. },
  119. hrefoKc() {
  120. wx.navigateTo({
  121. url: '/pages/packages/packages'
  122. })
  123. },
  124. hideAllBox() {
  125. this.setData({
  126. //遮罩层隐藏
  127. mask: false,
  128. booking: false,
  129. bookingreturn: false
  130. })
  131. },
  132. bindPickerChange: function(e) {
  133. this.setData({
  134. index_setp: e.detail.value
  135. })
  136. },
  137. submitForm: function(data) {
  138. let obj = {
  139. ...data.detail.value,
  140. }
  141. if (obj.phone.length < 11) {
  142. wx.showToast({
  143. title: '手机号填写不完整',
  144. icon: 'none',
  145. duration: 2000
  146. })
  147. return
  148. }
  149. if (obj.name == null || obj.name == '' ) {
  150. wx.showToast({
  151. title: '请填写孩子姓名',
  152. icon: 'none',
  153. duration: 2000
  154. })
  155. return
  156. }
  157. obj.college_code = this.data.booking_setp[obj.step]
  158. util.postData('/college/addCollegeBooking', obj)
  159. .then(res => {
  160. if (res == 1) {
  161. this.setData({
  162. booking: false,
  163. bookingreturn: true
  164. })
  165. }
  166. })
  167. }
  168. })