set.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. pics:[]
  114. };
  115. },
  116. onLoad() {
  117. this.userInfo = uni.getStorageSync('userInfo') || '';
  118. console.log(this.userInfo)
  119. },
  120. methods: {
  121. ...mapMutations('user',['logout']),
  122. //退出登录
  123. toLogout() {
  124. let obj = this;
  125. uni.showModal({
  126. content: '确定要退出登录么',
  127. success: e => {
  128. if (e.confirm) {
  129. logout({}).then(e => {
  130. obj.logout();
  131. uni.navigateTo({
  132. url:'/pages/public/login'
  133. })
  134. })
  135. .catch(e => {
  136. console.log(e);
  137. });
  138. }
  139. }
  140. });
  141. },
  142. imgsub() {
  143. let obj = this
  144. console.log('上传头像')
  145. this.$util.uploadImageOne('upload/image', function(res) {
  146. console.log('------',res);
  147. // this.pics.push(res.data.pathreplace(/http:\/\/mer.crmeb.net/,'http://zccy.liuniu946.com'));
  148. obj.userInfo.avatar = res.data.path.replace(/http:\/\/mer.crmeb.net/,'http://zccy.liuniu946.com')
  149. // obj.$set(this, 'pics', this.pics);
  150. // obj.$set(this, 'extract_pic', this.pics[0])
  151. });
  152. // uploads({
  153. // filename: ''
  154. // }).then(data => {
  155. // console.log("data",data);
  156. // this.userInfo.avatar = data[0].url;
  157. // })
  158. },
  159. edit() {
  160. const that = this;
  161. edit({
  162. avatar: this.userInfo.avatar,
  163. nickname: this.userInfo.nickname
  164. }).then( e =>{
  165. that.$api.msg('修改成功');
  166. setTimeout(()=> {
  167. uni.switchTab({
  168. url:'/pages/user/user'
  169. });
  170. }, 1000);
  171. }).catch(e =>{
  172. console.log(e);
  173. that.$api.msg('修改失败');
  174. })
  175. }
  176. }
  177. };
  178. </script>
  179. <style lang='scss'>
  180. /* page{
  181. background: $page-color-base;
  182. }
  183. .list-cell{
  184. display:flex;
  185. align-items:baseline;
  186. padding: 20rpx $page-row-spacing;
  187. line-height:60rpx;
  188. position:relative;
  189. background: #fff;
  190. justify-content: center;
  191. &.log-out-btn{
  192. margin-top: 40rpx;
  193. .cell-tit{
  194. color: $uni-color-primary;
  195. text-align: center;
  196. margin-right: 0;
  197. }
  198. }
  199. .cell-tit{
  200. flex: 1;
  201. font-size: $font-base + 2rpx;
  202. color: $font-color-dark;
  203. margin-right:10rpx;
  204. }
  205. .cell-tip{
  206. font-size: $font-base;
  207. color: $font-color-light;
  208. }
  209. switch{
  210. transform: translateX(16rpx) scale(.84);
  211. }
  212. } */
  213. page {
  214. background-color: #f3f3f3;
  215. min-height: 100%;
  216. .container{
  217. height: 100%;
  218. }
  219. }
  220. .row {
  221. background-color: #fff;
  222. padding: 42rpx 25rpx;
  223. font-size: 30rpx;
  224. color: #333333;
  225. image{
  226. width: 80rpx;
  227. height: 80rpx;
  228. border-radius: 50%;
  229. }
  230. .input {
  231. text-align: right;
  232. color: #333333;
  233. }
  234. }
  235. .submit-box{
  236. padding-top: 157rpx;
  237. .submit{
  238. margin: 40rpx auto;
  239. width: 560rpx;
  240. background-color: #901b21;
  241. color: #FFFFFF;
  242. text-align: center;
  243. padding:26rpx 0rpx;
  244. border-radius: 50rpx;
  245. }
  246. }
  247. .jg {
  248. margin-bottom: 20rpx;
  249. }
  250. </style>