demo.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="wrap">
  3. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  4. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
  5. :showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  6. </view>
  7. </template>
  8. <script>
  9. import {
  10. mapState
  11. } from 'vuex';
  12. export default {
  13. components: {
  14. },
  15. data() {
  16. return {
  17. isShowAlert: false,
  18. content: '当前登入信息验证失败,是否重新登录?',
  19. }
  20. },
  21. onLoad() {
  22. },
  23. // #ifndef MP
  24. onNavigationBarButtonTap(e) {
  25. const index = e.index;
  26. if (index === 0) {
  27. this.navTo('/pages/set/set');
  28. } else if (index === 1) {
  29. // #ifdef APP-PLUS
  30. const pages = getCurrentPages();
  31. const page = pages[pages.length - 1];
  32. const currentWebview = page.$getAppWebview();
  33. currentWebview.hideTitleNViewButtonRedDot({
  34. index
  35. });
  36. // #endif
  37. uni.navigateTo({
  38. url: '/pages/notice/notice'
  39. })
  40. }
  41. },
  42. // #endif
  43. computed: {
  44. ...mapState(['hasLogin', 'userInfo']),
  45. },
  46. onShow() {
  47. uni.showLoading({
  48. title:"加载中...",
  49. mask:true
  50. })
  51. uni.hideLoading()
  52. this.$forceUpdate()//刷新data数据
  53. that.$api.msg('添加成功')
  54. that.$refs.uToast.show({
  55. title: '提交成功',
  56. type: 'success'
  57. })
  58. // 深拷贝
  59. let b = this.$u.deepClone(a);
  60. uni.setStorageSync("depotAcquisition_warehouseName",this.warehouseName)
  61. uni.getStorageSync("depotAcquisition_warehouseName")
  62. // 公司id
  63. compId: uni.getStorageSync('pcUserInfo').compId,
  64. uni.getStorageSync("userInfo").id//用戶id
  65. // 调用公用方法
  66. this.utils.getDistance(lat1,lng1,lat2,lng2)
  67. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  68. console.log("checkSession", res)
  69. if (res.data.data == "INVALID") {
  70. this.isShowAlert = true;
  71. }
  72. })
  73. console.log("hasLogin", this.hasLogin)
  74. },
  75. methods: {
  76. // // 软键盘下一项
  77. // keywordConfirm(e) {
  78. // console.log(e)
  79. // var index = (e.target.id).replace('input-', '');
  80. // var value = e.detail.value;
  81. // uni.hideKeyboard(); //隐藏软键盘
  82. // this.focus_index = Number(index)
  83. // this.$nextTick(function() {
  84. // this.focus_index = Number(index) + 1
  85. // });
  86. // if (index != '10' && value != '') {
  87. // this.focus_index = Number(index) + 1
  88. // }
  89. // },
  90. // confirm-type="search" type="number" :id="'input-17'" @confirm="keywordConfirm"
  91. // :focus="focus_index == 17"
  92. /**
  93. * 统一跳转接口,拦截未登录路由
  94. * navigator标签现在默认没有转场动画,所以用view
  95. */
  96. navTo(url) {
  97. if (!this.hasLogin) {
  98. url = '/pages/public/login';
  99. }
  100. uni.navigateTo({
  101. url
  102. })
  103. },
  104. alertBtn() {
  105. uni.navigateTo({
  106. url: '/pages/public/login'
  107. })
  108. },
  109. cancelClick() {
  110. this.isShowAlert = false
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang='scss' scoped>
  116. page {
  117. background: #F5F6FA;
  118. }
  119. .wrap {
  120. background: #fff;
  121. margin: 10px;
  122. border-radius: 10px;
  123. padding: 10px;
  124. }
  125. </style>