userinfo.vue 4.7 KB

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