routine_phone.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view v-if="isPhoneBox">
  3. <view class="mobile-bg" @click="close"></view>
  4. <view class="mobile-mask animated" :class="{slideInUp:isUp}">
  5. <view class="info-box">
  6. <image :src="logoUrl"></image>
  7. <view class="title">获取授权</view>
  8. <view class="txt">手机号快捷登录</view>
  9. </view>
  10. <button class="sub_btn" open-type="getPhoneNumber" @getphonenumber="getphonenumber">获取微信手机号</button>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. // +----------------------------------------------------------------------
  16. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  17. // +----------------------------------------------------------------------
  18. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  19. // +----------------------------------------------------------------------
  20. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  21. // +----------------------------------------------------------------------
  22. // | Author: CRMEB Team <admin@crmeb.com>
  23. // +----------------------------------------------------------------------
  24. const app = getApp();
  25. import Routine from '@/libs/routine';
  26. import { getUserPhone } from '@/api/public';
  27. import {
  28. mapGetters
  29. } from "vuex";
  30. import {silenceBindingSpread} from "../../../../utils";
  31. export default{
  32. name:'routine_phone',
  33. computed: mapGetters(['userInfo', 'isLogin', 'globalData']),
  34. props:{
  35. isPhoneBox:{
  36. type:Boolean,
  37. default:false,
  38. },
  39. logoUrl:{
  40. type:String,
  41. default:'',
  42. },
  43. authKey:{
  44. type:String,
  45. default:'',
  46. }
  47. },
  48. data(){
  49. return {
  50. keyCode:'',
  51. account:'',
  52. codeNum:'',
  53. isStatus:false
  54. }
  55. },
  56. mounted() {
  57. },
  58. methods:{
  59. // #ifdef MP
  60. // 小程序获取手机号码
  61. getphonenumber(e){
  62. uni.showLoading({ title: '加载中' });
  63. Routine.getCode()
  64. .then(code => {
  65. this.getUserPhoneNumber(e.detail.encryptedData, e.detail.iv, code);
  66. })
  67. .catch(error => {
  68. uni.hideLoading();
  69. });
  70. },
  71. // 小程序获取手机号码回调
  72. getUserPhoneNumber(encryptedData, iv, code) {
  73. getUserPhone({
  74. encryptedData: encryptedData,
  75. iv: iv,
  76. code: code,
  77. key:this.authKey,
  78. type: 'routine'
  79. })
  80. .then(res => {
  81. this.$store.commit('LOGIN', {
  82. token: res.data.token
  83. });
  84. this.$store.commit("SETUID", res.data.id);
  85. this.getUserInfo(res);
  86. if (res.data.isNew && res.data.newPeopleCouponList && res.data.newPeopleCouponList.length !== 0) {
  87. this.$Cache.set('newGift', res.data.newPeopleCouponList);
  88. } else {
  89. this.$Cache.clear('newGift');
  90. }
  91. })
  92. .catch(res => {
  93. uni.hideLoading();
  94. this.$util.Tips({
  95. title: res
  96. });
  97. });
  98. },
  99. /**
  100. * 获取个人用户信息
  101. */
  102. getUserInfo: function(res) {
  103. this.$store.dispatch("GetTokenIsExist");
  104. //分销绑定
  105. silenceBindingSpread(true,this.globalData.spread);
  106. // #ifdef MP
  107. if(!this.$Cache.get('wechatQRcode')) Routine.getQrcode()
  108. // #endif
  109. this.isStatus = true
  110. this.close()
  111. uni.hideLoading();
  112. },
  113. // #endif
  114. close(){
  115. this.$emit('close',{isStatus:this.isStatus})
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .mobile-bg{
  122. position: fixed;
  123. left: 0;
  124. top: 0;
  125. width: 100%;
  126. height: 100%;
  127. background: rgba(0,0,0,0.5);
  128. }
  129. .mobile-mask {
  130. z-index: 20;
  131. position: fixed;
  132. left: 0;
  133. bottom: 0;
  134. width: 100%;
  135. padding: 67rpx 30rpx;
  136. background: #fff;
  137. .info-box{
  138. display:flex;
  139. flex-direction: column;
  140. align-items: center;
  141. justify-content: center;
  142. image{
  143. width: 150rpx;
  144. height: 150rpx;
  145. border-radius: 10rpx;
  146. }
  147. .title{
  148. margin-top: 30rpx;
  149. margin-bottom: 20rpx;
  150. font-size: 36rpx;
  151. }
  152. .txt{
  153. font-size: 30rpx;
  154. color: #868686;
  155. }
  156. }
  157. .sub_btn{
  158. width: 690rpx;
  159. height: 86rpx;
  160. line-height: 86rpx;
  161. margin-top: 60rpx;
  162. background: $theme-color;
  163. border-radius: 43rpx;
  164. color: #fff;
  165. font-size: 28rpx;
  166. text-align: center;
  167. }
  168. }
  169. .animated{
  170. animation-duration:.4s
  171. }
  172. </style>