userinfo.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <text class="tit">头像</text>
  5. <view class="background-img" @click="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="add-btn out" @click="cancel" style="margin-top: 20rpx;">退出</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. let obj = this;
  95. uni.showModal({
  96. content: '确定要退出登录么',
  97. success: e => {
  98. if (e.confirm) {
  99. logout({}).then(e => {
  100. obj.logout();
  101. uni.switchTab({
  102. url: '/pages/index/index'
  103. })
  104. })
  105. .catch(e => {
  106. console.log(e);
  107. });
  108. }
  109. }
  110. });
  111. },
  112. qx() {
  113. this.password = '';
  114. this.$refs.popup.close();
  115. },
  116. pswQd() {
  117. if(this.password != this.userInfo.phone){
  118. this.$refs.popup.close();
  119. this.password = '';
  120. this.$api.msg("请输入自己的账户")
  121. return
  122. }
  123. this.$refs.popup.close();
  124. this.password = '';
  125. this.$api.msg("申请注销成功,请耐心等待审核")
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss">
  131. .row1 {
  132. display: flex;
  133. align-items: center;
  134. justify-content: space-between;
  135. position: relative;
  136. padding: 0 30upx;
  137. height: 110upx;
  138. background: #fff;
  139. margin-bottom: 20upx;
  140. .tit {
  141. flex-shrink: 0;
  142. width: 120upx;
  143. font-size: $font-lg;
  144. color: $font-color-dark;
  145. }
  146. .background-img {
  147. width: 80rpx;
  148. height: 80rpx;
  149. border-radius: 50%;
  150. background: #f2f2f2;
  151. }
  152. }
  153. .row {
  154. display: flex;
  155. align-items: center;
  156. padding: 0 30upx;
  157. height: 110upx;
  158. background: #fff;
  159. .tit {
  160. flex-shrink: 0;
  161. width: 120upx;
  162. font-size: $font-lg;
  163. color: $font-color-dark;
  164. }
  165. .input {
  166. flex: 1;
  167. text-align: right;
  168. font-size: $font-base;
  169. color: $color-gray;
  170. }
  171. }
  172. .add-btn {
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. margin: 158rpx auto 30rpx;
  177. width: 560rpx;
  178. height: 80rpx;
  179. background: #feca00;
  180. border-radius: 40px;
  181. color: #FFFFFF;
  182. }
  183. .out {
  184. display: flex;
  185. align-items: center;
  186. justify-content: center;
  187. margin: 0 auto 30rpx;
  188. width: 560rpx;
  189. height: 80rpx;
  190. border: 1px solid #feca00;
  191. background: #FFFFFF;
  192. border-radius: 40px;
  193. color: #feca00;
  194. }
  195. .psw-wrapper {
  196. width: 548rpx;
  197. height: 344rpx;
  198. background-color: #ffffff;
  199. .psw-title {
  200. width: 100%;
  201. font-size: 35rpx;
  202. padding: 43rpx 0 49rpx;
  203. text-align: center;
  204. font-weight: 800;
  205. }
  206. .psw-ipt {
  207. display: block;
  208. background-color: #dce3ed;
  209. height: 90rpx;
  210. width: 464rpx;
  211. padding-left: 30rpx;
  212. margin: 0 auto;
  213. font-size: 80rpx;
  214. }
  215. .psw-btn text {
  216. display: inline-block;
  217. text-align: center;
  218. width: 50%;
  219. padding-top: 29rpx;
  220. font-size: 35rpx;
  221. }
  222. .psw-qd {
  223. color: #32C6FF;
  224. }
  225. }
  226. </style>