index.vue 14 KB

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