index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. const app = getApp()
  2. Page({
  3. onShareAppMessage() {
  4. return {
  5. title: 'swiper',
  6. path: 'page/component/pages/swiper/swiper'
  7. }
  8. },
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. frameStyle: { useTop: true, name: '练习', leftArrow: true, useBar: false},
  14. // 主体高度
  15. infoHeight: '',
  16. latitude: 23.099994,
  17. longitude: 113.324520,
  18. x: 0,
  19. y: 0,
  20. scale: 2,
  21. background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
  22. indicatorDots: true,
  23. vertical: false,
  24. autoplay: false,
  25. interval: 2000,
  26. duration: 500,
  27. iconSize: [20, 30, 40, 50, 60, 70],
  28. iconColor: [
  29. 'red', 'orange', 'yellow', 'green', 'rgb(0,255,255)', 'blue', 'purple'
  30. ],
  31. iconType: [
  32. 'success', 'success_no_circle', 'info', 'warn', 'waiting', 'cancel', 'download', 'search', 'clear'
  33. ],
  34. chosen: '',
  35. focus: false,
  36. inputValue: '',
  37. checkboxItems: [
  38. {name: 'USA', value: '美国'},
  39. {name: 'CHN', value: '中国', checked: 'true'}
  40. ],
  41. radioItems: [
  42. {name: 'USA', value: '美国'},
  43. {name: 'CHN', value: '中国', checked: 'true'}
  44. ],
  45. hidden: false,
  46. height: 20,
  47. focus: false
  48. },
  49. bindButtonTap: function() {
  50. this.setData({
  51. focus: true
  52. })
  53. },
  54. bindTextAreaBlur: function(e) {
  55. console.log(e.detail.value)
  56. },
  57. bindFormSubmit: function(e) {
  58. console.log(e.detail.value.textarea)
  59. },
  60. radioChange(e) {
  61. const checked = e.detail.value
  62. const changed = {}
  63. for (let i = 0; i < this.data.radioItems.length; i++) {
  64. if (checked.indexOf(this.data.radioItems[i].name) !== -1) {
  65. changed['radioItems[' + i + '].checked'] = true
  66. } else {
  67. changed['radioItems[' + i + '].checked'] = false
  68. }
  69. }
  70. this.setData(changed)
  71. },
  72. bindKeyInput: function (e) {
  73. this.setData({
  74. inputValue: e.detail.value
  75. })
  76. },
  77. changeIndicatorDots() {
  78. this.setData({
  79. indicatorDots: !this.data.indicatorDots
  80. })
  81. },
  82. formReset(e) {
  83. console.log('form发生了reset事件,携带数据为:', e.detail.value)
  84. this.setData({
  85. chosen: ''
  86. })
  87. },
  88. changeAutoplay() {
  89. this.setData({
  90. autoplay: !this.data.autoplay
  91. })
  92. },
  93. intervalChange(e) {
  94. this.setData({
  95. interval: e.detail.value
  96. })
  97. },
  98. durationChange(e) {
  99. this.setData({
  100. duration: e.detail.value
  101. })
  102. },
  103. tap() {
  104. this.setData({
  105. x: 30,
  106. y: 30
  107. })
  108. },
  109. tap2() {
  110. this.setData({
  111. scale: 3
  112. })
  113. },
  114. onChange(e) {
  115. console.log(e.detail)
  116. },
  117. onScale(e) {
  118. console.log(e.detail)
  119. },
  120. back: function () {
  121. wx.navigateBack({ url: '/pages/home/index' })
  122. },
  123. /**
  124. * 生命周期函数--监听页面加载
  125. */
  126. onLoad: function () {
  127. // 计算高度
  128. this.searchHeight()
  129. },
  130. // 计算高度
  131. searchHeight: function () {
  132. let frameStyle = this.data.frameStyle;
  133. let client = app.globalData.client;
  134. // 减去状态栏
  135. let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
  136. // 是否减去底部菜单
  137. if (frameStyle.useBar) infoHeight = infoHeight - 50;
  138. if (infoHeight) this.setData({ infoHeight: infoHeight })
  139. },
  140. /**
  141. * 生命周期函数--监听页面初次渲染完成
  142. */
  143. onReady: function () {
  144. },
  145. /**
  146. * 生命周期函数--监听页面显示
  147. */
  148. onShow: function () {
  149. },
  150. /**
  151. * 生命周期函数--监听页面隐藏
  152. */
  153. onHide: function () {
  154. },
  155. /**
  156. * 生命周期函数--监听页面卸载
  157. */
  158. onUnload: function () {
  159. },
  160. /**
  161. * 页面相关事件处理函数--监听用户下拉动作
  162. */
  163. onPullDownRefresh: function () {
  164. },
  165. /**
  166. * 页面上拉触底事件的处理函数
  167. */
  168. onReachBottom: function () {
  169. },
  170. /**
  171. * 用户点击右上角分享
  172. */
  173. onShareAppMessage: function () {
  174. }
  175. })