u
This commit is contained in:
		
							parent
							
								
									04e449cce6
								
							
						
					
					
						commit
						452a21a4eb
					
				
							
								
								
									
										40
									
								
								usertool.js
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								usertool.js
									
									
									
									
									
								
							@ -62,7 +62,8 @@ export default {
 | 
				
			|||||||
    const mylang = getApp()?.$store?.state?.i18n?.mylang // 不要用 pageNow.$store,防止在 App.vue 里无法获取当前页面。
 | 
					    const mylang = getApp()?.$store?.state?.i18n?.mylang // 不要用 pageNow.$store,防止在 App.vue 里无法获取当前页面。
 | 
				
			||||||
    const pageNow = this.thisPage() // 需要兼顾在 App.vue 时无法获取当前页面的情况,因为如果在 topWindow 里调用本函数,getApp() 和 getCurrentPages()[getCurrentPages().length-1] 就是 undefined。
 | 
					    const pageNow = this.thisPage() // 需要兼顾在 App.vue 时无法获取当前页面的情况,因为如果在 topWindow 里调用本函数,getApp() 和 getCurrentPages()[getCurrentPages().length-1] 就是 undefined。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    uni.setNavigationBarTitle({ // 也会被用于浏览器的标签标题,因此要用 document.title 去覆盖
 | 
					    uni.setNavigationBarTitle({
 | 
				
			||||||
 | 
					      // 也会被用于浏览器的标签标题,因此要用 document.title 去覆盖
 | 
				
			||||||
      title:
 | 
					      title:
 | 
				
			||||||
        pageTitle ||
 | 
					        pageTitle ||
 | 
				
			||||||
        pageNow?.i18nText?.[mylang]?.tPageTitle || // 页面.vue 的 i18nText 对象
 | 
					        pageNow?.i18nText?.[mylang]?.tPageTitle || // 页面.vue 的 i18nText 对象
 | 
				
			||||||
@ -172,10 +173,10 @@ export default {
 | 
				
			|||||||
      const uniObj = uniCloud.importObject(apiWho)
 | 
					      const uniObj = uniCloud.importObject(apiWho)
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        result = await uniObj[apiTodo](apiWhat)
 | 
					        result = await uniObj[apiTodo](apiWhat)
 | 
				
			||||||
      }catch(error){
 | 
					      } catch (error) {
 | 
				
			||||||
        result = { _state: 'CLINET_BASEND_EXCEPTION', error }
 | 
					        result = { _state: 'CLINET_BASEND_EXCEPTION', error }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }else if (basendType === 'UNICLOUD') {
 | 
					    } else if (basendType === 'UNICLOUD') {
 | 
				
			||||||
      let { /* success, header, requestedId, */ result: resultCloud = {} } = await uniCloud
 | 
					      let { /* success, header, requestedId, */ result: resultCloud = {} } = await uniCloud
 | 
				
			||||||
        .callFunction({
 | 
					        .callFunction({
 | 
				
			||||||
          name: apiWho,
 | 
					          name: apiWho,
 | 
				
			||||||
@ -225,7 +226,7 @@ export default {
 | 
				
			|||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        result = resultServer
 | 
					        result = resultServer
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }else {
 | 
					    } else {
 | 
				
			||||||
      result = { _state: 'CLIENT_BASEND_TYPE_UNKNOWN' }
 | 
					      result = { _state: 'CLIENT_BASEND_TYPE_UNKNOWN' }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // 注意1,resultServer 和 resultCloud 推荐遵循同样的格式 { _state, error | data },这样方便前端做统一判断。
 | 
					    // 注意1,resultServer 和 resultCloud 推荐遵循同样的格式 { _state, error | data },这样方便前端做统一判断。
 | 
				
			||||||
@ -453,17 +454,27 @@ export default {
 | 
				
			|||||||
    })
 | 
					    })
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  showToast ({ tool, type, image, title, duration = 2000, ...rest }) {
 | 
					  showToast ({ tool, type, image, title, duration = 2000, ...rest }) {
 | 
				
			||||||
 | 
					    if (tool !== 'uni') {
 | 
				
			||||||
 | 
					      // 来自 <ucToast> 或 <u-toast> 或 <u-top-tips>
 | 
				
			||||||
      const toast = this.thisPage()?.$refs?.toast || getApp().globalData.toast || wo.toast
 | 
					      const toast = this.thisPage()?.$refs?.toast || getApp().globalData.toast || wo.toast
 | 
				
			||||||
    if (tool!=='uni' && toast) { // 来自 <ucToast> 或 <u-toast> 或 <u-top-tips>
 | 
					      const pupup = this.thisPage()?.$refs?.popup || getApp().globalData.popup || wo.popup
 | 
				
			||||||
 | 
					      if (toast) {
 | 
				
			||||||
        toast.show({ type, title, duration, ...rest })
 | 
					        toast.show({ type, title, duration, ...rest })
 | 
				
			||||||
    } else {
 | 
					        return
 | 
				
			||||||
 | 
					      } else if (popup) {
 | 
				
			||||||
 | 
					        wo.ss.toastType = type
 | 
				
			||||||
 | 
					        wo.ss.toastMessage = title
 | 
				
			||||||
 | 
					        wo.ss.toastDuration = duration
 | 
				
			||||||
 | 
					        popup.open()
 | 
				
			||||||
 | 
					        return
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    // #ifdef APP-PLUS
 | 
					    // #ifdef APP-PLUS
 | 
				
			||||||
    uni.showToast({ icon: 'none', title, duration, ...rest })
 | 
					    uni.showToast({ icon: 'none', title, duration, ...rest })
 | 
				
			||||||
    // #endif
 | 
					    // #endif
 | 
				
			||||||
    // #ifdef H5
 | 
					    // #ifdef H5
 | 
				
			||||||
    uni.showToast({ icon: 'none', image, title, duration, ...rest })
 | 
					    uni.showToast({ icon: 'none', image, title, duration, ...rest })
 | 
				
			||||||
    // #endif
 | 
					    // #endif
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  formatMoney (value, precision = 2) {
 | 
					  formatMoney (value, precision = 2) {
 | 
				
			||||||
@ -556,7 +567,7 @@ export default {
 | 
				
			|||||||
        uni.switchTab({ url: pageName })
 | 
					        uni.switchTab({ url: pageName })
 | 
				
			||||||
      } else if (forget) {
 | 
					      } else if (forget) {
 | 
				
			||||||
        uni.navigateTo({ url: pageName })
 | 
					        uni.navigateTo({ url: pageName })
 | 
				
			||||||
      }else {
 | 
					      } else {
 | 
				
			||||||
        uni.redirectTo({ url: pageName })
 | 
					        uni.redirectTo({ url: pageName })
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
@ -564,15 +575,14 @@ export default {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  next_focus(currentFocus, focusList=this.thisPage().focusList){
 | 
					  next_focus (currentFocus, focusList = this.thisPage().focusList) {
 | 
				
			||||||
    if (focusList) {
 | 
					    if (focusList) {
 | 
				
			||||||
      for (let n in focusList) {
 | 
					      for (let n in focusList) {
 | 
				
			||||||
        focusList[n]=false
 | 
					        focusList[n] = false
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      setTimeout(()=>{
 | 
					      setTimeout(() => {
 | 
				
			||||||
        focusList[(parseInt(currentFocus)+1) % Object.keys(focusList).length]=true
 | 
					        focusList[(parseInt(currentFocus) + 1) % Object.keys(focusList).length] = true
 | 
				
			||||||
      },200) // 如果没有 setTimeout 至少 200ms, 焦点短暂跳到下一个后,又会消失
 | 
					      }, 200) // 如果没有 setTimeout 至少 200ms, 焦点短暂跳到下一个后,又会消失
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  },
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user