userinfo.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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="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">邀请码</text>
  36. <input class="input" v-model="userInfo.uid" type="text" disabled="true" placeholder-class="placeholder"
  37. style="color: #999;" />
  38. </view>
  39. <!-- v-if="agents!=''" -->
  40. <!-- <view class="row b-b flex" v-if="!Array.isArray(userInfo.agent)">
  41. <text class="tit">代理区域</text>
  42. <view class="agents" style="color: #999;text-align: right;">
  43. <view class="agent" v-for="(item,index) in userInfo.agent" :key="index">
  44. {{item}}
  45. </view>
  46. </view>
  47. </view> -->
  48. <view class="row b-b flex" v-if="userInfo.account || userInfo.phone">
  49. <text class="tit">用户账号</text>
  50. <input class="input" v-model="userInfo.account || userInfo.phone" type="number" disabled="true"
  51. placeholder-class="placeholder" />
  52. </view>
  53. <view class="submit-box flex">
  54. <view class="submit" @click="edit">确认修改</view>
  55. <view class="submit dl" @click="toLogout">退出登录</view>
  56. <view class="submit zx" @click="zhuxiao">
  57. 注销账号
  58. </view>
  59. </view>
  60. <uni-popup ref="popupYue" type="center">
  61. <view class="yue-box">
  62. <view class="yue-title">
  63. 注销账号
  64. </view>
  65. <view class="yue-cont">
  66. <input type="number" class="yue-content" placeholder="请输入账号" v-model="userName">
  67. <input type="password" class="yue-content" placeholder="请输入密码" v-model="password">
  68. </view>
  69. <view class="comfirm-box">
  70. <view class="cancel" @click="quxiao()">取消</view>
  71. <view class="comfirm" @click="quire()">确定</view>
  72. </view>
  73. </view>
  74. </uni-popup>
  75. </view>
  76. </template>
  77. <script>
  78. // import uniList from "@/components/uni-list/uni-list.vue"
  79. // import uniListItem from "@/components/uni-list-item/uni-list-item.vue"
  80. // import { logout } from '@/api/set.js';
  81. // import {
  82. // mapMutations
  83. // } from 'vuex';
  84. // export default {
  85. // components: {
  86. // uniList,uniListItem
  87. // },
  88. // data() {
  89. // return {
  90. // };
  91. // },
  92. // methods:{
  93. // ...mapMutations('user',['logout']),
  94. // navTo(url){
  95. // uni.navigateTo({
  96. // url:url
  97. // })
  98. // },
  99. // //退出登录
  100. // toLogout(){
  101. // let obj = this;
  102. // uni.showModal({
  103. // content: '确定要退出登录么',
  104. // success: (e)=>{
  105. // if(e.confirm){
  106. // logout({}).then((e) => {
  107. // uni.navigateBack();
  108. // }).catch((e) => {
  109. // console.log(e);
  110. // })
  111. // obj.logout();
  112. // }
  113. // }
  114. // });
  115. // },
  116. // //switch切换触发方法
  117. // switchChange(e){
  118. // console.log(e);
  119. // let statusTip = e.value ? '打开': '关闭';
  120. // this.$api.msg(`${statusTip}消息推送`);
  121. // },
  122. // }
  123. // }
  124. import uniList from '@/components/uni-list/uni-list.vue';
  125. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  126. import {
  127. mapState,
  128. mapMutations
  129. } from 'vuex';
  130. import {
  131. logout
  132. } from '@/api/set.js';
  133. import {
  134. edit
  135. } from '@/api/user.js';
  136. import {
  137. upload
  138. } from '@/api/order.js'
  139. export default {
  140. components: {
  141. uniList,
  142. uniListItem
  143. },
  144. data() {
  145. return {
  146. userInfo: {},
  147. pics: [],
  148. userName: '',
  149. password: '',
  150. isTijiao: false
  151. };
  152. },
  153. onLoad() {
  154. this.userInfo = uni.getStorageSync('userInfo') || '';
  155. console.log(this.userInfo)
  156. },
  157. methods: {
  158. ...mapMutations('user', ['logout']),
  159. //退出登录
  160. toLogout() {
  161. let obj = this;
  162. uni.showModal({
  163. content: '确定要退出登录么',
  164. success: e => {
  165. if (e.confirm) {
  166. logout({}).then(e => {
  167. obj.logout();
  168. uni.switchTab({
  169. url: '/pages/index/index'
  170. })
  171. })
  172. .catch(e => {
  173. console.log(e);
  174. });
  175. }
  176. }
  177. });
  178. },
  179. zhuxiao() {
  180. let shenhe = uni.getStorage({
  181. key:'shenhe',
  182. success: (res) => {
  183. console.log(res,'www');
  184. if(res.data == false){
  185. this.$api.msg('审核中')
  186. }
  187. // this.$refs.popupYue.open()
  188. },fail: (err) => {
  189. console.log(err);
  190. this.$refs.popupYue.open()
  191. }
  192. })
  193. console.log(shenhe,'2222');
  194. },
  195. quire() {
  196. if (this.userName == '' || this.password == '') {
  197. this.$api.msg('账号密码不得为空')
  198. } else if (this.userName != this.userInfo.phone) {
  199. this.$api.msg('请输入正确手机号')
  200. } else {
  201. uni.setStorage({
  202. key: 'shenhe',
  203. data: this.isTijiao
  204. })
  205. this.$refs.popupYue.close()
  206. }
  207. },
  208. quxiao(){
  209. this.$refs.popupYue.close()
  210. },
  211. imgsub() {
  212. let obj = this
  213. console.log('上传头像')
  214. // this.$util.uploadImageOne('upload/image', function(res) {
  215. // console.log('------',res);
  216. // this.pics.push(res.data.pathreplace(/http:\/\/mer.crmeb.net/,'https://hy.liuniu946.com'));
  217. // // obj.userInfo.avatar = res.data.path.replace(/http:\/\/mer.crmeb.net/,'http://zccy.frp.liuniu946.com')
  218. // obj.$set(this, 'pics', this.pics);
  219. // obj.$set(this, 'extract_pic', this.pics[0])
  220. // });
  221. // uploads({
  222. // filename: ''
  223. // }).then(data => {
  224. // console.log("data",data);
  225. // this.userInfo.avatar = data[0].url;
  226. // })
  227. upload({
  228. filename: ''
  229. }).then(res => {
  230. console.log(res[0].url)
  231. obj.userInfo.avatar = res[0].url
  232. // console.log(obj.userInfo.avatar)
  233. });
  234. },
  235. edit() {
  236. const that = this;
  237. uni.showLoading({
  238. title: '提交中...',
  239. mask: true
  240. })
  241. edit({
  242. avatar: this.userInfo.avatar,
  243. nickname: this.userInfo.nickname
  244. }).then(e => {
  245. uni.hideLoading()
  246. that.$api.msg('修改成功');
  247. setTimeout(() => {
  248. uni.switchTab({
  249. url: '/pages/user/user'
  250. });
  251. }, 1000);
  252. }).catch(e => {
  253. console.log(e);
  254. that.$api.msg('修改失败');
  255. })
  256. }
  257. }
  258. };
  259. </script>
  260. <style lang='scss'>
  261. /* page{
  262. background: $page-color-base;
  263. }
  264. .list-cell{
  265. display:flex;
  266. align-items:baseline;
  267. padding: 20rpx $page-row-spacing;
  268. line-height:60rpx;
  269. position:relative;
  270. background: #fff;
  271. justify-content: center;
  272. &.log-out-btn{
  273. margin-top: 40rpx;
  274. .cell-tit{
  275. color: $uni-color-primary;
  276. text-align: center;
  277. margin-right: 0;
  278. }
  279. }
  280. .cell-tit{
  281. flex: 1;
  282. font-size: $font-base + 2rpx;
  283. color: $font-color-dark;
  284. margin-right:10rpx;
  285. }
  286. .cell-tip{
  287. font-size: $font-base;
  288. color: $font-color-light;
  289. }
  290. switch{
  291. transform: translateX(16rpx) scale(.84);
  292. }
  293. } */
  294. page {
  295. background-color: #f3f3f3;
  296. min-height: 100%;
  297. .container {
  298. height: 100%;
  299. }
  300. }
  301. .row {
  302. background-color: #fff;
  303. padding: 42rpx 25rpx;
  304. font-size: 30rpx;
  305. color: #333333;
  306. image {
  307. width: 80rpx;
  308. height: 80rpx;
  309. border-radius: 50%;
  310. }
  311. .input {
  312. text-align: right;
  313. color: #333333;
  314. }
  315. }
  316. .submit-box {
  317. display: flex;
  318. flex-direction: column;
  319. padding-top: 157rpx;
  320. .submit {
  321. margin: 40rpx auto;
  322. width: 560rpx;
  323. background-color: #ff4c4b;
  324. color: #FFFFFF;
  325. text-align: center;
  326. padding: 26rpx 0rpx;
  327. border-radius: 50rpx;
  328. }
  329. .dl {
  330. background-color: #FFFFFF;
  331. color: #ff4c4b;
  332. }
  333. .zx {
  334. color: #FFFFFF;
  335. background-color: gray;
  336. }
  337. }
  338. .jg {
  339. margin-bottom: 20rpx;
  340. }
  341. .yue-box {
  342. display: flex;
  343. flex-direction: column;
  344. align-items: center;
  345. justify-content: space-around;
  346. width: 582rpx;
  347. height: 377rpx;
  348. background: #FFFFFF;
  349. border-radius: 20rpx;
  350. .yue-title{
  351. font-size: 32rpx;
  352. font-weight: 500;margin-top: 20rpx;
  353. }
  354. .yue-tit {
  355. align-items: center;
  356. font-size: 42rpx;
  357. font-weight: 500;
  358. color: #0C1732;
  359. line-height: 56rpx;
  360. }
  361. .password {
  362. text-align: center;
  363. align-items: center;
  364. }
  365. // .yue-cont{
  366. // border-color: #5655EF;
  367. // width: 400rpx;
  368. // height: 80rpx;
  369. // }
  370. .yue-content {
  371. margin: 20rpx 0;
  372. text-align: center;
  373. // width: 300rpx;
  374. height: 70rpx;
  375. border-radius: 20rpx;
  376. border: 2rpx solid gray;
  377. font-size: 36rpx;
  378. font-weight: 500;
  379. // color: red;
  380. }
  381. .comfirm-box {
  382. width: 90%;
  383. display: flex;
  384. justify-content: space-between;
  385. .cancel {
  386. text-align: center;
  387. line-height: 78rpx;
  388. width: 200rpx;
  389. height: 62rpx;
  390. border: 2rpx solid #999999;
  391. border-radius: 10rpx;
  392. font-size: 34rpx;
  393. font-weight: 500;
  394. color: #333333;
  395. }
  396. .comfirm {
  397. text-align: center;
  398. width: 200rpx;
  399. height: 62rpx;
  400. background: #FF5454;
  401. border-radius: 10rpx;
  402. font-size: 34rpx;
  403. font-weight: 500;
  404. color: #FFFFFF;
  405. line-height: 78rpx;
  406. }
  407. }
  408. }
  409. </style>