index.vue 4.6 KB

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