index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 plain 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 v-if="hasLogin" icon="order" icon-size="38" :icon-style="{color:'#ff5500'}" index="0" @click="toPage" title="我的订单"></u-cell-item>
  30. <u-cell-item v-if="hasLogin" icon="gift" icon-size="40" :icon-style="{color:'#00aaff'}" index="1" @click="toPage" title="投递记录"></u-cell-item>
  31. <u-cell-item icon="question-circle" icon-size="40" :icon-style="{color:'#19be6b'}" index="2" @click="toPage" title="常见问题"></u-cell-item>
  32. <u-cell-item icon="phone" icon-size="40" :icon-style="{color:'#f00'}" @click="callPhone" title="联系客服" index="3"></u-cell-item>
  33. <u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="4" @click="toPage" title="服务协议"></u-cell-item>
  34. <!-- <u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#55aa00'}" index="4" @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. hasLogin: false
  45. };
  46. },
  47. onShow() {
  48. checkLogin().then(res => {
  49. console.log(res)
  50. this.hasLogin = res.status == 200
  51. })
  52. },
  53. onLoad() {
  54. },
  55. methods:{
  56. // 打开对应的页面
  57. toPage(index){
  58. console.log(index)
  59. let pageUrl=[
  60. '/pages/userCenter/deliveryRecord',
  61. '/pages/order/order',
  62. '/pages/userCenter/question',
  63. '/pages/agreement/agreement?fromPage=usercenter',
  64. '/pages/userCenter/aboutUs'
  65. ]
  66. uni.navigateTo({
  67. url: pageUrl[index]
  68. })
  69. },
  70. // 电话客服
  71. callPhone () {
  72. uni.makePhoneCall({
  73. phoneNumber: this.$store.state.vuex_kfMobile
  74. })
  75. },
  76. // 跳转
  77. toUserPage(){
  78. // 未登录跳转登录,已登录跳转用户信息页
  79. if(this.hasLogin){
  80. uni.navigateTo({
  81. url: '/pages/userCenter/userInfo/userInfo'
  82. })
  83. }else{
  84. this.toLoginPage()
  85. }
  86. },
  87. // 乐豆明细
  88. toLdPage(){
  89. uni.navigateTo({
  90. url: '/pages/userCenter/ldDetailed'
  91. })
  92. },
  93. bindGetUserInfo(res){
  94. console.log(res)
  95. },
  96. toLoginPage(){
  97. uni.navigateTo({
  98. url: '/pages/login/login'
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss">
  105. .user-content{
  106. width: 100%;
  107. .user-head{
  108. background: #01c9b2;
  109. display: flex;
  110. align-items: center;
  111. padding: 35rpx 55rpx;
  112. .user-info{
  113. flex-grow: 1;
  114. padding: 0 20rpx;
  115. color: #FFFFFF;
  116. }
  117. .user-photo{
  118. width: 100rpx;
  119. height: 100rpx;
  120. border-radius: 50%;
  121. overflow: hidden;
  122. margin-right: 5rpx;
  123. }
  124. }
  125. .my-ledou{
  126. background: #FFFFFF;
  127. border-radius: 15upx;
  128. display: flex;
  129. align-items: center;
  130. justify-content: space-between;
  131. padding: 20upx;
  132. margin: 20upx;
  133. box-shadow: 0upx 3upx 6upx #eee;
  134. .user-jifen{
  135. display: flex;
  136. align-items: center;
  137. text{
  138. font-size: 40upx;
  139. font-weight: bold;
  140. color: red;
  141. }
  142. >view{
  143. &:first-child{
  144. display: flex;
  145. align-items: center;
  146. }
  147. }
  148. }
  149. }
  150. .user-list{
  151. border-radius: 15upx;
  152. margin: 20upx;
  153. overflow: hidden;
  154. box-shadow: 0upx 3upx 6upx #eee;
  155. }
  156. .user-btn{
  157. padding: 85rpx 200rpx;
  158. }
  159. }
  160. </style>