index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <view>
  3. <view class="header">
  4. <view class="info">
  5. <view class="avatar">
  6. <image :src="userInfo.avatar"></image>
  7. </view>
  8. <view class="text">
  9. <view class="name">{{userInfo.nickname}}<text>{{userInfo.levelname}}</text></view>
  10. <view>{{userInfo.mobile}}</view>
  11. </view>
  12. </view>
  13. <text @click="loginOut">退出</text>
  14. </view>
  15. <view class="money">
  16. <view class="balance">
  17. 账户余额(元)
  18. <view>{{userInfo.money}}</view>
  19. </view>
  20. <view>
  21. <navigator class="recharge" hover-class="none" url="/pages/users/recharge/index">充值</navigator>
  22. <navigator class="detail" hover-class="none" url="/pages/users/record/index?type=recharge">明细</navigator>
  23. </view>
  24. </view>
  25. <view class="order-wrapper">
  26. <view class="order-hd flex">
  27. <view class="left">我的订单</view>
  28. <navigator class="right flex" hover-class="none" url="/pages/users/order/index" open-type="navigate">
  29. 查看全部
  30. <text class="iconfont icon-xiangyou"></text>
  31. </navigator>
  32. </view>
  33. <view class="order-bd">
  34. <block v-for="(item,index) in orderMenu" :key="index">
  35. <navigator class="order-item" hover-class="none" :url="item.url">
  36. <view class="pic">
  37. <image :src="item.img" mode=""></image>
  38. <text class="order-status-num" v-if="item.num > 0">{{ item.num }}</text>
  39. </view>
  40. <view class="txt">{{item.title}}</view>
  41. </navigator>
  42. </block>
  43. </view>
  44. </view>
  45. <view class="menu">
  46. <view class="title">我的服务</view>
  47. <view class="list">
  48. <navigator class="item" url="/pages/users/spread/index" hover-class="none">
  49. <text class="iconfont icon-iconfontzhizuobiaozhun49"></text>
  50. <text>邀请好友</text>
  51. </navigator>
  52. <navigator class="item" url="/pages/users/record/index?type=consumption" hover-class="none">
  53. <text class="iconfont icon-xiaofeimingxi"></text>
  54. <text>消费明细</text>
  55. </navigator>
  56. <navigator class="item" url="/pages/users/commission/index" hover-class="none">
  57. <text class="iconfont icon-yongjinmingxi"></text>
  58. <text>佣金明细</text>
  59. </navigator>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. mapGetters
  67. } from "vuex";
  68. import {
  69. toLogin
  70. } from '@/libs/login.js';
  71. import {
  72. getUserInfo,
  73. getOrder
  74. } from '@/api/api.js';
  75. export default {
  76. data() {
  77. return {
  78. userInfo: {},
  79. orderMenu: [
  80. {
  81. title: '待支付',
  82. img: '../../static/images/order1.png',
  83. url: '/pages/users/order/index?status=0',
  84. num: 0
  85. },
  86. {
  87. title: '打单中',
  88. img: '../../static/images/order2.png',
  89. url: '/pages/users/order/index?status=1',
  90. num: 0
  91. },
  92. {
  93. title: '已出单',
  94. img: '../../static/images/order3.png',
  95. url: '/pages/users/order/index?status=2',
  96. num: 0
  97. },
  98. {
  99. title: '异常',
  100. img: '../../static/images/order4.png',
  101. url: '/pages/users/order/index?status=9',
  102. num: 0
  103. },
  104. {
  105. title: '退货',
  106. img: '../../static/images/order5.png',
  107. url: '/pages/users/order/index?status=-2',
  108. num: 0
  109. }
  110. ],
  111. }
  112. },
  113. computed: mapGetters(['isLogin']),
  114. onLoad() {
  115. if (this.isLogin) {
  116. this.getUserInfo();
  117. this.getOrderData();
  118. }else{
  119. toLogin();
  120. }
  121. },
  122. methods: {
  123. getUserInfo: function() {
  124. let that = this;
  125. getUserInfo().then(res => {
  126. that.userInfo = res.data;
  127. });
  128. },
  129. //获取订单统计数据
  130. getOrderData: function() {
  131. let that = this;
  132. getOrder().then(res => {
  133. that.orderMenu.forEach((item, index) => {
  134. switch (item.title) {
  135. case '待支付':
  136. item.num = res.data.unpaid
  137. break
  138. case '打单中':
  139. item.num = res.data.inorder
  140. break
  141. case '已出单':
  142. item.num = res.data.sendOrder
  143. break
  144. case '异常':
  145. item.num = res.data.abnormalOrder
  146. break
  147. case '退货':
  148. item.num = res.data.refundOrder
  149. break
  150. }
  151. })
  152. })
  153. },
  154. loginOut: function() {
  155. let that = this;
  156. uni.showModal({
  157. title: '提示',
  158. content: '确定退出登录?',
  159. success: function (res) {
  160. if (res.confirm) {
  161. that.$store.commit("LOGOUT");
  162. uni.switchTab({
  163. url: '/pages/index/index'
  164. });
  165. } else if (res.cancel) {
  166. console.log('用户点击取消');
  167. }
  168. }
  169. });
  170. }
  171. }
  172. }
  173. </script>
  174. <style scoped lang="scss">
  175. .header{
  176. display: flex;
  177. justify-content: space-between;
  178. height:360rpx;
  179. background: linear-gradient(90deg,#ff5c00 0,#FF464E);
  180. .info{
  181. display: flex;
  182. padding-top: 80rpx;
  183. padding-left: 25rpx;
  184. .avatar{
  185. width: 125rpx;
  186. height: 125rpx;
  187. display: flex;
  188. align-items: center;
  189. justify-content: center;
  190. border-radius: 50%;
  191. border: 1px solid hsla(0,0%,100%,.5);
  192. image{
  193. width:110rpx;
  194. height:110rpx;
  195. border-radius: 50%;
  196. }
  197. }
  198. .text{
  199. color:#fff;
  200. padding-left: 20rpx;
  201. padding-top: 10rpx;
  202. .name{
  203. font-size: 36rpx;
  204. font-weight: bolder;
  205. margin-bottom: 10rpx;
  206. text{
  207. color: #fff;
  208. opacity: 0.8;
  209. font-size: 24rpx;
  210. border: 1px solid hsla(0,0%,100%,.6);
  211. border-radius: 30rpx;
  212. padding: 2rpx 15rpx;
  213. margin-left: 15rpx;
  214. }
  215. }
  216. }
  217. }
  218. text{
  219. color:#fff;
  220. padding-top: 80rpx;
  221. padding-right: 25rpx;
  222. }
  223. }
  224. .money{
  225. width:700rpx;
  226. margin-left: 25rpx;
  227. margin-top: -100rpx;
  228. background: #fff;
  229. border-radius: 20rpx;
  230. padding: 30rpx;
  231. display: flex;
  232. justify-content:space-between;
  233. .balance{
  234. font-size: 30rpx;
  235. view{
  236. font-size: 50rpx;
  237. font-weight: 600;
  238. color: #ff5c00;
  239. margin-top: 20rpx;
  240. }
  241. }
  242. .recharge{
  243. background: #ff5c00;
  244. color:#fff;
  245. font-size: 28rpx;
  246. text-align: center;
  247. border-radius: 30rpx;
  248. width:150rpx;
  249. height:60rpx;
  250. line-height: 60rpx;
  251. margin-bottom: 20rpx;
  252. }
  253. .detail{
  254. width:150rpx;
  255. height:60rpx;
  256. line-height: 60rpx;
  257. border: 1rpx solid #ebedf0;
  258. border-radius: 30rpx;
  259. font-size: 28rpx;
  260. text-align: center;
  261. }
  262. }
  263. .order-wrapper {
  264. width:700rpx;
  265. margin-left: 25rpx;
  266. background: #fff;
  267. border-radius: 15rpx;
  268. .order-hd {
  269. justify-content: space-between;
  270. padding: 25rpx 20rpx;
  271. margin-top: 25rpx;
  272. font-size: 30rpx;
  273. color: #282828;
  274. .right {
  275. align-items: center;
  276. color: #666666;
  277. font-size: 26rpx;
  278. .icon-xiangyou {
  279. margin-left: 5rpx;
  280. margin-top: 6rpx;
  281. font-size: 26rpx;
  282. }
  283. }
  284. }
  285. .order-bd {
  286. display: flex;
  287. .order-item {
  288. display: flex;
  289. flex-direction: column;
  290. justify-content: center;
  291. align-items: center;
  292. width: 20%;
  293. height: 160rpx;
  294. .pic {
  295. position: relative;
  296. text-align: center;
  297. image {
  298. width: 70rpx;
  299. height: 70rpx;
  300. }
  301. }
  302. .txt {
  303. font-size: 26rpx;
  304. color: #454545;
  305. }
  306. }
  307. }
  308. }
  309. .menu{
  310. width:700rpx;
  311. margin: 25rpx;
  312. padding: 25rpx 20rpx;
  313. border-radius: 15rpx;
  314. background: #fff;
  315. .title{
  316. font-size: 30rpx;
  317. }
  318. .list{
  319. width:660rpx;
  320. overflow: hidden;
  321. .item{
  322. width:25%;
  323. float:left;
  324. text-align: center;
  325. margin-top: 30rpx;
  326. image{
  327. width:70rpx;
  328. height:70rpx;
  329. }
  330. text{
  331. display: block;
  332. color:#636363;
  333. }
  334. .iconfont{
  335. font-size: 70rpx;
  336. }
  337. }
  338. }
  339. }
  340. .order-status-num {
  341. min-width:12rpx;
  342. background-color: #fff;
  343. color: #ee5a52;
  344. border-radius: 15px;
  345. position: absolute;
  346. right:-12rpx;
  347. top: -10rpx;
  348. font-size: 20rpx;
  349. padding: 0 8rpx;
  350. border: 1px solid #ee5a52;
  351. }
  352. </style>