index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <!-- 非H5撑高元素 -->
  4. <view class="status_bar"></view>
  5. <!-- 头部背景 -->
  6. <view class="user"></view>
  7. <!-- 账户信息 -->
  8. <view class="account">
  9. <view class="flex account-ava">
  10. <image :src="avatar" mode="aspectFill" v-if="loginState"></image>
  11. <image src="../../static/logo.png" mode="aspectFill" v-else></image>
  12. <view class="account-ava-name" v-if="loginState">{{ userInfo.nickName }}</view>
  13. <view class="account-ava-no" @click="toLogin" v-else>登录</view>
  14. </view>
  15. <view class="flex account-info" v-if="loginState">
  16. <navigator url="/pages/prize/index" class="flex account-info-item" hover-class="navigator-hover">
  17. <view>{{ initData.prizeNum }}</view>
  18. <view>我的奖品库</view>
  19. </navigator>
  20. <navigator url="/pages/ticket/index" class="flex account-info-item" hover-class="navigator-hover">
  21. <view>{{ initData.ticketNum }}</view>
  22. <view>我的盲票包</view>
  23. </navigator>
  24. <navigator url="/pages/bean/index" class="flex account-info-item" hover-class="navigator-hover">
  25. <view>{{ initData.coinNum }}</view>
  26. <view>我的盲豆</view>
  27. </navigator>
  28. </view>
  29. <view class="flex account-info" v-else @click="notLogin">
  30. <view class="flex account-info-item">
  31. <view>-</view>
  32. <view>我的奖品库</view>
  33. </view>
  34. <view class="flex account-info-item">
  35. <view>-</view>
  36. <view>我的盲票包</view>
  37. </view>
  38. <view class="flex account-info-item">
  39. <view>-</view>
  40. <view>我的盲豆</view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 操作项 -->
  45. <view class="action">
  46. <u-cell-group :border="false">
  47. <u-cell icon="order" title="我的订单" :isLink="true" @click="toOrder"></u-cell>
  48. <u-cell icon="map" title="我的地址" :isLink="true" @click="toAddress"></u-cell>
  49. <u-cell icon="kefu-ermai" title="联系客服" :isLink="true"></u-cell>
  50. <u-cell icon="info-circle" title="关于我们" :border="false" :isLink="true" :url="'/pages/about/index'">
  51. </u-cell>
  52. </u-cell-group>
  53. </view>
  54. <view class="cancel">
  55. <u-cell icon="close-circle" title="注销登录" :isLink="true" :border="false" @click="logout"></u-cell>
  56. </view>
  57. <custom-tab-bar :activeValue="'user'" />
  58. </view>
  59. </template>
  60. <script>
  61. import env from '../../config/env.js'
  62. import $http from '@/utils/request.js'
  63. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  64. import Auth from '../../components/auth/auth.vue'
  65. export default {
  66. components: {
  67. CustomTabBar,
  68. Auth
  69. },
  70. data() {
  71. return {
  72. loginState: false, // 判断是否登录
  73. authState: false,
  74. userInfo: {}, //
  75. avatar: '',
  76. certifyStatus: {},
  77. info: {},
  78. authShow: false,
  79. initData: {},
  80. };
  81. },
  82. onShow() {
  83. this.loginState = uni.getStorageSync('token') ? true : false
  84. this.userInfo = uni.getStorageSync('userInfo')
  85. this.avatar = env.filePublic + this.userInfo.avatar
  86. if (this.loginState) {
  87. this.getInit()
  88. }
  89. },
  90. methods: {
  91. // 我的数据
  92. getInit() {
  93. uni.showLoading({
  94. title: '加载中'
  95. });
  96. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  97. uni.hideLoading();
  98. if (res.code == 0) {
  99. this.initData = res.data
  100. }
  101. }).catch(() => {
  102. uni.hideLoading();
  103. })
  104. },
  105. // 跳转登录
  106. toLogin() {
  107. uni.navigateTo({
  108. url: "/pages/login/index"
  109. })
  110. },
  111. // 我的订单
  112. toOrder() {
  113. if (!this.loginState) {
  114. uni.$u.toast('请登录!');
  115. return
  116. }
  117. uni.navigateTo({
  118. url: '/pages/order/index'
  119. })
  120. },
  121. // 我的地址
  122. toAddress() {
  123. if (!this.loginState) {
  124. uni.$u.toast('请登录!');
  125. return
  126. }
  127. uni.navigateTo({
  128. url: '/pages/address/index'
  129. })
  130. },
  131. // 没有登录
  132. notLogin() {
  133. uni.$u.toast('请登录!');
  134. },
  135. // 注销登录
  136. logout() {
  137. let _this = this
  138. if (!this.loginState) {
  139. uni.$u.toast('已注销登录!');
  140. return
  141. }
  142. uni.showModal({
  143. title: '注销登录',
  144. content: '确定要注销登录吗?',
  145. success(res) {
  146. if (res.confirm) {
  147. uni.clearStorage()
  148. _this.loginState = false
  149. _this.authState = false
  150. }
  151. }
  152. })
  153. },
  154. },
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. /deep/ .u-cell__body {
  159. padding: 20rpx 0;
  160. }
  161. .status_bar {
  162. width: 100%;
  163. height: var(--status-bar-height);
  164. }
  165. </style>
  166. <style lang="scss" scoped>
  167. .user {
  168. display: flex;
  169. align-items: center;
  170. height: 230rpx;
  171. padding: 0 36rpx;
  172. background: url(https://file02.16sucai.com/d/file/2014/1103/1b73e5346d5579badbc83cb15586f0a8.jpg) center no-repeat;
  173. }
  174. .account {
  175. margin: 0 20rpx;
  176. padding: 34rpx;
  177. background-color: #FFFFFF;
  178. border-radius: 10rpx;
  179. margin-top: -106rpx;
  180. margin-bottom: 40rpx;
  181. &-ava {
  182. justify-content: flex-start;
  183. margin-bottom: 46rpx;
  184. image {
  185. width: 106rpx;
  186. height: 106rpx;
  187. border-radius: 50%;
  188. overflow: hidden;
  189. }
  190. &-name {
  191. margin-left: 20rpx;
  192. font-size: 32rpx;
  193. }
  194. &-no {
  195. margin-left: 20rpx;
  196. color: #C0C0C0;
  197. font-size: 32rpx;
  198. }
  199. }
  200. &-info {
  201. justify-content: space-around;
  202. &-item {
  203. flex-direction: column;
  204. view {
  205. line-height: 40rpx;
  206. }
  207. view:first-child {
  208. line-height: 56rpx;
  209. font-size: 40rpx;
  210. }
  211. }
  212. }
  213. }
  214. .action {
  215. margin: 0 20rpx;
  216. padding: 10rpx 20rpx 0;
  217. background-color: #FFFFFF;
  218. border-radius: 10rpx;
  219. margin-bottom: 40rpx;
  220. }
  221. .cancel {
  222. margin: 0 20rpx;
  223. padding: 10rpx 20rpx;
  224. background-color: #FFFFFF;
  225. border-radius: 10rpx;
  226. }
  227. </style>