12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- const app = getApp()
- export default {
- loading (title) {
- wx.showLoading({
- title: title || '加载中...',
- mask: true
- })
- },
- errorToast (title) {
- wx.showToast({
- title: title || '请先登录',
- icon: 'error'
- })
- },
- navigateTo (url,permissionTitle) {
- if (url) {
- if (app.globalData.userInfo.login) {
- wx.navigateTo({
- url: 'url'
- })
- } else {
- wx.showToast({
- title: permissionTitle || '请先登录',
- icon: 'error'
- })
- }
- } else {
- wx.showToast({
- title: '地址错误',
- icon: 'error'
- })
- }
- },
- loginAuth () {
- return app.globalData.userInfo.login
- },
- // UUID
- getUUID () {
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
- return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
- })
- },
- randomStr (length = 16) {
- var res = ''
- var baseStr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
- for (let index = 0; index < length; index++) {
- var random = parseInt(Math.random() * 26)
- res = res + baseStr[random]
- }
- return res
- }
- }
|