index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="wrap">
  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 class="action-item flex" @click="toOrder">
  53. <view class="action-item-left flex">
  54. <image src="../../static/user/user_order.png" mode=""></image>
  55. <view class="title">我的订单</view>
  56. </view>
  57. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  58. </view>
  59. <view class="action-item flex" @click="toAddress">
  60. <view class="action-item-left flex">
  61. <image class="addr" src="../../static/user/user_addr.png" mode=""></image>
  62. <view class="title">我的地址</view>
  63. </view>
  64. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  65. </view>
  66. <view class="action-item flex" @click="contactService">
  67. <view class="action-item-left flex">
  68. <image src="../../static/user/user_kefu.png" mode=""></image>
  69. <view class="title">联系客服</view>
  70. </view>
  71. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  72. </view>
  73. <view class="action-item flex" @click="toAbout">
  74. <view class="action-item-left flex">
  75. <image src="../../static/user/user_about.png" mode=""></image>
  76. <view class="title">关于我们</view>
  77. </view>
  78. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  79. </view>
  80. </view>
  81. <view class="action">
  82. <!-- <u-cell icon="close-circle" title="退出登录" :isLink="true" :border="false" @click="logout" /> -->
  83. <view class="action-item flex" @click="logout">
  84. <view class="action-item-left flex">
  85. <image class="close" src="../../static/user/user_close.png" mode=""></image>
  86. <view class="title">退出登录</view>
  87. </view>
  88. <u-icon name="arrow-right" color="#666" size="16"></u-icon>
  89. </view>
  90. </view>
  91. <custom-tab-bar :activeValue="'user'" />
  92. </view>
  93. </template>
  94. <script>
  95. import env from '../../config/env.js'
  96. import $http from '@/utils/request.js'
  97. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  98. import Auth from '../../components/auth/auth.vue'
  99. export default {
  100. components: {
  101. CustomTabBar,
  102. Auth,
  103. },
  104. data() {
  105. return {
  106. loginState: false, // 判断是否登录
  107. authState: false,
  108. userInfo: {}, //
  109. avatar: '',
  110. certifyStatus: {},
  111. info: {},
  112. authShow: false,
  113. initData: {},
  114. };
  115. },
  116. onShow() {
  117. this.loginState = uni.getStorageSync('token') ? true : false
  118. if (this.loginState) {
  119. this.getInit()
  120. this.getBaseInfo()
  121. }
  122. },
  123. methods: {
  124. // 我的数据
  125. getInit() {
  126. uni.showLoading({
  127. title: '加载中'
  128. });
  129. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  130. uni.hideLoading();
  131. if (res.code == 0) {
  132. this.initData = res.data
  133. }
  134. }).catch(() => {
  135. uni.hideLoading();
  136. })
  137. },
  138. getBaseInfo() {
  139. $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
  140. if (res.code == 0) {
  141. this.userInfo = res.data
  142. this.avatar = env.filePublic + res.data.avatar
  143. }
  144. }).catch(() => {
  145. })
  146. },
  147. // 跳转登录
  148. toLogin() {
  149. uni.navigateTo({
  150. url: "/pages/login/index"
  151. })
  152. },
  153. // 我的订单
  154. toOrder() {
  155. if (!this.loginState) {
  156. uni.$u.toast('请登录');
  157. return
  158. }
  159. uni.navigateTo({
  160. url: '/packageGoods/order/index'
  161. })
  162. },
  163. // 我的地址
  164. toAddress() {
  165. if (!this.loginState) {
  166. uni.$u.toast('请登录');
  167. return
  168. }
  169. uni.navigateTo({
  170. url: '/packageOperate/address/index'
  171. })
  172. },
  173. // 关于我们
  174. toAbout() {
  175. uni.navigateTo({
  176. url: '/packageOther/about/index'
  177. })
  178. },
  179. // 没有登录
  180. notLogin() {
  181. uni.$u.toast('请登录');
  182. },
  183. // 注销登录
  184. logout() {
  185. let _this = this
  186. if (!this.loginState) {
  187. uni.$u.toast('已退出登录');
  188. return
  189. }
  190. uni.showModal({
  191. title: '退出登录',
  192. content: '确定要退出登录吗?',
  193. success(res) {
  194. if (res.confirm) {
  195. uni.clearStorage()
  196. _this.loginState = false
  197. _this.authState = false
  198. }
  199. }
  200. })
  201. },
  202. // 联系客服
  203. contactService() {
  204. // #ifdef MP-WEIXIN
  205. wx.openCustomerServiceChat({
  206. extInfo: {
  207. url: 'https://work.weixin.qq.com/kfid/kfc36c0d90028adbd24'
  208. },
  209. corpId: 'ww02da63d80c66284b',
  210. })
  211. // #endif
  212. },
  213. },
  214. onShareAppMessage(res) {
  215. return {
  216. title: '盲票,玩的就是有趣',
  217. path: '/pages/index/index'
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. /deep/ .u-cell__body {
  224. padding: 20rpx 0;
  225. }
  226. .status_bar {
  227. width: 100%;
  228. height: var(--status-bar-height);
  229. }
  230. </style>
  231. <style lang="scss" scoped>
  232. .wrap {
  233. padding-bottom: 200rpx;
  234. }
  235. .user {
  236. display: flex;
  237. align-items: center;
  238. height: 560rpx;
  239. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/mine_bkg.png) center center no-repeat;
  240. background-size: 100vw 560rpx;
  241. }
  242. .account {
  243. margin-top: -350rpx;
  244. margin-bottom: 34rpx;
  245. // 头像
  246. &-ava {
  247. justify-content: flex-start;
  248. margin-bottom: 34rpx;
  249. padding: 0 30rpx;
  250. image {
  251. width: 170rpx;
  252. height: 170rpx;
  253. border-radius: 50%;
  254. border: 2px solid #FFFFFF;
  255. overflow: hidden;
  256. }
  257. .no-ava {
  258. width: 170rpx;
  259. height: 170rpx;
  260. border-radius: 50%;
  261. overflow: hidden;
  262. background: #fff;
  263. }
  264. &-name {
  265. margin-left: 20rpx;
  266. font-size: 34rpx;
  267. color: #FFFFFF;
  268. }
  269. &-no {
  270. margin-left: 20rpx;
  271. color: #FFFFFF;
  272. font-size: 34rpx;
  273. }
  274. }
  275. // 信息
  276. &-info {
  277. height: 216rpx;
  278. justify-content: space-around;
  279. background-color: #FFFFFF;
  280. border-radius: 18rpx;
  281. &-item {
  282. flex-direction: column;
  283. font-size: 34rpx;
  284. view {
  285. line-height: 52rpx;
  286. }
  287. view:first-child {
  288. color: #FD7B24;
  289. line-height: 60rpx;
  290. font-size: 52rpx;
  291. }
  292. }
  293. }
  294. }
  295. .action {
  296. margin: 0 34rpx;
  297. padding: 0 34rpx;
  298. background-color: #FFFFFF;
  299. border-radius: 18rpx;
  300. margin-bottom: 34rpx;
  301. &-item {
  302. justify-content: space-between;
  303. padding: 36rpx 0;
  304. border-bottom: 1px solid #eee;
  305. &-left {
  306. color: #666;
  307. image {
  308. width: 44rpx;
  309. height: 44rpx;
  310. margin-right: 20rpx;
  311. }
  312. .title {
  313. font-size: 30rpx;
  314. line-height: 30rpx;
  315. }
  316. .addr {
  317. width: 38rpx;
  318. height: 46rpx;
  319. }
  320. .close {
  321. width: 50rpx;
  322. height: 46rpx;
  323. }
  324. }
  325. }
  326. &-item:last-child {
  327. border-bottom: none;
  328. }
  329. }
  330. </style>