user.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="container">
  3. <view class="uesrInfo">
  4. <view class="userPhoto">
  5. <image class="img" :src="userInfo.avatar"></image>
  6. <uni-file-picker
  7. ref="picker"
  8. class="picker"
  9. limit="1"
  10. mode="list"
  11. file-mediatype="image"
  12. @select="select"
  13. @progress="progress"
  14. @success="success"
  15. @fail="fail"
  16. >
  17. <image class="icon" src="https://mall.rongtongh.cn/storage/img/mine/icon1.png" mode="widthFix"></image>
  18. </uni-file-picker>
  19. </view>
  20. <uni-list class="list">
  21. <uni-list-item class="listItem" title="用户昵称" :rightText="userInfo.nickname" showArrow clickable @click="onClick" />
  22. <uni-list-item class="listItem" title="手机号" :rightText="userInfo.mobile" clickable @click="onClick">
  23. <template v-slot:footer>
  24. <view class="right">
  25. <button class="m_button button" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">
  26. <span v-if="userInfo.mobile">更换</span>
  27. <span v-else>绑定</span>
  28. </button>
  29. <span>{{userInfo.mobile}}</span>
  30. </view>
  31. </template>
  32. </uni-list-item>
  33. </uni-list>
  34. </view>
  35. <!-- <uni-popup ref="inputDialog" type="dialog">
  36. <uni-popup-dialog
  37. ref="inputClose"
  38. mode="input"
  39. title="修改用户昵称" :
  40. value=""
  41. placeholder="请输入用户昵称"
  42. @confirm="dialogInputConfirm"
  43. >
  44. </uni-popup-dialog>
  45. </uni-popup> -->
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. logOffApi,
  51. bindPhoneApi,
  52. userInfoApi
  53. } from "@/api/user.js"
  54. export default {
  55. data() {
  56. return {
  57. userInfo: {}
  58. }
  59. },
  60. onShow() {
  61. this.getUserInfo()
  62. },
  63. methods: {
  64. // 获取上传状态
  65. select(e){
  66. console.log('选择文件:',e)
  67. },
  68. // 获取上传进度
  69. progress(e){
  70. console.log('上传进度:',e)
  71. },
  72. // 上传成功
  73. success(e){
  74. console.log(e, '上传成功')
  75. },
  76. // 上传失败
  77. fail(e){
  78. console.log('上传失败:',e)
  79. },
  80. dialogInputConfirm() {
  81. },
  82. getUserInfo() {
  83. userInfoApi().then(res => {
  84. this.userInfo = res.data
  85. console.log(this.userInfo, '用户信息')
  86. })
  87. },
  88. decryptPhoneNumber(e) {
  89. console.log(e, 'eeee')
  90. let params = {
  91. iv: e.detail.iv,
  92. encryptedData: e.detail.encryptedData
  93. }
  94. bindPhoneApi(params).then(res => {
  95. console.log(res, 'rrr')
  96. })
  97. },
  98. loginOut() {
  99. wx.removeStorageSync('userInfo')
  100. wx.removeStorageSync('userId')
  101. wx.removeStorageSync('token')
  102. getApp().globalData.hasLogin = false;
  103. wx.switchTab({
  104. url: '/pages/mine/mine'
  105. })
  106. },
  107. logOff() {
  108. wx.showModal({
  109. title: '确认注销账号?',
  110. content: '注销账号后xxxxx',
  111. success: (res) => {
  112. if (res.confirm) {
  113. console.log('用户点击确定')
  114. logOffApi().then(res => {
  115. wx.removeStorageSync('userInfo')
  116. wx.removeStorageSync('userId')
  117. wx.removeStorageSync('token')
  118. getApp().globalData.hasLogin = false;
  119. wx.switchTab({
  120. url: '/pages/mine/mine'
  121. })
  122. })
  123. } else if (res.cancel) {
  124. console.log('用户点击取消')
  125. }
  126. }
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <style scoped lang="scss">
  133. .uesrInfo {
  134. background: #fff;
  135. overflow: hidden;
  136. padding: 0 15px;
  137. }
  138. .userPhoto {
  139. width: 74px;
  140. height: 74px;
  141. position: relative;
  142. margin: 30px auto 30px auto;
  143. position: relative;
  144. .img {
  145. width: 100%;
  146. height: 100%;
  147. border-radius: 50%;
  148. background: #dedede;
  149. }
  150. .icon {
  151. width: 20px;
  152. position: absolute;
  153. right: 0;
  154. bottom: 0;
  155. }
  156. }
  157. .list {
  158. // margin: 0 10px;
  159. }
  160. .right {
  161. display: flex;
  162. justify-content: center;
  163. align-items: center;
  164. }
  165. .button {
  166. display: inline-block;
  167. font-size: 11px;
  168. font-weight: 500;
  169. width: 34px;
  170. height: 22px;
  171. line-height: 22px;
  172. padding: 0;
  173. margin-right: 5px;
  174. }
  175. </style>
  176. <style scoped>
  177. .listItem >>> .uni-list-item__extra-text {
  178. color: #000;
  179. font-size: 14px;
  180. font-weight: 600;
  181. }
  182. .userPhoto >>> .uni-file-picker__lists {
  183. display: none !important;
  184. }
  185. </style>