index.vue 4.3 KB

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