index.vue 5.8 KB

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