index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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 + '?imageView2/2/w/150'" mode="aspectFill" v-if="loginState" @click="toSetAvatar()"></image>
  11. <view class="no-ava" v-else @click="toLogin"></view>
  12. <view class="account-ava-name" v-if="loginState" @click="toSetAvatar()">{{ 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/bean/index" class="flex account-info-item" hover-class="navigator-hover">
  17. <view>{{ initData.coinNum }}</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/prize/index" class="flex account-info-item" hover-class="navigator-hover">
  25. <view>{{ initData.prizeNum }}</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="mass">
  46. <view class="mass-title flex">
  47. <view>我的订单</view>
  48. <view @click="toOrder()">全部订单></view>
  49. </view>
  50. <view class="action">
  51. <view class="action-item flex" @click="toOrder('0')">
  52. <image class="image2" src="../../static/user/user_order1.png" mode="scaleToFill"></image>
  53. <view class="title">待付款</view>
  54. </view>
  55. <view class="action-item flex" @click="toOrder('1,4')">
  56. <image class="image2" src="../../static/user/user_order2.png" mode="scaleToFill"></image>
  57. <view class="title">待发货</view>
  58. </view>
  59. <view class="action-item flex" @click="toOrder('2')">
  60. <image class="image2" src="../../static/user/user_order3.png" mode="scaleToFill"></image>
  61. <view class="title">待收货</view>
  62. </view>
  63. <view class="action-item flex" @click="toOrder('3')">
  64. <image class="image2" src="../../static/user/user_order4.png" mode="scaleToFill"></image>
  65. <view class="title">已完成</view>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="mass">
  70. <view class="mass-title flex">
  71. <view>常用功能</view>
  72. <view></view>
  73. </view>
  74. <view class="action">
  75. <view class="action-item flex" @click="toMyLottery">
  76. <image class="image1" src="../../static/user/user_exchange.png" mode="scaleToFill"></image>
  77. <view class="title">我的拼团</view>
  78. </view>
  79. <view class="action-item flex" @click="toExchange">
  80. <image class="image1" src="../../static/user/user_exchange.png" mode="scaleToFill"></image>
  81. <view class="title">兑换码</view>
  82. </view>
  83. <view class="action-item flex" @click="toAddress">
  84. <image class="image1" src="../../static/user/user_addr.png" mode="scaleToFill"></image>
  85. <view class="title">我的地址</view>
  86. </view>
  87. <view class="action-item flex" @click="toCreator">
  88. <image class="image1" src="../../static/user/user_slice.png" mode="scaleToFill"></image>
  89. <view class="title">申请创客</view>
  90. </view>
  91. <!-- #ifdef MP-WEIXIN -->
  92. <view class="action-item flex" @click="contactService">
  93. <image class="image1" src="../../static/user/user_kefu.png" mode="scaleToFill"></image>
  94. <view class="title">联系客服</view>
  95. </view>
  96. <!-- #endif -->
  97. <view class="action-item flex" @click="toAbout">
  98. <image class="image1" src="../../static/user/user_about.png" mode="scaleToFill"></image>
  99. <view class="title">关于我们</view>
  100. </view>
  101. <view class="action-item flex" @click="logout">
  102. <image class="image1" src="../../static/user/user_close.png" mode="scaleToFill"></image>
  103. <view class="title">退出登录</view>
  104. </view>
  105. </view>
  106. </view>
  107. <custom-tab-bar :activeValue="'user'" />
  108. </view>
  109. </template>
  110. <script>
  111. import env from '../../config/env.js'
  112. import $http from '@/utils/request.js'
  113. import appId from '@/config/appId.js'
  114. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  115. import Auth from '../../components/auth/auth.vue'
  116. export default {
  117. components: {
  118. CustomTabBar,
  119. Auth,
  120. },
  121. data() {
  122. return {
  123. loginState: false, // 判断是否登录
  124. authState: false,
  125. userInfo: {}, //
  126. avatar: '',
  127. certifyStatus: {},
  128. info: {},
  129. authShow: false,
  130. initData: {},
  131. userInfo: '',
  132. };
  133. },
  134. onShow() {
  135. this.loginState = uni.getStorageSync('token') ? true : false
  136. if (this.loginState) {
  137. this.getInit()
  138. this.getBaseInfo()
  139. }
  140. },
  141. methods: {
  142. // 我的数据
  143. getInit() {
  144. uni.showLoading({
  145. title: '加载中'
  146. });
  147. $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
  148. uni.hideLoading();
  149. if (res.code == 0) {
  150. this.initData = res.data
  151. }
  152. }).catch(() => {
  153. uni.hideLoading();
  154. })
  155. },
  156. getBaseInfo() {
  157. $http.post('/api/v1/mp/user/getLoginUserinfo', { appSource: appId }).then(res => {
  158. if (res.code == 0) {
  159. this.userInfo = res.data
  160. this.avatar = env.filePublic + res.data.avatar
  161. }
  162. }).catch(() => {
  163. })
  164. },
  165. //我的拼团
  166. toMyLottery(){
  167. uni.navigateTo({
  168. url: "/packageOperate/lottery/my"
  169. })
  170. },
  171. // 跳转编辑头像与昵称页面
  172. toSetAvatar() {
  173. uni.navigateTo({
  174. url: "/packageOther/avatar/index"
  175. })
  176. },
  177. // 跳转登录
  178. toLogin() {
  179. uni.navigateTo({
  180. url: "/pages/login/index"
  181. })
  182. },
  183. // 我的订单
  184. toOrder(e) {
  185. if (!this.loginState) {
  186. uni.$u.toast('请登录');
  187. return
  188. }
  189. if (e) {
  190. uni.navigateTo({
  191. url: `/packageGoods/order/index?status=${e}`
  192. })
  193. } else {
  194. uni.navigateTo({
  195. url: `/packageGoods/order/index`
  196. })
  197. }
  198. },
  199. //兑换专区
  200. toExchange() {
  201. if (!this.loginState) {
  202. uni.$u.toast('请登录');
  203. return
  204. }
  205. uni.navigateTo({
  206. url: '/packageOperate/exchange/index'
  207. })
  208. },
  209. // 我的地址
  210. toAddress() {
  211. if (!this.loginState) {
  212. uni.$u.toast('请登录');
  213. return
  214. }
  215. uni.navigateTo({
  216. url: '/packageOperate/address/index'
  217. })
  218. },
  219. //申请创客
  220. toCreator() {
  221. if (!this.loginState) {
  222. uni.$u.toast('请登录');
  223. return
  224. }
  225. uni.navigateTo({
  226. url: '/packageOperate/creator/index'
  227. })
  228. },
  229. // 关于我们
  230. toAbout() {
  231. uni.navigateTo({
  232. url: '/packageOther/about/index'
  233. })
  234. },
  235. // 没有登录
  236. notLogin() {
  237. uni.$u.toast('请登录');
  238. },
  239. // 注销登录
  240. logout() {
  241. let _this = this
  242. if (!this.loginState) {
  243. uni.$u.toast('已退出登录');
  244. return
  245. }
  246. uni.showModal({
  247. title: '退出登录',
  248. content: '确定要退出登录吗?',
  249. success(res) {
  250. if (res.confirm) {
  251. uni.clearStorage()
  252. _this.loginState = false
  253. _this.authState = false
  254. }
  255. }
  256. })
  257. },
  258. // 联系客服
  259. contactService() {
  260. // #ifdef MP-WEIXIN
  261. if (appId == 1) {
  262. // wx.openCustomerServiceChat({
  263. // extInfo: {
  264. // url: 'https://work.weixin.qq.com/kfid/kfc36c0d90028adbd24'
  265. // },
  266. // corpId: 'ww02da63d80c66284b',
  267. // })
  268. uni.navigateTo({
  269. url: `/pages/index/wxofficial`
  270. })
  271. } else {
  272. wx.openCustomerServiceChat({
  273. extInfo: {
  274. url: 'https://work.weixin.qq.com/kfid/kfcf9da505d4dc18c87'
  275. },
  276. corpId: 'ww8522e336cfe5045b',
  277. })
  278. }
  279. // #endif
  280. },
  281. },
  282. //分享好友
  283. onShareAppMessage(res) {
  284. return {
  285. title: '盲票,玩的就是有趣',
  286. path: '/pages/index/index'
  287. }
  288. },
  289. //分享朋友圈
  290. onShareTimeline() {
  291. return {
  292. title: '盲票,玩的就是有趣',
  293. // query: { userId: this.userInfo.userId,
  294. // type: 1, },
  295. query: `userId=${this.userInfo.userId ? this.userInfo.userId : null}&type=1`
  296. }
  297. }
  298. }
  299. </script>
  300. <style lang="scss" scoped>
  301. ::v-deep .u-cell__body {
  302. padding: 20rpx 0;
  303. }
  304. .status_bar {
  305. width: 100%;
  306. height: var(--status-bar-height);
  307. }
  308. </style>
  309. <style lang="scss" scoped>
  310. .wrap {
  311. padding-bottom: 200rpx;
  312. }
  313. .user {
  314. display: flex;
  315. align-items: center;
  316. height: 520rpx;
  317. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/static/mine_bkg.png)
  318. center center no-repeat;
  319. background-size: 100vw 520rpx;
  320. }
  321. .account {
  322. margin-top: -350rpx;
  323. margin-bottom: 34rpx;
  324. // 头像
  325. &-ava {
  326. justify-content: flex-start;
  327. margin-top: 34rpx;
  328. padding: 0 30rpx;
  329. image {
  330. width: 106rpx;
  331. height: 106rpx;
  332. border-radius: 50%;
  333. border: 2px solid #ffffff;
  334. overflow: hidden;
  335. }
  336. .no-ava {
  337. width: 106rpx;
  338. height: 106rpx;
  339. border-radius: 50%;
  340. overflow: hidden;
  341. background: #fff;
  342. }
  343. &-name {
  344. margin-left: 20rpx;
  345. font-size: 32rpx;
  346. color: #333;
  347. }
  348. &-no {
  349. margin-left: 20rpx;
  350. color: #ffffff;
  351. font-size: 34rpx;
  352. }
  353. }
  354. // 信息
  355. &-info {
  356. height: 200rpx;
  357. justify-content: space-between;
  358. padding: 0 28rpx;
  359. border-radius: 18rpx;
  360. &-item {
  361. flex-direction: column;
  362. background: linear-gradient(
  363. 90deg,
  364. #faf8fe 0%,
  365. rgba(255, 255, 255, 0) 100%
  366. );
  367. box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.12);
  368. border-radius: 6rpx;
  369. width: 31%;
  370. font-size: 28rpx;
  371. height: 124rpx;
  372. view {
  373. line-height: 50rpx;
  374. }
  375. view:first-child {
  376. color: $uni-text-color;
  377. font-size: 36rpx;
  378. }
  379. }
  380. }
  381. }
  382. .mass {
  383. margin: 0 28rpx;
  384. padding: 40rpx 30rpx;
  385. background-color: #ffffff;
  386. box-shadow: 0px 0px 5px 0px rgba(51, 51, 51, 0.12);
  387. border-radius: 10rpx;
  388. margin-bottom: 34rpx;
  389. &-title {
  390. justify-content: space-between;
  391. view:first-child {
  392. font-size: 32rpx;
  393. font-weight: 500;
  394. color: #000033;
  395. line-height: 19px;
  396. }
  397. view:last-child {
  398. font-size: 28rpx;
  399. font-weight: 400;
  400. color: #999999;
  401. }
  402. }
  403. .action {
  404. display: flex;
  405. flex-wrap: wrap;
  406. &-item {
  407. width: 25%;
  408. flex-direction: column;
  409. margin-top: 40rpx;
  410. .image1 {
  411. width: 56rpx;
  412. height: 56rpx;
  413. }
  414. .image2 {
  415. width: 68rpx;
  416. height: 68rpx;
  417. }
  418. .title {
  419. margin-top: 20rpx;
  420. font-size: 28rpx;
  421. color: #666666;
  422. line-height: 32rpx;
  423. }
  424. }
  425. }
  426. }
  427. </style>