set.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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"
  41. placeholder-class="placeholder" />
  42. </view>
  43. <view class="submit-box ">
  44. <view class="submit" @click="edit">确认修改</view>
  45. <!-- <view class="out" @click="toLogout">退出登录</view> -->
  46. <view class="submit submit1" @click="toLogout">退出登录</view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. // import uniList from "@/components/uni-list/uni-list.vue"
  52. // import uniListItem from "@/components/uni-list-item/uni-list-item.vue"
  53. // import { logout } from '@/api/set.js';
  54. // import {
  55. // mapMutations
  56. // } from 'vuex';
  57. // export default {
  58. // components: {
  59. // uniList,uniListItem
  60. // },
  61. // data() {
  62. // return {
  63. // };
  64. // },
  65. // methods:{
  66. // ...mapMutations('user',['logout']),
  67. // navTo(url){
  68. // uni.navigateTo({
  69. // url:url
  70. // })
  71. // },
  72. // //退出登录
  73. // toLogout(){
  74. // let obj = this;
  75. // uni.showModal({
  76. // content: '确定要退出登录么',
  77. // success: (e)=>{
  78. // if(e.confirm){
  79. // logout({}).then((e) => {
  80. // uni.navigateBack();
  81. // }).catch((e) => {
  82. // console.log(e);
  83. // })
  84. // obj.logout();
  85. // }
  86. // }
  87. // });
  88. // },
  89. // //switch切换触发方法
  90. // switchChange(e){
  91. // console.log(e);
  92. // let statusTip = e.value ? '打开': '关闭';
  93. // this.$api.msg(`${statusTip}消息推送`);
  94. // },
  95. // }
  96. // }
  97. import uniList from '@/components/uni-list/uni-list.vue';
  98. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  99. import {
  100. mapState,
  101. mapMutations
  102. } from 'vuex';
  103. import {
  104. logout
  105. } from '@/api/set.js';
  106. import {
  107. uploads,
  108. edit,
  109. upload
  110. } from '@/api/user.js';
  111. export default {
  112. components: {
  113. uniList,
  114. uniListItem
  115. },
  116. data() {
  117. return {
  118. // nickName:'李淡淡',
  119. // id:'HFBNXISN',
  120. // account:'13745262356',
  121. userInfo: {},
  122. pics: []
  123. };
  124. },
  125. onLoad() {
  126. this.userInfo = uni.getStorageSync('userInfo') || '';
  127. console.log(this.userInfo)
  128. },
  129. methods: {
  130. ...mapMutations('user', ['logout']),
  131. //退出登录
  132. toLogout() {
  133. let obj = this;
  134. uni.showModal({
  135. content: '确定要退出登录么',
  136. success: e => {
  137. if (e.confirm) {
  138. logout({}).then(e => {
  139. obj.logout();
  140. uni.switchTab({
  141. url: '/pages/index/index'
  142. })
  143. })
  144. .catch(e => {
  145. console.log(e);
  146. });
  147. }
  148. }
  149. });
  150. },
  151. imgsub() {
  152. let obj = this
  153. // console.log('上传头像')
  154. // this.$util.uploadImageOne('upload/image', function(res) {
  155. // console.log('------',res);
  156. // // this.pics.push(res.data.pathreplace(/http:\/\/mer.crmeb.net/,'http://zccy.liuniu946.com'));
  157. // obj.userInfo.avatar = res.data.path.replace(/http:\/\/mer.crmeb.net/,'http://zccy.frp.liuniu946.com')
  158. // // obj.$set(this, 'pics', this.pics);
  159. // // obj.$set(this, 'extract_pic', this.pics[0])
  160. // });
  161. // uploads({
  162. // filename: ''
  163. // }).then(data => {
  164. // console.log("data",data);
  165. // this.userInfo.avatar = data[0].url;
  166. // })
  167. upload({
  168. filename: ''
  169. }).then(res => {
  170. console.log(res, '上传图片')
  171. console.log(res[0].url)
  172. obj.userInfo.avatar = res[0].url
  173. // console.log(obj.userInfo.avatar)
  174. });
  175. },
  176. edit() {
  177. const that = this;
  178. uni.showLoading({
  179. title: '提交中...',
  180. mask: true
  181. })
  182. edit({
  183. avatar: this.userInfo.avatar,
  184. nickname: this.userInfo.nickname
  185. }).then(e => {
  186. uni.hideLoading()
  187. that.$api.msg('修改成功');
  188. setTimeout(() => {
  189. uni.switchTab({
  190. url: '/pages/user/user'
  191. });
  192. }, 1000);
  193. }).catch(e => {
  194. console.log(e);
  195. that.$api.msg('修改失败');
  196. })
  197. }
  198. }
  199. };
  200. </script>
  201. <style lang='scss'>
  202. /* page{
  203. background: $page-color-base;
  204. }
  205. .list-cell{
  206. display:flex;
  207. align-items:baseline;
  208. padding: 20rpx $page-row-spacing;
  209. line-height:60rpx;
  210. position:relative;
  211. background: #fff;
  212. justify-content: center;
  213. &.log-out-btn{
  214. margin-top: 40rpx;
  215. .cell-tit{
  216. color: $uni-color-primary;
  217. text-align: center;
  218. margin-right: 0;
  219. }
  220. }
  221. .cell-tit{
  222. flex: 1;
  223. font-size: $font-base + 2rpx;
  224. color: $font-color-dark;
  225. margin-right:10rpx;
  226. }
  227. .cell-tip{
  228. font-size: $font-base;
  229. color: $font-color-light;
  230. }
  231. switch{
  232. transform: translateX(16rpx) scale(.84);
  233. }
  234. } */
  235. page {
  236. background-color: #f3f3f3;
  237. min-height: 100%;
  238. .container {
  239. height: 100%;
  240. }
  241. }
  242. .row {
  243. background-color: #fff;
  244. padding: 42rpx 25rpx;
  245. font-size: 30rpx;
  246. color: #333333;
  247. image {
  248. width: 80rpx;
  249. height: 80rpx;
  250. border-radius: 50%;
  251. }
  252. .input {
  253. text-align: right;
  254. color: #333333;
  255. }
  256. }
  257. .submit-box {
  258. padding-top: 157rpx;
  259. .submit {
  260. margin: 40rpx auto;
  261. width: 560rpx;
  262. background-color: #901b21;
  263. color: #FFFFFF;
  264. text-align: center;
  265. padding: 26rpx 0rpx;
  266. border-radius: 50rpx;
  267. }
  268. .submit1 {
  269. background-color: #FFFFFF;
  270. color:#901b21 ;
  271. border: 1px solid #901b21;
  272. }
  273. }
  274. .jg {
  275. margin-bottom: 20rpx;
  276. }
  277. .out {
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. margin: 0 auto 30rpx;
  282. width: 560rpx;
  283. height: 80rpx;
  284. border: 1px solid #58BAB0;
  285. background: #FFFFFF;
  286. border-radius: 40px;
  287. color: #58BAB0;
  288. }
  289. </style>