bindCompanyUser.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="content">
  3. <image v-show="isBind" src="https://cos.his.cdwjyyh.com/fs/20250414/3da41caccf8346b188809fac656ba834.jpg" mode="widthFix"></image>
  4. <view v-show="!isBind" class="bindbox">{{msg}}</view>
  5. <!-- <view class="bindbox">
  6. <image :src="baseUrl + '/images/bindComUser.png'" mode="aspectFill"></image>
  7. <view>立即绑定,享受更多权益</view>
  8. </view>
  9. <button class="bind-btn" :loading="btnLodaing" :disabled="btnLodaing" @click="handleBind">立即绑定</button> -->
  10. </view>
  11. </template>
  12. <script>
  13. import {getUserInfo} from '@/api/user.js'
  14. import { bindCompanyFsUser } from '@/api/companyUser.js'
  15. export default {
  16. data() {
  17. return {
  18. isBind: false,
  19. msg: '绑定中...',
  20. baseUrl:uni.getStorageSync('requestPath'),
  21. btnLodaing: false,
  22. companyUserId: '',
  23. }
  24. },
  25. onLoad(option) {
  26. let q = {}
  27. if(option.q) {
  28. q = decodeURIComponent(option.q) // 获取到二维码原始链接内容
  29. }
  30. this.companyUserId = q.companyUserId || option.companyUserId
  31. const historyApp = uni.getStorageSync('historyApp') || '';
  32. if(historyApp) {
  33. this.handleBind()
  34. } else {
  35. this.getUser()
  36. }
  37. },
  38. methods: {
  39. getUser() {
  40. uni.showLoading({
  41. title: '绑定中...'
  42. })
  43. getUserInfo().then(
  44. res => {
  45. if(res.code==200){
  46. if(res.user!=null){
  47. if(res.user.historyApp) {
  48. uni.setStorageSync('historyApp',res.user.historyApp)
  49. this.handleBind()
  50. } else {
  51. uni.hideLoading()
  52. uni.redirectTo({
  53. url: '/pages_user/downApp'
  54. })
  55. }
  56. }
  57. else{
  58. uni.hideLoading()
  59. this.utils.loginOut();
  60. }
  61. }else{
  62. uni.hideLoading()
  63. uni.showToast({
  64. icon:'none',
  65. title: "请求失败",
  66. });
  67. }
  68. },
  69. rej => {}
  70. ).catch(()=>{
  71. uni.hideLoading()
  72. });
  73. },
  74. handleBind() {
  75. uni.showLoading({
  76. title: '绑定中...'
  77. })
  78. this.msg = '绑定中...'
  79. this.$isLogin().then(
  80. res => {
  81. if(res){
  82. this.submit();
  83. }
  84. else{
  85. uni.hideLoading()
  86. uni.navigateTo({
  87. url:'/pages/auth/login'
  88. })
  89. }
  90. }
  91. ).catch(()=>{
  92. this.msg = '绑定失败'
  93. uni.hideLoading()
  94. });
  95. },
  96. submit() {
  97. this.btnLodaing = true
  98. uni.showLoading({
  99. title: '绑定中...'
  100. })
  101. bindCompanyFsUser(this.companyUserId).then(res=>{
  102. this.btnLodaing = false
  103. uni.hideLoading()
  104. if(res.code == 200) {
  105. this.isBind = true
  106. this.msg = '绑定成功'
  107. uni.showToast({
  108. title: res.msg,
  109. icon: 'none'
  110. })
  111. }else {
  112. this.msg = res.msg
  113. this.isBind = false
  114. uni.showToast({
  115. title: res.msg,
  116. icon: 'none'
  117. })
  118. }
  119. }).catch(()=>{
  120. this.msg = '绑定失败'
  121. this.isBind = false
  122. this.btnLodaing = false
  123. uni.hideLoading()
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .bindbox {
  131. display: flex;
  132. flex-direction: column;
  133. align-items: center;
  134. justify-content: center;
  135. padding-top: 20vh;
  136. font-family: PingFang SC, PingFang SC;
  137. font-weight: 400;
  138. font-size: 32rpx;
  139. color: #757575;
  140. image {
  141. height: 150rpx;
  142. width: 150rpx;
  143. margin-bottom: 50rpx;
  144. }
  145. }
  146. .content {
  147. width: 100%;
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. padding-bottom: calc(var(--window-bottom) + 150rpx);
  152. }
  153. .bind-btn {
  154. margin: 20vh auto 20px auto;
  155. width: 300px;
  156. height: 44px;
  157. line-height: 44px;
  158. text-align: center;
  159. background: #FF5C03 !important;
  160. color: #fff !important;
  161. font-size: 16px;
  162. font-weight: 500;
  163. border-radius: 22px;
  164. display: block;
  165. &:after {
  166. border: none;
  167. }
  168. }
  169. </style>