index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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="/packagePrize/prize/index" class="flex account-info-item" hover-class="navigator-hover">
  17. <view>{{ initData.prizeNum }}</view>
  18. <view>我的奖品库</view>
  19. </navigator>
  20. <navigator url="/packagePrize/ticket/index" class="flex account-info-item" hover-class="navigator-hover">
  21. <view>{{ initData.ticketNum }}</view>
  22. <view>我的盲票</view>
  23. </navigator>
  24. <navigator url="/packagePrize/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" />
  48. <u-cell icon="map" title="我的地址" :isLink="true" @click="toAddress" />
  49. <u-cell icon="kefu-ermai" title="联系我们" :isLink="true" @click="contactService" />
  50. <u-cell icon="info-circle" title="关于我们" :border="false" :isLink="true" :url="'/packageOther/about/index'" />
  51. </u-cell-group>
  52. </view>
  53. <view class="cancel">
  54. <u-cell icon="close-circle" title="退出登录" :isLink="true" :border="false" @click="logout" />
  55. </view>
  56. <custom-tab-bar :activeValue="'user'" />
  57. </view>
  58. </template>
  59. <script>
  60. import env from '../../config/env.js'
  61. import $http from '@/utils/request.js'
  62. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  63. import Auth from '../../components/auth/auth.vue'
  64. export default {
  65. components: {
  66. CustomTabBar,
  67. Auth,
  68. },
  69. data() {
  70. return {
  71. loginState: false, // 判断是否登录
  72. authState: false,
  73. userInfo: {}, //
  74. avatar: '',
  75. certifyStatus: {},
  76. info: {},
  77. authShow: false,
  78. initData: {},
  79. };
  80. },
  81. onShow() {
  82. this.loginState = uni.getStorageSync('token') ? true : false
  83. if (this.loginState) {
  84. this.getInit()
  85. this.getBaseInfo()
  86. }
  87. },
  88. methods: {
  89. // 我的数据
  90. getInit() {
  91. uni.showLoading({
  92. title: '加载中'
  93. });
  94. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  95. uni.hideLoading();
  96. if (res.code == 0) {
  97. this.initData = res.data
  98. }
  99. }).catch(() => {
  100. uni.hideLoading();
  101. })
  102. },
  103. getBaseInfo() {
  104. $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
  105. if (res.code == 0) {
  106. this.userInfo = res.data
  107. this.avatar = env.filePublic + res.data.avatar
  108. }
  109. }).catch(() => {
  110. })
  111. },
  112. // 跳转登录
  113. toLogin() {
  114. uni.navigateTo({
  115. url: "/pages/login/index"
  116. })
  117. },
  118. // 我的订单
  119. toOrder() {
  120. if (!this.loginState) {
  121. uni.$u.toast('请登录!');
  122. return
  123. }
  124. uni.navigateTo({
  125. url: '/packageGoods/order/index'
  126. })
  127. },
  128. // 我的地址
  129. toAddress() {
  130. if (!this.loginState) {
  131. uni.$u.toast('请登录!');
  132. return
  133. }
  134. uni.navigateTo({
  135. url: '/packageOperate/address/index'
  136. })
  137. },
  138. // 没有登录
  139. notLogin() {
  140. uni.$u.toast('请登录!');
  141. },
  142. // 注销登录
  143. logout() {
  144. let _this = this
  145. if (!this.loginState) {
  146. uni.$u.toast('已退出登录!');
  147. return
  148. }
  149. uni.showModal({
  150. title: '退出登录',
  151. content: '确定要退出登录吗?',
  152. success(res) {
  153. if (res.confirm) {
  154. uni.clearStorage()
  155. _this.loginState = false
  156. _this.authState = false
  157. }
  158. }
  159. })
  160. },
  161. // 联系客服
  162. contactService() {
  163. // #ifdef MP-WEIXIN
  164. wx.openCustomerServiceChat({
  165. extInfo: {
  166. url: 'https://work.weixin.qq.com/kfid/kfc36c0d90028adbd24'
  167. },
  168. corpId: 'ww02da63d80c66284b',
  169. })
  170. // #endif
  171. },
  172. },
  173. onShareAppMessage(res) {
  174. return {
  175. title: '盲票,玩的就是有趣',
  176. path: '/pages/index/index'
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. /deep/ .u-cell__body {
  183. padding: 20rpx 0;
  184. }
  185. .status_bar {
  186. width: 100%;
  187. height: var(--status-bar-height);
  188. }
  189. </style>
  190. <style lang="scss" scoped>
  191. .user {
  192. display: flex;
  193. align-items: center;
  194. height: 300rpx;
  195. padding: 0 36rpx;
  196. // background: linear-gradient(to right, #a1c4fd 0%, #c2e9fb 100%);
  197. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/my-bkgd.png) center center;
  198. }
  199. .account {
  200. margin: 0 20rpx;
  201. padding: 34rpx;
  202. background-color: #FFFFFF;
  203. border-radius: 10rpx;
  204. margin-top: -90rpx;
  205. margin-bottom: 40rpx;
  206. &-ava {
  207. justify-content: flex-start;
  208. margin-bottom: 46rpx;
  209. image {
  210. width: 106rpx;
  211. height: 106rpx;
  212. border-radius: 50%;
  213. overflow: hidden;
  214. }
  215. .no-ava {
  216. width: 106rpx;
  217. height: 106rpx;
  218. border-radius: 50%;
  219. overflow: hidden;
  220. background: #C0C0C0;
  221. }
  222. &-name {
  223. margin-left: 20rpx;
  224. font-size: 32rpx;
  225. }
  226. &-no {
  227. margin-left: 20rpx;
  228. color: #C0C0C0;
  229. font-size: 32rpx;
  230. }
  231. }
  232. &-info {
  233. justify-content: space-around;
  234. &-item {
  235. flex-direction: column;
  236. view {
  237. line-height: 40rpx;
  238. }
  239. view:first-child {
  240. line-height: 56rpx;
  241. font-size: 40rpx;
  242. }
  243. }
  244. }
  245. }
  246. .action {
  247. margin: 0 20rpx;
  248. padding: 10rpx 20rpx 0;
  249. background-color: #FFFFFF;
  250. border-radius: 10rpx;
  251. margin-bottom: 40rpx;
  252. }
  253. .cancel {
  254. margin: 0 20rpx;
  255. padding: 10rpx 20rpx;
  256. background-color: #FFFFFF;
  257. border-radius: 10rpx;
  258. }
  259. </style>