123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- const app = getApp()
- Page({
-
- data: {
- search: '',
- isWechat:0,
- list: []
- },
-
- onLoad: function (options) {
- this.setData(options)
- console.log(options)
- const {status}=options;
- const parentVipList = app.globalData.parentVipList || wx.getStorageSync('parentVipList');
- const parentVipLiIdx = app.globalData.parentVipLiIdx || wx.getStorageSync('parentVipLiIdx');
- this.setData({parentVipList, parentVipLiIdx});
- this.getLocation()
- setTimeout(() => {
- wx.getSetting({
- success: res => {
- if (!res.authSetting['scope.userLocation']) {
- this.openLocationConfirm()
- }
- }
- })
- }, 1000)
- },
-
- onReady: function () {
-
- },
-
- onShow: function () {
-
- },
-
- onHide: function () {
-
- },
-
- onUnload: function () {
-
- },
-
- onPullDownRefresh: function () {
-
- },
-
- onReachBottom: function () {
-
- },
-
- onShareAppMessage: function () {
-
- },
-
- redirectCtl: app.redirectCtl,
- navigateCtl: app.navigateCtl,
-
- inputCtl: function (e) {
- const { value } = e.detail
- this.setData({
- search: value
- })
- this.getSchoolList()
- },
-
- getLocation: function () {
- wx.showLoading({
- title: '定位中'
- })
- wx.getLocation({
- type: 'wgs84',
- success: res => {
- console.log(res)
- this.setData({
- location: {
- longitude: res.longitude,
- latitude: res.latitude
- }
- })
- this.getSchoolList({
- longitude: res.longitude,
- latitude: res.latitude
- })
- },
- fail: res => {
- wx.showToast({
- title: '定位失败',
- icon: 'none'
- })
- },
- complete: res => {
- wx.hideLoading()
- }
- })
- },
-
- openLocationConfirm: function () {
- wx.showModal({
- content: '检测到您没打开定位权限,是否去设置打开?',
- confirmText: "确认",
- cancelText: "取消",
- success: res => {
- if (res.confirm) {
- wx.openSetting({
- success: res => {
- if (res.authSetting['scope.userLocation']) {
- this.getLocation()
- } else {
- wx.navigateBack({
- delta: 1
- })
- }
- }
- })
- } else {
- wx.navigateBack({
- delta: 1
- })
- }
- }
- })
- },
-
- getSchoolList: function (e) {
- const postData = { fn: this.getSchoolList, param: { ...arguments } }
- const { location, search, libId, schoolState, schoolList, isAddChild} = this.data
- const { longitude, latitude } = location || e
- if (isAddChild==1){
- var data = { longitude, latitude, search, libId: !schoolList ? '' : libId }
- }else{
- var data = { longitude, latitude, search, libId: schoolState == 1 ? '' : libId }
- }
- wx.showLoading({
- title: '加载中...',
- })
- app.post('/api/parents/parents/V2/getSchoolList', data, 0, postData).then(res => {
- wx.hideLoading()
- const {list}=res.data;
-
-
-
- this.setData({ list})
- })
- },
-
- saveSchool:function(){
- const postData = { fn: this.saveSchool, param: { ...arguments } }
- const {search } = this.data;
- app.post('/api/parents/parents/V2/saveSchoolCopy', { name:search }, 0, postData).then(res => {
- })
- }
- })
|