set.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <!-- <view class="container">
  3. <uni-list>
  4. <uni-list-item title="个人资料" @click="navTo('/pages/set/userinfo')" ></uni-list-item>
  5. <uni-list-item title="修改密码" @click="navTo('/pages/set/password')" ></uni-list-item>
  6. <uni-list-item title="实名认证" @click="navTo('/pages/set/phone')" ></uni-list-item>
  7. <uni-list-item title="收货地址" @click="navTo('/pages/set/address')" ></uni-list-item>
  8. </uni-list>
  9. <uni-list class="margin-t-20">
  10. <uni-list-item title="消息推送" :switch-checked='true' :show-switch="true" :show-arrow="false" switch-color='#5dbc7c' @switchChange='switchChange'>
  11. </uni-list-item>
  12. </uni-list>
  13. <uni-list class="margin-t-20">
  14. <uni-list-item title="清除缓存" ></uni-list-item>
  15. <uni-list-item title="检查更新" >
  16. <template slot="right">
  17. 当前版本 1.0.3
  18. </template>
  19. </uni-list-item>
  20. </uni-list>
  21. <view class="list-cell log-out-btn" @click="toLogout">
  22. <text class="cell-tit">退出登录</text>
  23. </view>
  24. </view> -->
  25. <view class="container">
  26. <view class="row b-b flex jg">
  27. <text class="tit">头像</text>
  28. <image :src="userInfo.avatar" @click.stop="imgsub"></image>
  29. </view>
  30. <view class="row b-b flex">
  31. <text class="tit">昵称</text>
  32. <input class="input" v-model="userInfo.nickname" type="text" placeholder-class="placeholder" />
  33. </view>
  34. <view class="row b-b flex">
  35. <text class="tit">ID</text>
  36. <input class="input" v-model="userInfo.uid" type="text" disabled="true" placeholder-class="placeholder" />
  37. </view>
  38. <view class="row b-b flex">
  39. <text class="tit">用户账号</text>
  40. <input class="input" v-model="userInfo.account || userInfo.phone" type="number" disabled="true" placeholder-class="placeholder" />
  41. </view>
  42. <view class="submit-box flex" >
  43. <view class="submit" @click="edit">确认修改</view>
  44. <!-- <view class="submit" @click="toLogout">退出登录</view> -->
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. // import uniList from "@/components/uni-list/uni-list.vue"
  50. // import uniListItem from "@/components/uni-list-item/uni-list-item.vue"
  51. // import { logout } from '@/api/set.js';
  52. // import {
  53. // mapMutations
  54. // } from 'vuex';
  55. // export default {
  56. // components: {
  57. // uniList,uniListItem
  58. // },
  59. // data() {
  60. // return {
  61. // };
  62. // },
  63. // methods:{
  64. // ...mapMutations('user',['logout']),
  65. // navTo(url){
  66. // uni.navigateTo({
  67. // url:url
  68. // })
  69. // },
  70. // //退出登录
  71. // toLogout(){
  72. // let obj = this;
  73. // uni.showModal({
  74. // content: '确定要退出登录么',
  75. // success: (e)=>{
  76. // if(e.confirm){
  77. // logout({}).then((e) => {
  78. // uni.navigateBack();
  79. // }).catch((e) => {
  80. // console.log(e);
  81. // })
  82. // obj.logout();
  83. // }
  84. // }
  85. // });
  86. // },
  87. // //switch切换触发方法
  88. // switchChange(e){
  89. // console.log(e);
  90. // let statusTip = e.value ? '打开': '关闭';
  91. // this.$api.msg(`${statusTip}消息推送`);
  92. // },
  93. // }
  94. // }
  95. import uniList from '@/components/uni-list/uni-list.vue';
  96. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  97. import { mapState, mapMutations } from 'vuex';
  98. import { logout } from '@/api/set.js';
  99. import {
  100. uploads,edit
  101. } from '@/api/user.js';
  102. export default {
  103. components: {
  104. uniList,
  105. uniListItem
  106. },
  107. data() {
  108. return {
  109. // nickName:'李淡淡',
  110. // id:'HFBNXISN',
  111. // account:'13745262356',
  112. userInfo:'',
  113. };
  114. },
  115. onLoad() {
  116. this.userInfo = uni.getStorageSync('userInfo') || '';
  117. console.log(this.userInfo)
  118. },
  119. methods: {
  120. ...mapMutations('user',['logout']),
  121. //退出登录
  122. toLogout() {
  123. let obj = this;
  124. uni.showModal({
  125. content: '确定要退出登录么',
  126. success: e => {
  127. if (e.confirm) {
  128. logout({}).then(e => {
  129. obj.logout();
  130. uni.navigateTo({
  131. url:'/pages/public/login'
  132. })
  133. })
  134. .catch(e => {
  135. console.log(e);
  136. });
  137. }
  138. }
  139. });
  140. },
  141. imgsub() {
  142. console.log('上传头像')
  143. uploads({
  144. filename: ''
  145. }).then(data => {
  146. console.log("data",data);
  147. this.userInfo.avatar = data[0].url;
  148. })
  149. },
  150. edit() {
  151. const that = this;
  152. edit({
  153. avatar: this.userInfo.avatar,
  154. nickname: this.userInfo.nickname
  155. }).then( e =>{
  156. that.$api.msg('修改成功');
  157. setTimeout(()=> {
  158. uni.switchTab({
  159. url:'/pages/user/user'
  160. });
  161. }, 1000);
  162. }).catch(e =>{
  163. console.log(e);
  164. that.$api.msg('修改失败');
  165. })
  166. }
  167. }
  168. };
  169. </script>
  170. <style lang='scss'>
  171. /* page{
  172. background: $page-color-base;
  173. }
  174. .list-cell{
  175. display:flex;
  176. align-items:baseline;
  177. padding: 20rpx $page-row-spacing;
  178. line-height:60rpx;
  179. position:relative;
  180. background: #fff;
  181. justify-content: center;
  182. &.log-out-btn{
  183. margin-top: 40rpx;
  184. .cell-tit{
  185. color: $uni-color-primary;
  186. text-align: center;
  187. margin-right: 0;
  188. }
  189. }
  190. .cell-tit{
  191. flex: 1;
  192. font-size: $font-base + 2rpx;
  193. color: $font-color-dark;
  194. margin-right:10rpx;
  195. }
  196. .cell-tip{
  197. font-size: $font-base;
  198. color: $font-color-light;
  199. }
  200. switch{
  201. transform: translateX(16rpx) scale(.84);
  202. }
  203. } */
  204. page {
  205. background-color: #f3f3f3;
  206. min-height: 100%;
  207. .container{
  208. height: 100%;
  209. }
  210. }
  211. .row {
  212. background-color: #fff;
  213. padding: 42rpx 25rpx;
  214. font-size: 30rpx;
  215. color: #333333;
  216. image{
  217. width: 80rpx;
  218. height: 80rpx;
  219. border-radius: 50%;
  220. }
  221. .input {
  222. text-align: right;
  223. color: #333333;
  224. }
  225. }
  226. .submit-box{
  227. padding-top: 157rpx;
  228. .submit{
  229. margin: 40rpx auto;
  230. width: 560rpx;
  231. background-color: #901b21;
  232. color: #FFFFFF;
  233. text-align: center;
  234. padding:26rpx 0rpx;
  235. border-radius: 50rpx;
  236. }
  237. }
  238. .jg {
  239. margin-bottom: 20rpx;
  240. }
  241. </style>