index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. <view class="no-ava" v-else @click="toLogin"></view>
  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. if (this.loginState) {
  85. this.getInit()
  86. this.getBaseInfo()
  87. }
  88. },
  89. methods: {
  90. // 我的数据
  91. getInit() {
  92. uni.showLoading({
  93. title: '加载中'
  94. });
  95. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  96. uni.hideLoading();
  97. if (res.code == 0) {
  98. this.initData = res.data
  99. }
  100. }).catch(() => {
  101. uni.hideLoading();
  102. })
  103. },
  104. getBaseInfo() {
  105. $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
  106. console.log(res);
  107. if (res.code == 0) {
  108. this.userInfo = res.data
  109. this.avatar = env.filePublic + res.data.avatar
  110. }
  111. }).catch(() => {
  112. })
  113. },
  114. // 跳转登录
  115. toLogin() {
  116. uni.navigateTo({
  117. url: "/pages/login/index"
  118. })
  119. },
  120. // 我的订单
  121. toOrder() {
  122. if (!this.loginState) {
  123. uni.$u.toast('请登录!');
  124. return
  125. }
  126. uni.navigateTo({
  127. url: '/pages/order/index'
  128. })
  129. },
  130. // 我的地址
  131. toAddress() {
  132. if (!this.loginState) {
  133. uni.$u.toast('请登录!');
  134. return
  135. }
  136. uni.navigateTo({
  137. url: '/pages/address/index'
  138. })
  139. },
  140. // 没有登录
  141. notLogin() {
  142. uni.$u.toast('请登录!');
  143. },
  144. // 注销登录
  145. logout() {
  146. let _this = this
  147. if (!this.loginState) {
  148. uni.$u.toast('已退出登录!');
  149. return
  150. }
  151. uni.showModal({
  152. title: '退出登录',
  153. content: '确定要退出登录吗?',
  154. success(res) {
  155. if (res.confirm) {
  156. uni.clearStorage()
  157. _this.loginState = false
  158. _this.authState = false
  159. }
  160. }
  161. })
  162. },
  163. },
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. /deep/ .u-cell__body {
  168. padding: 20rpx 0;
  169. }
  170. .status_bar {
  171. width: 100%;
  172. height: var(--status-bar-height);
  173. }
  174. </style>
  175. <style lang="scss" scoped>
  176. .user {
  177. display: flex;
  178. align-items: center;
  179. height: 300rpx;
  180. padding: 0 36rpx;
  181. // background: linear-gradient(to right, #a1c4fd 0%, #c2e9fb 100%);
  182. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/my-bkgd.png) center center;
  183. }
  184. .account {
  185. margin: 0 20rpx;
  186. padding: 34rpx;
  187. background-color: #FFFFFF;
  188. border-radius: 10rpx;
  189. margin-top: -90rpx;
  190. margin-bottom: 40rpx;
  191. &-ava {
  192. justify-content: flex-start;
  193. margin-bottom: 46rpx;
  194. image {
  195. width: 106rpx;
  196. height: 106rpx;
  197. border-radius: 50%;
  198. overflow: hidden;
  199. }
  200. .no-ava{
  201. width: 106rpx;
  202. height: 106rpx;
  203. border-radius: 50%;
  204. overflow: hidden;
  205. background: #C0C0C0;
  206. }
  207. &-name {
  208. margin-left: 20rpx;
  209. font-size: 32rpx;
  210. }
  211. &-no {
  212. margin-left: 20rpx;
  213. color: #C0C0C0;
  214. font-size: 32rpx;
  215. }
  216. }
  217. &-info {
  218. justify-content: space-around;
  219. &-item {
  220. flex-direction: column;
  221. view {
  222. line-height: 40rpx;
  223. }
  224. view:first-child {
  225. line-height: 56rpx;
  226. font-size: 40rpx;
  227. }
  228. }
  229. }
  230. }
  231. .action {
  232. margin: 0 20rpx;
  233. padding: 10rpx 20rpx 0;
  234. background-color: #FFFFFF;
  235. border-radius: 10rpx;
  236. margin-bottom: 40rpx;
  237. }
  238. .cancel {
  239. margin: 0 20rpx;
  240. padding: 10rpx 20rpx;
  241. background-color: #FFFFFF;
  242. border-radius: 10rpx;
  243. }
  244. </style>