App.vue 4.71 KB
Newer Older
1
<script>
潘永坪's avatar
潘永坪 committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// 1、uni-app的页面生命周期仅在page页面有效,而单独封装的组件中【页面周期无效】,
//但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】
// 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created
// 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default {
  onLaunch: function(options) { //初始化完成时触发(全局只触发一次
    let today = this.$commonjs.today()
    let oldDate = uni.getStorageSync('oldDate')
    //大于7天重新登录
    if (oldDate) {
      let number = this.$commonjs.dateDifference(today, oldDate)
      if (number > 7) {
        uni.clearStorageSync()
      }
    } else {
      //用于处理这个功能之前登录过的用户,未保存登录时间
      uni.clearStorageSync()
    }
    let path = options.path
    uni.setStorageSync('enterOptions', options)
潘永坪's avatar
潘永坪 committed
23
    let token = uni.getStorageSync('token')||''
潘永坪's avatar
潘永坪 committed
24 25 26 27 28 29 30
    if (!token && path.indexOf('pages/payment/ourPayment/ourPayment') == -1) { //扫码支付页面不需要在此登录
      setTimeout(() => { //解决关联普通二维码扫码首次进入时一直显示登录中
        uni.navigateTo({
          url: '/pages/login/login'
        })
      }, 300)
    }
潘永坪's avatar
潘永坪 committed
31 32 33
    //#ifdef MP-WEIXIN
    uni.setStorageSync('appid', 'wxe678d5240e98a7b8')
    //#endif
34

潘永坪's avatar
潘永坪 committed
35 36 37 38 39 40 41 42
    //#ifdef MP-ALIPAY
    uni.setStorageSync('appid', '2021001194629244')
    if (options.query && options.query.qrCode) {
      uni.setStorageSync('alipayQrCode', options.query.qrCode)
    } else {
      uni.removeStorageSync('alipayQrCode')
    }
    //#endif
43 44
    //清除之前的companyId
    uni.removeStorageSync('companyId')
潘永坪's avatar
潘永坪 committed
45 46 47 48 49 50 51 52
    /* 版本自动更新代码 */
    const updateManager = uni.getUpdateManager()
    updateManager.onCheckForUpdate(function (res) {
      console.log('是否有更新:' + res.hasUpdate) // 请求完新版本信息的回调 true说明有更新
    })
    updateManager.onUpdateReady(function () {
      uni.showModal({
        title: '更新检测', // 此处可自定义提示标题
53 54
        showCancel:false,
        content: '检测到新版本,请点击确认按钮重启小程序?', // 此处可自定义提示消息内容
潘永坪's avatar
潘永坪 committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
        success: function (res) {
          if (res.confirm) {
            // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
            updateManager.applyUpdate()
          }
        }
      })
    })
    updateManager.onUpdateFailed(function () {
      // 新的版本下载失败
      uni.showModal({
        title: '更新提示',
        content: '新版本下载失败',
        showCancel: false
      })
    })
  },
  onShow: function() {
潘永坪's avatar
潘永坪 committed
73
    
潘永坪's avatar
潘永坪 committed
74 75 76 77
  },
  onHide: function() {
  }
}
78 79
</script>

潘永坪's avatar
潘永坪 committed
80
<style lang="scss">
81
	@import "uview-ui/index.scss";
潘永坪's avatar
潘永坪 committed
82
	
83 84 85 86
	page {
		font-size: 28rpx;
		color: #333333;
		background: #F7F7F7;
潘永坪's avatar
潘永坪 committed
87
		height:100vh;
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
	}
	view,
	text,
	image,
	video,
	button,
	checkbox,
	form,
	input,
	label,
	radio,
	switch,
	textarea {
		box-sizing: border-box;
	}
潘永坪's avatar
潘永坪 committed
103 104
	//小按钮
	.btn{
潘永坪's avatar
潘永坪 committed
105
		background:#FE6600;
106 107
		display: inline-block;
		color: #FFFFFF;
潘永坪's avatar
潘永坪 committed
108 109 110
		width: 135rpx;
		height: 70rpx;
		line-height: 70rpx;
潘永坪's avatar
潘永坪 committed
111
		font-size:28rpx;
潘永坪's avatar
潘永坪 committed
112
		border-radius:12rpx;
潘永坪's avatar
潘永坪 committed
113 114 115 116
		text-align: center;
	}
	//中等按钮
	.middle-btn{
潘永坪's avatar
潘永坪 committed
117
		background:#FE6600;
潘永坪's avatar
潘永坪 committed
118 119
		display: inline-block;
		color: #FFFFFF;
潘永坪's avatar
潘永坪 committed
120 121 122
		width: 180rpx;
		height: 80rpx;
		line-height: 80rpx;
潘永坪's avatar
潘永坪 committed
123
		font-size:32rpx;
潘永坪's avatar
潘永坪 committed
124
		border-radius:20rpx;
潘永坪's avatar
潘永坪 committed
125 126 127 128
		text-align: center;
	}
	//大按钮
	.big-btn{
潘永坪's avatar
潘永坪 committed
129
		background:#FE6600;
潘永坪's avatar
潘永坪 committed
130 131
		display: inline-block;
		color: #FFFFFF;
潘永坪's avatar
潘永坪 committed
132 133 134
		width: 240rpx;
		height: 100rpx;
		line-height:100rpx;
潘永坪's avatar
潘永坪 committed
135 136
		font-size:36rpx;
		border-radius:28rpx;
137
		text-align: center;
潘永坪's avatar
潘永坪 committed
138
		font-weight: bold;
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
	}

	/*单行溢出*/
	.one-txt-cut {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	/*多行溢出 手机端使用*/
	.txt-cut {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		/* -webkit-line-clamp: 2; */
		-webkit-box-orient: vertical;
	}
潘永坪's avatar
潘永坪 committed
156 157 158 159 160 161 162
	//设置checkbox背景色
	checkbox.blue[checked] .wx-checkbox-input,
	checkbox.blue.checked .uni-checkbox-input{
		background-color: #3688FF !important;
		border-color: #3688FF !important;
		color: #ffffff !important;
	}
163 164 165
	checkbox.round .wx-checkbox-input {
		border-radius: 50% !important;
	}
潘永坪's avatar
潘永坪 committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179
	// swiper轮播图
	.indicator-num {
		padding: 2px 0;
		background-color: rgba(0, 0, 0, 0.35);
		border-radius: 100px;
		width: 35px;
		@include flex;
		justify-content: center;
	
		&__text {
				 color: #FFFFFF;
				 font-size: 12px;
		 }
	}
180
</style>