index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head">
  5. <view class="user-photo">
  6. <open-data type="userAvatarUrl"></open-data>
  7. </view>
  8. <view class="user-info">
  9. <open-data type="userNickName"></open-data>
  10. </view>
  11. </view>
  12. <!-- 列表 -->
  13. <view class="user-list">
  14. <u-cell-group>
  15. <u-cell-item icon="gift" index="0" @click="toPage" title="我的优惠卷"></u-cell-item>
  16. <u-cell-item icon="order" index="1" @click="toPage" title="我的订单"></u-cell-item>
  17. <u-cell-item icon="file-text" index="2" @click="toPage" title="服务协议"></u-cell-item>
  18. <!-- <u-cell-item icon="info-circle" index="3" @click="toPage" title="关于我们"></u-cell-item> -->
  19. </u-cell-group>
  20. </view>
  21. <!-- 退出 -->
  22. <view class="user-btn">
  23. <u-button type="error" @click="quitSys" shape="circle">退出登录</u-button>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {logout} from '@/api/login.js'
  29. import {getLookUpDatas} from '@/api/data.js'
  30. export default {
  31. data() {
  32. return {
  33. };
  34. },
  35. onShow() {
  36. },
  37. onLoad() {
  38. // 获取订单状态数据字典
  39. this.getCodeList('ORDER_STATUS')
  40. // 获取支付方式数据字典
  41. this.getCodeList('PAY_TYPE')
  42. },
  43. methods:{
  44. // 获取数据字典
  45. getCodeList (code) {
  46. getLookUpDatas({type:code}).then(res =>{
  47. if (res.status == 200) {
  48. console.log(res.data,'res.data')
  49. if (code == 'ORDER_STATUS') {
  50. this.$u.vuex('vuex_payStatus', res.data)
  51. } else {
  52. this.$u.vuex('vuex_payType', res.data)
  53. }
  54. }
  55. })
  56. },
  57. // 打开对应的页面
  58. toPage(index){
  59. let pageUrl=['/pages/coupon/index/index','/pages/order/order','/pages/agreement/agreement?fromPage=usercenter']
  60. uni.navigateTo({
  61. url: pageUrl[index]
  62. })
  63. },
  64. // 退出登录
  65. quitSys(){
  66. let _this = this
  67. uni.showModal({
  68. title: '提示',
  69. content: '您确定要退出登录吗?',
  70. success(res) {
  71. if (res.confirm) {
  72. logout({}).then(res => {
  73. getApp().globalData.token = ''
  74. _this.$u.vuex('vuex_token','')
  75. uni.reLaunch({
  76. url: '/pages/index/index'
  77. });
  78. });
  79. }
  80. }
  81. });
  82. },
  83. bindGetUserInfo(res){
  84. console.log(res)
  85. },
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. .user-content{
  91. width: 100%;
  92. .user-head{
  93. display: flex;
  94. align-items: center;
  95. padding: 35rpx;
  96. .user-info{
  97. flex-grow: 1;
  98. padding: 0 20rpx;
  99. }
  100. .user-photo{
  101. width: 100rpx;
  102. height: 100rpx;
  103. border-radius: 50%;
  104. overflow: hidden;
  105. margin-right: 30rpx;
  106. }
  107. }
  108. .user-list{
  109. padding:0 20rpx;
  110. }
  111. .user-btn{
  112. padding: 85rpx 100rpx;
  113. }
  114. }
  115. </style>