makePiano.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. // pages/makePiano/makePiano.js
  2. const app = getApp()
  3. const util = require("../../utils/util")
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. animationBox: {},
  10. animationBg: {},
  11. weekList:[],
  12. curIndex:0,
  13. array: [
  14. '全部时间',
  15. '08:00 ~ 10:00',
  16. '10:00 ~ 12:00',
  17. '12:00 ~ 14:00',
  18. '14:00 ~ 16:00',
  19. '16:00 ~ 18:00',
  20. '18:00 ~ 20:00',
  21. '20:00 ~ 22:00',
  22. ],
  23. objectArray: [
  24. {
  25. id: 0,
  26. name: '全部时间'
  27. },
  28. {
  29. id: 1,
  30. name: '08:00 ~ 10:00'
  31. },
  32. {
  33. id: 2,
  34. name: '10:00 ~ 12:00'
  35. },
  36. {
  37. id: 3,
  38. name: '12:00 ~ 14:00'
  39. },
  40. {
  41. id: 4,
  42. name: '14:00 ~ 16:00'
  43. },
  44. {
  45. id: 5,
  46. name: '16:00 ~ 18:00'
  47. },
  48. {
  49. id: 6,
  50. name: '18:00 ~ 20:00'
  51. },
  52. {
  53. id: 7,
  54. name: '20:00 ~ 22:00'
  55. }
  56. ],
  57. index: 0,
  58. schoolList:[
  59. {},
  60. {},
  61. {},
  62. {},
  63. {},
  64. ],
  65. loading:'上拉加载',
  66. flag:0,
  67. },
  68. getWeek:function(e){
  69. this.setData({
  70. curIndex : e.currentTarget.dataset.index
  71. })
  72. },
  73. bindPickerChange: function (e) {
  74. this.setData({
  75. index: e.detail.value
  76. })
  77. },
  78. localtionMethod: function () {
  79. var that = this
  80. wx.getLocation({
  81. type: 'wgs84',
  82. success(res) {
  83. console.log(res)
  84. wx.setStorageSync('latlng', res)
  85. },
  86. fail(res){
  87. wx.hideLoading({
  88. success: (res) => {
  89. wx.showModal({
  90. title: '提示',
  91. content: "定位失败,请检查手机'位置服务'或GPS功能已开启并授权小程序位置信息",
  92. })
  93. },
  94. })
  95. }
  96. })
  97. },
  98. showSelect:function(){
  99. var animation = wx.createAnimation({
  100. timingFunction: 'linear',
  101. })
  102. this.animation = animation
  103. var num = 0
  104. var opacity = 0
  105. if(this.data.yFlag == false){
  106. num = 165
  107. opacity = 0.4
  108. this.setData({
  109. yFlag: true
  110. })
  111. } else {
  112. num = -360
  113. opacity = 0
  114. this.setData({
  115. yFlag: false
  116. })
  117. }
  118. animation.translateY(num).step()
  119. this.setData({
  120. animationBox:animation.export()
  121. })
  122. var animation2 = wx.createAnimation({
  123. timingFunction: 'linear',
  124. })
  125. this.animation2 = animation2
  126. animation2.opacity(opacity).step()
  127. this.setData({
  128. animationBg:animation2.export()
  129. })
  130. },
  131. /**
  132. * 生命周期函数--监听页面加载
  133. */
  134. onLoad: function (options) {
  135. var list = []
  136. for(var i = 0; i < 7; i++){
  137. var date = util.fun_date(i)
  138. var week = util.fun_week(date)
  139. var json = {
  140. date: date.substring(5,date.length),
  141. week: week
  142. }
  143. list.push(json)
  144. }
  145. this.setData({
  146. weekList: list
  147. })
  148. this.localtionMethod()
  149. },
  150. /**
  151. * 生命周期函数--监听页面初次渲染完成
  152. */
  153. onReady: function () {
  154. },
  155. /**
  156. * 生命周期函数--监听页面显示
  157. */
  158. onShow: function () {
  159. },
  160. /**
  161. * 生命周期函数--监听页面隐藏
  162. */
  163. onHide: function () {
  164. },
  165. /**
  166. * 生命周期函数--监听页面卸载
  167. */
  168. onUnload: function () {
  169. },
  170. /**
  171. * 页面相关事件处理函数--监听用户下拉动作
  172. */
  173. onPullDownRefresh: function () {
  174. },
  175. /**
  176. * 页面上拉触底事件的处理函数
  177. */
  178. onReachBottom: function () {
  179. if(this.data.flag == 0){
  180. this.setData({
  181. loading: '加载中',
  182. flag: 1
  183. })
  184. setTimeout(() => {
  185. this.setData({
  186. schoolList:[
  187. {},
  188. {},
  189. {},
  190. {},
  191. {},
  192. {},
  193. {},
  194. {},
  195. {},
  196. {},
  197. ],
  198. loading: '没有更多数据',
  199. flag: 2
  200. })
  201. }, 2000);
  202. }
  203. },
  204. /**
  205. * 用户点击右上角分享
  206. */
  207. onShareAppMessage: function () {
  208. }
  209. })