@@ -74,53 +74,67 @@ Page({
7474 title : "数据加载中..." ,
7575 } ) ;
7676
77- store . get ( ) . then ( ( res ) => {
78- let data = res . data ;
79- /**
80- * 处理 occurpyProblemNumber,errorProblemNumber,designProblemNumber
81- */
82- let occurpyProblemNumber = 0 ;
83- let errorProblemNumber = 0 ;
84- let designProblemNumber = 0 ;
85- res . data . forEach ( ( item ) => {
86- if ( item . problemLabel === "盲道破损" ) {
87- errorProblemNumber ++ ;
88- } else if ( item . problemLabel === "盲道占用" ) {
89- occurpyProblemNumber ++ ;
90- } else if ( item . problemLabel === "盲道设计" ) {
91- designProblemNumber ++ ;
92- }
93- } ) ;
77+ wx . cloud
78+ . callFunction ( {
79+ name : "getStore" ,
80+ } )
81+ . then ( ( res ) => {
82+ console . log ( "云函数获取store" , res . result )
83+ if ( res . result . errMsg = "collection.get:ok" ) {
84+ let data = res . result . data ;
85+ /**
86+ * 处理 occurpyProblemNumber,errorProblemNumber,designProblemNumber
87+ */
88+ let occurpyProblemNumber = 0 ;
89+ let errorProblemNumber = 0 ;
90+ let designProblemNumber = 0 ;
91+ res . result . data . forEach ( ( item ) => {
92+ if ( item . problemLabel === "盲道破损" ) {
93+ errorProblemNumber ++ ;
94+ } else if ( item . problemLabel === "盲道占用" ) {
95+ occurpyProblemNumber ++ ;
96+ } else if ( item . problemLabel === "盲道设计" ) {
97+ designProblemNumber ++ ;
98+ }
99+ } ) ;
94100
95- this . setData ( {
96- occurpyProblemNumber,
97- errorProblemNumber,
98- designProblemNumber,
99- } ) ;
101+ this . setData ( {
102+ occurpyProblemNumber,
103+ errorProblemNumber,
104+ designProblemNumber,
105+ } ) ;
100106
101- /***
102- * 处理marker
103- * 将 _id 给 id ,确保 marker 事件的正确触发
104- */
105- data . map ( ( item , index ) => {
106- item . id = index ;
107- item . width = 20 ;
108- item . height = 25 ;
109- item . title = item . problemLabel ;
110- // item.customCallout = {
111- // anchorX: 0,
112- // anchorY: -20,
113- // display: "BYCLICK"
114- // }
115- } ) ;
116- this . setData ( {
117- stores : data ,
118- } ,
119- ( ) => {
120- wx . hideLoading ( ) ;
107+ /***
108+ * 处理marker
109+ * 将 _id 给 id ,确保 marker 事件的正确触发
110+ */
111+ data . map ( ( item , index ) => {
112+ item . id = index ;
113+ item . width = 20 ;
114+ item . height = 25 ;
115+ item . title = item . problemLabel ;
116+ // item.customCallout = {
117+ // anchorX: 0,
118+ // anchorY: -20,
119+ // display: "BYCLICK"
120+ // }
121+ } ) ;
122+ this . setData ( {
123+ stores : data ,
124+ } ,
125+ ( ) => {
126+ wx . hideLoading ( ) ;
127+ }
128+ ) ;
129+ } else {
130+ ( ) => {
131+ wx . showToast ( {
132+ title : '获取数据失败' ,
133+ } )
134+ wx . hideLoading ( ) ;
135+ }
121136 }
122- ) ;
123- } ) ;
137+ } ) ;
124138 } ,
125139
126140 getUserInfo : function ( e ) {
@@ -250,10 +264,28 @@ Page({
250264 } ) ;
251265 } ,
252266
253- addMarker : function ( ) {
254- wx . navigateTo ( {
255- url : "../add/add" ,
256- } ) ;
267+ addMarker : async function ( ) {
268+ const nickName = wx . getStorageSync ( 'nickName' )
269+ if ( ! nickName ) {
270+ wx . getUserProfile ( {
271+ desc : '用于记录上传者信息' ,
272+ success : ( res ) => {
273+ this . setData ( {
274+ nickName : res . userInfo . nickName ,
275+ avatarUrl : res . userInfo . avatarUrl ,
276+ } )
277+ wx . setStorageSync ( "avatarUrl" , res . userInfo . avatarUrl ) ;
278+ wx . setStorageSync ( "nickName" , res . userInfo . nickName ) ;
279+ wx . navigateTo ( {
280+ url : "../add/add" ,
281+ } ) ;
282+ }
283+ } )
284+ } else {
285+ wx . navigateTo ( {
286+ url : "../add/add" ,
287+ } ) ;
288+ }
257289 } ,
258290
259291 goArticle : function ( ) {
0 commit comments