123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- // pages/pianoDetail/pianoDetail.js
- var app = getApp()
- var util = require('../../utils/util')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgShow: false,
- childTitle:"练琴卡详情",
- item:null,
- schoolList:[],
- moreFlag: 0,
- code: ''
- },
- closeWindow:function(){
- this.setData({
- imgShow:false
- })
- },
- showImg:function(){
- this.setData({
- imgShow:true
- })
- },
- getSchool:function(id){
- let params = {
- id : id
- }
- util.doPost(
- 'exercuseSchool',params
- ).then(rs =>{
- if(rs.success == 1){
- for (var i = 0; i < rs.data.length; i++) {
- if (typeof rs.data[i].lat != 'undefined' && rs.data[i].lat != '' && rs.data[i].lat != null) {
- rs.data[i].distance = util.distance(rs.data[i].LONGITUDE, rs.data[i].LONGITUDE, wx.getStorageSync('latlng').latitude, wx.getStorageSync('latlng').longitude)
- rs.data[i].distance = parseFloat(rs.data[i].distance)
- } else {
- rs.data[i].distance = 999999
- }
- if (rs.data[i].id == id) {
- list = rs.data[i]
- rs.data.list.splice(i, 1)
- i--;
- }
- }
- for (var i = 0; i < rs.data.length; i++) {
- for (var j = i; j < rs.data.length; j++) {
- if (rs.data[i].distance > rs.data[j].distance) {
- var tmp = rs.data[i];
- rs.data[i] = rs.data[j];
- rs.data[j] = tmp;
- }
- }
- }
- this.setData({
- schoolList:rs.data
- })
- }
- })
- },
- getMoreSchool:function(){
- if(this.data.moreFlag == 0){
- this.setData({
- moreFlag: 1
- })
- } else{
- this.setData({
- moreFlag: 0
- })
- }
- },
- callPhone(e){
- const index = e.currentTarget.dataset.index
-
- const phone = this.data.schoolList[index].CONTRACT_TELEPHONE
- if(phone){
- wx.makePhoneCall({
- phoneNumber: phone
- })
- } else{
- wx.showToast({
- title: '暂无联系电话',
- icon:"none"
- })
- }
- },
- getCode:function(content){
- const params = {
- content: content
- }
- util.codePost(
- 'generate',params
- ).then(res =>{
- console.log(res)
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // 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}'
- // const obj = JSON.parse(options)
- const obj = JSON.parse(options.obj)
- this.setData({
- obj,
- codeImg: 'https://app.schoolwisdoms.com/schoolbaby/api/code/generate?content='+obj.code
- })
- this.getSchool(obj.schemeId)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|