index.wpy 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <style lang="less">
  2. .login-box {
  3. padding-top: 40px;
  4. .avatar-wrapper {
  5. padding: 0px;
  6. width: 196rpx;
  7. height: 196rpx;
  8. border-radius: 50%;
  9. image {
  10. width: 196rpx;
  11. height: 196rpx;
  12. border-radius: 50%;
  13. }
  14. }
  15. .avatar-tip {
  16. text-align: center;
  17. font-family: PingFang SC;
  18. font-size: 28rpx;
  19. font-weight: 400;
  20. line-height: 44rpx;
  21. text-align: center;
  22. }
  23. .bind-btn-box {
  24. position: fixed;
  25. bottom: 228rpx;
  26. left: 50%;
  27. transform: translateX(-50%);
  28. .bind-btn {
  29. width: 548rpx;
  30. height: 100rpx;
  31. line-height: 100rpx;
  32. border-radius: 56rpx;
  33. background: rgba(61, 203, 204, 1);
  34. border: none;
  35. font-family: PingFang SC;
  36. font-size: 32rpx;
  37. font-weight: 400;
  38. letter-spacing: 0px;
  39. text-align: center;
  40. color: #fff;
  41. }
  42. .bind-btn-tip {
  43. //styleName: 14/常规;
  44. font-family: PingFang SC;
  45. padding-top: 32rpx;
  46. font-size: 28rpx;
  47. font-weight: 400;
  48. line-height: 44rpx;
  49. text-align: center;
  50. color: rgba(139, 148, 158, 1);
  51. }
  52. }
  53. .home-btn {
  54. margin-top: 240rpx;
  55. width: 548rpx;
  56. height: 100rpx;
  57. line-height: 100rpx;
  58. border-radius: 56rpx;
  59. border: 1px solid rgba(61, 203, 204, 1);
  60. }
  61. }
  62. </style>
  63. <template>
  64. <div class="login-box">
  65. <button class="avatar-wrapper"
  66. v-if="canIUseGetUserProfile"
  67. open-type="chooseAvatar"
  68. bind:chooseavatar="onChooseAvatar">
  69. <image class="avatar" src="{{avatarUrl}}"/>
  70. </button>
  71. <div class="avatar-tip" v-if="canIUseGetUserProfile">可点击获取头像</div>
  72. <div class="bind-btn-box">
  73. <button class="bind-btn"
  74. open-type="getPhoneNumber"
  75. bindgetphonenumber="phonenumberAuth"
  76. >微信手机号认证</button>
  77. <!-- @click="goBindTenant" -->
  78. <!-- bindgetphonenumber="phonenumberAuth" -->
  79. <div class="bind-btn-tip">确保是入职公司使用的手机号</div>
  80. </div>
  81. <button class="home-btn" @click="goHome">首页</button>
  82. </div>
  83. </template>
  84. <script>
  85. import wepy from '@wepy/core';
  86. import { mapState } from '@wepy/x';
  87. import store from '@/store';
  88. import config from '@/config';
  89. import { setAvatar, setUserInfoByAuth } from '@/service/user';
  90. import { getCompanyByPhone } from '@/api/user';
  91. let defaultAvatarUrl =
  92. config.h5StaticPath + '/page-bind-tenant/default_avatar.svg';
  93. wepy.page({
  94. store,
  95. config: {
  96. navigationBarTitleText: 'test'
  97. },
  98. data: {
  99. nicknameValue: '',
  100. avatarUrl: defaultAvatarUrl,
  101. msg: '测试数据',
  102. canIUseGetUserProfile: false,
  103. userInformation: wx.getStorageSync('userInformation')
  104. },
  105. onLoad() {
  106. if (wx.getUserProfile) {
  107. this.canIUseGetUserProfile = true;
  108. }
  109. },
  110. onShow() {},
  111. methods: {
  112. // 绑定租户
  113. bindTenant() {},
  114. onChooseAvatar(e) {
  115. this.avatarUrl = e.$wx.detail.avatarUrl;
  116. let avatarUrl = this.avatarUrl;
  117. let that = this;
  118. wx.getFileSystemManager().readFile({
  119. filePath: avatarUrl,
  120. encoding: 'base64',
  121. success: function(res) {
  122. console.log(res.data);
  123. that.avatarUrl = 'data:image/png;base64,' + res.data;
  124. setAvatar(that.avatarUrl);
  125. }
  126. });
  127. },
  128. getPageCompanyByPhone() {},
  129. goHome() {
  130. wx.navigateTo({
  131. url: '/packagesEnv/pages/home/index'
  132. });
  133. },
  134. // 手机号认证
  135. phonenumberAuth(e) {
  136. console.log(e);
  137. // this.goBindTenant();
  138. let detail = e.$wx.detail;
  139. let code = detail.code;
  140. let errMsg = detail.errMsg;
  141. console.log(detail);
  142. store.commit('setUserPhone', 15321277745);
  143. // wx.setStorage('userPhone', 15321277745);
  144. // wx.navigateTo({
  145. // url: '/pages/bindTenant/index'
  146. // });
  147. },
  148. goBindTenant() {
  149. console.log('被点击了');
  150. wx.navigateTo({
  151. url: '/pages/bindTenant/index'
  152. });
  153. }
  154. },
  155. created() {}
  156. });
  157. </script>
  158. <config>
  159. {
  160. navigationBarTitleText: '首页',
  161. }
  162. </config>