index.vue 4.5 KB

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