person-card.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view class="test">
  3. <view v-if="showChangeName" class="change-name-wrapper">
  4. <view class="change-name">
  5. <view class="title">昵称修改</view>
  6. <view class="oldName">
  7. 旧昵称:<input type="text" :value="oldName" disabled />
  8. </view>
  9. <view class="newName">
  10. 新昵称:<input type="text" v-model="newName" focus maxlength="12" placeholder="请输入您的新昵称" />
  11. </view>
  12. <view class="bar">
  13. <text @click="showChangeName = false">取消</text>
  14. <text class="save" @click="changeName">保存</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="content">
  19. <view class="top-bg">
  20. <image :src="info.avatar" mode="widthFix"></image>
  21. </view>
  22. <view class="info">
  23. <image class="avatar" :src="info.avatar"></image>
  24. <view class="nickname">{{ info.nickname || '' }}</view>
  25. <view class="realname">
  26. <text class="left">真实姓名</text>
  27. <text class="right">{{ info.real_name || '' }}</text>
  28. </view>
  29. <view class="phone">
  30. <text class="left">联系方式</text>
  31. <text class="right">{{ info.mobile }}</text>
  32. </view>
  33. </view>
  34. <view class="level-info">
  35. <view class="level-items" :class="{ open: open }">
  36. <view class="level-item">
  37. <text class="left">代理级别</text>
  38. <text class="right">{{ info.level }}</text>
  39. </view>
  40. <view class="level-item">
  41. <text class="left">邀请人</text>
  42. <text class="right">{{ info.recom_nickname }}</text>
  43. </view>
  44. <view class="level-item">
  45. <text class="left">上级代理</text>
  46. <text class="right">{{ info.up_nickname || '' }}</text>
  47. </view>
  48. </view>
  49. <view class="level-lock basecolor" @tap="toogle">{{ open ? '收起' : '显示更多' }}</view>
  50. </view>
  51. <view class="team-info">
  52. <view v-if="this.title == '我的名片'" @tap="showChangeName = true">
  53. <text class="left">修改昵称</text>
  54. <text class="cuIcon-right"></text>
  55. </view>
  56. <view v-if="info.status == 0" @tap="toAuthCard">
  57. <text class="left">授权书</text>
  58. <text class="cuIcon-right"></text>
  59. </view>
  60. <view>
  61. <text class="left">团队人数</text>
  62. <text class="right">{{ info.team_num || '0' }}人</text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import { _API_TeamPerData } from '@/apis/team.js'
  70. import { _API_Proxy_ChangeName } from '@/apis/user.js'
  71. export default {
  72. data() {
  73. return {
  74. title: '个人名片',
  75. info: {},
  76. open: false,
  77. id: '',
  78. showChangeName: false,
  79. oldName: this.$store.state.userinfo.nickname,
  80. newName: ''
  81. }
  82. },
  83. onLoad(opt) {
  84. if (opt.self) { // 如果是用户查看自己的命片
  85. this.title = '我的名片'
  86. }
  87. this.id = opt.id
  88. _API_TeamPerData({ id: opt.id }).then(res => {
  89. this.info = res.data
  90. if (this.title !== '我的名片') {
  91. if (this.info.real_name) {
  92. this.info.real_name = this.info.real_name.replace(/./g, '*').replace(/^\*/, this.info.real_name[0])
  93. } else {
  94. this.info.real_name = '***'
  95. }
  96. }
  97. })
  98. },
  99. methods: {
  100. toogle() {
  101. this.open = !this.open
  102. },
  103. toAuthCard() {
  104. uni.navigateTo({ url: `../auth-card/auth-card?id=${this.id}` })
  105. },
  106. changeName() {
  107. if (this.newName.trim()) {
  108. uni.loading()
  109. _API_Proxy_ChangeName({ nickname: this.newName.trim() }).then(res => {
  110. this.info.nickname = this.newName.trim()
  111. uni.loading()
  112. uni.$emit('INIT')
  113. this.showChangeName = false
  114. this.newName = ''
  115. })
  116. } else {
  117. uni.toast('新昵称不能为空')
  118. }
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. .test {
  125. @include page();
  126. .change-name-wrapper {
  127. z-index: 1;
  128. width: 100vw;
  129. height: 100vh;
  130. @include flex();
  131. position: fixed;
  132. background: rgba(0, 0, 0, .3);
  133. .change-name {
  134. width: 540rpx;
  135. height: 400rpx;
  136. font-size: 32rpx;
  137. background: #FFFFFF;
  138. border-radius: 6rpx;
  139. @include flex(column);
  140. justify-content: space-between;
  141. .title {
  142. width: 100%;
  143. height: 90rpx;
  144. @include flex();
  145. }
  146. .oldName , .newName {
  147. width: 100%;
  148. @include flex();
  149. justify-content: flex-start;
  150. margin-left: 41rpx;
  151. input {
  152. width: 335rpx;
  153. height: 54rpx;
  154. border: 1rpx solid #AAAAAA;
  155. box-sizing: border-box;
  156. padding: 0 8rpx;
  157. font-size: 28rpx;
  158. }
  159. }
  160. .bar {
  161. width: 100%;
  162. height: 76rpx;
  163. @include flex();
  164. color: #666666;
  165. border-top: 1rpx solid #F2F4F5;
  166. text {
  167. flex: 1;
  168. height: 100%;
  169. @include flex();
  170. &.save {
  171. color: $app-base-color;
  172. border-left: 1rpx solid #F2F4F5;
  173. }
  174. }
  175. }
  176. }
  177. }
  178. .content {
  179. .top-bg {
  180. height: 300rpx;
  181. overflow: hidden;
  182. filter: blur(8rpx);
  183. image {
  184. width: 100%;
  185. transform: translateY(-25%);
  186. }
  187. }
  188. .info {
  189. @include flex(column);
  190. height: 270rpx;
  191. font-size: 26rpx;
  192. position: relative;
  193. background: #FFFFFF;
  194. justify-content: flex-end;
  195. border-bottom: 1rpx solid $app-base-bg;
  196. .avatar {
  197. top: 0;
  198. left: 50%;
  199. width: 108rpx;
  200. height: 108rpx;
  201. position: absolute;
  202. border-radius: 8rpx;
  203. transform: translate(-50%, -50%);
  204. }
  205. >view {
  206. @include flex();
  207. width: 100%;
  208. padding: 0 30rpx;
  209. line-height: 72rpx;
  210. box-sizing: border-box;
  211. justify-content: flex-start;
  212. &.nickname {
  213. margin-bottom: 12rpx;
  214. justify-content: center;
  215. }
  216. .left {
  217. width: 300rpx;
  218. }
  219. }
  220. }
  221. .level-info {
  222. background: #FFFFFF;
  223. margin-bottom: 20rpx;
  224. .level-items {
  225. height: 0;
  226. overflow: hidden;
  227. &.open {
  228. height: 270rpx;
  229. }
  230. >view {
  231. @include flex();
  232. width: 100%;
  233. height: 90rpx;
  234. padding: 0 30rpx;
  235. box-sizing: border-box;
  236. justify-content: flex-start;
  237. border-bottom: 1rpx solid $app-base-bg;
  238. .left {
  239. width: 300rpx;
  240. }
  241. }
  242. }
  243. .level-lock {
  244. @include flex();
  245. height: 60rpx;
  246. }
  247. }
  248. .team-info {
  249. >view {
  250. @include flex();
  251. width: 100%;
  252. height: 90rpx;
  253. padding: 0 30rpx;
  254. font-size: 32rpx;
  255. background: #FFFFFF;
  256. box-sizing: border-box;
  257. justify-content: space-between;
  258. border-bottom: 1rpx solid $app-base-bg;
  259. .left {
  260. width: 300rpx;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. </style>