t-m-info.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="content">
  3. <view class="user">
  4. <view class="left">
  5. <view class="img">
  6. <image v-if="user.avatar" :src="user.avatar" mode=""></image>
  7. <view class="avatar" v-if="!user.avatar" :style="{backgroundColor:bgColor[1]}">{{user.name.split('').pop()}}</view>
  8. </view>
  9. <view class="info">
  10. <view class="name">{{user.name}} <text style="color: #999;font-size: 14px;margin-left: 10px;" v-if="mobile">({{mobile}})</text> </view>
  11. <view class="section">{{user.section}}</view>
  12. </view>
  13. </view>
  14. <view class="right">
  15. <!-- <uni-icons type="arrowright"></uni-icons> -->
  16. </view>
  17. </view>
  18. <view class="tip" v-if="tip_password">
  19. <view class="icon"></view>
  20. <view class="text">当前密码为初始密码,请及时修改。</view>
  21. </view>
  22. <view class="tip" v-if="tip_mobile">
  23. <view class="icon"></view>
  24. <view class="text">未绑定手机号,请立即绑定手机号。</view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name:"t-m-user",
  31. data() {
  32. return {
  33. // 用户基本信息
  34. user:{},
  35. // 手机号
  36. mobile:'',
  37. // 头像随机色
  38. bgColor:[],
  39. // 密码提示
  40. tip_password:false,
  41. // 手机绑定
  42. tip_mobile:false
  43. };
  44. },
  45. created() {
  46. console.log(uni.getStorageSync('user'))
  47. // 获取用户基本信息
  48. this.user = uni.getStorageSync('user');
  49. this.mobile = uni.getStorageSync('mobile');
  50. // 设置头像
  51. for(let i=0;i<2;i++){
  52. // 获取随机色
  53. let r = parseInt(Math.random() * 256)
  54. let g = parseInt(Math.random() * 256)
  55. let b = parseInt(Math.random() * 256)
  56. // ES6 字符串拼接
  57. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  58. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  59. // console.log(color)
  60. this.bgColor.push(color)
  61. }
  62. // 判断是否为初始密码
  63. uni.getStorageSync('login_password')
  64. // console.log(uni.getStorageSync('login_password'))
  65. if(uni.getStorageSync('login_password') == "Zhks123456+"){
  66. this.tip_password = true
  67. }
  68. // 判断是否绑定手机号
  69. if(!this.mobile){
  70. this.tip_mobile = true
  71. }
  72. setTimeout(()=>{
  73. if(!this.mobile){
  74. uni.showModal({
  75. title: '温馨提示',
  76. content: '当前还未绑定手机号,请及时绑定。',
  77. showCancel:false,
  78. success: function (res) {
  79. if (res.confirm) {
  80. console.log('用户点击确定');
  81. uni.navigateTo({
  82. url:"../../my/setPhone/setPhone"
  83. })
  84. }
  85. }
  86. });
  87. }
  88. },500)
  89. },
  90. methods:{
  91. }
  92. }
  93. </script>
  94. <style lang="scss">
  95. .content{
  96. box-sizing: border-box;
  97. padding: 0 25rpx;
  98. }
  99. .user{
  100. margin-top: -50px;
  101. width: 700rpx;
  102. height: 100px;
  103. background: #FFFFFF;
  104. box-shadow: 0px 0px 3px 3px rgba(0,0,0,0.05);
  105. border-radius: 3px;
  106. display: flex;
  107. justify-content: space-between;
  108. align-items: center;
  109. box-sizing: border-box;
  110. padding-right: 14px;
  111. padding-left: 8px;
  112. .left{
  113. display: flex;
  114. align-items: center;
  115. .img{
  116. width: 66px;
  117. height: 66px;
  118. border-radius: 50%;
  119. overflow: hidden;
  120. image{
  121. width: 66px;
  122. height: 66px;
  123. }
  124. .avatar{
  125. width: 66px;
  126. height: 66px;
  127. text-align: center;
  128. line-height: 66px;
  129. color: #FFFFFF;
  130. font-size: 28px;
  131. }
  132. }
  133. .info{
  134. margin-left: 12px;
  135. .name{
  136. font-size: 19px;
  137. font-weight: 500;
  138. color: #232627;
  139. line-height: 26px;
  140. }
  141. .section{
  142. margin-top: 4px;
  143. font-size: 14px;
  144. font-weight: 500;
  145. color: #232627;
  146. line-height: 19px;
  147. }
  148. }
  149. }
  150. .right{
  151. }
  152. }
  153. .tip{
  154. margin-top: 8px;
  155. height: 45px;
  156. background: #FFFFFF;
  157. box-shadow: 0px 0px 3px 3px rgba(0,0,0,0.05);
  158. border-radius: 3px;
  159. display: flex;
  160. align-items: center;
  161. box-sizing: border-box;
  162. padding-left: 9px;
  163. .icon{
  164. width: 22px;
  165. height: 22px;
  166. background-image: url(./icon/tip.png);
  167. background-size: cover;
  168. background-repeat: no-repeat;
  169. }
  170. .text{
  171. margin-left: 6px;
  172. font-size: 15px;
  173. color: #7F8C8D;
  174. line-height: 19px;
  175. }
  176. }
  177. </style>