userinfo.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="content">
  3. <view class="row flex">
  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 flex">
  8. <text class="tit">昵称</text>
  9. <input class="input" type="text" v-model="userInfo.nickname" placeholder-class="placeholder"/>
  10. </view>
  11. <view class="row flex">
  12. <text class="tit">账号</text>
  13. <view class="input">
  14. {{userInfo.phone}}
  15. </view>
  16. </view>
  17. <!-- <view class="row">
  18. <text class="tit">ID</text>
  19. <input class="input" type="text" disabled="true" v-model="userInfo.uid" placeholder-class="placeholder" />
  20. </view> -->
  21. <view class="list-cell log-out-btn" @click="confirm">
  22. <text class="cell-tit">修改</text>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { mapState,mapMutations } from 'vuex';
  28. import { upload } from '@/api/order.js';
  29. import {userEdit,logout} from '@/api/set.js';
  30. export default {
  31. data(){
  32. return{
  33. show:false,
  34. password: '',
  35. }
  36. },
  37. onLoad() {
  38. console.log(this.userInfo)
  39. },
  40. computed: {
  41. ...mapState('user',['userInfo'])
  42. },
  43. methods: {
  44. ...mapMutations('user',['logout']),
  45. imgsub() {
  46. console.log('上传头像')
  47. upload({
  48. filename: ''
  49. }).then(data => {
  50. console.log("data",data);
  51. this.userInfo.avatar = data[0].url;
  52. })
  53. },
  54. confirm() {
  55. userEdit({ avatar: this.userInfo.avatar ,nickname: this.userInfo.nickname})
  56. .then(e => {
  57. uni.showToast({
  58. // title: '修改成功',
  59. title: this.$t("safe.d3"),
  60. icon:"success",
  61. mask:true
  62. });
  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: this.$t('login.b7'),
  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. let obj = this;
  93. uni.showModal({
  94. content: this.$t('login.b7'),
  95. success: e => {
  96. if (e.confirm) {
  97. logout({}).then(e => {
  98. obj.logout();
  99. uni.switchTab({
  100. url: '/pages/index/index'
  101. })
  102. })
  103. .catch(e => {
  104. console.log(e);
  105. });
  106. }
  107. }
  108. });
  109. },
  110. qx() {
  111. this.password = '';
  112. this.$refs.popup.close();
  113. },
  114. pswQd() {
  115. if(this.password != this.userInfo.phone){
  116. this.$refs.popup.close();
  117. this.password = '';
  118. this.$api.msg(obj.$t("safe.f3"))
  119. return
  120. }
  121. this.$refs.popup.close();
  122. this.password = '';
  123. this.$api.msg(obj.$t("safe.f4"))
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. page{
  130. background-color: #051137;
  131. }
  132. .list-cell{
  133. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  134. margin: 30rpx;
  135. color: #FFF;
  136. font-size: 30rpx;
  137. padding: 20rpx;
  138. text-align: center;
  139. border-radius: 10rpx;
  140. line-height: 1;
  141. }
  142. .row {
  143. padding: 20rpx;
  144. background: #fff;
  145. background-color:#1F2A4A ;
  146. border-radius: 10rpx;
  147. margin: 0 30rpx 30rpx 30rpx;
  148. .tit {
  149. flex-shrink: 0;
  150. font-size: $font-base;
  151. color:#FFF;
  152. }
  153. .input {
  154. flex: 1;
  155. text-align: right;
  156. font-size: $font-base;
  157. color: $color-gray;
  158. }
  159. .background-img {
  160. width: 80rpx;
  161. height: 80rpx;
  162. border-radius: 50%;
  163. background: #f2f2f2;
  164. }
  165. }
  166. .add-btn {
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. margin: 158rpx auto 30rpx;
  171. width: 560rpx;
  172. height: 80rpx;
  173. background: #feca00;
  174. border-radius: 40px;
  175. color: #FFFFFF;
  176. }
  177. .out {
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. margin: 0 auto 30rpx;
  182. width: 560rpx;
  183. height: 80rpx;
  184. border: 1px solid #feca00;
  185. background: #FFFFFF;
  186. border-radius: 40px;
  187. color: #feca00;
  188. }
  189. .psw-wrapper {
  190. width: 548rpx;
  191. height: 344rpx;
  192. background-color: #ffffff;
  193. .psw-title {
  194. width: 100%;
  195. font-size: 35rpx;
  196. padding: 43rpx 0 49rpx;
  197. text-align: center;
  198. font-weight: 800;
  199. }
  200. .psw-ipt {
  201. display: block;
  202. background-color: #dce3ed;
  203. height: 90rpx;
  204. width: 464rpx;
  205. padding-left: 30rpx;
  206. margin: 0 auto;
  207. font-size: 80rpx;
  208. }
  209. .psw-btn text {
  210. display: inline-block;
  211. text-align: center;
  212. width: 50%;
  213. padding-top: 29rpx;
  214. font-size: 35rpx;
  215. }
  216. .psw-qd {
  217. color: #32C6FF;
  218. }
  219. }
  220. </style>