index.vue 6.1 KB

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