index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <view class="container">
  3. <!-- 机构信息区域 -->
  4. <template v-if="isRequest">
  5. <view class="ws-header">
  6. <!-- 用户信息 -->
  7. <view class="user-info">
  8. <image
  9. class="user_default"
  10. v-if="!hasLogin && isRequest"
  11. :src="StaticUrl + 'icon-default-avatar.png'"
  12. mode="widthFix"
  13. ></image>
  14. <image class="user_default" v-else :src="userInfo.headImgUrl" mode="widthFix"></image>
  15. <view class="user-login" v-if="!hasLogin && isRequest" @click="navigator('/pages/login/login')"
  16. >登录</view
  17. >
  18. <view class="user-text" v-else> {{ userIdentity == 1 ? userInfo.nickName : userInfo.name }} </view>
  19. </view>
  20. <!-- 背景图 -->
  21. <image class="user-bg" :src="StaticUrl + 'icon-user-bg@2x.png'" mode="widthFix"></image>
  22. </view>
  23. <!-- 机构信息END -->
  24. <!-- 订单状态区域 -->
  25. <view class="order-wrap">
  26. <view class="more">
  27. <text class="title">我的订单</text>
  28. <view @click="OrderNavigator(0)">
  29. <text class="more-right">全部订单</text> <text class="iconfont icon-chakangengduo"></text>
  30. </view>
  31. </view>
  32. <view class="line"></view>
  33. <!-- 菜单选项 -->
  34. <view class="order-nav">
  35. <view class="order-nav-item" @click="OrderNavigator(1)">
  36. <image :src="StaticUrl + 'icon-order-1@2x.png'" mode="widthFix"></image> <text>待付款</text>
  37. <view class="tui-badge tui-badge-box" v-if="hasLogin && paymentCount > 0">
  38. <tui-badge :scaleRatio="0.8" type="danger">{{ paymentCount | countNum }}</tui-badge>
  39. </view>
  40. </view>
  41. <view class="order-nav-item" @click="OrderNavigator(2)">
  42. <image :src="StaticUrl + 'icon-order-2@2x.png'" mode="widthFix"></image> <text>待发货</text>
  43. <view class="tui-badge tui-badge-box" v-if="hasLogin && waitShipmentsCount > 0">
  44. <tui-badge :scaleRatio="0.8" type="danger">{{ waitShipmentsCount | countNum }}</tui-badge>
  45. </view>
  46. </view>
  47. <view class="order-nav-item" @click="OrderNavigator(3)">
  48. <image :src="StaticUrl + 'icon-order-3@2x.png'" mode="widthFix"></image> <text>已发货</text>
  49. <view class="tui-badge tui-badge-box" v-if="hasLogin && shipmentsCount > 0">
  50. <tui-badge :scaleRatio="0.8" type="danger">{{ shipmentsCount | countNum }}</tui-badge>
  51. </view>
  52. </view>
  53. <view class="order-nav-item" @click="OrderNavigator(3)">
  54. <image :src="StaticUrl + 'icon-order-4@2x.png'" mode="widthFix"></image> <text>退货/款</text>
  55. <view class="tui-badge tui-badge-box" v-if="hasLogin && salesReturnCount > 0">
  56. <tui-badge :scaleRatio="0.8" type="danger">{{ salesReturnCount | countNum }}</tui-badge>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 订单状态区域END -->
  62. <!-- 菜单导航区域 -->
  63. <view class="place-menu-conten clearfix">
  64. <view class="place-menu-cell" @click="navigator('/pages/user/activity/coupon-list')">
  65. <view class="place-left">
  66. <image class="place-menu-icon" :src="StaticUrl + 'icon-coupon.png'" mode=""></image>
  67. <text class="place-menu-title">优惠券</text> <text class="coupons-count" v-if="unusedNum > 0">{{ unusedNum }}</text>
  68. </view>
  69. <text class="iconfont icon-chakangengduo"></text>
  70. </view>
  71. <view
  72. class="place-menu-cell"
  73. @click="navigator('/pages/user/activity/activity-list')"
  74. v-if="userIdentity == 2"
  75. >
  76. <view class="place-left">
  77. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-h@2x.png'" mode=""></image>
  78. <text class="place-menu-title">活动专区</text>
  79. </view>
  80. <text class="iconfont icon-chakangengduo"></text>
  81. </view>
  82. <view class="place-menu-cell" @click="navigator('/pages/user/address/address')">
  83. <view class="place-left">
  84. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-d@2x.png'" mode=""></image>
  85. <text class="place-menu-title">收货地址</text>
  86. </view>
  87. <text class="iconfont icon-chakangengduo"></text>
  88. </view>
  89. <button class="place-menu-cell last" open-type="contact" @bindcontact="handleContact">
  90. <view class="place-left">
  91. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-c@2x.png'" mode=""></image>
  92. <text class="place-menu-title">在线客服</text>
  93. </view>
  94. <text class="iconfont icon-chakangengduo"></text>
  95. </button>
  96. </view>
  97. <!-- 菜单导航区域END -->
  98. <!-- 底部 -->
  99. <view class="user-support" :class="userIdentity == 2 ? 'top' : ''">
  100. <image class="user-support-image" :src="StaticUrl + 'icon-logo@1x.png'" mode=""></image>
  101. <view class="user-support-text">采美365网提供商品技术服务</view>
  102. </view>
  103. </template>
  104. </view>
  105. </template>
  106. <script>
  107. import nutBadge from '@/components/thorui/tui-badge/tui-badge.vue'
  108. import { mapGetters, mapMutations, mapActions } from 'vuex'
  109. import authorize from '@/common/authorize.js'
  110. import wxLogin from '@/services/wxLogin.js'
  111. export default {
  112. components: {
  113. nutBadge
  114. },
  115. data() {
  116. return {
  117. StaticUrl: this.$Static,
  118. CustomBar: this.CustomBar, // 顶部导航栏高度
  119. isRequest: true,
  120. paymentCount: 0, //待付款角标
  121. waitShipmentsCount: 0, //待收货角标
  122. shipmentsCount: 0, //已发货角标
  123. salesReturnCount: 0 //退货/款角标
  124. }
  125. },
  126. computed: {
  127. ...mapGetters(['hasLogin', 'userInfo', 'userId', 'userIdentity', 'unusedNum'])
  128. },
  129. filters: {
  130. countNum(value) {
  131. return value > 99 ? '99+' : value
  132. }
  133. },
  134. onShow() {
  135. if (this.hasLogin) {
  136. this.getCartNumber()
  137. this.GetUserInfoPersonal()
  138. this.initReceiveCouponCount()
  139. }
  140. },
  141. methods: {
  142. ...mapMutations('app', ['login', 'logout']),
  143. ...mapActions('cart', ['getCartNumber']),
  144. ...mapActions('coupon', ['initReceiveCouponCount']),
  145. //初始化个人中心数据
  146. GetUserInfoPersonal() {
  147. this.UserService.GetUserOrderTotal({
  148. userId: this.userId
  149. })
  150. .then(response => {
  151. const data = response.data
  152. this.paymentCount = data.paymentCount //待付款
  153. this.waitShipmentsCount = data.waitShipmentsCount //待收货
  154. this.shipmentsCount = data.shipmentsCount //已发货
  155. this.salesReturnCount = data.salesReturnCount //退货/款
  156. })
  157. .catch(error => {
  158. this.$util.msg(error.msg, 2000)
  159. })
  160. },
  161. handleContact(e) {
  162. //客服
  163. console.log(e.detail.path)
  164. console.log(e.detail.query)
  165. },
  166. OrderNavigator(state) {
  167. // 栏目跳转
  168. if (this.hasLogin) {
  169. if (this.userIdentity == 2) {
  170. this.$api.navigateTo(`/pages/user/order/order-list-retail?state=${state}`)
  171. } else {
  172. this.$api.navigateTo(`/pages/user/order/order-list?state=${state}`)
  173. }
  174. } else {
  175. this.$api.navigateTo('/pages/login/login')
  176. }
  177. },
  178. navigator(url) {
  179. if (this.hasLogin) {
  180. this.$api.navigateTo(url)
  181. } else {
  182. this.$api.navigateTo('/pages/login/login')
  183. }
  184. }
  185. },
  186. onPullDownRefresh() {
  187. //下拉刷新
  188. if (this.hasLogin) {
  189. this.GetUserInfo()
  190. setTimeout(() => {
  191. uni.stopPullDownRefresh()
  192. }, 2000)
  193. } else {
  194. uni.stopPullDownRefresh()
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. @import '@/uni.scss';
  201. .container {
  202. box-sizing: border-box;
  203. background: #f7f7f7;
  204. }
  205. // 用户登录信息区域
  206. .ws-title {
  207. width: 100%;
  208. position: fixed;
  209. top: 0;
  210. left: 0;
  211. font-size: 34rpx;
  212. text-align: center;
  213. }
  214. .ws-header {
  215. position: relative;
  216. height: 280rpx;
  217. .user-info {
  218. position: absolute;
  219. z-index: 10;
  220. width: 750rpx;
  221. height: 280rpx;
  222. display: flex;
  223. flex-direction: column;
  224. align-items: center;
  225. justify-content: center;
  226. .user_default {
  227. display: block;
  228. width: 120rpx;
  229. height: 120rpx;
  230. border-radius: 50%;
  231. }
  232. }
  233. // 登录按钮
  234. .user-login {
  235. width: 184rpx;
  236. height: 56rpx;
  237. margin-top: 25rpx;
  238. border-radius: 28rpx;
  239. background: #ffffff;
  240. line-height: 56rpx;
  241. text-align: center;
  242. color: $color-system;
  243. font-size: $font-size-28;
  244. }
  245. // 公司名
  246. .user-text {
  247. width: 446rpx;
  248. margin-top: 25rpx;
  249. color: #fff;
  250. font-size: 28rpx;
  251. line-height: 40rpx;
  252. text-align: center;
  253. white-space: nowrap;
  254. overflow: hidden;
  255. text-overflow: ellipsis;
  256. }
  257. .user-bg {
  258. width: 100%;
  259. }
  260. }
  261. .more {
  262. width: 750rpx;
  263. display: flex;
  264. justify-content: space-between;
  265. align-items: center;
  266. padding: 23rpx 25rpx;
  267. box-sizing: border-box;
  268. background: #fff;
  269. .more-right {
  270. font-size: 26rpx;
  271. line-height: 37rpx;
  272. margin-right: 10rpx;
  273. }
  274. .title {
  275. font-size: 32rpx;
  276. line-height: 45rpx;
  277. color: #333333;
  278. }
  279. .iconfont {
  280. font-size: 20rpx;
  281. vertical-align: middle;
  282. }
  283. }
  284. .order-wrap {
  285. background: #fff;
  286. .line {
  287. width: 702rpx;
  288. height: 1px;
  289. margin: 0 auto;
  290. background: #f0f0f0;
  291. }
  292. .order-nav {
  293. display: flex;
  294. justify-content: space-evenly;
  295. align-items: center;
  296. padding: 40rpx 0;
  297. .order-nav-item {
  298. position: relative;
  299. display: flex;
  300. align-items: center;
  301. flex-direction: column;
  302. image {
  303. width: 64rpx;
  304. height: 64rpx;
  305. }
  306. text {
  307. font-size: 26rpx;
  308. line-height: 37rpx;
  309. margin-top: 8rpx;
  310. }
  311. .tui-badge {
  312. position: absolute;
  313. top: -15rpx;
  314. right: -25rpx;
  315. z-index: 999;
  316. }
  317. }
  318. }
  319. }
  320. .place-menu-conten {
  321. margin-top: 20rpx;
  322. width: 100%;
  323. height: auto;
  324. box-sizing: border-box;
  325. padding: 0 24rpx;
  326. background-color: #ffffff;
  327. .place-menu-cell {
  328. width: 100%;
  329. height: 110rpx;
  330. box-sizing: border-box;
  331. padding: 36rpx 0;
  332. text-align: left;
  333. float: left;
  334. border-bottom: 1px solid #e1e1e1;
  335. position: relative;
  336. &.last {
  337. border-bottom: none;
  338. }
  339. .place-left {
  340. width: 650rpx;
  341. height: 100%;
  342. .place-menu-icon {
  343. width: 36rpx;
  344. height: 36rpx;
  345. display: block;
  346. float: left;
  347. }
  348. .place-menu-title {
  349. width: 300rpx;
  350. margin-left: 16rpx;
  351. float: left;
  352. height: 36rpx;
  353. line-height: 36rpx;
  354. font-size: $font-size-28;
  355. color: #333333;
  356. }
  357. .coupons-count {
  358. width: 240rpx;
  359. float: right;
  360. height: 36rpx;
  361. line-height: 36rpx;
  362. font-size: $font-size-28;
  363. text-align: right;
  364. color: #ff457b;
  365. }
  366. }
  367. .iconfont {
  368. width: 36rpx;
  369. height: 36rpx;
  370. display: block;
  371. line-height: 36rpx;
  372. text-align: center;
  373. font-size: $font-size-30;
  374. color: #cccccc;
  375. position: absolute;
  376. right: 0;
  377. top: 36rpx;
  378. }
  379. }
  380. }
  381. .user-support {
  382. width: 100%;
  383. float: left;
  384. display: flex;
  385. flex-direction: column;
  386. align-items: center;
  387. justify-content: center;
  388. &.top {
  389. margin-top: 100rpx;
  390. }
  391. .user-support-image {
  392. width: 54rpx;
  393. height: 46rpx;
  394. display: block;
  395. margin-bottom: 5rpx;
  396. }
  397. .user-support-text {
  398. font-size: 20rpx;
  399. line-height: 30rpx;
  400. color: #cccccc;
  401. }
  402. }
  403. </style>