index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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-if="hasLogin">{{user.mobile||'--'}}</text>
  11. <u-button v-else="!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:'#aa55ff'}" index="5" @click="toPage" title="我的奖品"></u-cell-item>
  31. <u-cell-item v-if="hasLogin" icon="coupon" icon-size="40" :icon-style="{color:'#f29100'}" index="6" @click="toPage" title="我的礼品卡"></u-cell-item>
  32. <u-cell-item v-if="hasLogin" icon="list-dot" icon-size="36" :icon-style="{color:'#00aaff'}" index="1" @click="toPage" title="投递记录"></u-cell-item>
  33. <u-cell-item icon="question-circle" icon-size="39" :icon-style="{color:'#19be6b'}" index="2" @click="toPage" title="常见问题"></u-cell-item>
  34. <u-cell-item icon="phone" icon-size="40" :icon-style="{color:'#f00'}" @click="callPhone" title="联系客服"></u-cell-item>
  35. <u-cell-item icon="file-text" icon-size="40" :icon-style="{color:'#ffaa00'}" index="3" @click="toPage" title="服务协议"></u-cell-item>
  36. <u-cell-item icon="info-circle" icon-size="38" :icon-style="{color:'#55aa00'}" index="4" @click="toPage" title="关于我们"></u-cell-item>
  37. </u-cell-group>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import { checkLogin, getUserInfo } from '@/api/login.js'
  43. export default {
  44. data() {
  45. return {
  46. hasLogin: false,
  47. userData: {}
  48. };
  49. },
  50. onShow() {
  51. checkLogin().then(res => {
  52. this.hasLogin = res.status == 200
  53. if(this.hasLogin){
  54. this.getUserInfo()
  55. }else{
  56. uni.navigateTo({
  57. url:"/pages/login/login"
  58. })
  59. }
  60. })
  61. },
  62. computed: {
  63. user() {
  64. return this.userData
  65. }
  66. },
  67. onLoad() {
  68. // 开启分享
  69. uni.showShareMenu({
  70. withShareTicket: true,
  71. menus: ['shareAppMessage', 'shareTimeline']
  72. })
  73. },
  74. methods:{
  75. // 获取用户信息
  76. getUserInfo(){
  77. getUserInfo().then(res => {
  78. console.log(res,'getUserInfo')
  79. if(res.status == 200){
  80. this.$u.vuex("vuex_userData",res.data)
  81. this.userData = res.data
  82. }
  83. })
  84. },
  85. // 打开对应的页面
  86. toPage(index){
  87. console.log(index)
  88. let pageUrl=[
  89. '/pagesA/order/order',
  90. '/pages/userCenter/deliveryRecord',
  91. '/pages/userCenter/question',
  92. '/pages/agreement/agreement?fromPage=usercenter',
  93. '/pages/userCenter/aboutUs',
  94. '/pagesA/luckDraw/myJp?fromPage=usercenter',
  95. '/pagesA/giftCard/giftCard'
  96. ]
  97. uni.navigateTo({
  98. url: pageUrl[index]
  99. })
  100. },
  101. // 电话客服
  102. callPhone () {
  103. uni.makePhoneCall({
  104. phoneNumber: this.$store.state.vuex_kfMobile
  105. })
  106. },
  107. // 跳转
  108. toUserPage(){
  109. // 未登录跳转登录,已登录跳转用户信息页
  110. if(this.hasLogin){
  111. uni.navigateTo({
  112. url: '/pages/userCenter/userInfo/userInfo'
  113. })
  114. }else{
  115. this.toLoginPage()
  116. }
  117. },
  118. // 乐豆明细
  119. toLdPage(){
  120. uni.navigateTo({
  121. url: '/pages/userCenter/ldDetailed'
  122. })
  123. },
  124. bindGetUserInfo(res){
  125. console.log(res)
  126. },
  127. toLoginPage(){
  128. uni.navigateTo({
  129. url: '/pages/login/login'
  130. })
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss">
  136. .user-content{
  137. width: 100%;
  138. .user-head{
  139. background: #01c9b2;
  140. display: flex;
  141. align-items: center;
  142. padding: 35rpx 55rpx;
  143. .user-info{
  144. flex-grow: 1;
  145. padding: 0 20rpx;
  146. color: #FFFFFF;
  147. }
  148. .user-photo{
  149. width: 100rpx;
  150. height: 100rpx;
  151. border-radius: 50%;
  152. overflow: hidden;
  153. margin-right: 5rpx;
  154. }
  155. }
  156. .my-ledou{
  157. background: #FFFFFF;
  158. border-radius: 15upx;
  159. display: flex;
  160. align-items: center;
  161. justify-content: space-between;
  162. padding: 20upx;
  163. margin: 20upx;
  164. box-shadow: 0upx 3upx 6upx #eee;
  165. .user-jifen{
  166. display: flex;
  167. align-items: center;
  168. text{
  169. font-size: 40upx;
  170. font-weight: bold;
  171. color: red;
  172. }
  173. >view{
  174. &:first-child{
  175. display: flex;
  176. align-items: center;
  177. }
  178. }
  179. }
  180. }
  181. .user-list{
  182. border-radius: 15upx;
  183. margin: 20upx;
  184. overflow: hidden;
  185. box-shadow: 0upx 3upx 6upx #eee;
  186. }
  187. .user-btn{
  188. padding: 85rpx 200rpx;
  189. }
  190. }
  191. </style>