EA&UML日拱一卒-微信小程序實戰:位置鬧鈴 (7)-在畫面之間共享數據

序列圖


爲了理順用戶的操作邏輯,我們將監控點的設定分到選擇監控點和編輯監控條件兩個畫面進行;


爲了新建監控點和編輯監控點流程的共通化,創建監控點對象的工作被分配到了主畫面。


序列圖如下:

index.js


newButtonTaped: function () {

   console.log("index.js::newButtonTaped")   

   this.mapCtx.getCenterLocation({

     success: function (res) {

       app.globalData.currentAlarm = {

         longitude: res.longitude,

         latitude: res.latitude

       }

       wx.navigateTo({

         url: '../setpoint/setpoint'

       })

     }

   })

 },


創建監控點畫面的同時,設定座標的初值。


setpoint.js


getPoisInformation:function(){

   var that = this

   var mapCtx = wx.createMapContext('alarmMap')

   mapCtx.getCenterLocation({

     success: function (res) {

       util.getPoisByLocation(res.longitude, res.latitude, function (data) {

         console.log(data)

         that.setData({

           pois: data.pois,

           location: res.latitude.toFixed(4) + ',' + res.longitude.toFixed(4),

         });

         app.globalData.currentAlarm = {

           longitude: res.longitude,

           latitude: res.latitude,

           title: data.pois[0].title

         };

       })

     }

   })

 },


設定座標和監控點標題。其畫面如下:




畫面上選擇了大連會議中心。上面就是著名的音樂噴泉廣場。


editaction.js


編輯監控條件畫面的功能正在編寫中。先給大家看畫面。



畫面只是一個雛形,目前可以顯示選擇監控點畫面指定的地點和鈴聲。選擇其他鈴聲後,可以播放該鈴聲。


小程序代碼


最新代碼已經將代碼上傳到GitHub上了。這樣大家就可以隨時看到小程序的進步。歡迎參觀,拍磚。


https://github.com/xueweiguo/alarmmap


寫在文章的最後


既然已經讀到這裏了,拜託大家再用一分鐘時間,將文章轉發到各位的朋友圈,微信羣中。本公衆號的成長需要您的支持!
閱讀更多更新文章,請掃描下面二維碼,關注微信公衆號【面向對象思考】