pianoDetail.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // pages/pianoDetail/pianoDetail.js
  2. var app = getApp()
  3. var util = require('../../utils/util')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. imgShow: false,
  10. childTitle:"练琴卡详情",
  11. item:null,
  12. schoolList:[],
  13. moreFlag: 0,
  14. code: ''
  15. },
  16. closeWindow:function(){
  17. this.setData({
  18. imgShow:false
  19. })
  20. },
  21. showImg:function(){
  22. this.setData({
  23. imgShow:true
  24. })
  25. },
  26. getSchool:function(id){
  27. let params = {
  28. id : id
  29. }
  30. util.doPost(
  31. 'exercuseSchool',params
  32. ).then(rs =>{
  33. if(rs.success == 1){
  34. for (var i = 0; i < rs.data.length; i++) {
  35. if (typeof rs.data[i].lat != 'undefined' && rs.data[i].lat != '' && rs.data[i].lat != null) {
  36. rs.data[i].distance = util.distance(rs.data[i].LONGITUDE, rs.data[i].LONGITUDE, wx.getStorageSync('latlng').latitude, wx.getStorageSync('latlng').longitude)
  37. rs.data[i].distance = parseFloat(rs.data[i].distance)
  38. } else {
  39. rs.data[i].distance = 999999
  40. }
  41. if (rs.data[i].id == id) {
  42. list = rs.data[i]
  43. rs.data.list.splice(i, 1)
  44. i--;
  45. }
  46. }
  47. for (var i = 0; i < rs.data.length; i++) {
  48. for (var j = i; j < rs.data.length; j++) {
  49. if (rs.data[i].distance > rs.data[j].distance) {
  50. var tmp = rs.data[i];
  51. rs.data[i] = rs.data[j];
  52. rs.data[j] = tmp;
  53. }
  54. }
  55. }
  56. this.setData({
  57. schoolList:rs.data
  58. })
  59. }
  60. })
  61. },
  62. getMoreSchool:function(){
  63. if(this.data.moreFlag == 0){
  64. this.setData({
  65. moreFlag: 1
  66. })
  67. } else{
  68. this.setData({
  69. moreFlag: 0
  70. })
  71. }
  72. },
  73. callPhone(e){
  74. const index = e.currentTarget.dataset.index
  75. const phone = this.data.schoolList[index].CONTRACT_TELEPHONE
  76. if(phone){
  77. wx.makePhoneCall({
  78. phoneNumber: phone
  79. })
  80. } else{
  81. wx.showToast({
  82. title: '暂无联系电话',
  83. icon:"none"
  84. })
  85. }
  86. },
  87. getCode:function(content){
  88. const params = {
  89. content: content
  90. }
  91. util.codePost(
  92. 'generate',params
  93. ).then(res =>{
  94. console.log(res)
  95. })
  96. },
  97. /**
  98. * 生命周期函数--监听页面加载
  99. */
  100. onLoad: function (options) {
  101. // options = '{"imgUrl":"https://file.schoolwisdoms.com/image/9fa41861-ac29-40ca-b7af-2307eea72c8d.jpg","code":"20210202163522308958","createdDate":"2021-02-02","money":0.01,"schemeType":"19.9元特惠练琴卡","orderId":"2961ccdb31ee4875b472df42e645bd54","openId":"osm1O5J-wFamXgipGs1JztHbWNC4","schemeId":"61f88dd017394c1f9e27593d20b8968a","id":"a7ffea33814d47cab6ee84fd9e1e927f","payStatus":1,"REMARK":"这是一个神奇的卡片,优惠多多","status":2}'
  102. // const obj = JSON.parse(options)
  103. const obj = JSON.parse(options.obj)
  104. this.setData({
  105. obj,
  106. codeImg: 'https://app.schoolwisdoms.com/schoolbaby/api/code/generate?content='+obj.code
  107. })
  108. this.getSchool(obj.schemeId)
  109. },
  110. /**
  111. * 生命周期函数--监听页面初次渲染完成
  112. */
  113. onReady: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面显示
  117. */
  118. onShow: function () {
  119. },
  120. /**
  121. * 生命周期函数--监听页面隐藏
  122. */
  123. onHide: function () {
  124. },
  125. /**
  126. * 生命周期函数--监听页面卸载
  127. */
  128. onUnload: function () {
  129. },
  130. /**
  131. * 页面相关事件处理函数--监听用户下拉动作
  132. */
  133. onPullDownRefresh: function () {
  134. },
  135. /**
  136. * 页面上拉触底事件的处理函数
  137. */
  138. onReachBottom: function () {
  139. },
  140. /**
  141. * 用户点击右上角分享
  142. */
  143. onShareAppMessage: function () {
  144. }
  145. })