getmobile.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view>
  3. <uni-popup ref="telmodal" type="bottom" :mask-click="false">
  4. <view class="getphone">
  5. <view @click="close"><text>×</text></view>
  6. <view>手机号授权提醒</view>
  7. <view>获取司机手机号码授权,同步换电云数据</view>
  8. <view><button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">请授权获取手机号码</button></view>
  9. </view>
  10. </uni-popup>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name:"getmobile",
  16. data() {
  17. return {
  18. };
  19. },
  20. mounted() {
  21. this.$refs.telmodal.open('bottom')
  22. },
  23. methods:{
  24. close(){
  25. // this.$refs.telmodal.close()
  26. this.$utils.switchTab('index/index');
  27. },
  28. getPhoneNumber(e){
  29. const userinfo=this.$store.state.users;
  30. // wx.login({
  31. // success(res){
  32. // console.log(res.code)
  33. // }
  34. // })
  35. if(userinfo && e.detail.errMsg == "getPhoneNumber:ok"){
  36. let params={
  37. encryptedData:e.detail.encryptedData,
  38. iv:e.detail.iv,
  39. openId:userinfo.openId,
  40. nickName:userinfo.nickName,
  41. avatar:userinfo.avatarUrl
  42. }
  43. this.$http.wxLogin(params).then(res=>{
  44. if(res.data){
  45. this.$store.commit("UPDATETOKEN",res.data.token);
  46. this.$store.commit("UPDATEMOBILE",res.data.telephone);
  47. this.$store.commit("UPDATEUSERS",res.data);
  48. this.$emit('updatetopinfo',res.data)
  49. this.$refs.telmodal.close();
  50. }
  51. }).catch(error=>{
  52. this.$utils.msg(error);
  53. });
  54. }else{
  55. this.$utils.navigateTo('public/login');
  56. }
  57. },
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. .getphone{
  63. background-color: #fff;
  64. border-top-left-radius: 20rpx;
  65. border-top-right-radius: 20rpx;
  66. display: flex;
  67. flex-direction: column;
  68. text-align: center;
  69. position: relative;
  70. view:first-child{
  71. right: 10rpx;
  72. top:-10rpx;
  73. font-size: 54rpx;
  74. color: #7e7e80;
  75. position: absolute;
  76. }
  77. view:nth-child(2){
  78. font-weight: bold;
  79. padding-top: 30rpx;
  80. }
  81. view:nth-child(3){
  82. color: #7e7e80;
  83. padding-top: 20rpx;
  84. }
  85. button{
  86. width: 80%;
  87. margin: 25rpx auto;
  88. background-color:#58be6b ;
  89. color: #fff;
  90. }
  91. }
  92. </style>