index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head" @click="toUserPage">
  5. <view class="user-photo">
  6. <text v-if="hasLogin"><open-data type="userAvatarUrl"></open-data></text>
  7. <u-image v-else src="/static/logo.png" width="100" height="100"></u-image>
  8. </view>
  9. <view class="user-info">
  10. <text v-if="hasLogin"><open-data type="userNickName"></open-data></text>
  11. <u-button v-else size="mini" shape="circle" @click="toLoginPage">登录</u-button>
  12. </view>
  13. <view v-if="hasLogin">
  14. <u-icon name="arrow-right" color="#fff"></u-icon>
  15. </view>
  16. </view>
  17. <view class="my-ledou" v-if="hasLogin">
  18. <view class="user-jifen">
  19. <view>我的乐豆:<text>345</text></view>
  20. <u-image mode="scaleToFill" width="35rpx" height="35rpx" src="/static/ledou.png"></u-image>
  21. </view>
  22. <view>
  23. <u-button size="mini" type="warning" shape="circle" @click="toLdPage">查看明细</u-button>
  24. </view>
  25. </view>
  26. <!-- 列表 -->
  27. <view class="user-list">
  28. <u-cell-group>
  29. <u-cell-item icon="order" icon-size="38" :icon-style="{color:'#ff5500'}" index="1" @click="toPage" title="我的订单"></u-cell-item>
  30. <u-cell-item icon="gift" icon-size="40" :icon-style="{color:'#00aaff'}" index="0" @click="toPage" title="投递记录"></u-cell-item>
  31. <u-cell-item icon="question-circle" icon-size="40" :icon-style="{color:'#19be6b'}" index="0" @click="toPage" title="常见问题"></u-cell-item>
  32. <u-cell-item icon="phone" icon-size="40" :icon-style="{color:'#f00'}" index="0" @click="toPage" title="联系客服"></u-cell-item>
  33. <u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="2" @click="toPage" title="服务协议"></u-cell-item>
  34. <!-- <u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#55aa00'}" index="3" @click="toPage" title="关于我们"></u-cell-item> -->
  35. </u-cell-group>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {logout, checkLogin } from '@/api/login.js'
  41. export default {
  42. data() {
  43. return {
  44. quitButton: {
  45. borderRadius:'100rpx',
  46. fontSize:'30rpx',
  47. background: '#01c9b2'
  48. },
  49. hasLogin: false
  50. };
  51. },
  52. onShow() {
  53. checkLogin().then(res => {
  54. console.log(res)
  55. this.hasLogin = res.status == 200
  56. })
  57. },
  58. onLoad() {
  59. },
  60. methods:{
  61. // 打开对应的页面
  62. toPage(index){
  63. let pageUrl=[
  64. '/pages/userCenter/deliveryRecord',
  65. '/pages/order/order',
  66. '/pages/agreement/agreement?fromPage=usercenter',
  67. '/pages/userCenter/aboutUs'
  68. ]
  69. if(index<2&&this.hasLogin || index>=2){
  70. uni.navigateTo({
  71. url: pageUrl[index]
  72. })
  73. }else{
  74. this.toLoginPage()
  75. }
  76. },
  77. // 跳转
  78. toUserPage(){
  79. // 未登录跳转登录,已登录跳转用户信息页
  80. if(this.hasLogin){
  81. uni.navigateTo({
  82. url: '/pages/userCenter/userInfo/userInfo'
  83. })
  84. }else{
  85. this.toLoginPage()
  86. }
  87. },
  88. // 乐豆明细
  89. toLdPage(){
  90. uni.navigateTo({
  91. url: '/pages/userCenter/ldDetailed'
  92. })
  93. },
  94. bindGetUserInfo(res){
  95. console.log(res)
  96. },
  97. toLoginPage(){
  98. uni.navigateTo({
  99. url: '/pages/login/login'
  100. })
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss">
  106. .user-content{
  107. width: 100%;
  108. .user-head{
  109. background: #01c9b2;
  110. display: flex;
  111. align-items: center;
  112. padding: 35rpx 55rpx;
  113. .user-info{
  114. flex-grow: 1;
  115. padding: 0 20rpx;
  116. color: #FFFFFF;
  117. }
  118. .user-photo{
  119. width: 100rpx;
  120. height: 100rpx;
  121. border-radius: 50%;
  122. overflow: hidden;
  123. margin-right: 5rpx;
  124. }
  125. }
  126. .my-ledou{
  127. background: #FFFFFF;
  128. border-radius: 15upx;
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. padding: 20upx;
  133. margin: 20upx;
  134. box-shadow: 0upx 3upx 6upx #eee;
  135. .user-jifen{
  136. display: flex;
  137. align-items: center;
  138. text{
  139. font-size: 40upx;
  140. font-weight: bold;
  141. color: red;
  142. }
  143. >view{
  144. &:first-child{
  145. display: flex;
  146. align-items: center;
  147. }
  148. }
  149. }
  150. }
  151. .user-list{
  152. border-radius: 15upx;
  153. margin: 20upx;
  154. overflow: hidden;
  155. box-shadow: 0upx 3upx 6upx #eee;
  156. }
  157. .user-btn{
  158. padding: 85rpx 200rpx;
  159. }
  160. }
  161. </style>