index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. <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. userInfo: {
  72. head: '',
  73. nickname: '',
  74. phone: '',
  75. },
  76. isShow:false,
  77. showAuthorizeUser:false,
  78. value:false,
  79. customStyleUnOk: {
  80. marginTop: '20rpx',
  81. color: '#eaad1a',
  82. "font-weight": 'bold',
  83. "background":'#F2F2F2',
  84. "border-radius": "10px",
  85. fontSize: "32rpx"
  86. },
  87. customStyleOk: {
  88. marginTop: '20rpx',
  89. color: '#000',
  90. // border: '2px solid #eaad1a',
  91. "border-radius": "10px",
  92. fontSize: "32rpx",
  93. "font-weight": 'bold',
  94. padding:'40rpx',
  95. background: " linear-gradient(to right,#FED41E,#FDC21D);"
  96. },
  97. };
  98. },
  99. props: {
  100. content: {
  101. type: String,
  102. default: ""
  103. },
  104. },
  105. watch:{
  106. },
  107. mounted() {
  108. that = this
  109. },
  110. computed: {
  111. },
  112. methods: {
  113. radiochange(e){
  114. },
  115. open(){
  116. this.showAuthorizePhone=true
  117. },
  118. async getPhoneNumber(e) {
  119. console.log(0)
  120. that.userInfo = await this.$request.wxlogin()
  121. console.log(that.userInfo,1111)
  122. that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
  123. console.log(that.userInfo,2222)
  124. this.showAuthorizeUser = true
  125. },
  126. custom(){
  127. uni.showToast({
  128. icon: "none",
  129. title: '请阅读并勾选用户协议和隐私政策',
  130. duration: 3000
  131. });
  132. },
  133. async authUser(type) {
  134. //同步信息,没有头像和昵称自动生成
  135. this.userInfo = await this.$request.syncInfo(this.userInfo)
  136. if (this.userInfo.openId) {
  137. uni.setStorageSync("userInfo", that.userInfo)
  138. that.showAuthorizeUser = false
  139. uni.navigateBack()
  140. // that.mescroll.resetUpScroll()
  141. }
  142. },
  143. //获取昵称输入内容
  144. userNameInput(e) {
  145. this.userInfo.nickname = e.detail.value
  146. },
  147. async onChooseAvatar(e) {
  148. this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
  149. },
  150. toBase64(url) {
  151. return new Promise(resolve => {
  152. pathToBase64(url).then(path => {
  153. resolve(path);
  154. }).catch(error => {
  155. console.log(error)
  156. })
  157. })
  158. },
  159. }
  160. }
  161. </script>
  162. <style lang='scss' scoped>
  163. .loginWrap{
  164. background:#fff;
  165. height:100vh;
  166. }
  167. /deep/.u-transition{
  168. align-items: center;
  169. }
  170. .path{
  171. color:#FDC21D;
  172. }
  173. /deep/.u-radio-group{
  174. flex: 0.7 !important;
  175. }
  176. .auth-btncard {
  177. display: flex !important;
  178. justify-content: space-between !important;
  179. .btn-unok {
  180. width: 40%;
  181. }
  182. .btn-ok {
  183. width: 40%;
  184. }
  185. }
  186. .auth-card {
  187. text-align: center;
  188. .avatar-img {
  189. width: 200rpx;
  190. }
  191. .title {
  192. font-size: 20rpx;
  193. }
  194. .content {
  195. font-size: 32rpx;
  196. font-weight: bold;
  197. color: #1A1A1A;
  198. margin-bottom: 30rpx;
  199. }
  200. }
  201. .avatar-wrapper {
  202. color: #333 !important;
  203. border: none !important;
  204. border-radius: 0 !important;
  205. background-color: transparent !important;
  206. padding: 0;
  207. }
  208. .avatar-wrapper::after {
  209. border: none !important;
  210. }
  211. .avatar {
  212. width: 80rpx;
  213. height: 80rpx;
  214. overflow: hidden;
  215. border-radius: 100%;
  216. }
  217. /deep/.u-popup__content {
  218. border-radius: 20rpx !important;
  219. }
  220. /deep/.u-button--normal{
  221. padding: 0 5px;
  222. }
  223. /deep/.u-input{
  224. padding:0 !important;
  225. }
  226. </style>