index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class='loginWrap'>
  3. <view style='text-align:center;padding:60rpx;'>
  4. <u--image width='80' height='80' src="/static/logo.png" radius='10' shape="square"></u--image>
  5. </view>
  6. <view style='width:80%;margin:0 auto;'>
  7. <u-button v-if='!value' @click='custom' :customStyle="customStyleOk"> 微信用户一键登录</u-button>
  8. <u-button v-else :customStyle="customStyleOk" open-type="getPhoneNumber"
  9. @getphonenumber="getPhoneNumber"> 微信用户一键登录</u-button>
  10. </view>
  11. <!-- <view><u-button :customStyle="customStyleUnOk" @click="showAuthorizePhone=false" :plain="true">
  12. 拒绝</u-button></view> -->
  13. <view style='margin:40rpx 0;'>
  14. <view style='width: 77%;margin: 0 auto;' class='flex align-item-center'>
  15. <view style='margin-right:5rpx;'>
  16. <view >
  17. <u--image @click='value= !value' width='16' height='16' :src="value?'/static/image/login/checked.png':'/static/image/login/no-checked.png'" radius='10' shape="square"></u--image>
  18. </view>
  19. </view>
  20. 登录代表您已同意<navigator
  21. url="/pageA/webview?can_share=false&url=liangxin.zthymaoyi.com/youyuquan.html"
  22. class="path" hover-class="navigator-hover">用户服务协议和隐私政策</navigator>
  23. </view>
  24. </view>
  25. <login-pop-up ref='loginpopup' :content='"手机登录后才能查看我的哦~"'></login-pop-up>
  26. <u-modal :show="showAuthorizeUser" :showConfirmButton="false">
  27. <view class="slot-content">
  28. <view class="auth-card">
  29. <view class="img">
  30. <img class="avatar-img" src="@/static/logo.png" mode="widthFix">
  31. </view>
  32. <view class="content">邀请您补全个人信息<br></br>(昵称、头像)</view>
  33. <view style="margin-left: 100rpx;margin-right: 100rpx">
  34. <u-form :model="userInfo" ref="uForm">
  35. <u-form-item label="头像">
  36. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
  37. slot="right">
  38. <image class="avatar"
  39. :src="userInfo.head?userInfo.head:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'">
  40. </image>
  41. </button>
  42. </u-form-item>
  43. <u-form-item label="昵称">
  44. <u-input inputAlign='right' v-model="userInfo.nickname" class="weui-input"
  45. @blur="userNameInput" placeholder="请输入昵称" border="false" />
  46. <!-- <input type="nickname" :value="userInfo.nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称"/> -->
  47. </u-form-item>
  48. </u-form>
  49. </view>
  50. </view>
  51. <view class="auth-btncard">
  52. <view class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="authUser(0)">
  53. 拒绝</u-button>
  54. </view>
  55. <view class="btn-ok">
  56. <u-button :customStyle="customStyleOk" @click="authUser(1)"> 允许</u-button>
  57. </view>
  58. </view>
  59. </view>
  60. </u-modal>
  61. </view>
  62. </template>
  63. <script>
  64. var that
  65. import loginPopUp from "@/components/loginPopUp/index.vue"
  66. import {
  67. pathToBase64,
  68. base64ToPath
  69. } from 'image-tools'
  70. export default {
  71. components: {
  72. loginPopUp
  73. },
  74. data() {
  75. return {
  76. userInfo: {
  77. head: '',
  78. nickname: '',
  79. phone: '',
  80. },
  81. isShow:false,
  82. showAuthorizeUser:false,
  83. value:false,
  84. customStyleUnOk: {
  85. marginTop: '20rpx',
  86. color: '#eaad1a',
  87. "font-weight": 'bold',
  88. "background":'#F2F2F2',
  89. "border-radius": "10px",
  90. fontSize: "32rpx"
  91. },
  92. customStyleOk: {
  93. marginTop: '20rpx',
  94. color: '#000',
  95. // border: '2px solid #eaad1a',
  96. "border-radius": "10px",
  97. fontSize: "32rpx",
  98. "font-weight": 'bold',
  99. padding:'40rpx',
  100. background: " linear-gradient(to right,#FED41E,#FDC21D);"
  101. },
  102. };
  103. },
  104. props: {
  105. content: {
  106. type: String,
  107. default: ""
  108. },
  109. },
  110. watch:{
  111. },
  112. mounted() {
  113. that = this
  114. },
  115. computed: {
  116. },
  117. methods: {
  118. radiochange(e){
  119. },
  120. open(){
  121. this.showAuthorizePhone=true
  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.$refs.loginpopup.useropen(that.userInfo)
  130. // this.showAuthorizeUser = true
  131. },
  132. custom(){
  133. uni.showToast({
  134. icon: "none",
  135. title: '请阅读并勾选用户协议和隐私政策',
  136. duration: 3000
  137. });
  138. },
  139. async authUser(type) {
  140. //同步信息,没有头像和昵称自动生成
  141. this.userInfo = await this.$request.syncInfo(this.userInfo)
  142. if (this.userInfo.openId) {
  143. uni.setStorageSync("userInfo", that.userInfo)
  144. that.showAuthorizeUser = false
  145. uni.navigateBack()
  146. // that.mescroll.resetUpScroll()
  147. }
  148. },
  149. //获取昵称输入内容
  150. userNameInput(e) {
  151. this.userInfo.nickname = e.detail.value
  152. },
  153. async onChooseAvatar(e) {
  154. this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
  155. },
  156. toBase64(url) {
  157. return new Promise(resolve => {
  158. pathToBase64(url).then(path => {
  159. resolve(path);
  160. }).catch(error => {
  161. console.log(error)
  162. })
  163. })
  164. },
  165. }
  166. }
  167. </script>
  168. <style lang='scss' scoped>
  169. .loginWrap{
  170. background:#fff;
  171. height:100vh;
  172. }
  173. /deep/.u-transition{
  174. align-items: center;
  175. }
  176. .path{
  177. color:#FDC21D;
  178. }
  179. /deep/.u-radio-group{
  180. flex: 0.7 !important;
  181. }
  182. /deep/.u-popup__content {
  183. border-radius: 20rpx !important;
  184. }
  185. /deep/.u-button--normal{
  186. padding: 0 5px;
  187. }
  188. /deep/.u-input{
  189. padding:0 !important;
  190. }
  191. /deep/.u-form-item__body__right.rightclass{
  192. flex:0.7 !important;
  193. }
  194. </style>