mine.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <u-navbar title="我的" titleStyle="color: #fff;" @leftClick="leftClick" height="44px" bgColor="rgb(255,255,255,0)" :placeholder="true"></u-navbar>
  5. <view class="top hflex acenter">
  6. <image :src="user.headimg" mode="aspectFill" class="avatar"></image>
  7. <view class="top_text text_hide">{{user.nickname}}</view>
  8. </view>
  9. <view class="hflex acenter jbetween tabs">
  10. <block v-for="(item,index) in tabs" :key="index">
  11. <view class="vflex acenter tab_item" @click="toDetail(item.url)">
  12. <image :src="item.src" class="tab_icon"></image>
  13. <view class="tab_text">{{item.name}}</view>
  14. </view>
  15. </block>
  16. </view>
  17. <view class="order">
  18. <view class="hflex acenter jbetween">
  19. <view class="title">我的订单</view>
  20. <view class="right" @click="toOrder(0)">查看全部</view>
  21. </view>
  22. <view class="hflex acenter jbetween" style="margin-top: 32rpx;">
  23. <block v-for="(item,index) in orderList" :key="index">
  24. <view class="vflex acenter order_item" @click="toOrder(item.id)">
  25. <view class="order_icon">
  26. <image :src="item.src" mode="aspectFill" style="width: 100%;height: 100%;"></image>
  27. <view class="num" v-if="item.num > 0">{{item.num}}</view>
  28. </view>
  29. <view class="order_text">{{item.name}}</view>
  30. </view>
  31. </block>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import $api from '@/static/js/api.js'
  39. var that = ''
  40. export default {
  41. data() {
  42. return {
  43. user: {},
  44. tabs: [
  45. {
  46. src: '/static/images/shop/consulting.png',
  47. name: '消息',
  48. url: '/page_shop/pages/mine/chat'
  49. },
  50. {
  51. src: '/static/images/shop/collect.png',
  52. name: '收藏',
  53. url: '/page_shop/pages/mine/collect'
  54. },
  55. {
  56. src: '/static/images/shop/address.png',
  57. name: '地址',
  58. url: '/page_shop/pages/address/list'
  59. }
  60. ],
  61. orderList: [
  62. {
  63. src: 'https://ship.shipcc.cn/common/order_icon1.png',
  64. name: '待付款',
  65. num: 0,
  66. id: 1,
  67. },
  68. {
  69. src: 'https://ship.shipcc.cn/common/order_icon2.png',
  70. name: '待发货',
  71. num: 0,
  72. id: 2,
  73. },
  74. {
  75. src: 'https://ship.shipcc.cn/common/order_icon3.png',
  76. name: '待收货',
  77. num: 0,
  78. id: 3,
  79. },
  80. {
  81. src: 'https://ship.shipcc.cn/common/order_icon4.png',
  82. name: '退款/售后',
  83. num: 0,
  84. id: 4,
  85. }
  86. ]
  87. }
  88. },
  89. onLoad() {
  90. that = this
  91. that.getUser()
  92. },
  93. onShow() {
  94. var token = uni.getStorageSync('token')
  95. if(!token) {
  96. $api.info('请先登录')
  97. setTimeout(() =>{
  98. $api.jump('/pages/login/password_login')
  99. }, 1000)
  100. }
  101. that.getNum()
  102. },
  103. onPullDownRefresh() {
  104. that.getNum()
  105. },
  106. methods: {
  107. // 返回
  108. leftClick() {
  109. console.log('返回');
  110. $api.jump(-1)
  111. },
  112. getUser() {
  113. $api.req({
  114. url: '/data/api.auth.Center/get',
  115. method: 'POST'
  116. }, function(res) {
  117. if(res.code == 1) {
  118. that.user = res.data
  119. }
  120. })
  121. },
  122. getNum() {
  123. $api.req({
  124. url: '/data/api.Order/order_num'
  125. }, function(res) {
  126. uni.stopPullDownRefresh();
  127. if(res.code == 1) {
  128. for(var i=0;i<that.orderList.length;i++) {
  129. console.log(res.data[i]);
  130. that.$set(that.orderList[i],'num',res.data[i])
  131. }
  132. }
  133. })
  134. },
  135. // 进入详情页面
  136. toDetail(url) {
  137. $api.jump(url)
  138. },
  139. toOrder(id) {
  140. if(id == 4) {
  141. $api.jump('/page_shop/pages/order/refund')
  142. } else {
  143. id = id + 1
  144. $api.jump('/page_shop/pages/order/list?id=' + id)
  145. }
  146. }
  147. },
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .content {
  152. background: #F5F5F5;
  153. .box {
  154. width: 100%;
  155. background: linear-gradient(360deg, #F5F5F5 0%, #506DFF 100%);
  156. box-sizing: border-box;
  157. padding: 0 30rpx;
  158. .top {
  159. width: 100%;
  160. padding: 8rpx 0 30rpx;
  161. .avatar {
  162. width: 120rpx;
  163. height: 120rpx;
  164. border-radius: 50%;
  165. border: 2px solid #FFFFFF;
  166. }
  167. .top_text {
  168. max-width: 400rpx;
  169. font-size: 40rpx;
  170. font-weight: 500;
  171. color: #FFFFFF;
  172. line-height: 56rpx;
  173. margin-left: 12rpx;
  174. }
  175. }
  176. .tabs {
  177. padding: 30rpx 0 40rpx;
  178. .tab_item {
  179. width: 33%;
  180. text-align: center;
  181. .tab_icon {
  182. width: 52rpx;
  183. height: 52rpx;
  184. }
  185. .tab_text {
  186. font-size: 26rpx;
  187. font-weight: 400;
  188. color: #FFFFFF;
  189. line-height: 36rpx;
  190. padding-top: 12rpx;
  191. }
  192. }
  193. }
  194. .order {
  195. width: 100%;
  196. box-sizing: border-box;
  197. padding: 24rpx 20rpx;
  198. background: #FFFFFF;
  199. border-radius: 10px;
  200. .title {
  201. font-size: 28rpx;
  202. font-weight: 500;
  203. color: #0A0A0A;
  204. line-height: 40rpx;
  205. }
  206. .right {
  207. font-size: 24rpx;
  208. font-weight: 400;
  209. color: #B4B4B4;
  210. line-height: 34rpx;
  211. }
  212. .order_item{
  213. width: 25%;
  214. text-align: center;
  215. .order_icon {
  216. width: 52rpx;
  217. height: 52rpx;
  218. position: relative;
  219. .num {
  220. position: absolute;
  221. right: -10rpx;
  222. top: 0;
  223. width: 26rpx;
  224. height: 24rpx;
  225. background-color: #fb3e32;
  226. border-radius: 12rpx 12rpx 12rpx 4rpx;
  227. font-size: 20rpx;
  228. color: #fff;
  229. text-align: center;
  230. }
  231. }
  232. .order_text {
  233. padding-top: 24rpx;
  234. font-size: 26rpx;
  235. font-weight: 400;
  236. color: #0A0A0A;
  237. line-height: 36rpx;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. </style>