index.vue 4.4 KB

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