index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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"
  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 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 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. toDetail(){
  118. this.showAuthorizePhone = false
  119. uni.navigateTo({
  120. url:'/pageA/login/index'
  121. })
  122. },
  123. async getPhoneNumber(e) {
  124. console.log(0)
  125. that.userInfo = await this.$request.wxlogin()
  126. console.log(that.userInfo,1111)
  127. that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
  128. console.log(that.userInfo,2222)
  129. this.showAuthorizePhone = false
  130. this.showAuthorizeUser = true
  131. },
  132. async authUser(type) {
  133. //同步信息,没有头像和昵称自动生成
  134. this.userInfo = await this.$request.syncInfo(this.userInfo)
  135. if (this.userInfo.openId) {
  136. uni.setStorageSync("userInfo", that.userInfo)
  137. that.showAuthorizeUser = false
  138. // that.mescroll.resetUpScroll()
  139. }
  140. },
  141. //获取昵称输入内容
  142. userNameInput(e) {
  143. this.userInfo.nickname = e.detail.value
  144. },
  145. async onChooseAvatar(e) {
  146. this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
  147. },
  148. toBase64(url) {
  149. return new Promise(resolve => {
  150. pathToBase64(url).then(path => {
  151. resolve(path);
  152. }).catch(error => {
  153. console.log(error)
  154. })
  155. })
  156. },
  157. }
  158. }
  159. </script>
  160. <style lang='scss' scoped>
  161. .auth-btncard {
  162. display: flex !important;
  163. justify-content: space-between !important;
  164. .btn-unok {
  165. width: 40%;
  166. }
  167. .btn-ok {
  168. width: 40%;
  169. }
  170. }
  171. .auth-card {
  172. text-align: center;
  173. .avatar-img {
  174. width: 200rpx;
  175. }
  176. .title {
  177. font-size: 20rpx;
  178. }
  179. .content {
  180. font-size: 32rpx;
  181. font-weight: bold;
  182. color: #1A1A1A;
  183. margin-bottom: 30rpx;
  184. }
  185. }
  186. .avatar-wrapper {
  187. color: #333 !important;
  188. border: none !important;
  189. border-radius: 0 !important;
  190. background-color: transparent !important;
  191. padding: 0;
  192. }
  193. .avatar-wrapper::after {
  194. border: none !important;
  195. }
  196. .avatar {
  197. width: 100rpx;
  198. height: 100rpx;
  199. overflow: hidden;
  200. border-radius: 100%;
  201. }
  202. /deep/.u-popup__content {
  203. border-radius: 20rpx !important;
  204. }
  205. /deep/.u-button--normal{
  206. padding: 0 5px;
  207. }
  208. .slot-content{
  209. width: 100%;
  210. }
  211. </style>