Commit d4b9d450 authored by xinzhedeai's avatar xinzhedeai

自动更新 登录校验 手机号11位 home校验

parent 1294246c
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
} from 'vuex' } from 'vuex'
export default { export default {
onLaunch: function() { onLaunch: function() {
// #ifdef MP-WEIXIN
updateApp()
// #endif
}, },
onShow: function() { onShow: function() {
console.log('App Show') console.log('App Show')
...@@ -18,10 +21,49 @@ ...@@ -18,10 +21,49 @@
...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin']) ...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
} }
} }
// #ifdef MP-WEIXIN
function updateApp() {
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate);
});
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
showCancel: false,
success(res) {
if (res.confirm) {
updateManager.onUpdateReady((res) => {
// 新版本下载完成的回调,强制当前小程序应用上新版本并重启
updateManager.applyUpdate()
})
updateManager.onUpdateFailed((res) => {
// 新版本下载失败的回调
uni.showModal({
content: '下载失败,请您删除当前小程序,重新搜索打开',
showCancel: false,
confirmText: '知道了',
})
})
} else if (res.cancel) {
console.log('用户点击取消,不更新');
}
}
});
});
}
// #endif
</script> </script>
<style lang="scss"> <style lang="scss">
@import '@/uni_modules/uni-scss/index.scss'; @import '@/uni_modules/uni-scss/index.scss';
// *{ // *{
// font-family: Source Han Sans SC; // font-family: Source Han Sans SC;
// } // }
......
...@@ -14,3 +14,10 @@ export function getPhoneNumber(params) { // 登录获取token ...@@ -14,3 +14,10 @@ export function getPhoneNumber(params) { // 登录获取token
data: params.data data: params.data
}) })
} }
export function getExistedUser(params) { // 登录获取token
return request({
url: '/weixin/getUser',
method: 'get',
data: params.data
})
}
\ No newline at end of file
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
}, },
onLoad(options) {}, onLoad(options) {},
methods: { methods: {
// gobackDeal(){ gobackDeal(){
// console.log('XXXXXXXXX****8泛会上一页') // console.log('XXXXXXXXX****8泛会上一页')
// if(this.$store.state.blueConnectLoading){ // if(this.$store.state.blueConnectLoading){
// showCustomModal({ // showCustomModal({
...@@ -101,10 +101,10 @@ ...@@ -101,10 +101,10 @@
// }) // })
// return true // return true
// } // }
// uni.reLaunch({ uni.reLaunch({
// url: '/pages/home/home', url: '/pages/home/home',
// }); });
// }, },
openBluetoothAdapter() { openBluetoothAdapter() {
this.pageLoadText = '' this.pageLoadText = ''
this.misScanding = false; this.misScanding = false;
......
...@@ -76,6 +76,9 @@ ...@@ -76,6 +76,9 @@
import { import {
getExportData, getExportData,
} from '../../api/home.js' } from '../../api/home.js'
import {
getDict
} from '../../api/blueToothMeasure.js'
import { BASEURL } from "../../common/config.js"; import { BASEURL } from "../../common/config.js";
import { mapState } from "vuex"; import { mapState } from "vuex";
...@@ -92,6 +95,9 @@ ...@@ -92,6 +95,9 @@
*/ */
onLoad: function(options) { onLoad: function(options) {
uni.hideLoading() uni.hideLoading()
getDict({
type: 'zhuangyao_type'
})
}, },
onShow() { onShow() {
uni.hideLoading() uni.hideLoading()
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</view> </view>
<view class='content' v-if="!hasToken"> <view class='content' v-if="!hasToken">
<view class="title">手机号</view> <view class="title">手机号</view>
<input class="uni-input" focus placeholder="请输入手机号" v-model="phone" /> <input class="uni-input" focus placeholder="请输入手机号" maxlength="11" v-model="phone" />
<button class="tel-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"> <button class="tel-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<uni-icons type="phone" size="18"></uni-icons> <uni-icons type="phone" size="18"></uni-icons>
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
} from '../../common/util.js' } from '../../common/util.js'
import { import {
login, login,
getPhoneNumber getPhoneNumber,
getExistedUser
} from '../../api/login.js' } from '../../api/login.js'
export default { export default {
onLoad() { onLoad() {
...@@ -63,7 +64,8 @@ ...@@ -63,7 +64,8 @@
} }
}, },
mounted() { mounted() {
this.hasToken = !!storager.get('token') // this.hasToken = !!storager.get('token')
this.getExistedUser() // 判断是否为第一次登陆
}, },
methods: { methods: {
async getPhoneNumber(e) { async getPhoneNumber(e) {
...@@ -129,6 +131,7 @@ ...@@ -129,6 +131,7 @@
}); });
}, },
async getToken(code, userInfo) { async getToken(code, userInfo) {
popuper.hideLoading()
let res = await login({ let res = await login({
data: { data: {
"code": code, "code": code,
...@@ -138,15 +141,30 @@ ...@@ -138,15 +141,30 @@
}, },
}) })
console.log('res', res) console.log('res', res)
popuper.hideLoading()
if (res) { if (res) {
storager.set('token', res.token) storager.set('token', res.token)
console.log('获取token', res.token) console.log('获取token', res.token)
pager.relaunchTo('/pages/home/home') pager.relaunchTo('/pages/home/home')
} }
},
async getExistedUser() {
const loginRes = await this.getWxCode()
if (!loginRes.code) {
showCustomToast({
title: 'code未获取'
})
return
}
let res = await getExistedUser({
data: {
"code": loginRes.code,
},
})
console.log('res', res)
if (res) {
this.hasToken = !!res.boolean
}
} }
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment