userinfo.vue 4.4 KB

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