123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <script>
- export default {
- onLaunch: function() {
- const that = this;
- that.forceUpdate();
- },
- onShow: function() {
- const that = this;
- that.search();
- },
- onHide: function() {
- console.log('App Hide')
- },
- methods: {
- search() {
- const that = this;
- uni.login({
- success: function(res) {
- if (res.code) {
- uni.getStorage({
- key: 'openid',
- success: function(res) {},
- fail: async function(err) {
- const aee = await that.$api('/tool/app', 'GET', {
- js_code: res.code,
- config: that.$config.wx_projectkey
- })
- if (aee.errcode == '0') {
- uni.setStorage({
- key: "openid",
- data: aee.data.openid
- })
- } else {
- uni.showToast({
- title: aee.errmsg,
- icon: 'none'
- })
- }
- }
- })
- } else {
- uni.showToast({
- title: res.errMsg,
- icon: 'none'
- })
- }
- }
- });
- },
- // 强制更新
- forceUpdate() {
- const that = this;
- let system = uni.getSystemInfoSync();
- if (system.uniPlatform == 'mp-weixin') {
- const updateManager = uni.getUpdateManager();
- updateManager.onCheckForUpdate(function(res) {
- // 请求完新版本信息的回调
- console.log(res.hasUpdate);
- });
- updateManager.onUpdateReady(function(res) {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- if (res.confirm) {
- uni.clearStorage();
- updateManager.applyUpdate();
- }
- }
- });
- });
- updateManager.onUpdateFailed(function(res) {
- console.log(res);
- console.log('更新失败');
- });
- }
- }
- }
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import '@/uni_modules/uni-scss/index.scss';
- @import '@/common/css/font-icon.css';
- /* 公用 */
- .container {
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- width: 100vw;
- height: 100vh;
- }
- .textOver {
- overflow: hidden;
- text-overflow: ellipsis;
- word-break: break-all;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- }
- // 弹框公共样式
- .uni-dialog-content {
- padding: 2vw !important;
- max-height: 40vh;
- overflow-y: auto;
- align-items: normal !important;
- box-sizing: border-box;
- }
- /* 设置整个项目的公用样式*/
- page {
- /* 窗口可用高度 */
- /* 有头有底 */
- --oneHeight: 100vh;
- /* 有头无底 */
- --twoHeight: 92vh;
- /* 可用窗口背景颜色 */
- --mainColor: #ffffff;
- /* 底部菜单背景颜色 */
- --footColor: #f1f1f1;
- /* 字体大小 */
- --font20Szie: 20px;
- --font19Szie: 19px;
- --font18Szie: 18px;
- --font17Size: 17px;
- --font16Size: 16px;
- --font15Size: 15px;
- --font14Size: 14px;
- --font13Size: 13px;
- --font12Size: 12px;
- /* 颜色 */
- --f1Color: #f1f1f1;
- --f2Color: #f2f2f2;
- --f3Color: #f3f3f3;
- --f4Color: #f4f4f4;
- --f5Color: #f5f5f5;
- --f6Color: #f6f6f6;
- --f7Color: #f7f7f7;
- --f8Color: #f8f8f8;
- --f9Color: #f9f9f9;
- --f99Color: #999999;
- --f85Color: #858585;
- --f80Color: #808080;
- --fDCColor: #DCDCDC;
- --fcColor: #cccccc;
- --f00Color: #000000;
- --fffColor: #ffffff;
- --f3CColor: #007AFF;
- --fFB1Color: #7A7E83;
- --fF0Color: #FF0000;
- }
- </style>
|