userinfo.vue 4.5 KB

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