| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <template>
- <div>
- <van-tabbar v-model="active" placeholder route :before-change="beforeChange" active-color="#f0896e">
- <van-tabbar-item v-for="(item,index) in list" :key="index" :to="item.router">
- <span>{{item.text}}</span>
- <template #icon="props">
- <img :src="props.active ? item.selectedIconPath : item.iconPath" />
- </template>
- </van-tabbar-item>
- </van-tabbar>
- </div>
- </template>
- <script>
- import { userApi } from '../api/index.js'
- export default {
- data() {
- return {
- active: 0,
- list: [
- {
- iconPath: require('../assets/images/nav/home-off.png'),
- selectedIconPath: require('../assets/images/nav/home-on.png'),
- text: '首页',
- router: '/',
- },
- {
- iconPath: require('../assets/images/nav/book-off.png'),
- selectedIconPath: require('../assets/images/nav/book-on.png'),
- router: '/classRoom',
- text: '老年课堂',
- },
- {
- iconPath: require('../assets/images/nav/map-off.png'),
- selectedIconPath: require('../assets/images/nav/map-on.png'),
- router: '/circleHome',
- text: '养老服务圈',
- },
- // {
- // iconPath: require('../assets/images/nav/serve-store-off.png'),
- // selectedIconPath: require('../assets/images/nav/serve-store-on.png'),
- // router: '/shoppingMall',
- // text: '养老商城',
- // },
- // {
- // iconPath: require('../assets/images/nav/my-off.png'),
- // selectedIconPath: require('../assets/images/nav/my-on.png'),
- // text: '我的',
- // },
- {
- iconPath: require('../assets/images/nav/hea.png'),
- selectedIconPath: require('../assets/images/nav/hea1.png'),
- router: '/healthAssessmen',
- text: '健康管理',
- },
- ],
- appmark: 'sdzwapp',
- }
- },
- created() {},
- methods: {
- beforeChange(e) {
- if (e == 3) {
- if (!sessionStorage.getItem('userInfo')) {
- this.getUserInfo()
- } else {
- return true
- }
- } else {
- return true
- }
- },
- async userApi() {
- var userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
- // var mobile = '13895651855'
- const res = await userApi({
- command: 'reguserbyweixinphone',
- contactsPhone: userInfo.mobile,
- // contactsPhone: mobile,
- terminalType: 5,
- })
- sessionStorage.setItem('healthUser', JSON.stringify(res))
- // this.$toast(userInfo.name + '接口')
- // this.$dialog
- // .alert({
- // message: res.uname + '--------' + userInfo.name,
- // })
- // .then(() => {})
- this.$router.push({ path: '/healthAssessmen' })
- },
- /**
- * 通过jssdk方法获取APP本地用户票据
- */
- getUserInfo() {
- var that = this
- lightAppJssdk.user.getTicket({
- success: function (data) {
- //成功回调
- console.log(JSON.stringify(data), '111')
- if (data == '未登录') {
- onLoginApp() //APP用户未登录,调用登录页面
- } else {
- var jsonData = JSON.parse(data)
- if (jsonData.retcode == '000000') {
- var dataValueObj = JSON.parse(jsonData.data)
- var ticket = dataValueObj.ticket //解析出用户票据信息
- userType = dataValueObj.usertype //解析保存用户类型(个人法人)
- that.getUserToken(ticket)
- }
- }
- },
- fail: function (data) {
- //错误返回
- console.log(JSON.stringify(data))
- },
- })
- },
- /**
- * 使用jssdk调用登录页面
- */
- onLoginApp() {
- var that = this
- lightAppJssdk.user.loginapp({
- success: function (data) {
- if (data == '未登录') {
- //取消登录或登录失败,关闭页面
- oncloseWindow()
- } else {
- var dataObj = JSON.parse(data)
- if (dataObj.retcode == '000000') {
- //登录成功,返回用户的票据和用户类型
- var dataValueObj = JSON.parse(dataObj.data)
- that.getUserToken(dataValueObj.ticket) //解析出用户票据信息
- userType = jsonData.usertype //解析保存用户类型(个人法人)
- } else {
- //关闭页面
- oncloseWindow()
- }
- }
- },
- fail: function (data) {
- //关闭页面
- oncloseWindow()
- },
- })
- },
- /**
- * 通过用户票据获取用户的令牌数据,票据使用一次后失效,token时效性较长
- */
- getUserToken(ticket) {
- var that = this
- var params = '{"ticket":"' + ticket + '"}'
- const interfaceContent = {
- app_id: that.appmark,
- servicename: 'ticketValidate',
- params: params,
- }
- vaildInterfacefn(
- 'jisnzjk',
- 'ticketvalidate',
- JSON.stringify(interfaceContent),
- '2',
- 'https://' + urlCreatesign,
- 'https://' + urlGateway
- ).then((value) => {
- const data = JSON.parse(value)
- if (data.retcode == '000000') {
- const userToken = JSON.parse(data.data).token
- if (userType == '1') {
- //个人类型获取用户信息
- that.getUserInfoByToken(userToken)
- } else {
- //法人类型获取用户信息
- that.findCorUserByToken(userToken)
- }
- } else {
- lightAppJssdk.notification.alert({
- title: '提示', //可传空
- message: data.msg,
- buttonName: '确认',
- success: function (data) {
- oncloseWindow()
- },
- })
- }
- })
- },
- /**
- * 根据令牌获取个人完整信息
- */
- getUserInfoByToken(userToken) {
- var that = this
- const params = '{"token":"' + userToken + '"}'
- const interfaceContent = {
- app_id: that.appmark,
- servicename: 'findOutsideUserByToken',
- params: params,
- }
- try {
- vaildInterfacefn(
- 'jisnzjk',
- 'findoutsideuserbytoken',
- JSON.stringify(interfaceContent),
- '2',
- 'https://' + urlCreatesign,
- 'https://' + urlGateway
- ).then((value) => {
- const data = JSON.parse(value)
- if (data.retcode == '000000') {
- const userInfo = data.data
- sessionStorage.setItem('userInfo', userInfo)
- // that.$toast('调用接口getUserInfoByToken')
- that.userApi()
- } else {
- }
- })
- } catch (error) {}
- },
- /**
- * 根据令牌获取完整法人信息
- */
- findCorUserByToken(userToken) {
- var that = this
- try {
- const params = '{"token":"' + userToken + '"}'
- const interfaceContent = {
- app_id: that.appmark,
- servicename: 'findCorUserByToken',
- params: params,
- }
- vaildInterfacefn(
- 'jisnzjk',
- 'findcoruserytoken',
- JSON.stringify(interfaceContent),
- '2',
- 'https://' + urlCreatesign,
- 'https://' + urlGateway
- ).then((value) => {
- const data = JSON.parse(value)
- if (data.retcode == '000000') {
- const userInfo = JSON.stringify(data.data)
- // const userObj = JSON.parse(userInfo)
- sessionStorage.setItem('userInfo', userInfo)
- // document.getElementById('userinfo').innerText = userInfo
- // that.$toast('调用接口findCorUserByToken')
- that.userApi()
- } else {
- }
- })
- } catch (err) {}
- },
- /**
- * 关闭容器
- */
- oncloseWindow() {
- lightAppJssdk.navigation.close({
- success: function (data) {},
- fail: function (data) {},
- })
- },
- },
- }
- </script>
|