userinfo.vue 4.6 KB

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