index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view>
  3. <u-modal :show="showAuthorizePhone" :showConfirmButton="false">
  4. <view class="slot-content phone-wrap">
  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"
  18. @click="toDetail"> 立即登录</u-button>
  19. <!-- <u-button :customStyle="customStyleOk" open-type="getPhoneNumber"
  20. @getphonenumber="getPhoneNumber"> 立即登录</u-button> -->
  21. </view>
  22. </view>
  23. </view>
  24. </u-modal>
  25. <u-modal :show="showAuthorizeUser" :showConfirmButton="false">
  26. <view class="slot-content">
  27. <view class="auth-card">
  28. <view class="img">
  29. <img class="avatar-img" src="@/static/logo.png" mode="widthFix">
  30. </view>
  31. <view class="content">邀请您补全个人信息<br></br>(昵称、头像)</view>
  32. <view style="margin-left: 100rpx;margin-right: 100rpx">
  33. <u-form :model="userInfo" ref="uForm">
  34. <u-form-item :rightclass='"rightclass"' bodypadding='0' label="头像">
  35. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
  36. slot="right">
  37. <image class="avatar"
  38. :src="userInfo.head?userInfo.head:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'">
  39. </image>
  40. </button>
  41. </u-form-item>
  42. <u-form-item bodypadding='0' label="昵称">
  43. <u-input inputAlign='right' v-model="userInfo.nickname" class="weui-input"
  44. @blur="userNameInput" placeholder="请输入昵称" border="false" />
  45. <!-- <input type="nickname" :value="userInfo.nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称"/> -->
  46. </u-form-item>
  47. </u-form>
  48. </view>
  49. </view>
  50. <view class="auth-btncard">
  51. <view class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="authUser(0)">
  52. 拒绝</u-button>
  53. </view>
  54. <view class="btn-ok">
  55. <u-button :customStyle="customStyleOk" @click="authUser(1)"> 允许</u-button>
  56. </view>
  57. </view>
  58. </view>
  59. </u-modal>
  60. </view>
  61. </template>
  62. <script>
  63. var that
  64. import {
  65. pathToBase64,
  66. base64ToPath
  67. } from 'image-tools'
  68. export default {
  69. data() {
  70. return {
  71. showAuthorizePhone:false,
  72. showAuthorizeUser:false,
  73. userInfo: {
  74. head: '',
  75. nickname: '',
  76. phone: '',
  77. },
  78. customStyleUnOk: {
  79. marginTop: '20rpx',
  80. color: '#eaad1a',
  81. // border: '2px solid #eaad1a',
  82. "font-weight": 'bold',
  83. "background":'#F2F2F2',
  84. "border-radius": "10px",
  85. fontSize: "32rpx"
  86. },
  87. customStyleOk: {
  88. marginTop: '20rpx',
  89. color: '#fff',
  90. // border: '2px solid #eaad1a',
  91. "font-weight": 'bold',
  92. "background":'#F2F2F2',
  93. "border-radius": "10px",
  94. fontSize: "32rpx",
  95. padding:'0 20rpx',
  96. background: "#eaad1a"
  97. },
  98. };
  99. },
  100. props: {
  101. content: {
  102. type: String,
  103. default: ""
  104. },
  105. },
  106. watch:{
  107. },
  108. mounted() {
  109. that = this
  110. },
  111. computed: {
  112. },
  113. methods: {
  114. open(){
  115. this.showAuthorizePhone=true
  116. },
  117. useropen(user){
  118. this.userInfo=user
  119. this.showAuthorizeUser=true
  120. },
  121. toDetail(){
  122. this.showAuthorizePhone = false
  123. uni.navigateTo({
  124. url:'/pageA/login/index'
  125. })
  126. },
  127. async getPhoneNumber(e) {
  128. console.log(0)
  129. that.userInfo = await this.$request.wxlogin()
  130. console.log(that.userInfo,1111)
  131. that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
  132. console.log(that.userInfo,2222)
  133. this.showAuthorizePhone = false
  134. this.showAuthorizeUser = true
  135. },
  136. async authUser(type) {
  137. //同步信息,没有头像和昵称自动生成
  138. this.userInfo = await this.$request.syncInfo(this.userInfo)
  139. if (this.userInfo.openId) {
  140. uni.setStorageSync("userInfo", that.userInfo)
  141. that.showAuthorizeUser = false
  142. // that.mescroll.resetUpScroll()
  143. }
  144. },
  145. //获取昵称输入内容
  146. userNameInput(e) {
  147. this.userInfo.nickname = e.detail.value
  148. },
  149. async onChooseAvatar(e) {
  150. this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
  151. },
  152. toBase64(url) {
  153. return new Promise(resolve => {
  154. pathToBase64(url).then(path => {
  155. resolve(path);
  156. }).catch(error => {
  157. console.log(error)
  158. })
  159. })
  160. },
  161. }
  162. }
  163. </script>
  164. <style lang='scss' scoped>
  165. .auth-btncard {
  166. width:80%;
  167. margin:40rpx auto 0;
  168. display: flex !important;
  169. justify-content: space-between !important;
  170. .btn-unok {
  171. width: 45%;
  172. }
  173. .btn-ok {
  174. width: 45%;
  175. }
  176. }
  177. .auth-card {
  178. text-align: center;
  179. .avatar-img {
  180. width: 200rpx;
  181. margin-bottom:30rpx;
  182. }
  183. .title {
  184. font-size: 20rpx;
  185. }
  186. .content {
  187. font-size: 32rpx;
  188. font-weight: bold;
  189. color: #1A1A1A;
  190. margin-bottom: 60rpx;
  191. }
  192. }
  193. .phone-wrap .content {
  194. margin-bottom: 100rpx;
  195. }
  196. .avatar-wrapper {
  197. color: #333 !important;
  198. border: none !important;
  199. border-radius: 0 !important;
  200. background-color: transparent !important;
  201. padding: 0;
  202. }
  203. .avatar-wrapper::after {
  204. border: none !important;
  205. }
  206. .avatar {
  207. width: 80rpx;
  208. height: 80rpx;
  209. overflow: hidden;
  210. border-radius: 100%;
  211. }
  212. /deep/.u-popup__content {
  213. border-radius: 20rpx !important;
  214. }
  215. /deep/.u-button--normal{
  216. padding: 0 5px;
  217. }
  218. .slot-content{
  219. width: 100%;
  220. }
  221. button{
  222. line-height: 1;;
  223. }
  224. </style>