index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view>
  3. <u-modal :show="showAuthorizePhone" :showConfirmButton="false">
  4. <view class="slot-content">
  5. <view class="auth-card">
  6. <view class="img">
  7. <img class="avatar-img" src="@/static/logo.png" mode="widthFix">
  8. </view>
  9. <view class="content">{{content}}</view>
  10. </view>
  11. <view class="auth-btncard">
  12. <view class="btn-unok">
  13. <u-button :customStyle="customStyleUnOk" @click="showAuthorizePhone=false" :plain="true">
  14. 拒绝</u-button>
  15. </view>
  16. <view class="btn-ok">
  17. <u-button :customStyle="customStyleOk" open-type="getPhoneNumber"
  18. @getphonenumber="getPhoneNumber"> 立即登录</u-button>
  19. </view>
  20. </view>
  21. </view>
  22. </u-modal>
  23. <u-modal :show="showAuthorizeUser" :showConfirmButton="false">
  24. <view class="slot-content">
  25. <view class="auth-card">
  26. <view class="img">
  27. <img class="avatar-img" src="@/static/logo.png" mode="widthFix">
  28. </view>
  29. <view class="content">邀请您补全个人信息<br></br>(昵称、头像)</view>
  30. <view style="margin-left: 100rpx;margin-right: 100rpx">
  31. <u-form :model="userInfo" ref="uForm">
  32. <u-form-item label="头像">
  33. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
  34. slot="right">
  35. <image class="avatar"
  36. :src="userInfo.head?userInfo.head:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'">
  37. </image>
  38. </button>
  39. </u-form-item>
  40. <u-form-item label="昵称">
  41. <u-input inputAlign='right' v-model="userInfo.nickname" class="weui-input"
  42. @blur="userNameInput" placeholder="请输入昵称" border="false" />
  43. <!-- <input type="nickname" :value="userInfo.nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称"/> -->
  44. </u-form-item>
  45. </u-form>
  46. </view>
  47. </view>
  48. <view class="auth-btncard">
  49. <view class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="authUser(0)">
  50. 拒绝</u-button>
  51. </view>
  52. <view class="btn-ok">
  53. <u-button :customStyle="customStyleOk" @click="authUser(1)"> 允许</u-button>
  54. </view>
  55. </view>
  56. </view>
  57. </u-modal>
  58. </view>
  59. </template>
  60. <script>
  61. var that
  62. export default {
  63. data() {
  64. return {
  65. showAuthorizePhone:false,
  66. showAuthorizeUser:false,
  67. userInfo: {
  68. head: '',
  69. nickname: '',
  70. phone: '',
  71. },
  72. customStyleUnOk: {
  73. marginTop: '20rpx',
  74. color: '#eaad1a',
  75. border: '2px solid #eaad1a',
  76. "border-radius": "10px",
  77. fontSize: "32rpx"
  78. },
  79. customStyleOk: {
  80. marginTop: '20rpx',
  81. color: '#fff',
  82. border: '2px solid #eaad1a',
  83. "border-radius": "10px",
  84. fontSize: "32rpx",
  85. padding:'0 5px',
  86. background: "#eaad1a"
  87. },
  88. };
  89. },
  90. props: {
  91. content: {
  92. type: String,
  93. default: ""
  94. },
  95. },
  96. watch:{
  97. },
  98. mounted() {
  99. that = this
  100. },
  101. computed: {
  102. },
  103. methods: {
  104. open(){
  105. this.showAuthorizePhone=true
  106. },
  107. async getPhoneNumber(e) {
  108. console.log(0)
  109. that.userInfo = await this.$request.wxlogin()
  110. console.log(that.userInfo,1111)
  111. that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
  112. console.log(that.userInfo,2222)
  113. this.showAuthorizePhone = false
  114. this.showAuthorizeUser = true
  115. },
  116. async authUser(type) {
  117. //同步信息,没有头像和昵称自动生成
  118. this.userInfo = await this.$request.syncInfo(this.userInfo)
  119. if (this.userInfo.openId) {
  120. uni.setStorageSync("userInfo", that.userInfo)
  121. that.showAuthorizeUser = false
  122. // that.mescroll.resetUpScroll()
  123. }
  124. },
  125. }
  126. }
  127. </script>
  128. <style lang='scss' scoped>
  129. .auth-btncard {
  130. display: flex !important;
  131. justify-content: space-between !important;
  132. .btn-unok {
  133. width: 40%;
  134. }
  135. .btn-ok {
  136. width: 40%;
  137. }
  138. }
  139. .auth-card {
  140. text-align: center;
  141. .avatar-img {
  142. width: 250rpx;
  143. }
  144. .title {
  145. font-size: 20rpx;
  146. }
  147. .content {
  148. font-size: 32rpx;
  149. font-weight: bold;
  150. color: #1A1A1A;
  151. margin-bottom: 30rpx;
  152. }
  153. }
  154. .avatar-wrapper {
  155. color: #333 !important;
  156. border: none !important;
  157. border-radius: 0 !important;
  158. background-color: transparent !important;
  159. padding: 0;
  160. }
  161. .avatar-wrapper::after {
  162. border: none !important;
  163. }
  164. .avatar {
  165. width: 100rpx;
  166. height: 100rpx;
  167. overflow: hidden;
  168. border-radius: 100%;
  169. }
  170. /deep/.u-popup__content {
  171. border-radius: 20rpx !important;
  172. }
  173. /deep/.u-button--normal{
  174. padding: 0 5px;
  175. }
  176. </style>