userinfo.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <text class="tit">头像</text>
  5. <view class="background-img" @click.stop="imgsub"><image class="background-img" v-model="userInfo.avatar" :src="userInfo.avatar" mode="aspectFill"></image></view>
  6. </view>
  7. <view class="row">
  8. <text class="tit">昵称</text>
  9. <input class="input" type="text" v-model="userInfo.nickname" placeholder-class="placeholder" />
  10. </view>
  11. <view class="row">
  12. <text class="tit">ID</text>
  13. <input class="input" type="text" disabled="true" v-model="userInfo.uid" placeholder-class="placeholder" />
  14. </view>
  15. <view class="row">
  16. <text class="tit">账户</text>
  17. <input class="input" type="text" disabled="true" v-model="userInfo.phone" placeholder-class="placeholder" />
  18. </view>
  19. <view class="out ooo" @click="cancel">注销账户</view>
  20. <view class="out" @click="toLogout">退出登录</view>
  21. <view class="add-btn" @click="confirm">提交</view>
  22. <uni-popup ref="popup" type="center">
  23. <view class="psw-wrapper">
  24. <view class="psw-title">请输入自己的账户</view>
  25. <input type="text" v-model="password" class="psw-ipt" />
  26. <view class="psw-btn">
  27. <text @click.stop="qx">取消</text>
  28. <text class="psw-qd" @click.stop="pswQd">确定</text>
  29. </view>
  30. </view>
  31. </uni-popup>
  32. </view>
  33. </template>
  34. <script>
  35. import { mapState,mapMutations } from 'vuex';
  36. import { upload } from '@/api/order.js';
  37. import {userEdit,logout} from '@/api/set.js';
  38. export default {
  39. data(){
  40. return{
  41. show:false,
  42. password: '',
  43. }
  44. },
  45. onLoad() {
  46. console.log(this.userInfo)
  47. },
  48. computed: {
  49. ...mapState('user',['userInfo'])
  50. },
  51. methods: {
  52. ...mapMutations('user',['logout']),
  53. imgsub() {
  54. console.log('上传头像')
  55. upload({
  56. filename: ''
  57. }).then(data => {
  58. console.log("data",data);
  59. this.userInfo.avatar = data[0].url;
  60. })
  61. },
  62. confirm() {
  63. userEdit({ avatar: this.userInfo.avatar ,nickname: this.userInfo.nickname})
  64. .then(e => {
  65. this.$api.msg('修改成功');
  66. setTimeout(()=> {
  67. uni.switchTab({
  68. url:'/pages/user/user'
  69. });
  70. }, 1000);
  71. console.log(e);
  72. })
  73. .catch(e => {
  74. console.log(e);
  75. });
  76. },
  77. toLogout(){
  78. let obj = this;
  79. uni.showModal({
  80. content: '确定要退出登录么',
  81. success: (e)=>{
  82. if(e.confirm){
  83. logout({}).then((e) => {
  84. uni.navigateBack();
  85. }).catch((e) => {
  86. console.log(e);
  87. })
  88. obj.logout();
  89. }
  90. }
  91. });
  92. },
  93. cancel(){
  94. this.$refs.popup.open();
  95. },
  96. qx() {
  97. this.password = '';
  98. this.$refs.popup.close();
  99. },
  100. pswQd() {
  101. if(this.password != this.userInfo.phone){
  102. this.$refs.popup.close();
  103. this.password = '';
  104. this.$api.msg("请输入自己的账户")
  105. return
  106. }
  107. this.$refs.popup.close();
  108. this.password = '';
  109. this.$api.msg("申请注销成功,请耐心等待审核")
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. .row1 {
  116. display: flex;
  117. align-items: center;
  118. justify-content: space-between;
  119. position: relative;
  120. padding: 0 30upx;
  121. height: 110upx;
  122. background: #fff;
  123. margin-bottom: 20upx;
  124. .tit {
  125. flex-shrink: 0;
  126. width: 120upx;
  127. font-size: $font-lg;
  128. color: $font-color-dark;
  129. }
  130. .background-img {
  131. width: 80rpx;
  132. height: 80rpx;
  133. border-radius: 50%;
  134. background: #f2f2f2;
  135. }
  136. }
  137. .row {
  138. display: flex;
  139. align-items: center;
  140. padding: 0 30upx;
  141. height: 110upx;
  142. background: #fff;
  143. .tit {
  144. flex-shrink: 0;
  145. width: 120upx;
  146. font-size: $font-lg;
  147. color: $font-color-dark;
  148. }
  149. .input {
  150. flex: 1;
  151. text-align: right;
  152. font-size: $font-base;
  153. color: $color-gray;
  154. }
  155. }
  156. .add-btn {
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. margin: 58rpx auto 30rpx;
  161. width: 560rpx;
  162. height: 80rpx;
  163. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  164. border-radius: 40px;
  165. color: #FFFFFF;
  166. }
  167. .out {
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. margin: 0 auto 30rpx;
  172. width: 560rpx;
  173. height: 80rpx;
  174. border: 1px solid #32C6FF;
  175. background: #FFFFFF;
  176. border-radius: 40px;
  177. color: #32C6FF;
  178. }
  179. .ooo{
  180. margin-top: 100rpx;
  181. }
  182. .psw-wrapper {
  183. width: 548rpx;
  184. height: 344rpx;
  185. background-color: #ffffff;
  186. .psw-title {
  187. width: 100%;
  188. font-size: 35rpx;
  189. padding: 43rpx 0 49rpx;
  190. text-align: center;
  191. font-weight: 800;
  192. }
  193. .psw-ipt {
  194. display: block;
  195. background-color: #dce3ed;
  196. height: 90rpx;
  197. width: 464rpx;
  198. padding-left: 30rpx;
  199. margin: 0 auto;
  200. font-size: 80rpx;
  201. }
  202. .psw-btn text {
  203. display: inline-block;
  204. text-align: center;
  205. width: 50%;
  206. padding-top: 29rpx;
  207. font-size: 35rpx;
  208. }
  209. .psw-qd {
  210. color: #32C6FF;
  211. }
  212. }
  213. </style>